bbb.lib.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class bbb
  5. * This script initiates a video conference session, calling the BigBlueButton
  6. * API
  7. * @package chamilo.plugin.bigbluebutton
  8. *
  9. * BigBlueButton-Chamilo connector class
  10. */
  11. //namespace Chamilo\Plugin\BBB;
  12. /**
  13. * Class bbb
  14. * @package Chamilo\Plugin\BBB
  15. */
  16. class bbb
  17. {
  18. public $url;
  19. public $salt;
  20. public $api;
  21. public $userCompleteName = '';
  22. public $protocol = 'http://';
  23. public $debug = false;
  24. public $logoutUrl = '';
  25. public $pluginEnabled = false;
  26. public $enableGlobalConference = false;
  27. public $enableGlobalConferencePerUser = false;
  28. public $isGlobalConference = false;
  29. public $groupSupport = false;
  30. public $userSupport = false;
  31. public $accessUrl = 1;
  32. public $userId = 0;
  33. public $plugin;
  34. private $courseCode;
  35. private $sessionId;
  36. private $groupId;
  37. /**
  38. * Constructor (generates a connection to the API and the Chamilo settings
  39. * required for the connection to the video conference server)
  40. * @param string $host
  41. * @param string $salt
  42. * @param bool $isGlobalConference
  43. * @param int $isGlobalPerUser
  44. */
  45. public function __construct($host = '', $salt = '', $isGlobalConference = false, $isGlobalPerUser = 0)
  46. {
  47. $this->courseCode = api_get_course_id();
  48. $this->sessionId = api_get_session_id();
  49. $this->groupId = api_get_group_id();
  50. // Initialize video server settings from global settings
  51. $this->plugin = BBBPlugin::create();
  52. $bbbPluginEnabled = $this->plugin->get('tool_enable');
  53. $bbb_host = !empty($host) ? $host : $this->plugin->get('host');
  54. $bbb_salt = !empty($salt) ? $salt : $this->plugin->get('salt');
  55. $this->logoutUrl = $this->getListingUrl();
  56. $this->table = Database::get_main_table('plugin_bbb_meeting');
  57. $this->enableGlobalConference = (bool) $this->plugin->get('enable_global_conference');
  58. $this->isGlobalConference = (bool) $isGlobalConference;
  59. $columns = Database::listTableColumns($this->table);
  60. $this->groupSupport = isset($columns['group_id']) ? true : false;
  61. $this->userSupport = isset($columns['user_id']) ? true : false;
  62. $this->accessUrl = api_get_current_access_url_id();
  63. if ($this->userSupport && !empty($isGlobalPerUser)) {
  64. $this->enableGlobalConferencePerUser = (bool) $this->plugin->get('enable_global_conference_per_user');
  65. $this->userId = $isGlobalPerUser;
  66. } else {
  67. $this->enableGlobalConferencePerUser = false;
  68. }
  69. if ($this->groupSupport) {
  70. // Plugin check
  71. $this->groupSupport = (bool) $this->plugin->get('enable_conference_in_course_groups');
  72. if ($this->groupSupport) {
  73. // Platform check
  74. $bbbSetting = api_get_setting('bbb_enable_conference_in_course_groups');
  75. $bbbSetting = isset($bbbSetting['bbb']) ? $bbbSetting['bbb'] === 'true' : false;
  76. if ($bbbSetting) {
  77. // Course check
  78. $courseInfo = api_get_course_info();
  79. if ($courseInfo) {
  80. $this->groupSupport = api_get_course_setting('bbb_enable_conference_in_groups', $courseInfo['code']) === '1';
  81. }
  82. }
  83. }
  84. }
  85. if ($bbbPluginEnabled === 'true') {
  86. $userInfo = api_get_user_info();
  87. if (empty($userInfo) && !empty($isGlobalPerUser)) {
  88. // If we are following a link to a global "per user" conference
  89. // then generate a random guest name to join the conference
  90. // because there is no part of the process where we give a name
  91. $this->userCompleteName = 'Guest'.rand(1000, 9999);
  92. } else {
  93. $this->userCompleteName = $userInfo['complete_name'];
  94. }
  95. $this->salt = $bbb_salt;
  96. $info = parse_url($bbb_host);
  97. $this->url = $bbb_host.'/bigbluebutton/';
  98. if (isset($info['scheme'])) {
  99. $this->protocol = $info['scheme'].'://';
  100. $this->url = str_replace($this->protocol, '', $this->url);
  101. }
  102. // Setting BBB api
  103. define('CONFIG_SECURITY_SALT', $this->salt);
  104. define('CONFIG_SERVER_BASE_URL', $this->url);
  105. $this->api = new BigBlueButtonBN();
  106. $this->pluginEnabled = true;
  107. }
  108. }
  109. /**
  110. * Set forced the course, session or group IDs
  111. * @param string $courseCode
  112. * @param int $sessionId
  113. * @param int $groupId
  114. */
  115. public function forceCIdReq($courseCode, $sessionId = 0, $groupId = 0)
  116. {
  117. $this->courseCode = $courseCode;
  118. $this->sessionId = intval($sessionId);
  119. $this->groupId = intval($groupId);
  120. }
  121. /**
  122. * @return bool
  123. */
  124. public function isGlobalConferenceEnabled()
  125. {
  126. return $this->enableGlobalConference;
  127. }
  128. /**
  129. * @return bool
  130. */
  131. public function isGlobalConferencePerUserEnabled()
  132. {
  133. return $this->enableGlobalConferencePerUser;
  134. }
  135. /**
  136. * @return bool
  137. */
  138. public function isGlobalConference()
  139. {
  140. if ($this->isGlobalConferenceEnabled() === false) {
  141. return false;
  142. }
  143. return (bool) $this->isGlobalConference;
  144. }
  145. /**
  146. * @return bool
  147. */
  148. public function hasGroupSupport()
  149. {
  150. return $this->groupSupport;
  151. }
  152. /**
  153. * Checks whether a user is teacher in the current course
  154. * @return bool True if the user can be considered a teacher in this course, false otherwise
  155. */
  156. public function isConferenceManager()
  157. {
  158. if (api_is_coach() || api_is_platform_admin()) {
  159. return true;
  160. }
  161. if ($this->isGlobalConferencePerUserEnabled()) {
  162. $currentUserId = api_get_user_id();
  163. if ($this->userId === $currentUserId) {
  164. return true;
  165. } else {
  166. return false;
  167. }
  168. }
  169. $courseInfo = api_get_course_info();
  170. if (!empty($courseInfo)) {
  171. return api_is_course_admin();
  172. }
  173. return false;
  174. }
  175. /**
  176. * See this file in you BBB to set up default values
  177. * @param array $params Array of parameters that will be completed if not containing all expected variables
  178. /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
  179. *
  180. More record information:
  181. http://code.google.com/p/bigbluebutton/wiki/RecordPlaybackSpecification
  182. # Default maximum number of users a meeting can have.
  183. # Doesn't get enforced yet but is the default value when the create
  184. # API doesn't pass a value.
  185. defaultMaxUsers=20
  186. # Default duration of the meeting in minutes.
  187. # Current default is 0 (meeting doesn't end).
  188. defaultMeetingDuration=0
  189. # Remove the meeting from memory when the end API is called.
  190. # This allows 3rd-party apps to recycle the meeting right-away
  191. # instead of waiting for the meeting to expire (see below).
  192. removeMeetingWhenEnded=false
  193. # The number of minutes before the system removes the meeting from memory.
  194. defaultMeetingExpireDuration=1
  195. # The number of minutes the system waits when a meeting is created and when
  196. # a user joins. If after this period, a user hasn't joined, the meeting is
  197. # removed from memory.
  198. defaultMeetingCreateJoinDuration=5
  199. *
  200. * @return mixed
  201. */
  202. public function createMeeting($params)
  203. {
  204. $courseCode = api_get_course_id();
  205. $params['c_id'] = api_get_course_int_id();
  206. $params['session_id'] = api_get_session_id();
  207. if ($this->hasGroupSupport()) {
  208. $params['group_id'] = api_get_group_id();
  209. }
  210. if ($this->isGlobalConferencePerUserEnabled()) {
  211. $currentUserId = api_get_user_id();
  212. if ($this->userId === $currentUserId) {
  213. $params['user_id'] = $this->userId;
  214. }
  215. }
  216. $params['attendee_pw'] = isset($params['attendee_pw']) ? $params['attendee_pw'] : $this->getUserMeetingPassword();
  217. $attendeePassword = $params['attendee_pw'];
  218. $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword();
  219. $moderatorPassword = $params['moderator_pw'];
  220. $params['record'] = api_get_course_setting('big_blue_button_record_and_store', $courseCode) == 1 ? true : false;
  221. $max = api_get_course_setting('big_blue_button_max_students_allowed', $courseCode);
  222. $max = isset($max) ? $max : -1;
  223. $params['status'] = 1;
  224. // Generate a pseudo-global-unique-id to avoid clash of conferences on
  225. // the same BBB server with several Chamilo portals
  226. $params['remote_id'] = uniqid(true, true);
  227. // Each simultaneous conference room needs to have a different
  228. // voice_bridge composed of a 5 digits number, so generating a random one
  229. $params['voice_bridge'] = rand(10000, 99999);
  230. if ($this->debug) {
  231. error_log("enter create_meeting ".print_r($params, 1));
  232. }
  233. $params['created_at'] = api_get_utc_datetime();
  234. $params['access_url'] = $this->accessUrl;
  235. $id = Database::insert($this->table, $params);
  236. if ($id) {
  237. if ($this->debug) {
  238. error_log("create_meeting: $id ");
  239. }
  240. $meetingName = isset($params['meeting_name']) ? $params['meeting_name'] : $this->getCurrentVideoConferenceName();
  241. $welcomeMessage = isset($params['welcome_msg']) ? $params['welcome_msg'] : null;
  242. $record = isset($params['record']) && $params['record'] ? 'true' : 'false';
  243. $duration = isset($params['duration']) ? intval($params['duration']) : 0;
  244. // This setting currently limits the maximum conference duration,
  245. // to avoid lingering sessions on the video-conference server #6261
  246. $duration = 300;
  247. $bbbParams = array(
  248. 'meetingId' => $params['remote_id'], // REQUIRED
  249. 'meetingName' => $meetingName, // REQUIRED
  250. 'attendeePw' => $attendeePassword, // Match this value in getJoinMeetingURL() to join as attendee.
  251. 'moderatorPw' => $moderatorPassword, // Match this value in getJoinMeetingURL() to join as moderator.
  252. 'welcomeMsg' => $welcomeMessage, // ''= use default. Change to customize.
  253. 'dialNumber' => '', // The main number to call into. Optional.
  254. 'voiceBridge' => $params['voice_bridge'], // PIN to join voice. Required.
  255. 'webVoice' => '', // Alphanumeric to join voice. Optional.
  256. 'logoutUrl' => $this->logoutUrl,
  257. 'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number]
  258. 'record' => $record, // New. 'true' will tell BBB to record the meeting.
  259. 'duration' => $duration, // Default = 0 which means no set duration in minutes. [number]
  260. //'meta_category' => '', // Use to pass additional info to BBB server. See API docs.
  261. );
  262. if ($this->debug) {
  263. error_log("create_meeting params: ".print_r($bbbParams,1));
  264. }
  265. $status = false;
  266. $meeting = null;
  267. while ($status === false) {
  268. $result = $this->api->createMeetingWithXmlResponseArray(
  269. $bbbParams
  270. );
  271. if (isset($result) && strval($result['returncode']) == 'SUCCESS') {
  272. if ($this->debug) {
  273. error_log(
  274. "create_meeting result: " . print_r($result, 1)
  275. );
  276. }
  277. $meeting = $this->joinMeeting($meetingName, true);
  278. return $meeting;
  279. }
  280. }
  281. return $this->logoutUrl;
  282. }
  283. }
  284. /**
  285. * Save a participant in a meeting room
  286. * @param int $meetingId
  287. * @param int $participantId
  288. * @return false|int The last inserted ID. Otherwise return false
  289. */
  290. public function saveParticipant($meetingId, $participantId)
  291. {
  292. return Database::insert(
  293. 'plugin_bbb_room',
  294. [
  295. 'meeting_id' => $meetingId,
  296. 'participant_id' => $participantId,
  297. 'in_at' => api_get_utc_datetime(),
  298. 'out_at' => api_get_utc_datetime()
  299. ]
  300. );
  301. }
  302. /**
  303. * Tells whether the given meeting exists and is running
  304. * (using course code as name)
  305. * @param string $meetingName Meeting name (usually the course code)
  306. *
  307. * @return bool True if meeting exists, false otherwise
  308. * @assert ('') === false
  309. * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
  310. */
  311. public function meetingExists($meetingName)
  312. {
  313. if (empty($meetingName)) {
  314. return false;
  315. }
  316. $courseId = api_get_course_int_id();
  317. $sessionId = api_get_session_id();
  318. $conditions = array(
  319. 'where' => array(
  320. 'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 AND access_url = ?' =>
  321. array($courseId, $sessionId, $meetingName, $this->accessUrl)
  322. )
  323. );
  324. if ($this->hasGroupSupport()) {
  325. $groupId = api_get_group_id();
  326. $conditions = array(
  327. 'where' => array(
  328. 'c_id = ? AND session_id = ? AND meeting_name = ? AND group_id = ? AND status = 1 AND access_url = ?' =>
  329. array($courseId, $sessionId, $meetingName, $groupId, $this->accessUrl)
  330. )
  331. );
  332. }
  333. $meetingData = Database::select(
  334. '*',
  335. $this->table,
  336. $conditions,
  337. 'first'
  338. );
  339. if ($this->debug) {
  340. error_log("meeting_exists ".print_r($meetingData, 1));
  341. }
  342. if (empty($meetingData)) {
  343. return false;
  344. } else {
  345. return true;
  346. }
  347. }
  348. /**
  349. * Returns a meeting "join" URL
  350. * @param string The name of the meeting (usually the course code)
  351. * @return mixed The URL to join the meeting, or false on error
  352. * @todo implement moderator pass
  353. * @assert ('') === false
  354. * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
  355. */
  356. public function joinMeeting($meetingName, $loop = false)
  357. {
  358. if (empty($meetingName)) {
  359. return false;
  360. }
  361. $manager = $this->isConferenceManager();
  362. if ($manager) {
  363. $pass = $this->getModMeetingPassword();
  364. } else {
  365. $pass = $this->getUserMeetingPassword();
  366. }
  367. $meetingData = Database::select(
  368. '*',
  369. $this->table,
  370. array('where' => array('meeting_name = ? AND status = 1 AND access_url = ?' => array($meetingName, $this->accessUrl))),
  371. 'first'
  372. );
  373. if (empty($meetingData) || !is_array($meetingData)) {
  374. if ($this->debug) {
  375. error_log("meeting does not exist: $meetingName");
  376. }
  377. return false;
  378. }
  379. $params = array(
  380. 'meetingId' => $meetingData['remote_id'],
  381. // -- REQUIRED - The unique id for the meeting
  382. 'password' => $this->getModMeetingPassword()
  383. // -- REQUIRED - The moderator password for the meeting
  384. );
  385. $status = false;
  386. $meetingInfoExists = false;
  387. while ($status === false) {
  388. $meetingIsRunningInfo = $this->getMeetingInfo($params);
  389. if ($meetingIsRunningInfo === false) {
  390. //checking with the remote_id didn't work, so just in case and
  391. // to provide backwards support, check with the id
  392. $params = array(
  393. 'meetingId' => $meetingData['id'],
  394. // -- REQUIRED - The unique id for the meeting
  395. 'password' => $this->getModMeetingPassword()
  396. // -- REQUIRED - The moderator password for the meeting
  397. );
  398. $meetingIsRunningInfo = $this->getMeetingInfo($params);
  399. }
  400. if ($this->debug) {
  401. error_log(print_r($meetingIsRunningInfo, 1));
  402. }
  403. if (strval($meetingIsRunningInfo['returncode']) == 'SUCCESS' &&
  404. isset($meetingIsRunningInfo['meetingName']) &&
  405. !empty($meetingIsRunningInfo['meetingName'])
  406. //strval($meetingIsRunningInfo['running']) == 'true'
  407. ) {
  408. $meetingInfoExists = true;
  409. }
  410. if ($this->debug) {
  411. error_log(
  412. "meeting is running: " . intval($meetingInfoExists)
  413. );
  414. }
  415. if ($meetingInfoExists) {
  416. $status = true;
  417. }
  418. if ($loop) {
  419. continue;
  420. } else {
  421. break;
  422. }
  423. }
  424. if ($meetingInfoExists) {
  425. $joinParams = array(
  426. 'meetingId' => $meetingData['remote_id'], // -- REQUIRED - A unique id for the meeting
  427. 'username' => $this->userCompleteName, //-- REQUIRED - The name that will display for the user in the meeting
  428. 'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
  429. //'createTime' => api_get_utc_datetime(), //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
  430. 'userID' => api_get_user_id(), //-- OPTIONAL - string
  431. 'webVoiceConf' => '' // -- OPTIONAL - string
  432. );
  433. $url = $this->api->getJoinMeetingURL($joinParams);
  434. $url = $this->protocol.$url;
  435. } else {
  436. $url = $this->logoutUrl;
  437. }
  438. if ($this->debug) {
  439. error_log("return url :" . $url);
  440. }
  441. return $url;
  442. }
  443. /**
  444. * Get information about the given meeting
  445. * @param array ...?
  446. * @return mixed Array of information on success, false on error
  447. * @assert (array()) === false
  448. */
  449. public function getMeetingInfo($params)
  450. {
  451. try {
  452. $result = $this->api->getMeetingInfoWithXmlResponseArray($params);
  453. if ($result == null) {
  454. if ($this->debug) {
  455. error_log("Failed to get any response. Maybe we can't contact the BBB server.");
  456. }
  457. } else {
  458. return $result;
  459. }
  460. } catch (Exception $e) {
  461. if ($this->debug) {
  462. error_log('Caught exception: ', $e->getMessage(), "\n");
  463. }
  464. }
  465. return false;
  466. }
  467. /**
  468. * @param int $courseId
  469. * @param int $sessionId
  470. * @param int $status
  471. *
  472. * @return array
  473. */
  474. public function getAllMeetingsInCourse($courseId, $sessionId, $status)
  475. {
  476. $conditions = array(
  477. 'where' => array(
  478. 'status = ? AND c_id = ? AND session_id = ? ' => array(
  479. $status,
  480. $courseId,
  481. $sessionId,
  482. ),
  483. ),
  484. );
  485. $meetingList = Database::select(
  486. '*',
  487. $this->table,
  488. $conditions
  489. );
  490. return $meetingList;
  491. }
  492. /**
  493. * Gets all the course meetings saved in the plugin_bbb_meeting table
  494. * @param int $courseId
  495. * @param int $sessionId
  496. * @param int $groupId
  497. * @param bool $isAdminReport Optional. Set to true then the report is for admins
  498. * @param array $dateRange Optional
  499. * @return array Array of current open meeting rooms
  500. */
  501. public function getMeetings(
  502. $courseId = 0,
  503. $sessionId = 0,
  504. $groupId = 0,
  505. $isAdminReport = false,
  506. $dateRange = []
  507. ) {
  508. $em = Database::getManager();
  509. $manager = $this->isConferenceManager();
  510. $conditions = [];
  511. if ($courseId || $sessionId || $groupId) {
  512. $conditions = array(
  513. 'where' => array(
  514. 'c_id = ? AND session_id = ? ' => array($courseId, $sessionId),
  515. ),
  516. );
  517. if ($this->hasGroupSupport()) {
  518. $conditions = array(
  519. 'where' => array(
  520. 'c_id = ? AND session_id = ? AND group_id = ? ' => array($courseId, $sessionId, $groupId)
  521. )
  522. );
  523. }
  524. }
  525. if (!empty($dateRange)) {
  526. $dateStart = date_create($dateRange['search_meeting_start']);
  527. $dateStart = date_format($dateStart, 'Y-m-d H:i:s');
  528. $dateEnd = date_create($dateRange['search_meeting_end']);
  529. $dateEnd = $dateEnd->add(new DateInterval('P1D'));
  530. $dateEnd = date_format($dateEnd, 'Y-m-d H:i:s');
  531. $conditions = array(
  532. 'where' => array(
  533. 'created_at BETWEEN ? AND ? ' => array($dateStart, $dateEnd),
  534. ),
  535. );
  536. }
  537. $meetingList = Database::select(
  538. '*',
  539. $this->table,
  540. $conditions
  541. );
  542. $isGlobal = $this->isGlobalConference();
  543. $newMeetingList = array();
  544. foreach ($meetingList as $meetingDB) {
  545. $item = array();
  546. $courseId = $meetingDB['c_id'];
  547. $courseInfo = api_get_course_info_by_id($courseId);
  548. $courseCode = $courseInfo['code'];
  549. if ($manager) {
  550. $pass = $this->getUserMeetingPassword($courseCode);
  551. } else {
  552. $pass = $this->getModMeetingPassword($courseCode);
  553. }
  554. $meetingBBB = $this->getMeetingInfo(
  555. [
  556. 'meetingId' => $meetingDB['remote_id'],
  557. 'password' => $pass
  558. ]
  559. );
  560. if ($meetingBBB === false) {
  561. //checking with the remote_id didn't work, so just in case and
  562. // to provide backwards support, check with the id
  563. $params = array(
  564. 'meetingId' => $meetingDB['id'],
  565. // -- REQUIRED - The unique id for the meeting
  566. 'password' => $pass
  567. // -- REQUIRED - The moderator password for the meeting
  568. );
  569. $meetingBBB = $this->getMeetingInfo($params);
  570. }
  571. if ($meetingDB['visibility'] == 0 && $this->isConferenceManager() === false) {
  572. continue;
  573. }
  574. $meetingBBB['end_url'] = $this->endUrl($meetingDB);
  575. if (isset($meetingBBB['returncode']) && (string)$meetingBBB['returncode'] == 'FAILED') {
  576. if ($meetingDB['status'] == 1 && $this->isConferenceManager()) {
  577. $this->endMeeting($meetingDB['id'], $courseCode);
  578. }
  579. } else {
  580. $meetingBBB['add_to_calendar_url'] = $this->addToCalendarUrl($meetingDB);
  581. }
  582. if ($meetingDB['record'] == 1) {
  583. // backwards compatibility (when there was no remote ID)
  584. $mId = $meetingDB['remote_id'];
  585. if (empty($mId)) {
  586. $mId = $meetingDB['id'];
  587. }
  588. if (empty($mId)) {
  589. // if the id is still empty (should *never* occur as 'id' is
  590. // the table's primary key), skip this conference
  591. continue;
  592. }
  593. $record = [];
  594. if (empty($meetingDB['video_url'])) {
  595. $recordingParams = ['meetingId' => $mId];
  596. $records = $this->api->getRecordingsWithXmlResponseArray($recordingParams);
  597. if (!empty($records)) {
  598. if (!isset($records['messageKey']) || $records['messageKey'] != 'noRecordings') {
  599. $record = end($records);
  600. if (!is_array($record) || !isset($record['recordId'])) {
  601. continue;
  602. }
  603. $this->updateMeetingVideoUrl($meetingDB['id'], $record['playbackFormatUrl']);
  604. if (!$this->isConferenceManager()) {
  605. $record = [];
  606. }
  607. }
  608. }
  609. } else {
  610. $record['playbackFormatUrl'] = $meetingDB['video_url'];
  611. }
  612. $recordLink = isset($record['playbackFormatUrl']) && !empty($record['playbackFormatUrl'])
  613. ? Display::url(
  614. $this->plugin->get_lang('ViewRecord'),
  615. $record['playbackFormatUrl'],
  616. ['target' => '_blank']
  617. )
  618. : get_lang('NoRecording');
  619. if ($isAdminReport) {
  620. $this->forceCIdReq($courseInfo['code'], $meetingDB['session_id'], $meetingDB['group_id']);
  621. }
  622. $actionLinks = $this->getActionLinks($meetingDB, $record, $isGlobal, $isAdminReport);
  623. $item['show_links'] = $recordLink;
  624. } else {
  625. $actionLinks = $this->getActionLinks($meetingDB, [], $isGlobal, $isAdminReport);
  626. $item['show_links'] = get_lang('NoRecording');
  627. }
  628. $item['action_links'] = implode(PHP_EOL, $actionLinks);
  629. $item['created_at'] = api_convert_and_format_date($meetingDB['created_at']);
  630. // created_at
  631. $meetingDB['created_at'] = $item['created_at']; //avoid overwrite in array_merge() below
  632. $item['publish_url'] = $this->publishUrl($meetingDB);
  633. $item['unpublish_url'] = $this->unPublishUrl($meetingBBB);
  634. if ($meetingDB['status'] == 1) {
  635. $joinParams = array(
  636. 'meetingId' => $meetingDB['remote_id'], //-- REQUIRED - A unique id for the meeting
  637. 'username' => $this->userCompleteName, //-- REQUIRED - The name that will display for the user in the meeting
  638. 'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
  639. 'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
  640. 'userID' => '', // -- OPTIONAL - string
  641. 'webVoiceConf' => '' // -- OPTIONAL - string
  642. );
  643. $item['go_url'] = $this->protocol.$this->api->getJoinMeetingURL($joinParams);
  644. }
  645. $item = array_merge($item, $meetingDB, $meetingBBB);
  646. $item['course'] = $em->find('ChamiloCoreBundle:Course', $item['c_id']);
  647. $item['session'] = $em->find('ChamiloCoreBundle:Session', $item['session_id']);
  648. $newMeetingList[] = $item;
  649. }
  650. return $newMeetingList;
  651. }
  652. /**
  653. * Function disabled
  654. */
  655. public function publishMeeting($id)
  656. {
  657. //return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt);
  658. if (empty($id)) {
  659. return false;
  660. }
  661. $id = intval($id);
  662. Database::update($this->table, array('visibility' => 1), array('id = ? ' => $id));
  663. return true;
  664. }
  665. /**
  666. * Function disabled
  667. */
  668. public function unpublishMeeting($id)
  669. {
  670. //return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt);
  671. if (empty($id)) {
  672. return false;
  673. }
  674. $id = intval($id);
  675. Database::update($this->table, array('visibility' => 0), array('id = ?' => $id));
  676. return true;
  677. }
  678. /**
  679. * Closes a meeting (usually when the user click on the close button from
  680. * the conferences listing.
  681. * @param string The internal ID of the meeting (id field for this meeting)
  682. * @param string $courseCode
  683. *
  684. * @return void
  685. * @assert (0) === false
  686. */
  687. public function endMeeting($id, $courseCode = null)
  688. {
  689. if (empty($id)) {
  690. return false;
  691. }
  692. $meetingData = Database::select(
  693. '*',
  694. $this->table,
  695. array('where' => array('id = ?' => array($id))),
  696. 'first'
  697. );
  698. $manager = $this->isConferenceManager();
  699. if ($manager) {
  700. $pass = $this->getUserMeetingPassword($courseCode);
  701. } else {
  702. $pass = $this->getModMeetingPassword($courseCode);
  703. }
  704. $endParams = array(
  705. 'meetingId' => $meetingData['remote_id'], // REQUIRED - We have to know which meeting to end.
  706. 'password' => $pass, // REQUIRED - Must match moderator pass for meeting.
  707. );
  708. $this->api->endMeetingWithXmlResponseArray($endParams);
  709. Database::update(
  710. $this->table,
  711. array('status' => 0, 'closed_at' => api_get_utc_datetime()),
  712. array('id = ? ' => $id)
  713. );
  714. }
  715. /**
  716. * Gets the password for a specific meeting for the current user
  717. * @param string $courseCode
  718. * @return string A moderator password if user is teacher, or the course code otherwise
  719. *
  720. */
  721. public function getUserMeetingPassword($courseCode = null)
  722. {
  723. if ($this->isGlobalConferencePerUserEnabled()) {
  724. return 'url_'.$this->userId.'_'.api_get_current_access_url_id();
  725. }
  726. if ($this->isGlobalConference()) {
  727. return 'url_'.api_get_current_access_url_id();
  728. }
  729. $courseCode = empty($courseCode) ? api_get_course_id() : $courseCode;
  730. return $courseCode;
  731. }
  732. /**
  733. * Generated a moderator password for the meeting
  734. * @param string $courseCode
  735. *
  736. * @return string A password for the moderation of the videoconference
  737. */
  738. public function getModMeetingPassword($courseCode = null)
  739. {
  740. if ($this->isGlobalConferencePerUserEnabled()) {
  741. return 'url_'.$this->userId.'_'.api_get_current_access_url_id().'_mod';
  742. }
  743. if ($this->isGlobalConference()) {
  744. return 'url_'.api_get_current_access_url_id().'_mod';
  745. }
  746. $courseCode = empty($courseCode) ? api_get_course_id() : $courseCode;
  747. return $courseCode.'mod';
  748. }
  749. /**
  750. * Get users online in the current course room
  751. * @return int The number of users currently connected to the videoconference
  752. * @assert () > -1
  753. */
  754. public function getUsersOnlineInCurrentRoom()
  755. {
  756. $courseId = api_get_course_int_id();
  757. $sessionId = api_get_session_id();
  758. $conditions = array(
  759. 'where' => array(
  760. 'c_id = ? AND session_id = ? AND status = 1 AND access_url = ?' => array(
  761. $courseId,
  762. $sessionId,
  763. $this->accessUrl
  764. ),
  765. ),
  766. );
  767. if ($this->hasGroupSupport()) {
  768. $groupId = api_get_group_id();
  769. $conditions = array(
  770. 'where' => array(
  771. 'c_id = ? AND session_id = ? AND group_id = ? AND status = 1 AND access_url = ?' => array(
  772. $courseId,
  773. $sessionId,
  774. $groupId,
  775. $this->accessUrl
  776. ),
  777. ),
  778. );
  779. }
  780. if ($this->isGlobalConferencePerUserEnabled()) {
  781. $conditions = array(
  782. 'where' => array(
  783. 'user_id = ? AND status = 1 AND access_url = ?' => array(
  784. $this->userId,
  785. $this->accessUrl
  786. ),
  787. ),
  788. );
  789. }
  790. $meetingData = Database::select(
  791. '*',
  792. $this->table,
  793. $conditions,
  794. 'first'
  795. );
  796. if (empty($meetingData)) {
  797. return 0;
  798. }
  799. $pass = $this->getModMeetingPassword();
  800. $info = $this->getMeetingInfo(array('meetingId' => $meetingData['remote_id'], 'password' => $pass));
  801. if ($info === false) {
  802. //checking with the remote_id didn't work, so just in case and
  803. // to provide backwards support, check with the id
  804. $params = array(
  805. 'meetingId' => $meetingData['id'],
  806. // -- REQUIRED - The unique id for the meeting
  807. 'password' => $pass
  808. // -- REQUIRED - The moderator password for the meeting
  809. );
  810. $info = $this->getMeetingInfo($params);
  811. }
  812. if (!empty($info) && isset($info['participantCount'])) {
  813. return $info['participantCount'];
  814. }
  815. return 0;
  816. }
  817. /**
  818. * Deletes a previous recording of a meeting
  819. * @param int $id ID of the recording
  820. * @return array ?
  821. * @assert () === false
  822. * @todo Also delete links and agenda items created from this recording
  823. */
  824. public function deleteRecord($id)
  825. {
  826. if (empty($id)) {
  827. return false;
  828. }
  829. $meetingData = Database::select(
  830. '*',
  831. $this->table,
  832. array('where' => array('id = ?' => array($id))),
  833. 'first'
  834. );
  835. $recordingParams = array(
  836. /*
  837. * NOTE: Set the recordId below to a valid id after you have
  838. * created a recorded meeting, and received a real recordID
  839. * back from your BBB server using the
  840. * getRecordingsWithXmlResponseArray method.
  841. */
  842. // REQUIRED - We have to know which recording:
  843. 'recordId' => $meetingData['remote_id'],
  844. );
  845. $result = $this->api->deleteRecordingsWithXmlResponseArray($recordingParams);
  846. if (!empty($result) && isset($result['deleted']) && $result['deleted'] === 'true') {
  847. Database::delete(
  848. 'plugin_bbb_room',
  849. array('meeting_id = ?' => array($id))
  850. );
  851. Database::delete(
  852. $this->table,
  853. array('id = ?' => array($id))
  854. );
  855. }
  856. return $result;
  857. }
  858. /**
  859. * Creates a link in the links tool from the given videoconference recording
  860. * @param int $id ID of the item in the plugin_bbb_meeting table
  861. * @param string Hash identifying the recording, as provided by the API
  862. * @return mixed ID of the newly created link, or false on error
  863. * @assert (null, null) === false
  864. * @assert (1, null) === false
  865. * @assert (null, 'abcdefabcdefabcdefabcdef') === false
  866. */
  867. public function copyRecordToLinkTool($id)
  868. {
  869. if (empty($id)) {
  870. return false;
  871. }
  872. //$records = BigBlueButtonBN::getRecordingsUrl($id);
  873. $meetingData = Database::select('*', $this->table, array('where' => array('id = ?' => array($id))), 'first');
  874. $records = $this->api->getRecordingsWithXmlResponseArray(array('meetingId' => $meetingData['remote_id']));
  875. if (!empty($records)) {
  876. if (isset($records['message']) && !empty($records['message'])) {
  877. if ($records['messageKey'] == 'noRecordings') {
  878. $recordArray[] = $this->plugin->get_lang('NoRecording');
  879. } else {
  880. //$recordArray[] = $records['message'];
  881. }
  882. return false;
  883. } else {
  884. $record = $records[0];
  885. if (is_array($record) && isset($record['recordId'])) {
  886. $url = $record['playbackFormatUrl'];
  887. $link = new Link();
  888. $params['url'] = $url;
  889. $params['title'] = $meetingData['meeting_name'];
  890. $id = $link->save($params);
  891. return $id;
  892. }
  893. }
  894. }
  895. return false;
  896. }
  897. /**
  898. * Checks if the video conference server is running.
  899. * Function currently disabled (always returns 1)
  900. * @return bool True if server is running, false otherwise
  901. * @assert () === false
  902. */
  903. public function isServerRunning()
  904. {
  905. return true;
  906. //return BigBlueButtonBN::isServerRunning($this->protocol.$this->url);
  907. }
  908. /**
  909. * Get active session in the all platform
  910. */
  911. public function getActiveSessionsCount()
  912. {
  913. $meetingList = Database::select(
  914. 'count(id) as count',
  915. $this->table,
  916. array('where' => array('status = ? AND access_url = ?' => array(1, $this->accessUrl))),
  917. 'first'
  918. );
  919. return $meetingList['count'];
  920. }
  921. /**
  922. * @param string $url
  923. */
  924. public function redirectToBBB($url)
  925. {
  926. if (file_exists(__DIR__ . '/../config.vm.php')) {
  927. // Using VM
  928. echo Display::url($this->plugin->get_lang('ClickToContinue'), $url);
  929. exit;
  930. } else {
  931. // Classic
  932. header("Location: $url");
  933. exit;
  934. }
  935. }
  936. /**
  937. * @return string
  938. */
  939. public function getUrlParams()
  940. {
  941. if (empty($this->courseCode)) {
  942. if ($this->isGlobalConferencePerUserEnabled()) {
  943. return 'global=1&user_id='.$this->userId;
  944. }
  945. if ($this->isGlobalConference()) {
  946. return 'global=1';
  947. }
  948. return '';
  949. }
  950. return http_build_query([
  951. 'cidReq' => $this->courseCode,
  952. 'id_session' => $this->sessionId,
  953. 'gidReq' => $this->groupId
  954. ]);
  955. }
  956. /**
  957. * @return string
  958. */
  959. public function getCurrentVideoConferenceName()
  960. {
  961. if ($this->isGlobalConferencePerUserEnabled()) {
  962. return 'url_'.$this->userId.'_'.api_get_current_access_url_id();
  963. }
  964. if ($this->isGlobalConference()) {
  965. return 'url_'.api_get_current_access_url_id();
  966. }
  967. if ($this->hasGroupSupport()) {
  968. return api_get_course_id().'-'.api_get_session_id().'-'.api_get_group_id();
  969. }
  970. return api_get_course_id().'-'.api_get_session_id();
  971. }
  972. /**
  973. * @return string
  974. */
  975. public function getConferenceUrl()
  976. {
  977. return api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?launch=1&'.$this->getUrlParams();
  978. }
  979. /**
  980. * @return string
  981. */
  982. public function getListingUrl()
  983. {
  984. return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams();
  985. }
  986. /**
  987. * @param array $meeting
  988. * @return string
  989. */
  990. public function endUrl($meeting)
  991. {
  992. if (!isset($meeting['id'])) {
  993. return '';
  994. }
  995. return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=end&id='.$meeting['id'];
  996. }
  997. /**
  998. * @param array $meeting
  999. * @param array $record
  1000. * @return string
  1001. */
  1002. public function addToCalendarUrl($meeting, $record = [])
  1003. {
  1004. $url = isset($record['playbackFormatUrl']) ? $record['playbackFormatUrl'] : '';
  1005. return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=add_to_calendar&id='.$meeting['id'].'&start='.api_strtotime($meeting['created_at']).'&url='.$url;
  1006. }
  1007. /**
  1008. * @param array $meeting
  1009. * @return string
  1010. */
  1011. public function publishUrl($meeting)
  1012. {
  1013. if (!isset($meeting['id'])) {
  1014. return '';
  1015. }
  1016. return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=publish&id='.$meeting['id'];
  1017. }
  1018. /**
  1019. * @param array $meeting
  1020. * @return string
  1021. */
  1022. public function unPublishUrl($meeting)
  1023. {
  1024. if (!isset($meeting['id'])) {
  1025. return null;
  1026. }
  1027. return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=unpublish&id='.$meeting['id'];
  1028. }
  1029. /**
  1030. * @param array $meeting
  1031. * @return string
  1032. */
  1033. public function deleteRecordUrl($meeting)
  1034. {
  1035. if (!isset($meeting['id'])) {
  1036. return '';
  1037. }
  1038. return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=delete_record&id='.$meeting['id'];
  1039. }
  1040. /**
  1041. * @param array $meeting
  1042. * @return string
  1043. */
  1044. public function copyToRecordToLinkTool($meeting)
  1045. {
  1046. if (!isset($meeting['id'])) {
  1047. return '';
  1048. }
  1049. return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=copy_record_to_link_tool&id='.$meeting['id'];
  1050. }
  1051. /**
  1052. * Get the meeting info from DB by its name
  1053. * @param string $name
  1054. * @return array
  1055. */
  1056. public function findMeetingByName($name)
  1057. {
  1058. $meetingData = Database::select(
  1059. '*',
  1060. 'plugin_bbb_meeting',
  1061. array('where' => array('meeting_name = ? AND status = 1 ' => $name)),
  1062. 'first'
  1063. );
  1064. return $meetingData;
  1065. }
  1066. /**
  1067. * @param int $meetingId
  1068. * @return array
  1069. */
  1070. public function findMeetingParticipants($meetingId)
  1071. {
  1072. $em = Database::getManager();
  1073. $meetingData = Database::select(
  1074. '*',
  1075. 'plugin_bbb_room',
  1076. array('where' => array('meeting_id = ?' => intval($meetingId)))
  1077. );
  1078. $participantIds = [];
  1079. $return = [];
  1080. foreach ($meetingData as $participantInfo) {
  1081. if (in_array($participantInfo['participant_id'], $participantIds)) {
  1082. continue;
  1083. }
  1084. $participantIds[] = $participantInfo['participant_id'];
  1085. $return[] = [
  1086. 'id' => $participantInfo['id'],
  1087. 'meeting_id' => $participantInfo['meeting_id'],
  1088. 'participant' => $em->find('ChamiloUserBundle:User', $participantInfo['participant_id']),
  1089. 'in_at' => $participantInfo['in_at'],
  1090. 'out_at' => $participantInfo['out_at']
  1091. ];
  1092. }
  1093. return $return;
  1094. }
  1095. /**
  1096. * @param array $meetingInfo
  1097. * @param array $recordInfo
  1098. * @param bool $isGlobal
  1099. * @param bool $isAdminReport
  1100. * @return array
  1101. */
  1102. private function getActionLinks($meetingInfo, $recordInfo, $isGlobal = false, $isAdminReport = false)
  1103. {
  1104. $isVisible = $meetingInfo['visibility'] != 0;
  1105. $linkVisibility = $isVisible
  1106. ? Display::url(
  1107. Display::return_icon('visible.png', get_lang('MakeInvisible')),
  1108. $this->unPublishUrl($meetingInfo)
  1109. )
  1110. : Display::url(
  1111. Display::return_icon('invisible.png', get_lang('MakeVisible')),
  1112. $this->publishUrl($meetingInfo)
  1113. );
  1114. $links = [];
  1115. if (empty($recordInfo)) {
  1116. if (!$isAdminReport) {
  1117. $links[] = Display::url(
  1118. Display::return_icon('delete.png', get_lang('Delete')),
  1119. $this->deleteRecordUrl($meetingInfo)
  1120. );
  1121. $links[] = $linkVisibility;
  1122. return $links;
  1123. } else {
  1124. $links[] = Display::url(
  1125. Display::return_icon('course_home.png', get_lang('GoToCourse')),
  1126. $this->getListingUrl()
  1127. );
  1128. return $links;
  1129. }
  1130. }
  1131. if (!$isGlobal) {
  1132. $links[] = Display::url(
  1133. Display::return_icon('link.gif', get_lang('UrlMeetingToShare')),
  1134. $this->copyToRecordToLinkTool($meetingInfo)
  1135. );
  1136. $links[] = Display::url(
  1137. Display::return_icon('agenda.png', get_lang('AddToCalendar')),
  1138. $this->addToCalendarUrl($meetingInfo, $recordInfo)
  1139. );
  1140. }
  1141. if ($meetingInfo['has_video_m4v']) {
  1142. $links[] = Display::url(
  1143. Display::return_icon('save.png', get_lang('DownloadFile')),
  1144. $recordInfo['playbackFormatUrl'] . '/capture.m4v',
  1145. ['target' => '_blank']
  1146. );
  1147. } else {
  1148. $links[] = Display::url(
  1149. Display::return_icon('save.png', get_lang('DownloadFile')),
  1150. '#',
  1151. [
  1152. 'id' => "btn-check-meeting-video-{$meetingInfo['id']}",
  1153. 'class' => 'check-meeting-video',
  1154. 'data-id' => $meetingInfo['id']
  1155. ]
  1156. );
  1157. }
  1158. if (!$isAdminReport) {
  1159. $links[] = Display::url(
  1160. Display::return_icon('delete.png', get_lang('Delete')),
  1161. $this->deleteRecordUrl($meetingInfo)
  1162. );
  1163. $links[] = $linkVisibility;
  1164. } else {
  1165. $links[] = Display::url(
  1166. Display::return_icon('course_home.png', get_lang('GoToCourse')),
  1167. $this->getListingUrl()
  1168. );
  1169. }
  1170. return $links;
  1171. }
  1172. /**
  1173. * @param int $meetingId
  1174. * @param string $videoUrl
  1175. * @return bool|int
  1176. */
  1177. public function updateMeetingVideoUrl($meetingId, $videoUrl)
  1178. {
  1179. return Database::update(
  1180. 'plugin_bbb_meeting',
  1181. ['video_url' => $videoUrl],
  1182. ['id = ?' => intval($meetingId)]
  1183. );
  1184. }
  1185. /**
  1186. * Check if the meeting has a capture.m4v video file. If exists then the has_video_m4v field is updated
  1187. * @param int $meetingId
  1188. * @return bool
  1189. */
  1190. public function checkDirectMeetingVideoUrl($meetingId)
  1191. {
  1192. $meetingInfo = Database::select(
  1193. '*',
  1194. 'plugin_bbb_meeting',
  1195. [
  1196. 'where' => ['id = ?' => intval($meetingId)]
  1197. ],
  1198. 'first'
  1199. );
  1200. if (!isset($meetingInfo['video_url'])) {
  1201. return false;
  1202. }
  1203. $hasCapture = SocialManager::verifyUrl($meetingInfo['video_url'] . '/capture.m4v');
  1204. if ($hasCapture) {
  1205. return Database::update(
  1206. 'plugin_bbb_meeting',
  1207. ['has_video_m4v' => true],
  1208. ['id = ?' => intval($meetingId)]
  1209. );
  1210. }
  1211. return $hasCapture;
  1212. }
  1213. }