conference.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. <?php
  2. class imConference extends model
  3. {
  4. /**
  5. * Generate number of a conference based on its id.
  6. * The first character represents the length of id (which is on the tail of the number).
  7. * A padding of date is inserted between the length of id and the id if the number is not long enough.
  8. *
  9. * @param object $conference
  10. * @access public
  11. * @return string
  12. */
  13. public function getNumber($conference)
  14. {
  15. if (!empty($conference->number)) return $conference->number;
  16. $idLength = strlen((string)$conference->id);
  17. if($idLength > 8)
  18. {
  19. $number = $idLength . $conference->id;
  20. }
  21. else
  22. {
  23. /* Pad the number to length of 9 with openedDate if id is not long enough. */
  24. $dateNum = str_replace('-', '', current(explode(' ', $conference->openedDate)));
  25. $number = $idLength . substr($dateNum, 0, 8 - $idLength) . $conference->id;
  26. }
  27. return $number;
  28. }
  29. /**
  30. * Set the number of a conference.
  31. *
  32. * @param int $id conference id
  33. * @param string $number conference number
  34. * @access public
  35. * @return bool
  36. */
  37. public function setNumber($id, $number)
  38. {
  39. $this->dao->update(TABLE_IM_CONFERENCE)->set('number')->eq($number)->where('id')->eq($id)->exec();
  40. return !dao::isError();
  41. }
  42. /**
  43. * Extract id from number.
  44. *
  45. * @param string $number
  46. * @access public
  47. * @return int
  48. */
  49. public function extractIdFromNumber($number)
  50. {
  51. $len = strlen($number);
  52. /* Use first chars as length of id. */
  53. if($len > 10)
  54. {
  55. $id = substr($number, 2);
  56. }
  57. else
  58. {
  59. $idLength = intval(substr($number, 0, 1));
  60. $id = substr($number, $len - $idLength, $idLength);
  61. }
  62. return intval($id);
  63. }
  64. /**
  65. * Get a conference by number.
  66. * The number is generated by the getNumber method.
  67. *
  68. * @param int $number
  69. * @access public
  70. * @return object
  71. */
  72. public function getByNumber($number)
  73. {
  74. $id = $this->extractIdFromNumber($number);
  75. return $this->getById($id);
  76. }
  77. /**
  78. * Get the old conference by the id of chat.
  79. * @deprecated
  80. * @param string $chatID
  81. * @access public
  82. * @return object
  83. */
  84. public function getByChatID($chatID)
  85. {
  86. return $this->dao->select('*')->from(TABLE_IM_CONFERENCE)
  87. ->where('number')->eq('')
  88. ->andWhere('cgid')->eq($chatID)
  89. ->orderBy('id_asc')
  90. ->fetch();
  91. }
  92. /**
  93. * Get the latest conference by the id of chat.
  94. *
  95. * @param string $cgid
  96. * @access public
  97. * @return object
  98. */
  99. public function getLatestByChatID($cgid)
  100. {
  101. return $this->dao->select('*')->from(TABLE_IM_CONFERENCE)
  102. ->where('cgid')->eq($cgid)
  103. ->andWhere('status')->eq('open')
  104. ->orderBy('id_desc')
  105. ->fetch();
  106. }
  107. /**
  108. * Get a conference by id.
  109. *
  110. * @param int $id
  111. * @access public
  112. * @return object
  113. */
  114. public function getById($id)
  115. {
  116. return $this->dao->select('*')->from(TABLE_IM_CONFERENCE)
  117. ->where('id')->eq($id)
  118. ->fetch();
  119. }
  120. /**
  121. * get not started scheduled conferences.
  122. * @return object
  123. */
  124. public function getNotStartedSchedule()
  125. {
  126. return $this->dao->select('*')->from(TABLE_IM_CONFERENCE)
  127. ->where('status')->eq('notStarted')
  128. ->andWhere('type')->eq('scheduled')
  129. /* notStarted conferences notify count will be 1 when create. */
  130. ->andWhere('sentNotify')->eq(1)
  131. ->fetchAll();
  132. }
  133. /**
  134. * get will start scheduled conferences.
  135. * @return object
  136. */
  137. public function getWillStartSchedule()
  138. {
  139. return $this->dao->select('*')->from(TABLE_IM_CONFERENCE)
  140. ->where('status')->eq('notStarted')
  141. ->andWhere('type')->eq('scheduled')
  142. /* will start conference notify count should be 2 */
  143. ->andWhere('sentNotify')->in(2)
  144. ->fetchAll();
  145. }
  146. /**
  147. * Get conference by condition.
  148. * @param string $condition
  149. * @param array $options
  150. * @param int $userID
  151. * @return array
  152. */
  153. public function getByCondition($condition, $options, $pager, $userID)
  154. {
  155. if(!is_object($options) && is_array($options)) $options = (object)$options;
  156. $isCreateByMe = property_exists($options, 'isCreateByMe') ? $options->isCreateByMe : false;
  157. $conferences = array();
  158. switch($condition)
  159. {
  160. case 'immediate':
  161. $chatList = $this->loadModel('im')->chatGetGidListByUserID($userID);
  162. $conferences = $this->dao->select('t1.*, t2.hide, t2.user')->from(TABLE_IM_CONFERENCE)->alias('t1')
  163. ->leftJoin(TABLE_IM_CONFERENCEUSER)->alias('t2')
  164. ->on('t2.conference=t1.id and t2.user')->eq($userID)
  165. ->where('(t2.user is null')
  166. ->orWhere('t2.user')->eq($userID)
  167. ->andWhere('t2.hide')->ne(1)
  168. ->markRight(1)
  169. ->andWhere('t1.number')->ne('')
  170. ->andWhere('t1.type')->eq('default')
  171. ->beginIF($isCreateByMe)->andWhere('t1.openedBy')->eq($userID)
  172. ->fi()
  173. ->andWhere('t1.participants', true)->like("%,$userID,%")
  174. ->orWhere('t1.invitee')->like("%,$userID,%")
  175. ->orWhere('t1.subscribers')->like("%,$userID,%")
  176. ->orWhere('t1.cgid')->in($chatList)
  177. ->markRight(1)
  178. ->orderBy('id_desc')
  179. ->page($pager)
  180. ->fetchAll();
  181. break;
  182. case 'scheduled':
  183. $conferences = $this->dao->select('t1.*, t2.hide, t2.user')->from(TABLE_IM_CONFERENCE)->alias('t1')
  184. ->leftJoin(TABLE_IM_CONFERENCEUSER)->alias('t2')
  185. ->on('t2.conference=t1.id and t2.user')->eq($userID)
  186. ->where('(t2.user is null')
  187. ->orWhere('t2.user')->eq($userID)
  188. ->andWhere('t2.hide')->ne(1)
  189. ->markRight(1)
  190. ->andWhere('t1.type')->eq('scheduled')
  191. ->beginIF($isCreateByMe)->andWhere('t1.openedBy')->eq($userID)
  192. ->fi()
  193. ->andWhere('t1.invitee', true)->like("%,$userID,%")
  194. ->orWhere('t1.subscribers')->like("%,$userID,%")
  195. ->markRight(1)
  196. ->orderBy('id_desc')
  197. ->page($pager)
  198. ->fetchAll();
  199. break;
  200. }
  201. $thisClass = $this;
  202. return array_map(function($conference) use ($thisClass) { return $thisClass->format($conference); }, $conferences);
  203. }
  204. /**
  205. * Format conference data.
  206. *
  207. * @param object $conference
  208. * @access public
  209. * @return object
  210. */
  211. public function format($conference)
  212. {
  213. if(empty($conference)) return $conference;
  214. foreach(array('openedDate', 'startTime', 'endTime') as $key) $conference->$key = empty($conference->$key) || $conference->$key == null ? 0 : strtotime($conference->$key);
  215. if(!empty($conference->number) && !empty($conference->rid) && empty($conference->room))
  216. {
  217. $conference->room = $conference->rid;
  218. unset($conference->rid);
  219. }
  220. return $conference;
  221. }
  222. // /**
  223. // * Generate room password.
  224. // *
  225. // * @access private
  226. // * @return string
  227. // */
  228. // private function generateRoomPassword()
  229. // {
  230. // return sprintf("%06d", mt_rand(0, 999999));
  231. // }
  232. /**
  233. * Create a detached conference.
  234. *
  235. * @param string $chatID
  236. * @param string $invitee
  237. * @param string $topic
  238. * @param string $type
  239. * @param string $password
  240. * @param string $startTime
  241. * @param string $endTime
  242. * @param int $reminderTime
  243. * @param string $note
  244. * @param int $userID
  245. * @param bool $isPrivate
  246. * @param bool $isInner
  247. * @access public
  248. * @return object|boolean
  249. */
  250. public function createDetached($chatID, $invitee, $type = 'default', $topic = '', $password = '', $startTime = null, $endTime = null, $reminderTime = 0, $note = '', $isPrivate = false, $isInner = true, $userID = 0)
  251. {
  252. $conferenceData = new stdClass();
  253. $conferenceData->openedDate = helper::now();
  254. $this->dao->insert(TABLE_IM_CONFERENCE)->data($conferenceData)->exec();
  255. if(dao::isError()) return false;
  256. $id = $this->dao->lastInsertID();
  257. if(empty($id)) return false;
  258. $conference = $this->getById($id);
  259. if(empty($conference)) return false;
  260. $number = $this->getNumber($conference);
  261. $this->setNumber($id, $number);
  262. $conferenceData = new stdClass();
  263. $conferenceData->cgid = $chatID;
  264. $conferenceData->rid = $number;
  265. $conferenceData->status = $type == 'default' ? 'open' : 'notStarted';
  266. $conferenceData->openedBy = (int)$userID;
  267. $conferenceData->openedDate = helper::now();
  268. $conferenceData->subscribers = ",$userID,";
  269. $conferenceData->participants = $type == 'default' ? ",$userID," : '' ;
  270. $conferenceData->invitee = empty($invitee) ? '' : ",$invitee,";
  271. $conferenceData->topic = $topic;
  272. $conferenceData->type = $type;
  273. // $conferenceData->password = empty($password) ? $this->generateRoomPassword() : $password;
  274. $conferenceData->password = '';
  275. if(!empty($startTime)) $conferenceData->startTime = $startTime;
  276. if(!empty($endTime)) $conferenceData->endTime = $endTime;
  277. $conferenceData->number = $number;
  278. $conferenceData->reminderTime = $reminderTime;
  279. $conferenceData->note = $note;
  280. $conferenceData->moderators = ",$userID,";
  281. $conferenceData->isPrivate = $isPrivate === true ? '1' : '0';
  282. $conferenceData->isInner = $isInner === true ? '1' : '0';
  283. $this->dao->update(TABLE_IM_CONFERENCE)->data($conferenceData)->where('id')->eq($id)->exec();
  284. $conference = $this->getById($id);
  285. if(dao::isError()) return false;
  286. return $conference;
  287. }
  288. /**
  289. * set the scheduled conference status to open, and return the conference.
  290. * @param $conference
  291. * @return object
  292. */
  293. public function startSchedule($conference)
  294. {
  295. $this->dao->update(TABLE_IM_CONFERENCE)
  296. ->set('status')->eq('open')
  297. ->where('number')->eq($conference->number)
  298. ->exec();
  299. if(dao::isError()) return false;
  300. return $this->dao->select('*')->from(TABLE_IM_CONFERENCE)
  301. ->where('number')->eq($conference->number)
  302. ->fetch();
  303. }
  304. /**
  305. * Close a conference.
  306. *
  307. * @param string $conferenceId
  308. * @access public
  309. * @return boolean
  310. */
  311. public function close($conferenceId)
  312. {
  313. $conference = $this->getById($conferenceId);
  314. if($conference->status == 'closed') return true;
  315. $this->dao->update(TABLE_IM_CONFERENCE)
  316. ->set('status')->eq('closed')
  317. ->set('participants')->eq('')
  318. ->where('id')->eq($conference->id)
  319. ->exec();
  320. $this->dao->update(TABLE_IM_CONFERENCEINVITE)
  321. ->set('status')->eq('rejected')
  322. ->where('conferenceID')->eq($conference->id)
  323. ->exec();
  324. return !dao::isError();
  325. }
  326. /**
  327. * cancel a conference.
  328. *
  329. * @param string $conferenceId
  330. * @access public
  331. * @return boolean
  332. */
  333. public function cancel($conferenceId)
  334. {
  335. $conference = $this->getById($conferenceId);
  336. if($conference->status == 'canceled') return true;
  337. $this->dao->update(TABLE_IM_CONFERENCE)
  338. ->set('status')->eq('canceled')
  339. ->set('participants')->eq('')
  340. ->where('id')->eq($conference->id)
  341. ->exec();
  342. return !dao::isError();
  343. }
  344. /**
  345. * hide a conference.
  346. *
  347. * @param string $conferenceNumber
  348. * @param int $userID
  349. * @access public
  350. * @return bool
  351. */
  352. public function hide($conferenceNumber, $userID)
  353. {
  354. $conferenceId = $this->extractIdFromNumber($conferenceNumber);
  355. $data = $this->dao->select('*')->from(TABLE_IM_CONFERENCEUSER)->where('conference')->eq($conferenceId)->andWhere('user')->eq($userID)->fetch();
  356. if(empty($data))
  357. {
  358. $this->dao->insert(TABLE_IM_CONFERENCEUSER)
  359. ->set('conference')->eq($conferenceId)
  360. ->set('user')->eq($userID)
  361. ->set('hide')->eq(1)
  362. ->exec();
  363. }
  364. else
  365. {
  366. $this->dao->update(TABLE_IM_CONFERENCEUSER)
  367. ->set('hide')->eq(1)
  368. ->where('conference')->eq($conferenceId)
  369. ->andWhere('user')->eq($userID)
  370. ->exec();
  371. }
  372. return !dao::isError();
  373. }
  374. /**
  375. * update a conference.
  376. *
  377. * @param object $conference
  378. * @return bool
  379. */
  380. public function update($conference)
  381. {
  382. $this->dao->update(TABLE_IM_CONFERENCE)
  383. ->data($conference)
  384. ->where('number')->eq($conference->number)
  385. ->exec();
  386. return !dao::isError();
  387. }
  388. /**
  389. * after sent notify, update the sentNotify field.
  390. * @param object $conference
  391. * @param int $times
  392. * @return void
  393. */
  394. public function updateSentNotifyTimes($conference, $times) {
  395. $this->dao->update(TABLE_IM_CONFERENCE)
  396. ->set('sentNotify')->eq($times)
  397. ->where('number')->eq($conference->number)
  398. ->exec();
  399. }
  400. /**
  401. * Add invitee into a conference.
  402. *
  403. * @param string $conferenceNumber
  404. * @param array $newInvitee
  405. * @access public
  406. * @return string|boolean
  407. */
  408. public function addInvitee($conferenceNumber, $newInvitee)
  409. {
  410. $conference = $this->getByNumber($conferenceNumber);
  411. foreach($newInvitee as $uid)
  412. {
  413. $hasInviteRecord = $this->dao->select('id')->from(TABLE_IM_CONFERENCEINVITE)
  414. ->where('conferenceID')->eq($conference->id)
  415. ->andWhere('inviteeID')->eq($uid)
  416. ->fetch();
  417. if(empty($hasInviteRecord))
  418. {
  419. $now = helper::now();
  420. $data = new stdClass();
  421. $data->conferenceID = $conference->id;
  422. $data->inviteeID = $uid;
  423. $data->status = 'pending';
  424. $data->createdDate = $now;
  425. $data->updatedDate = $now;
  426. $this->dao->insert(TABLE_IM_CONFERENCEINVITE)
  427. ->data($data)
  428. ->exec();
  429. }
  430. else
  431. {
  432. $this->dao->update(TABLE_IM_CONFERENCEINVITE)
  433. ->set('status')->eq('pending')
  434. ->set('updatedDate')->eq(helper::now())
  435. ->where('id')->eq($hasInviteRecord->id);
  436. }
  437. }
  438. $invitee = explode(',', $conference->invitee);
  439. $invitee = array_filter($invitee);
  440. $invitee = array_merge($invitee, $newInvitee);
  441. $invitee = array_unique($invitee);
  442. $invitee = implode(',', $invitee);
  443. $invitee = empty($invitee) ? '' : ",$invitee,";
  444. $this->dao->update(TABLE_IM_CONFERENCE)
  445. ->set('invitee')->eq($invitee)
  446. ->where('id')->eq($conference->id)
  447. ->exec();
  448. if(dao::isError()) return false;
  449. return $invitee;
  450. }
  451. /**
  452. * Add participant into a conference.
  453. *
  454. * @param string $conferenceNumber
  455. * @param int $userID
  456. * @access public
  457. * @return string|boolean
  458. */
  459. public function addParticipant($conferenceNumber, $userID)
  460. {
  461. $conference = $this->getByNumber($conferenceNumber);
  462. $participants = explode(',', $conference->participants);
  463. $participants = array_filter($participants);
  464. $participants[] = $userID;
  465. $participants = array_unique($participants);
  466. $participants = implode(',', $participants);
  467. $participants = empty($participants) ? '' : ",$participants,";
  468. $this->dao->update(TABLE_IM_CONFERENCE)
  469. ->set('participants')->eq($participants)
  470. ->where('id')->eq($conference->id)
  471. ->exec();
  472. if(dao::isError()) return false;
  473. return $participants;
  474. }
  475. /**
  476. * Remove participant from a conference.
  477. *
  478. * @param string $conferenceNumber
  479. * @param int $userID
  480. * @access public
  481. * @return string|false
  482. */
  483. public function removeParticipant($conferenceNumber, $userID)
  484. {
  485. $conference = $this->getByNumber($conferenceNumber);
  486. if($conference->participants == '') return false;
  487. $participants = explode(',', $conference->participants);
  488. $participants = array_filter($participants);
  489. $participants = array_diff($participants, array($userID));
  490. $participants = implode(',', $participants);
  491. $participants = empty($participants) ? '' : ",$participants,";
  492. $this->dao->update(TABLE_IM_CONFERENCE)
  493. ->set('participants')->eq($participants)
  494. ->where('id')->eq($conference->id)
  495. ->exec();
  496. if(dao::isError()) return false;
  497. return $participants;
  498. }
  499. public function addModerator($conferenceNumber, $userID)
  500. {
  501. $conference = $this->getByNumber($conferenceNumber);
  502. if(empty($conference)) return false;
  503. $moderators = explode(',', $conference->moderators);
  504. $moderators = array_filter($moderators);
  505. $moderators = array_unique(array_merge($moderators, array($userID)));
  506. $moderators = implode(',', $moderators);
  507. $moderators = empty($moderators) ? '' : ",$moderators,";
  508. $this->dao->update(TABLE_IM_CONFERENCE)
  509. ->set('moderators')->eq($moderators)
  510. ->where('id')->eq($conference->id)
  511. ->exec();
  512. return true;
  513. }
  514. public function addSubscriber($conferenceNumber, $userID)
  515. {
  516. $conference = $this->dao->select('subscribers')->from(TABLE_IM_CONFERENCE)
  517. ->where('number')->eq($conferenceNumber)
  518. ->fetch();
  519. if (!empty($conference))
  520. {
  521. $subscribers = explode(',', $conference->subscribers);
  522. $subscribers = array_filter($subscribers);
  523. $subscribers = array_unique(array_merge($subscribers, array($userID)));
  524. $subscribers = ',' . implode(',', $subscribers) . ',';
  525. $this->dao->update(TABLE_IM_CONFERENCE)
  526. ->set('subscribers')->eq($subscribers)
  527. ->where('number')->eq($conferenceNumber)
  528. ->exec();
  529. }
  530. }
  531. /**
  532. * Remove the user from all related conferences and close if necessary.
  533. *
  534. * @param int $userID
  535. * @access public
  536. * @return string[]
  537. */
  538. public function removeUserFromConferences($userID)
  539. {
  540. $conferences = $this->dao->select('*')->from(TABLE_IM_CONFERENCE)
  541. ->where('participants')->like("%,$userID,%")
  542. ->fetchAll();
  543. $closedConferences = [];
  544. foreach($conferences as $conference)
  545. {
  546. $participants = explode(',', $conference->participants);
  547. $participants = array_filter($participants);
  548. $participants = array_values($participants);
  549. $participants = array_map(function($v){
  550. return (int)$v;
  551. }, $participants);
  552. if(in_array($userID, $participants))
  553. {
  554. $leftParticipants = $this->removeParticipant($conference->number, $userID);
  555. if($leftParticipants == '') $closedConferences[] = $conference->number;
  556. }
  557. }
  558. return $closedConferences;
  559. }
  560. /**
  561. * Try to remove user from a conference of a chat.
  562. *
  563. * @deprecated
  564. * @param string $chatID
  565. * @param int $userID
  566. * @access public
  567. * @return object|boolean
  568. */
  569. public function removeUserFromChat($chatID, $userID)
  570. {
  571. /* Ignore conference number. */
  572. if(is_numeric($chatID)) return false;
  573. $conference = $this->getByChatID($chatID);
  574. if(empty($conference)) return false;
  575. $participants = explode(',', $conference->participants);
  576. $participants = array_filter($participants);
  577. $participants = array_diff($participants, array($userID));
  578. if(count($participants) == 0)
  579. {
  580. $this->close($conference->id, $userID);
  581. return false;
  582. }
  583. $participants = implode(',', $participants);
  584. $conference->participants = $participants;
  585. return $conference;
  586. }
  587. /**
  588. * Reset status of conferences.
  589. *
  590. * @access public
  591. * @return void
  592. */
  593. public function resetStatus()
  594. {
  595. $this->dao->update(TABLE_IM_CONFERENCE)
  596. ->set('status')->eq('closed')
  597. ->set('participants')->eq('')
  598. ->where('status')->eq('open')
  599. ->exec();
  600. }
  601. /**
  602. * Check if there is a participant limit in license.
  603. * If there is no limit, return 'unlimited'.
  604. * Otherwise, return the limit number.
  605. *
  606. * @access public
  607. * @return int
  608. */
  609. public function getConferenceLimit()
  610. {
  611. $limit = extCommonModel::getLicensePropertyValue('unlimitedParticipants');
  612. // fallback for older value.
  613. if($limit === '1') $limit = null;
  614. if($limit === '0') $limit = 3;
  615. return $limit;
  616. }
  617. /**
  618. * accept a conference invite.
  619. *
  620. * @param int $conferenceID
  621. * @param int $invitee
  622. * @return bool
  623. */
  624. public function acceptInvite($conferenceID, $invitee)
  625. {
  626. $this->dao->update(TABLE_IM_CONFERENCEINVITE)
  627. ->set('status')->eq('accepted')
  628. ->set('updatedDate')->eq(helper::now())
  629. ->where('conferenceID')->eq($conferenceID)
  630. ->andWhere('inviteeID')->eq($invitee)
  631. ->exec();
  632. return !dao::isError();
  633. }
  634. /**
  635. * reject a conference invite.
  636. *
  637. * @param int $conferenceID
  638. * @param int $invitee
  639. * @return bool
  640. */
  641. public function rejectInvite($conferenceID, $invitee)
  642. {
  643. $this->dao->update(TABLE_IM_CONFERENCEINVITE)
  644. ->set('status')->eq('rejected')
  645. ->set('updatedDate')->eq(helper::now())
  646. ->where('conferenceID')->eq($conferenceID)
  647. ->andWhere('inviteeID')->eq($invitee)
  648. ->exec();
  649. return !dao::isError();
  650. }
  651. /**
  652. * get pending invites.
  653. *
  654. * @param int $userID
  655. * @return array
  656. */
  657. public function getPendingInvites($userID)
  658. {
  659. return $this->dao->select('t1.*, t2.*')->from(TABLE_IM_CONFERENCEINVITE)->alias('t1')
  660. ->leftJoin(TABLE_IM_CONFERENCE)->alias('t2')->on('t1.conferenceID = t2.id')
  661. ->where('t1.inviteeID')->eq($userID)
  662. ->andWhere('t1.status')->eq('pending')
  663. ->andWhere('t2.status')->eq('open')
  664. ->fetchAll();
  665. }
  666. /**
  667. * get the jwt secret for jitsi meet authentication.
  668. *
  669. * @return string
  670. */
  671. public function getJwtSecret()
  672. {
  673. return $this->dao->select('value')->from(TABLE_CONFIG)
  674. ->where('owner')->eq('system')
  675. ->andWhere('module')->eq('jitsi')
  676. ->andWhere('section')->eq('jwt')
  677. ->andWhere('`key`')->eq('secret')
  678. ->fetch('value');
  679. }
  680. }