|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
|
6
|
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Repository; |
|
8
|
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Entity\ConferenceMeeting; |
|
10
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
11
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Repository for the ConferenceMeeting entity. |
|
15
|
|
|
*/ |
|
16
|
|
|
class ConferenceMeetingRepository extends ServiceEntityRepository |
|
17
|
|
|
{ |
|
18
|
|
|
public function __construct(ManagerRegistry $registry) |
|
19
|
|
|
{ |
|
20
|
|
|
parent::__construct($registry, ConferenceMeeting::class); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function findByMeetingRemoteId(string $remoteId): array |
|
24
|
|
|
{ |
|
25
|
|
|
$qb = $this->createQueryBuilder('r') |
|
26
|
|
|
->innerJoin('r.meeting', 'm') |
|
27
|
|
|
->where('m.remoteId = :remoteId') |
|
28
|
|
|
->setParameter('remoteId', $remoteId); |
|
29
|
|
|
|
|
30
|
|
|
return $qb->getQuery()->getArrayResult(); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Find a meeting by remote ID and access URL, return as associative array. |
|
35
|
|
|
*/ |
|
36
|
|
|
public function findOneByRemoteIdAndAccessUrl(string $remoteId, int $accessUrlId): ?array |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->createQueryBuilder('m') |
|
39
|
|
|
->select('m.id', 'IDENTITY(m.user) AS user_id', 'm.remoteId', 'm.status', 'm.videoUrl') |
|
40
|
|
|
->where('m.remoteId = :remoteId') |
|
41
|
|
|
->andWhere('m.accessUrl = :accessUrlId') |
|
42
|
|
|
->setParameter('remoteId', $remoteId) |
|
43
|
|
|
->setParameter('accessUrlId', $accessUrlId) |
|
44
|
|
|
->setMaxResults(1) |
|
45
|
|
|
->getQuery() |
|
46
|
|
|
->getArrayResult()[0] ?? null; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Find meeting by ID and return as array. |
|
51
|
|
|
*/ |
|
52
|
|
|
public function findOneAsArrayById(int $id): ?array |
|
53
|
|
|
{ |
|
54
|
|
|
$qb = $this->createQueryBuilder('m') |
|
55
|
|
|
->where('m.id = :id') |
|
56
|
|
|
->setParameter('id', $id) |
|
57
|
|
|
->setMaxResults(1); |
|
58
|
|
|
|
|
59
|
|
|
$result = $qb->getQuery()->getArrayResult(); |
|
60
|
|
|
|
|
61
|
|
|
return $result[0] ?? null; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Insert a new ConferenceMeeting and flush immediately. |
|
66
|
|
|
*/ |
|
67
|
|
|
public function insert(ConferenceMeeting $meeting): void |
|
68
|
|
|
{ |
|
69
|
|
|
$this->_em->persist($meeting); |
|
70
|
|
|
$this->_em->flush(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Update the video URL for a meeting. |
|
75
|
|
|
*/ |
|
76
|
|
|
public function updateVideoUrl(int $id, string $url): void |
|
77
|
|
|
{ |
|
78
|
|
|
$qb = $this->_em->createQueryBuilder(); |
|
79
|
|
|
$qb->update(ConferenceMeeting::class, 'm') |
|
80
|
|
|
->set('m.videoUrl', ':url') |
|
81
|
|
|
->where('m.id = :id') |
|
82
|
|
|
->setParameter('url', $url) |
|
83
|
|
|
->setParameter('id', $id) |
|
84
|
|
|
->getQuery() |
|
85
|
|
|
->execute(); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Update visibility (1 = visible, 0 = invisible). |
|
90
|
|
|
*/ |
|
91
|
|
|
public function updateVisibility(int $id, bool $visible): void |
|
92
|
|
|
{ |
|
93
|
|
|
$qb = $this->_em->createQueryBuilder(); |
|
94
|
|
|
$qb->update(ConferenceMeeting::class, 'm') |
|
95
|
|
|
->set('m.visibility', ':visible') |
|
96
|
|
|
->where('m.id = :id') |
|
97
|
|
|
->setParameter('visible', $visible ? 1 : 0) |
|
98
|
|
|
->setParameter('id', $id) |
|
99
|
|
|
->getQuery() |
|
100
|
|
|
->execute(); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Close the meeting (status = 0, update closed_at). |
|
105
|
|
|
*/ |
|
106
|
|
|
public function closeMeeting(int $id, \DateTimeInterface $closedAt): void |
|
107
|
|
|
{ |
|
108
|
|
|
$qb = $this->_em->createQueryBuilder(); |
|
109
|
|
|
$qb->update(ConferenceMeeting::class, 'm') |
|
110
|
|
|
->set('m.status', 0) |
|
111
|
|
|
->set('m.closedAt', ':closedAt') |
|
112
|
|
|
->where('m.id = :id') |
|
113
|
|
|
->setParameter('closedAt', $closedAt) |
|
114
|
|
|
->setParameter('id', $id) |
|
115
|
|
|
->getQuery() |
|
116
|
|
|
->execute(); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Delete meeting by ID. |
|
121
|
|
|
*/ |
|
122
|
|
|
public function deleteById(int $id): void |
|
123
|
|
|
{ |
|
124
|
|
|
$qb = $this->_em->createQueryBuilder(); |
|
125
|
|
|
$qb->delete(ConferenceMeeting::class, 'm') |
|
126
|
|
|
->where('m.id = :id') |
|
127
|
|
|
->setParameter('id', $id) |
|
128
|
|
|
->getQuery() |
|
129
|
|
|
->execute(); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Find meetings created between two dates. |
|
134
|
|
|
* |
|
135
|
|
|
* @param \DateTimeInterface $start |
|
136
|
|
|
* @param \DateTimeInterface $end |
|
137
|
|
|
* @return ConferenceMeeting[] |
|
138
|
|
|
*/ |
|
139
|
|
|
public function findByDateRange(\DateTimeInterface $start, \DateTimeInterface $end): array |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->createQueryBuilder('m') |
|
142
|
|
|
->where('m.createdAt BETWEEN :start AND :end') |
|
143
|
|
|
->setParameter('start', $start->format('Y-m-d 00:00:00')) |
|
144
|
|
|
->setParameter('end', $end->format('Y-m-d 23:59:59')) |
|
145
|
|
|
->orderBy('m.createdAt', 'ASC') |
|
146
|
|
|
->getQuery() |
|
147
|
|
|
->getResult(); |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|