| Total Complexity | 259 |
| Total Lines | 1999 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like bbb often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use bbb, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 10 | class bbb |
||
| 11 | { |
||
| 12 | public $url; |
||
| 13 | public $salt; |
||
| 14 | public $api; |
||
| 15 | public $userCompleteName = ''; |
||
| 16 | public $protocol = 'http://'; |
||
| 17 | public $debug = false; |
||
| 18 | public $logoutUrl = ''; |
||
| 19 | public $pluginEnabled = false; |
||
| 20 | public $enableGlobalConference = false; |
||
| 21 | public $enableGlobalConferencePerUser = false; |
||
| 22 | public $isGlobalConference = false; |
||
| 23 | public $groupSupport = false; |
||
| 24 | public $userSupport = false; |
||
| 25 | public $accessUrl = 1; |
||
| 26 | public $userId = 0; |
||
| 27 | public $plugin; |
||
| 28 | private $courseCode; |
||
| 29 | private $courseId; |
||
| 30 | private $sessionId; |
||
| 31 | private $groupId; |
||
| 32 | private $maxUsersLimit; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Constructor (generates a connection to the API and the Chamilo settings |
||
| 36 | * required for the connection to the video conference server) |
||
| 37 | * |
||
| 38 | * @param string $host |
||
| 39 | * @param string $salt |
||
| 40 | * @param bool $isGlobalConference |
||
| 41 | * @param int $isGlobalPerUser |
||
| 42 | */ |
||
| 43 | public function __construct( |
||
| 44 | $host = '', |
||
| 45 | $salt = '', |
||
| 46 | $isGlobalConference = false, |
||
| 47 | $isGlobalPerUser = 0 |
||
| 48 | ) { |
||
| 49 | $this->courseCode = api_get_course_id(); |
||
| 50 | $this->courseId = api_get_course_int_id(); |
||
| 51 | $this->sessionId = api_get_session_id(); |
||
| 52 | $this->groupId = api_get_group_id(); |
||
| 53 | |||
| 54 | // Initialize video server settings from global settings |
||
| 55 | $this->plugin = BBBPlugin::create(); |
||
| 56 | $bbbPluginEnabled = $this->plugin->get('tool_enable'); |
||
|
|
|||
| 57 | |||
| 58 | $bbb_host = !empty($host) ? $host : $this->plugin->get('host'); |
||
| 59 | $bbb_salt = !empty($salt) ? $salt : $this->plugin->get('salt'); |
||
| 60 | |||
| 61 | $this->table = Database::get_main_table('plugin_bbb_meeting'); |
||
| 62 | $this->enableGlobalConference = $this->plugin->get('enable_global_conference') === 'true'; |
||
| 63 | $this->isGlobalConference = (bool) $isGlobalConference; |
||
| 64 | |||
| 65 | $columns = Database::listTableColumns($this->table); |
||
| 66 | $this->groupSupport = isset($columns['group_id']) ? true : false; |
||
| 67 | $this->userSupport = isset($columns['user_id']) ? true : false; |
||
| 68 | $this->accessUrl = api_get_current_access_url_id(); |
||
| 69 | |||
| 70 | $this->enableGlobalConferencePerUser = false; |
||
| 71 | if ($this->userSupport && !empty($isGlobalPerUser)) { |
||
| 72 | $this->enableGlobalConferencePerUser = $this->plugin->get('enable_global_conference_per_user') === 'true'; |
||
| 73 | $this->userId = $isGlobalPerUser; |
||
| 74 | } |
||
| 75 | |||
| 76 | if ($this->groupSupport) { |
||
| 77 | // Plugin check |
||
| 78 | $this->groupSupport = $this->plugin->get('enable_conference_in_course_groups') === 'true' ? true : false; |
||
| 79 | if ($this->groupSupport) { |
||
| 80 | // Platform check |
||
| 81 | $bbbSetting = api_get_setting('bbb_enable_conference_in_course_groups'); |
||
| 82 | $bbbSetting = isset($bbbSetting['bbb']) ? $bbbSetting['bbb'] === 'true' : false; |
||
| 83 | |||
| 84 | if ($bbbSetting) { |
||
| 85 | // Course check |
||
| 86 | $courseInfo = api_get_course_info(); |
||
| 87 | if ($courseInfo) { |
||
| 88 | $this->groupSupport = api_get_course_plugin_setting( |
||
| 89 | 'bbb', |
||
| 90 | 'bbb_enable_conference_in_groups', |
||
| 91 | $courseInfo |
||
| 92 | ) === '1'; |
||
| 93 | } |
||
| 94 | } |
||
| 95 | } |
||
| 96 | } |
||
| 97 | $this->maxUsersLimit = $this->plugin->get('max_users_limit'); |
||
| 98 | |||
| 99 | if ($bbbPluginEnabled === 'true') { |
||
| 100 | $userInfo = api_get_user_info(); |
||
| 101 | if (empty($userInfo) && !empty($isGlobalPerUser)) { |
||
| 102 | // If we are following a link to a global "per user" conference |
||
| 103 | // then generate a random guest name to join the conference |
||
| 104 | // because there is no part of the process where we give a name |
||
| 105 | //$this->userCompleteName = 'Guest'.rand(1000, 9999); |
||
| 106 | } else { |
||
| 107 | $this->userCompleteName = $userInfo['complete_name']; |
||
| 108 | } |
||
| 109 | |||
| 110 | if (api_is_anonymous()) { |
||
| 111 | $this->userCompleteName = get_lang('Guest').'_'.rand(1000, 9999); |
||
| 112 | } |
||
| 113 | |||
| 114 | $this->salt = $bbb_salt; |
||
| 115 | if (!empty($bbb_host)) { |
||
| 116 | if (substr($bbb_host, -1, 1) !== '/') { |
||
| 117 | $bbb_host .= '/'; |
||
| 118 | } |
||
| 119 | $this->url = $bbb_host; |
||
| 120 | if (!preg_match('#/bigbluebutton/$#', $bbb_host)) { |
||
| 121 | $this->url = $bbb_host.'bigbluebutton/'; |
||
| 122 | } |
||
| 123 | } |
||
| 124 | $info = parse_url($bbb_host); |
||
| 125 | |||
| 126 | if (isset($info['scheme'])) { |
||
| 127 | $this->protocol = $info['scheme'].'://'; |
||
| 128 | $this->url = str_replace($this->protocol, '', $this->url); |
||
| 129 | $urlWithProtocol = $bbb_host; |
||
| 130 | } else { |
||
| 131 | // We assume it's an http, if user wants to use https, the host *must* include the protocol. |
||
| 132 | $this->protocol = 'http://'; |
||
| 133 | $urlWithProtocol = $this->protocol.$bbb_host; |
||
| 134 | } |
||
| 135 | |||
| 136 | // Setting BBB api |
||
| 137 | define('CONFIG_SECURITY_SALT', $this->salt); |
||
| 138 | define('CONFIG_SERVER_URL_WITH_PROTOCOL', $urlWithProtocol); |
||
| 139 | define('CONFIG_SERVER_BASE_URL', $this->url); |
||
| 140 | define('CONFIG_SERVER_PROTOCOL', $this->protocol); |
||
| 141 | |||
| 142 | $this->api = new BigBlueButtonBN(); |
||
| 143 | $this->pluginEnabled = true; |
||
| 144 | $this->logoutUrl = $this->getListingUrl(); |
||
| 145 | } |
||
| 146 | } |
||
| 147 | |||
| 148 | /** |
||
| 149 | * @param int $courseId Optional. Course ID. |
||
| 150 | * @param int $sessionId Optional. Session ID. |
||
| 151 | * @param int $groupId Optional. Group ID. |
||
| 152 | * |
||
| 153 | * @return string |
||
| 154 | */ |
||
| 155 | public function getListingUrl($courseId = 0, $sessionId = 0, $groupId = 0) |
||
| 156 | { |
||
| 157 | return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?' |
||
| 158 | .$this->getUrlParams($courseId, $sessionId, $groupId); |
||
| 159 | } |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @param int $courseId Optional. Course ID. |
||
| 163 | * @param int $sessionId Optional. Session ID. |
||
| 164 | * @param int $groupId Optional. Group ID. |
||
| 165 | * |
||
| 166 | * @return string |
||
| 167 | */ |
||
| 168 | public function getUrlParams($courseId = 0, $sessionId = 0, $groupId = 0) |
||
| 169 | { |
||
| 170 | if (empty($this->courseCode) && !$courseId) { |
||
| 171 | if ($this->isGlobalConferencePerUserEnabled()) { |
||
| 172 | return 'global=1&user_id='.$this->userId; |
||
| 173 | } |
||
| 174 | |||
| 175 | if ($this->isGlobalConference()) { |
||
| 176 | return 'global=1'; |
||
| 177 | } |
||
| 178 | |||
| 179 | return ''; |
||
| 180 | } |
||
| 181 | |||
| 182 | $courseCode = $this->courseCode; |
||
| 183 | if (!empty($courseId)) { |
||
| 184 | $course = api_get_course_info_by_id($courseId); |
||
| 185 | if ($course) { |
||
| 186 | $courseCode = $course['code']; |
||
| 187 | } |
||
| 188 | } |
||
| 189 | |||
| 190 | return http_build_query( |
||
| 191 | [ |
||
| 192 | 'cid' => $courseId, |
||
| 193 | 'sid' => $sessionId ?: $this->sessionId, |
||
| 194 | 'gid' => $groupId ?: $this->groupId, |
||
| 195 | ] |
||
| 196 | ); |
||
| 197 | } |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @return bool |
||
| 201 | */ |
||
| 202 | public function isGlobalConferencePerUserEnabled() |
||
| 203 | { |
||
| 204 | return $this->enableGlobalConferencePerUser; |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @return bool |
||
| 209 | */ |
||
| 210 | public function isGlobalConference() |
||
| 211 | { |
||
| 212 | if ($this->isGlobalConferenceEnabled() === false) { |
||
| 213 | return false; |
||
| 214 | } |
||
| 215 | |||
| 216 | return (bool) $this->isGlobalConference; |
||
| 217 | } |
||
| 218 | |||
| 219 | /** |
||
| 220 | * @return bool |
||
| 221 | */ |
||
| 222 | public function isGlobalConferenceEnabled() |
||
| 223 | { |
||
| 224 | return $this->enableGlobalConference; |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @param array $userInfo |
||
| 229 | * |
||
| 230 | * @return bool |
||
| 231 | */ |
||
| 232 | public static function showGlobalConferenceLink($userInfo) |
||
| 233 | { |
||
| 234 | if (empty($userInfo)) { |
||
| 235 | return false; |
||
| 236 | } |
||
| 237 | $setting = api_get_plugin_setting('bbb', 'enable_global_conference'); |
||
| 238 | $settingLink = api_get_plugin_setting('bbb', 'enable_global_conference_link'); |
||
| 239 | if ($setting === 'true' && $settingLink === 'true') { |
||
| 240 | //$content = Display::url(get_lang('LaunchVideoConferenceRoom'), $url); |
||
| 241 | $allowedRoles = api_get_plugin_setting( |
||
| 242 | 'bbb', |
||
| 243 | 'global_conference_allow_roles' |
||
| 244 | ); |
||
| 245 | |||
| 246 | if (api_is_platform_admin()) { |
||
| 247 | $userInfo['status'] = PLATFORM_ADMIN; |
||
| 248 | } |
||
| 249 | |||
| 250 | $showGlobalLink = true; |
||
| 251 | if (!empty($allowedRoles)) { |
||
| 252 | if (!in_array($userInfo['status'], $allowedRoles)) { |
||
| 253 | $showGlobalLink = false; |
||
| 254 | } |
||
| 255 | } |
||
| 256 | |||
| 257 | return $showGlobalLink; |
||
| 258 | } |
||
| 259 | } |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Gets the global limit of users in a video-conference room. |
||
| 263 | * This value can be overridden by course-specific values |
||
| 264 | * @return int Maximum number of users set globally |
||
| 265 | */ |
||
| 266 | public function getMaxUsersLimit() |
||
| 307 | } |
||
| 308 | |||
| 309 | /** |
||
| 310 | * Sets the global limit of users in a video-conference room. |
||
| 311 | * |
||
| 312 | * @param int Maximum number of users (globally) |
||
| 313 | */ |
||
| 314 | public function setMaxUsersLimit($max) |
||
| 320 | } |
||
| 321 | |||
| 322 | /** |
||
| 323 | * See this file in you BBB to set up default values |
||
| 324 | * |
||
| 325 | * @param array $params Array of parameters that will be completed if not containing all expected variables |
||
| 326 | * |
||
| 327 | * /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties |
||
| 328 | * |
||
| 329 | * More record information: |
||
| 330 | * http://code.google.com/p/bigbluebutton/wiki/RecordPlaybackSpecification |
||
| 331 | * |
||
| 332 | * Default maximum number of users a meeting can have. |
||
| 333 | * Doesn't get enforced yet but is the default value when the create |
||
| 334 | * API doesn't pass a value. |
||
| 335 | * defaultMaxUsers=20 |
||
| 336 | * |
||
| 337 | * Default duration of the meeting in minutes. |
||
| 338 | * Current default is 0 (meeting doesn't end). |
||
| 339 | * defaultMeetingDuration=0 |
||
| 340 | * |
||
| 341 | * Remove the meeting from memory when the end API is called. |
||
| 342 | * This allows 3rd-party apps to recycle the meeting right-away |
||
| 343 | * instead of waiting for the meeting to expire (see below). |
||
| 344 | * removeMeetingWhenEnded=false |
||
| 345 | * |
||
| 346 | * The number of minutes before the system removes the meeting from memory. |
||
| 347 | * defaultMeetingExpireDuration=1 |
||
| 348 | * |
||
| 349 | * The number of minutes the system waits when a meeting is created and when |
||
| 350 | * a user joins. If after this period, a user hasn't joined, the meeting is |
||
| 351 | * removed from memory. |
||
| 352 | * defaultMeetingCreateJoinDuration=5 |
||
| 353 | * |
||
| 354 | * @return mixed |
||
| 355 | */ |
||
| 356 | public function createMeeting($params) |
||
| 357 | { |
||
| 358 | $params['c_id'] = api_get_course_int_id(); |
||
| 359 | $params['session_id'] = api_get_session_id(); |
||
| 360 | |||
| 361 | if ($this->hasGroupSupport()) { |
||
| 362 | $params['group_id'] = api_get_group_id(); |
||
| 363 | } |
||
| 364 | |||
| 365 | if ($this->isGlobalConferencePerUserEnabled() && !empty($this->userId)) { |
||
| 366 | $params['user_id'] = (int) $this->userId; |
||
| 367 | } |
||
| 368 | |||
| 369 | $params['attendee_pw'] = isset($params['attendee_pw']) ? $params['attendee_pw'] : $this->getUserMeetingPassword(); |
||
| 370 | $attendeePassword = $params['attendee_pw']; |
||
| 371 | $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword(); |
||
| 372 | $moderatorPassword = $params['moderator_pw']; |
||
| 373 | |||
| 374 | $params['record'] = api_get_course_plugin_setting('bbb', 'big_blue_button_record_and_store') == 1; |
||
| 375 | $max = api_get_course_plugin_setting('bbb', 'big_blue_button_max_students_allowed'); |
||
| 376 | $max = isset($max) ? $max : -1; |
||
| 377 | |||
| 378 | $params['status'] = 1; |
||
| 379 | // Generate a pseudo-global-unique-id to avoid clash of conferences on |
||
| 380 | // the same BBB server with several Chamilo portals |
||
| 381 | $params['remote_id'] = uniqid(true, true); |
||
| 382 | // Each simultaneous conference room needs to have a different |
||
| 383 | // voice_bridge composed of a 5 digits number, so generating a random one |
||
| 384 | $params['voice_bridge'] = rand(10000, 99999); |
||
| 385 | $params['created_at'] = api_get_utc_datetime(); |
||
| 386 | $params['access_url'] = $this->accessUrl; |
||
| 387 | $params['closed_at'] = ''; |
||
| 388 | |||
| 389 | |||
| 390 | $id = Database::insert($this->table, $params); |
||
| 391 | |||
| 392 | if ($id) { |
||
| 393 | Event::addEvent( |
||
| 394 | 'bbb_create_meeting', |
||
| 395 | 'meeting_id', |
||
| 396 | (int) $id, |
||
| 397 | null, |
||
| 398 | api_get_user_id(), |
||
| 399 | api_get_course_int_id(), |
||
| 400 | api_get_session_id() |
||
| 401 | ); |
||
| 402 | |||
| 403 | $meetingName = isset($params['meeting_name']) ? $params['meeting_name'] : $this->getCurrentVideoConferenceName(); |
||
| 404 | $welcomeMessage = isset($params['welcome_msg']) ? $params['welcome_msg'] : null; |
||
| 405 | $record = isset($params['record']) && $params['record'] ? 'true' : 'false'; |
||
| 406 | //$duration = isset($params['duration']) ? intval($params['duration']) : 0; |
||
| 407 | // This setting currently limits the maximum conference duration, |
||
| 408 | // to avoid lingering sessions on the video-conference server #6261 |
||
| 409 | $duration = 300; |
||
| 410 | $meetingDuration = (int) $this->plugin->get('meeting_duration'); |
||
| 411 | if (!empty($meetingDuration)) { |
||
| 412 | $duration = $meetingDuration; |
||
| 413 | } |
||
| 414 | $bbbParams = array( |
||
| 415 | 'meetingId' => $params['remote_id'], // REQUIRED |
||
| 416 | 'meetingName' => $meetingName, // REQUIRED |
||
| 417 | 'attendeePw' => $attendeePassword, // Match this value in getJoinMeetingURL() to join as attendee. |
||
| 418 | 'moderatorPw' => $moderatorPassword, // Match this value in getJoinMeetingURL() to join as moderator. |
||
| 419 | 'welcomeMsg' => $welcomeMessage, // ''= use default. Change to customize. |
||
| 420 | 'dialNumber' => '', // The main number to call into. Optional. |
||
| 421 | 'voiceBridge' => $params['voice_bridge'], // PIN to join voice. Required. |
||
| 422 | 'webVoice' => '', // Alphanumeric to join voice. Optional. |
||
| 423 | 'logoutUrl' => $this->logoutUrl.'&action=logout&remote_id='.$params['remote_id'], |
||
| 424 | 'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number] |
||
| 425 | 'record' => $record, // New. 'true' will tell BBB to record the meeting. |
||
| 426 | 'duration' => $duration, // Default = 0 which means no set duration in minutes. [number] |
||
| 427 | //'meta_category' => '', // Use to pass additional info to BBB server. See API docs. |
||
| 428 | ); |
||
| 429 | |||
| 430 | $status = false; |
||
| 431 | $meeting = null; |
||
| 432 | while ($status === false) { |
||
| 433 | $result = $this->api->createMeetingWithXmlResponseArray($bbbParams); |
||
| 434 | if (isset($result) && strval($result['returncode']) == 'SUCCESS') { |
||
| 435 | if ($this->plugin->get('allow_regenerate_recording') === 'true') { |
||
| 436 | $internalId = Database::escape_string($result['internalMeetingID']); |
||
| 437 | $sql = "UPDATE $this->table SET internal_meeting_id = '".$internalId."' |
||
| 438 | WHERE id = $id"; |
||
| 439 | Database::query($sql); |
||
| 440 | } |
||
| 441 | $meeting = $this->joinMeeting($meetingName, true); |
||
| 442 | |||
| 443 | return $meeting; |
||
| 444 | } |
||
| 445 | } |
||
| 446 | } |
||
| 447 | |||
| 448 | return false; |
||
| 449 | } |
||
| 450 | |||
| 451 | /** |
||
| 452 | * @return bool |
||
| 453 | */ |
||
| 454 | public function hasGroupSupport() |
||
| 455 | { |
||
| 456 | return $this->groupSupport; |
||
| 457 | } |
||
| 458 | |||
| 459 | /** |
||
| 460 | * Gets the password for a specific meeting for the current user |
||
| 461 | * |
||
| 462 | * @param string $courseCode |
||
| 463 | * |
||
| 464 | * @return string A moderator password if user is teacher, or the course code otherwise |
||
| 465 | * |
||
| 466 | */ |
||
| 467 | public function getUserMeetingPassword($courseCode = null) |
||
| 468 | { |
||
| 469 | if ($this->isGlobalConferencePerUserEnabled()) { |
||
| 470 | return 'url_'.$this->userId.'_'.api_get_current_access_url_id(); |
||
| 471 | } |
||
| 472 | |||
| 473 | if ($this->isGlobalConference()) { |
||
| 474 | return 'url_'.api_get_current_access_url_id(); |
||
| 475 | } |
||
| 476 | $courseCode = empty($courseCode) ? api_get_course_id() : $courseCode; |
||
| 477 | |||
| 478 | return $courseCode; |
||
| 479 | } |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Generated a moderator password for the meeting. |
||
| 483 | * |
||
| 484 | * @param string $courseCode |
||
| 485 | * |
||
| 486 | * @return string A password for the moderation of the videoconference |
||
| 487 | */ |
||
| 488 | public function getModMeetingPassword($courseCode = null) |
||
| 489 | { |
||
| 490 | if ($this->isGlobalConferencePerUserEnabled()) { |
||
| 491 | return 'url_'.$this->userId.'_'.api_get_current_access_url_id().'_mod'; |
||
| 492 | } |
||
| 493 | |||
| 494 | if ($this->isGlobalConference()) { |
||
| 495 | return 'url_'.api_get_current_access_url_id().'_mod'; |
||
| 496 | } |
||
| 497 | |||
| 498 | $courseCode = empty($courseCode) ? api_get_course_id() : $courseCode; |
||
| 499 | |||
| 500 | return $courseCode.'mod'; |
||
| 501 | } |
||
| 502 | |||
| 503 | /** |
||
| 504 | * @return string |
||
| 505 | */ |
||
| 506 | public function getCurrentVideoConferenceName() |
||
| 507 | { |
||
| 508 | if ($this->isGlobalConferencePerUserEnabled()) { |
||
| 509 | return 'url_'.$this->userId.'_'.api_get_current_access_url_id(); |
||
| 510 | } |
||
| 511 | |||
| 512 | if ($this->isGlobalConference()) { |
||
| 513 | return 'url_'.api_get_current_access_url_id(); |
||
| 514 | } |
||
| 515 | |||
| 516 | if ($this->hasGroupSupport()) { |
||
| 517 | return api_get_course_id().'-'.api_get_session_id().'-'.api_get_group_id(); |
||
| 518 | } |
||
| 519 | |||
| 520 | return api_get_course_id().'-'.api_get_session_id(); |
||
| 521 | } |
||
| 522 | |||
| 523 | /** |
||
| 524 | * Returns a meeting "join" URL |
||
| 525 | * |
||
| 526 | * @param string The name of the meeting (usually the course code) |
||
| 527 | * |
||
| 528 | * @return mixed The URL to join the meeting, or false on error |
||
| 529 | * @todo implement moderator pass |
||
| 530 | * @assert ('') === false |
||
| 531 | * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false |
||
| 532 | */ |
||
| 533 | public function joinMeeting($meetingName) |
||
| 534 | { |
||
| 535 | if ($this->debug) { |
||
| 536 | error_log("joinMeeting: $meetingName"); |
||
| 537 | } |
||
| 538 | |||
| 539 | if (empty($meetingName)) { |
||
| 540 | return false; |
||
| 541 | } |
||
| 542 | |||
| 543 | $manager = $this->isConferenceManager(); |
||
| 544 | if ($manager) { |
||
| 545 | $pass = $this->getModMeetingPassword(); |
||
| 546 | } else { |
||
| 547 | $pass = $this->getUserMeetingPassword(); |
||
| 548 | } |
||
| 549 | |||
| 550 | $meetingData = Database::select( |
||
| 551 | '*', |
||
| 552 | $this->table, |
||
| 553 | array( |
||
| 554 | 'where' => array( |
||
| 555 | 'meeting_name = ? AND status = 1 AND access_url = ?' => array( |
||
| 556 | $meetingName, |
||
| 557 | $this->accessUrl, |
||
| 558 | ), |
||
| 559 | ), |
||
| 560 | ), |
||
| 561 | 'first' |
||
| 562 | ); |
||
| 563 | |||
| 564 | if (empty($meetingData) || !is_array($meetingData)) { |
||
| 565 | if ($this->debug) { |
||
| 566 | error_log("meeting does not exist: $meetingName"); |
||
| 567 | } |
||
| 568 | |||
| 569 | return false; |
||
| 570 | } |
||
| 571 | |||
| 572 | $params = array( |
||
| 573 | 'meetingId' => $meetingData['remote_id'], |
||
| 574 | // -- REQUIRED - The unique id for the meeting |
||
| 575 | 'password' => $this->getModMeetingPassword() |
||
| 576 | // -- REQUIRED - The moderator password for the meeting |
||
| 577 | ); |
||
| 578 | |||
| 579 | $meetingInfoExists = false; |
||
| 580 | $meetingIsRunningInfo = $this->getMeetingInfo($params); |
||
| 581 | if ($this->debug) { |
||
| 582 | error_log('Searching meeting with params:'); |
||
| 583 | error_log(print_r($params, 1)); |
||
| 584 | error_log('Result:'); |
||
| 585 | error_log(print_r($meetingIsRunningInfo, 1)); |
||
| 586 | } |
||
| 587 | |||
| 588 | if ($meetingIsRunningInfo === false) { |
||
| 589 | // checking with the remote_id didn't work, so just in case and |
||
| 590 | // to provide backwards support, check with the id |
||
| 591 | $params = array( |
||
| 592 | 'meetingId' => $meetingData['id'], |
||
| 593 | // -- REQUIRED - The unique id for the meeting |
||
| 594 | 'password' => $this->getModMeetingPassword() |
||
| 595 | // -- REQUIRED - The moderator password for the meeting |
||
| 596 | ); |
||
| 597 | $meetingIsRunningInfo = $this->getMeetingInfo($params); |
||
| 598 | if ($this->debug) { |
||
| 599 | error_log('Searching meetingId with params:'); |
||
| 600 | error_log(print_r($params, 1)); |
||
| 601 | error_log('Result:'); |
||
| 602 | error_log(print_r($meetingIsRunningInfo, 1)); |
||
| 603 | } |
||
| 604 | } |
||
| 605 | |||
| 606 | if (strval($meetingIsRunningInfo['returncode']) === 'SUCCESS' && |
||
| 607 | isset($meetingIsRunningInfo['meetingName']) && |
||
| 608 | !empty($meetingIsRunningInfo['meetingName']) |
||
| 609 | ) { |
||
| 610 | $meetingInfoExists = true; |
||
| 611 | } |
||
| 612 | |||
| 613 | if ($this->debug) { |
||
| 614 | error_log( |
||
| 615 | "meeting is running: ".intval($meetingInfoExists) |
||
| 616 | ); |
||
| 617 | } |
||
| 618 | |||
| 619 | $url = false; |
||
| 620 | if ($meetingInfoExists) { |
||
| 621 | $joinParams = [ |
||
| 622 | 'meetingId' => $meetingData['remote_id'], |
||
| 623 | // -- REQUIRED - A unique id for the meeting |
||
| 624 | 'username' => $this->userCompleteName, |
||
| 625 | //-- REQUIRED - The name that will display for the user in the meeting |
||
| 626 | 'password' => $pass, |
||
| 627 | //-- REQUIRED - The attendee or moderator password, depending on what's passed here |
||
| 628 | //'createTime' => api_get_utc_datetime(), //-- OPTIONAL - string. Leave blank ('') unless you set this correctly. |
||
| 629 | 'userID' => api_get_user_id(), |
||
| 630 | //-- OPTIONAL - string |
||
| 631 | 'webVoiceConf' => '', |
||
| 632 | ]; |
||
| 633 | $url = $this->api->getJoinMeetingURL($joinParams); |
||
| 634 | $url = $this->protocol.$url; |
||
| 635 | } |
||
| 636 | |||
| 637 | if ($this->debug) { |
||
| 638 | error_log("return url :".$url); |
||
| 639 | } |
||
| 640 | |||
| 641 | return $url; |
||
| 642 | } |
||
| 643 | |||
| 644 | /** |
||
| 645 | * Checks whether a user is teacher in the current course |
||
| 646 | * @return bool True if the user can be considered a teacher in this course, false otherwise |
||
| 647 | */ |
||
| 648 | public function isConferenceManager() |
||
| 649 | { |
||
| 650 | if (api_is_coach() || api_is_platform_admin(false, true)) { |
||
| 651 | return true; |
||
| 652 | } |
||
| 653 | |||
| 654 | if ($this->isGlobalConferencePerUserEnabled()) { |
||
| 655 | $currentUserId = api_get_user_id(); |
||
| 656 | if ($this->userId === $currentUserId) { |
||
| 657 | return true; |
||
| 658 | } else { |
||
| 659 | return false; |
||
| 660 | } |
||
| 661 | } |
||
| 662 | |||
| 663 | $courseInfo = api_get_course_info(); |
||
| 664 | $groupId = api_get_group_id(); |
||
| 665 | if (!empty($groupId) && !empty($courseInfo)) { |
||
| 666 | $groupEnabled = api_get_course_plugin_setting('bbb', 'bbb_enable_conference_in_groups') === '1'; |
||
| 667 | if ($groupEnabled) { |
||
| 668 | $studentCanStartConference = api_get_course_plugin_setting( |
||
| 669 | 'bbb', |
||
| 670 | 'big_blue_button_students_start_conference_in_groups' |
||
| 671 | ) === '1'; |
||
| 672 | |||
| 673 | if ($studentCanStartConference) { |
||
| 674 | $isSubscribed = GroupManager::is_user_in_group( |
||
| 675 | api_get_user_id(), |
||
| 676 | GroupManager::get_group_properties($groupId) |
||
| 677 | ); |
||
| 678 | if ($isSubscribed) { |
||
| 679 | return true; |
||
| 680 | } |
||
| 681 | } |
||
| 682 | } |
||
| 683 | } |
||
| 684 | |||
| 685 | if (!empty($courseInfo)) { |
||
| 686 | return api_is_course_admin(); |
||
| 687 | } |
||
| 688 | |||
| 689 | return false; |
||
| 690 | } |
||
| 691 | |||
| 692 | /** |
||
| 693 | * Get information about the given meeting |
||
| 694 | * |
||
| 695 | * @param array ...? |
||
| 696 | * |
||
| 697 | * @return mixed Array of information on success, false on error |
||
| 698 | * @assert (array()) === false |
||
| 699 | */ |
||
| 700 | public function getMeetingInfo($params) |
||
| 701 | { |
||
| 702 | try { |
||
| 703 | $result = $this->api->getMeetingInfoWithXmlResponseArray($params); |
||
| 704 | if ($result == null) { |
||
| 705 | if ($this->debug) { |
||
| 706 | error_log("Failed to get any response. Maybe we can't contact the BBB server."); |
||
| 707 | } |
||
| 708 | } |
||
| 709 | |||
| 710 | return $result; |
||
| 711 | } catch (Exception $e) { |
||
| 712 | if ($this->debug) { |
||
| 713 | error_log('Caught exception: ', $e->getMessage(), "\n"); |
||
| 714 | } |
||
| 715 | } |
||
| 716 | |||
| 717 | return false; |
||
| 718 | } |
||
| 719 | |||
| 720 | |||
| 721 | /** |
||
| 722 | * @param int $meetingId |
||
| 723 | * @param int $userId |
||
| 724 | * |
||
| 725 | * @return array |
||
| 726 | */ |
||
| 727 | public function getMeetingParticipantInfo($meetingId, $userId) |
||
| 728 | { |
||
| 729 | $meetingData = Database::select( |
||
| 730 | '*', |
||
| 731 | 'plugin_bbb_room', |
||
| 732 | array('where' => array('meeting_id = ? AND participant_id = ?' => [$meetingId, $userId])), |
||
| 733 | 'first' |
||
| 734 | ); |
||
| 735 | |||
| 736 | if ($meetingData) { |
||
| 737 | return $meetingData; |
||
| 738 | } |
||
| 739 | |||
| 740 | return []; |
||
| 741 | } |
||
| 742 | |||
| 743 | /** |
||
| 744 | * Save a participant in a meeting room |
||
| 745 | * |
||
| 746 | * @param int $meetingId |
||
| 747 | * @param int $participantId |
||
| 748 | * |
||
| 749 | * @return false|int The last inserted ID. Otherwise return false |
||
| 750 | */ |
||
| 751 | public function saveParticipant($meetingId, $participantId) |
||
| 752 | { |
||
| 753 | $meetingData = Database::select( |
||
| 754 | '*', |
||
| 755 | 'plugin_bbb_room', |
||
| 756 | [ |
||
| 757 | 'where' => [ |
||
| 758 | 'meeting_id = ? AND participant_id = ? AND close = ?' => [ |
||
| 759 | $meetingId, |
||
| 760 | $participantId, |
||
| 761 | BBBPlugin::ROOM_OPEN, |
||
| 762 | ], |
||
| 763 | ], |
||
| 764 | ] |
||
| 765 | ); |
||
| 766 | |||
| 767 | foreach ($meetingData as $roomItem) { |
||
| 768 | $inAt = $roomItem['in_at']; |
||
| 769 | $outAt = $roomItem['out_at']; |
||
| 770 | $roomId = $roomItem['id']; |
||
| 771 | if (!empty($roomId)) { |
||
| 772 | if ($inAt != $outAt) { |
||
| 773 | Database::update( |
||
| 774 | 'plugin_bbb_room', |
||
| 775 | ['close' => BBBPlugin::ROOM_CLOSE], |
||
| 776 | ['id = ? ' => $roomId] |
||
| 777 | ); |
||
| 778 | } else { |
||
| 779 | Database::update( |
||
| 780 | 'plugin_bbb_room', |
||
| 781 | ['out_at' => api_get_utc_datetime(), 'close' => BBBPlugin::ROOM_CLOSE], |
||
| 782 | ['id = ? ' => $roomId] |
||
| 783 | ); |
||
| 784 | } |
||
| 785 | } |
||
| 786 | } |
||
| 787 | |||
| 788 | $params = [ |
||
| 789 | 'meeting_id' => $meetingId, |
||
| 790 | 'participant_id' => $participantId, |
||
| 791 | 'in_at' => api_get_utc_datetime(), |
||
| 792 | 'out_at' => api_get_utc_datetime(), |
||
| 793 | 'close' => BBBPlugin::ROOM_OPEN, |
||
| 794 | ]; |
||
| 795 | |||
| 796 | return Database::insert( |
||
| 797 | 'plugin_bbb_room', |
||
| 798 | $params |
||
| 799 | ); |
||
| 800 | } |
||
| 801 | |||
| 802 | /** |
||
| 803 | * Tells whether the given meeting exists and is running |
||
| 804 | * (using course code as name) |
||
| 805 | * |
||
| 806 | * @param string $meetingName Meeting name (usually the course code) |
||
| 807 | * |
||
| 808 | * @return bool True if meeting exists, false otherwise |
||
| 809 | * @assert ('') === false |
||
| 810 | * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false |
||
| 811 | */ |
||
| 812 | public function meetingExists($meetingName) |
||
| 813 | { |
||
| 814 | $meetingData = $this->getMeetingByName($meetingName); |
||
| 815 | |||
| 816 | return !empty($meetingData); |
||
| 817 | } |
||
| 818 | |||
| 819 | /** |
||
| 820 | * @param string $meetingName |
||
| 821 | * |
||
| 822 | * @return array |
||
| 823 | */ |
||
| 824 | public function getMeetingByName($meetingName) |
||
| 825 | { |
||
| 826 | if (empty($meetingName)) { |
||
| 827 | return []; |
||
| 828 | } |
||
| 829 | |||
| 830 | $courseId = api_get_course_int_id(); |
||
| 831 | $sessionId = api_get_session_id(); |
||
| 832 | $conditions = array( |
||
| 833 | 'where' => array( |
||
| 834 | 'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 AND access_url = ?' => |
||
| 835 | array($courseId, $sessionId, $meetingName, $this->accessUrl), |
||
| 836 | ), |
||
| 837 | ); |
||
| 838 | |||
| 839 | if ($this->hasGroupSupport()) { |
||
| 840 | $groupId = api_get_group_id(); |
||
| 841 | $conditions = array( |
||
| 842 | 'where' => array( |
||
| 843 | 'c_id = ? AND session_id = ? AND meeting_name = ? AND group_id = ? AND status = 1 AND access_url = ?' => |
||
| 844 | array( |
||
| 845 | $courseId, |
||
| 846 | $sessionId, |
||
| 847 | $meetingName, |
||
| 848 | $groupId, |
||
| 849 | $this->accessUrl, |
||
| 850 | ), |
||
| 851 | ), |
||
| 852 | ); |
||
| 853 | } |
||
| 854 | |||
| 855 | $meetingData = Database::select( |
||
| 856 | '*', |
||
| 857 | $this->table, |
||
| 858 | $conditions, |
||
| 859 | 'first' |
||
| 860 | ); |
||
| 861 | |||
| 862 | if ($this->debug) { |
||
| 863 | error_log('meeting_exists '.print_r($meetingData, 1)); |
||
| 864 | } |
||
| 865 | |||
| 866 | return $meetingData; |
||
| 867 | } |
||
| 868 | |||
| 869 | /** |
||
| 870 | * Gets a list from the database of all meetings attached to a course with the given status |
||
| 871 | * @param int $courseId |
||
| 872 | * @param int $sessionId |
||
| 873 | * @param int $status 0 for closed meetings, 1 for open meetings |
||
| 874 | * |
||
| 875 | * @return array |
||
| 876 | */ |
||
| 877 | public function getAllMeetingsInCourse($courseId, $sessionId, $status) |
||
| 878 | { |
||
| 879 | $conditions = array( |
||
| 880 | 'where' => array( |
||
| 881 | 'status = ? AND c_id = ? AND session_id = ? ' => array( |
||
| 882 | $status, |
||
| 883 | $courseId, |
||
| 884 | $sessionId, |
||
| 885 | ), |
||
| 886 | ), |
||
| 887 | ); |
||
| 888 | |||
| 889 | return Database::select( |
||
| 890 | '*', |
||
| 891 | $this->table, |
||
| 892 | $conditions |
||
| 893 | ); |
||
| 894 | } |
||
| 895 | |||
| 896 | /** |
||
| 897 | * Gets all the course meetings saved in the plugin_bbb_meeting table and |
||
| 898 | * generate actionable links (join/close/delete/etc) |
||
| 899 | * |
||
| 900 | * @param int $courseId |
||
| 901 | * @param int $sessionId |
||
| 902 | * @param int $groupId |
||
| 903 | * @param bool $isAdminReport Optional. Set to true then the report is for admins |
||
| 904 | * @param array $dateRange Optional |
||
| 905 | * |
||
| 906 | * @return array Array of current open meeting rooms |
||
| 907 | * @throws Exception |
||
| 908 | */ |
||
| 909 | public function getMeetings( |
||
| 910 | $courseId = 0, |
||
| 911 | $sessionId = 0, |
||
| 912 | $groupId = 0, |
||
| 913 | $isAdminReport = false, |
||
| 914 | $dateRange = [] |
||
| 915 | ) { |
||
| 916 | $em = Database::getManager(); |
||
| 917 | $manager = $this->isConferenceManager(); |
||
| 918 | |||
| 919 | $conditions = []; |
||
| 920 | if ($courseId || $sessionId || $groupId) { |
||
| 921 | $conditions = array( |
||
| 922 | 'where' => array( |
||
| 923 | 'c_id = ? AND session_id = ? ' => array($courseId, $sessionId), |
||
| 924 | ), |
||
| 925 | ); |
||
| 926 | |||
| 927 | if ($this->hasGroupSupport()) { |
||
| 928 | $conditions = array( |
||
| 929 | 'where' => array( |
||
| 930 | 'c_id = ? AND session_id = ? AND group_id = ? ' => array( |
||
| 931 | $courseId, |
||
| 932 | $sessionId, |
||
| 933 | $groupId, |
||
| 934 | ), |
||
| 935 | ), |
||
| 936 | ); |
||
| 937 | } |
||
| 938 | |||
| 939 | if ($this->isGlobalConferencePerUserEnabled()) { |
||
| 940 | $conditions = array( |
||
| 941 | 'where' => array( |
||
| 942 | 'c_id = ? AND session_id = ? AND user_id = ?' => array( |
||
| 943 | $courseId, |
||
| 944 | $sessionId, |
||
| 945 | $this->userId, |
||
| 946 | ), |
||
| 947 | ), |
||
| 948 | ); |
||
| 949 | } |
||
| 950 | } |
||
| 951 | |||
| 952 | if (!empty($dateRange)) { |
||
| 953 | $dateStart = date_create($dateRange['search_meeting_start']); |
||
| 954 | $dateStart = date_format($dateStart, 'Y-m-d H:i:s'); |
||
| 955 | $dateEnd = date_create($dateRange['search_meeting_end']); |
||
| 956 | $dateEnd = $dateEnd->add(new DateInterval('P1D')); |
||
| 957 | $dateEnd = date_format($dateEnd, 'Y-m-d H:i:s'); |
||
| 958 | |||
| 959 | $conditions = array( |
||
| 960 | 'where' => array( |
||
| 961 | 'created_at BETWEEN ? AND ? ' => array($dateStart, $dateEnd), |
||
| 962 | ), |
||
| 963 | ); |
||
| 964 | } |
||
| 965 | |||
| 966 | $conditions['order'] = 'created_at ASC'; |
||
| 967 | |||
| 968 | $meetingList = Database::select( |
||
| 969 | '*', |
||
| 970 | $this->table, |
||
| 971 | $conditions |
||
| 972 | ); |
||
| 973 | $isGlobal = $this->isGlobalConference(); |
||
| 974 | $newMeetingList = array(); |
||
| 975 | foreach ($meetingList as $meetingDB) { |
||
| 976 | $item = array(); |
||
| 977 | $courseId = $meetingDB['c_id']; |
||
| 978 | $courseInfo = api_get_course_info_by_id($courseId); |
||
| 979 | $courseCode = ''; |
||
| 980 | if (!empty($courseInfo)) { |
||
| 981 | $courseCode = $courseInfo['code']; |
||
| 982 | } |
||
| 983 | |||
| 984 | if ($manager) { |
||
| 985 | $pass = $meetingDB['moderator_pw']; |
||
| 986 | } else { |
||
| 987 | $pass = $meetingDB['attendee_pw']; |
||
| 988 | } |
||
| 989 | |||
| 990 | $meetingBBB = $this->getMeetingInfo( |
||
| 991 | [ |
||
| 992 | 'meetingId' => $meetingDB['remote_id'], |
||
| 993 | 'password' => $pass, |
||
| 994 | ] |
||
| 995 | ); |
||
| 996 | |||
| 997 | if ($meetingBBB === false) { |
||
| 998 | // Checking with the remote_id didn't work, so just in case and |
||
| 999 | // to provide backwards support, check with the id |
||
| 1000 | $params = array( |
||
| 1001 | 'meetingId' => $meetingDB['id'], |
||
| 1002 | // -- REQUIRED - The unique id for the meeting |
||
| 1003 | 'password' => $pass |
||
| 1004 | // -- REQUIRED - The moderator password for the meeting |
||
| 1005 | ); |
||
| 1006 | $meetingBBB = $this->getMeetingInfo($params); |
||
| 1007 | } |
||
| 1008 | |||
| 1009 | if ($meetingDB['visibility'] == 0 && $this->isConferenceManager() === false) { |
||
| 1010 | continue; |
||
| 1011 | } |
||
| 1012 | |||
| 1013 | $meetingBBB['end_url'] = $this->endUrl($meetingDB); |
||
| 1014 | |||
| 1015 | if (isset($meetingBBB['returncode']) && (string) $meetingBBB['returncode'] === 'FAILED') { |
||
| 1016 | if ($meetingDB['status'] == 1 && $this->isConferenceManager()) { |
||
| 1017 | $this->endMeeting($meetingDB['id'], $courseCode); |
||
| 1018 | } |
||
| 1019 | } else { |
||
| 1020 | $meetingBBB['add_to_calendar_url'] = $this->addToCalendarUrl($meetingDB); |
||
| 1021 | } |
||
| 1022 | |||
| 1023 | if ($meetingDB['record'] == 1) { |
||
| 1024 | // backwards compatibility (when there was no remote ID) |
||
| 1025 | $mId = $meetingDB['remote_id']; |
||
| 1026 | if (empty($mId)) { |
||
| 1027 | $mId = $meetingDB['id']; |
||
| 1028 | } |
||
| 1029 | if (empty($mId)) { |
||
| 1030 | // if the id is still empty (should *never* occur as 'id' is |
||
| 1031 | // the table's primary key), skip this conference |
||
| 1032 | continue; |
||
| 1033 | } |
||
| 1034 | |||
| 1035 | $record = []; |
||
| 1036 | $recordingParams = ['meetingId' => $mId]; |
||
| 1037 | $records = $this->api->getRecordingsWithXmlResponseArray($recordingParams); |
||
| 1038 | |||
| 1039 | if (!empty($records)) { |
||
| 1040 | if (!isset($records['messageKey']) || $records['messageKey'] !== 'noRecordings') { |
||
| 1041 | $record = end($records); |
||
| 1042 | if (!is_array($record) || !isset($record['recordId'])) { |
||
| 1043 | continue; |
||
| 1044 | } |
||
| 1045 | |||
| 1046 | if (!empty($record['playbackFormatUrl'])) { |
||
| 1047 | $this->updateMeetingVideoUrl($meetingDB['id'], $record['playbackFormatUrl']); |
||
| 1048 | } |
||
| 1049 | } |
||
| 1050 | } |
||
| 1051 | |||
| 1052 | if (isset($record['playbackFormatUrl']) && !empty($record['playbackFormatUrl'])) { |
||
| 1053 | $recordLink = Display::url( |
||
| 1054 | $this->plugin->get_lang('ViewRecord'), |
||
| 1055 | $record['playbackFormatUrl'], |
||
| 1056 | ['target' => '_blank', 'class' => 'btn btn-default'] |
||
| 1057 | ); |
||
| 1058 | } else { |
||
| 1059 | $recordLink = $this->plugin->get_lang('NoRecording'); |
||
| 1060 | } |
||
| 1061 | |||
| 1062 | if ($isAdminReport) { |
||
| 1063 | $this->forceCIdReq( |
||
| 1064 | $courseInfo['code'], |
||
| 1065 | $meetingDB['session_id'], |
||
| 1066 | $meetingDB['group_id'] |
||
| 1067 | ); |
||
| 1068 | } |
||
| 1069 | |||
| 1070 | $actionLinks = $this->getActionLinks( |
||
| 1071 | $meetingDB, |
||
| 1072 | $record, |
||
| 1073 | $isGlobal, |
||
| 1074 | $isAdminReport |
||
| 1075 | ); |
||
| 1076 | $item['show_links'] = $recordLink; |
||
| 1077 | } else { |
||
| 1078 | $actionLinks = $this->getActionLinks( |
||
| 1079 | $meetingDB, |
||
| 1080 | [], |
||
| 1081 | $isGlobal, |
||
| 1082 | $isAdminReport |
||
| 1083 | ); |
||
| 1084 | |||
| 1085 | $item['show_links'] = $this->plugin->get_lang('NoRecording'); |
||
| 1086 | } |
||
| 1087 | |||
| 1088 | $item['action_links'] = implode(PHP_EOL, $actionLinks); |
||
| 1089 | $item['created_at'] = api_convert_and_format_date($meetingDB['created_at']); |
||
| 1090 | // created_at |
||
| 1091 | $meetingDB['created_at'] = $item['created_at']; //avoid overwrite in array_merge() below |
||
| 1092 | |||
| 1093 | $item['closed_at'] = ''; |
||
| 1094 | if (!empty($meetingDB['closed_at'])) { |
||
| 1095 | $item['closed_at'] = api_convert_and_format_date($meetingDB['closed_at']); |
||
| 1096 | $meetingDB['closed_at'] = $item['closed_at']; |
||
| 1097 | } |
||
| 1098 | |||
| 1099 | $item['publish_url'] = $this->publishUrl($meetingDB); |
||
| 1100 | $item['unpublish_url'] = $this->unPublishUrl($meetingBBB); |
||
| 1101 | |||
| 1102 | if ($meetingDB['status'] == 1) { |
||
| 1103 | $joinParams = [ |
||
| 1104 | 'meetingId' => $meetingDB['remote_id'], |
||
| 1105 | //-- REQUIRED - A unique id for the meeting |
||
| 1106 | 'username' => $this->userCompleteName, |
||
| 1107 | //-- REQUIRED - The name that will display for the user in the meeting |
||
| 1108 | 'password' => $pass, |
||
| 1109 | //-- REQUIRED - The attendee or moderator password, depending on what's passed here |
||
| 1110 | 'createTime' => '', |
||
| 1111 | //-- OPTIONAL - string. Leave blank ('') unless you set this correctly. |
||
| 1112 | 'userID' => '', |
||
| 1113 | // -- OPTIONAL - string |
||
| 1114 | 'webVoiceConf' => '', |
||
| 1115 | ]; |
||
| 1116 | $item['go_url'] = $this->protocol.$this->api->getJoinMeetingURL($joinParams); |
||
| 1117 | } |
||
| 1118 | $item = array_merge($item, $meetingDB, $meetingBBB); |
||
| 1119 | |||
| 1120 | $item['course'] = api_get_course_entity($item['c_id']); |
||
| 1121 | $item['session'] = api_get_session_entity($item['session_id']); |
||
| 1122 | $newMeetingList[] = $item; |
||
| 1123 | } |
||
| 1124 | |||
| 1125 | return $newMeetingList; |
||
| 1126 | } |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * @param array $meeting |
||
| 1130 | * |
||
| 1131 | * @return string |
||
| 1132 | */ |
||
| 1133 | public function endUrl($meeting) |
||
| 1134 | { |
||
| 1135 | if (!isset($meeting['id'])) { |
||
| 1136 | return ''; |
||
| 1137 | } |
||
| 1138 | |||
| 1139 | return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=end&id='.$meeting['id']; |
||
| 1140 | } |
||
| 1141 | |||
| 1142 | /** |
||
| 1143 | * Closes a meeting (usually when the user click on the close button from |
||
| 1144 | * the conferences listing. |
||
| 1145 | * |
||
| 1146 | * @param string The internal ID of the meeting (id field for this meeting) |
||
| 1147 | * @param string $courseCode |
||
| 1148 | * |
||
| 1149 | * @return void |
||
| 1150 | * @assert (0) === false |
||
| 1151 | */ |
||
| 1152 | public function endMeeting($id, $courseCode = null) |
||
| 1153 | { |
||
| 1154 | if (empty($id)) { |
||
| 1155 | return false; |
||
| 1156 | } |
||
| 1157 | |||
| 1158 | $meetingData = Database::select( |
||
| 1159 | '*', |
||
| 1160 | $this->table, |
||
| 1161 | array('where' => array('id = ?' => array($id))), |
||
| 1162 | 'first' |
||
| 1163 | ); |
||
| 1164 | $manager = $this->isConferenceManager(); |
||
| 1165 | if ($manager) { |
||
| 1166 | $pass = $meetingData['moderator_pw']; |
||
| 1167 | } else { |
||
| 1168 | $pass = $meetingData['attendee_pw']; |
||
| 1169 | } |
||
| 1170 | |||
| 1171 | Event::addEvent( |
||
| 1172 | 'bbb_end_meeting', |
||
| 1173 | 'meeting_id', |
||
| 1174 | (int) $id, |
||
| 1175 | null, |
||
| 1176 | api_get_user_id(), |
||
| 1177 | api_get_course_int_id(), |
||
| 1178 | api_get_session_id() |
||
| 1179 | ); |
||
| 1180 | |||
| 1181 | $endParams = array( |
||
| 1182 | 'meetingId' => $meetingData['remote_id'], // REQUIRED - We have to know which meeting to end. |
||
| 1183 | 'password' => $pass, // REQUIRED - Must match moderator pass for meeting. |
||
| 1184 | ); |
||
| 1185 | $this->api->endMeetingWithXmlResponseArray($endParams); |
||
| 1186 | Database::update( |
||
| 1187 | $this->table, |
||
| 1188 | array('status' => 0, 'closed_at' => api_get_utc_datetime()), |
||
| 1189 | array('id = ? ' => $id) |
||
| 1190 | ); |
||
| 1191 | |||
| 1192 | // Update users with in_at y ou_at field equal |
||
| 1193 | $roomTable = Database::get_main_table('plugin_bbb_room'); |
||
| 1194 | $conditions['where'] = ['meeting_id=? AND in_at=out_at AND close=?' => [$id, BBBPlugin::ROOM_OPEN]]; |
||
| 1195 | $roomList = Database::select( |
||
| 1196 | '*', |
||
| 1197 | $roomTable, |
||
| 1198 | $conditions |
||
| 1199 | ); |
||
| 1200 | |||
| 1201 | foreach ($roomList as $roomDB) { |
||
| 1202 | $roomId = $roomDB['id']; |
||
| 1203 | if (!empty($roomId)) { |
||
| 1204 | Database::update( |
||
| 1205 | $roomTable, |
||
| 1206 | ['out_at' => api_get_utc_datetime(), 'close' => BBBPlugin::ROOM_CLOSE], |
||
| 1207 | ['id = ? ' => $roomId] |
||
| 1208 | ); |
||
| 1209 | } |
||
| 1210 | } |
||
| 1211 | |||
| 1212 | // Close all meeting rooms with meeting ID |
||
| 1213 | Database::update( |
||
| 1214 | $roomTable, |
||
| 1215 | ['close' => BBBPlugin::ROOM_CLOSE], |
||
| 1216 | ['meeting_id = ? ' => $id] |
||
| 1217 | ); |
||
| 1218 | } |
||
| 1219 | |||
| 1220 | /** |
||
| 1221 | * @param array $meeting |
||
| 1222 | * @param array $record |
||
| 1223 | * |
||
| 1224 | * @return string |
||
| 1225 | */ |
||
| 1226 | public function addToCalendarUrl($meeting, $record = []) |
||
| 1227 | { |
||
| 1228 | $url = isset($record['playbackFormatUrl']) ? $record['playbackFormatUrl'] : ''; |
||
| 1229 | |||
| 1230 | return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams( |
||
| 1231 | ).'&action=add_to_calendar&id='.$meeting['id'].'&start='.api_strtotime($meeting['created_at']).'&url='.$url; |
||
| 1232 | } |
||
| 1233 | |||
| 1234 | /** |
||
| 1235 | * @param int $meetingId |
||
| 1236 | * @param string $videoUrl |
||
| 1237 | * |
||
| 1238 | * @return bool|int |
||
| 1239 | */ |
||
| 1240 | public function updateMeetingVideoUrl($meetingId, $videoUrl) |
||
| 1241 | { |
||
| 1242 | return Database::update( |
||
| 1243 | 'plugin_bbb_meeting', |
||
| 1244 | ['video_url' => $videoUrl], |
||
| 1245 | ['id = ?' => intval($meetingId)] |
||
| 1246 | ); |
||
| 1247 | } |
||
| 1248 | |||
| 1249 | /** |
||
| 1250 | * Force the course, session and/or group IDs |
||
| 1251 | * |
||
| 1252 | * @param string $courseCode |
||
| 1253 | * @param int $sessionId |
||
| 1254 | * @param int $groupId |
||
| 1255 | */ |
||
| 1256 | public function forceCIdReq($courseCode, $sessionId = 0, $groupId = 0) |
||
| 1257 | { |
||
| 1258 | $this->courseCode = $courseCode; |
||
| 1259 | $this->sessionId = (int) $sessionId; |
||
| 1260 | $this->groupId = (int) $groupId; |
||
| 1261 | } |
||
| 1262 | |||
| 1263 | /** |
||
| 1264 | * @param array $meetingInfo |
||
| 1265 | * @param array $recordInfo |
||
| 1266 | * @param bool $isGlobal |
||
| 1267 | * @param bool $isAdminReport |
||
| 1268 | * |
||
| 1269 | * @return array |
||
| 1270 | */ |
||
| 1271 | private function getActionLinks( |
||
| 1272 | $meetingInfo, |
||
| 1273 | $recordInfo, |
||
| 1274 | $isGlobal = false, |
||
| 1275 | $isAdminReport = false |
||
| 1276 | ) { |
||
| 1277 | $isVisible = $meetingInfo['visibility'] != 0; |
||
| 1278 | $linkVisibility = $isVisible |
||
| 1279 | ? Display::url( |
||
| 1280 | Display::return_icon('visible.png', get_lang('MakeInvisible')), |
||
| 1281 | $this->unPublishUrl($meetingInfo) |
||
| 1282 | ) |
||
| 1283 | : Display::url( |
||
| 1284 | Display::return_icon('invisible.png', get_lang('MakeVisible')), |
||
| 1285 | $this->publishUrl($meetingInfo) |
||
| 1286 | ); |
||
| 1287 | |||
| 1288 | $links = []; |
||
| 1289 | if ($this->plugin->get('allow_regenerate_recording') === 'true' && $meetingInfo['record'] == 1) { |
||
| 1290 | if (!empty($recordInfo)) { |
||
| 1291 | $links[] = Display::url( |
||
| 1292 | Display::return_icon('reload.png', get_lang('RegenerateRecord')), |
||
| 1293 | $this->regenerateRecordUrl($meetingInfo, $recordInfo) |
||
| 1294 | ); |
||
| 1295 | } else { |
||
| 1296 | $links[] = Display::url( |
||
| 1297 | Display::return_icon('reload.png', get_lang('RegenerateRecord')), |
||
| 1298 | $this->regenerateRecordUrlFromMeeting($meetingInfo) |
||
| 1299 | ); |
||
| 1300 | } |
||
| 1301 | } |
||
| 1302 | |||
| 1303 | if (empty($recordInfo)) { |
||
| 1304 | if (!$isAdminReport) { |
||
| 1305 | if ($meetingInfo['status'] == 0) { |
||
| 1306 | $links[] = Display::url( |
||
| 1307 | Display::return_icon('delete.png', get_lang('Delete')), |
||
| 1308 | $this->deleteRecordUrl($meetingInfo) |
||
| 1309 | ); |
||
| 1310 | $links[] = $linkVisibility; |
||
| 1311 | } |
||
| 1312 | |||
| 1313 | return $links; |
||
| 1314 | } else { |
||
| 1315 | $links[] = Display::url( |
||
| 1316 | Display::return_icon('course_home.png', get_lang('GoToCourse')), |
||
| 1317 | $this->getListingUrl($meetingInfo['c_id'], $meetingInfo['session_id'], $meetingInfo['group_id']) |
||
| 1318 | ); |
||
| 1319 | |||
| 1320 | return $links; |
||
| 1321 | } |
||
| 1322 | } |
||
| 1323 | |||
| 1324 | if (!$isGlobal) { |
||
| 1325 | $links[] = Display::url( |
||
| 1326 | Display::return_icon('link.gif', get_lang('UrlMeetingToShare')), |
||
| 1327 | $this->copyToRecordToLinkTool($meetingInfo) |
||
| 1328 | ); |
||
| 1329 | $links[] = Display::url( |
||
| 1330 | Display::return_icon('agenda.png', get_lang('AddToCalendar')), |
||
| 1331 | $this->addToCalendarUrl($meetingInfo, $recordInfo) |
||
| 1332 | ); |
||
| 1333 | } |
||
| 1334 | |||
| 1335 | $hide = $this->plugin->get('disable_download_conference_link') === 'true' ? true : false; |
||
| 1336 | |||
| 1337 | if ($hide == false) { |
||
| 1338 | if ($meetingInfo['has_video_m4v']) { |
||
| 1339 | $links[] = Display::url( |
||
| 1340 | Display::return_icon('save.png', get_lang('DownloadFile')), |
||
| 1341 | $recordInfo['playbackFormatUrl'].'/capture.m4v', |
||
| 1342 | ['target' => '_blank'] |
||
| 1343 | ); |
||
| 1344 | } else { |
||
| 1345 | $links[] = Display::url( |
||
| 1346 | Display::return_icon('save.png', get_lang('DownloadFile')), |
||
| 1347 | '#', |
||
| 1348 | [ |
||
| 1349 | 'id' => "btn-check-meeting-video-{$meetingInfo['id']}", |
||
| 1350 | 'class' => 'check-meeting-video', |
||
| 1351 | 'data-id' => $meetingInfo['id'], |
||
| 1352 | ] |
||
| 1353 | ); |
||
| 1354 | } |
||
| 1355 | } |
||
| 1356 | |||
| 1357 | |||
| 1358 | if (!$isAdminReport) { |
||
| 1359 | $links[] = Display::url( |
||
| 1360 | Display::return_icon('delete.png', get_lang('Delete')), |
||
| 1361 | $this->deleteRecordUrl($meetingInfo) |
||
| 1362 | ); |
||
| 1363 | $links[] = $linkVisibility; |
||
| 1364 | } else { |
||
| 1365 | $links[] = Display::url( |
||
| 1366 | Display::return_icon('course_home.png', get_lang('GoToCourse')), |
||
| 1367 | $this->getListingUrl($meetingInfo['c_id'], $meetingInfo['session_id'], $meetingInfo['group_id']) |
||
| 1368 | ); |
||
| 1369 | } |
||
| 1370 | |||
| 1371 | |||
| 1372 | return $links; |
||
| 1373 | } |
||
| 1374 | |||
| 1375 | /** |
||
| 1376 | * @param array $meeting |
||
| 1377 | * |
||
| 1378 | * @return string |
||
| 1379 | */ |
||
| 1380 | public function unPublishUrl($meeting) |
||
| 1381 | { |
||
| 1382 | if (!isset($meeting['id'])) { |
||
| 1383 | return null; |
||
| 1384 | } |
||
| 1385 | |||
| 1386 | return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams( |
||
| 1387 | ).'&action=unpublish&id='.$meeting['id']; |
||
| 1388 | } |
||
| 1389 | |||
| 1390 | /** |
||
| 1391 | * @param array $meeting |
||
| 1392 | * |
||
| 1393 | * @return string |
||
| 1394 | */ |
||
| 1395 | public function publishUrl($meeting) |
||
| 1396 | { |
||
| 1397 | if (!isset($meeting['id'])) { |
||
| 1398 | return ''; |
||
| 1399 | } |
||
| 1400 | |||
| 1401 | return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams( |
||
| 1402 | ).'&action=publish&id='.$meeting['id']; |
||
| 1403 | } |
||
| 1404 | |||
| 1405 | /** |
||
| 1406 | * @param array $meeting |
||
| 1407 | * @param array $recordInfo |
||
| 1408 | * |
||
| 1409 | * @return string |
||
| 1410 | */ |
||
| 1411 | public function regenerateRecordUrl($meeting, $recordInfo) |
||
| 1412 | { |
||
| 1413 | if ($this->plugin->get('allow_regenerate_recording') !== 'true') { |
||
| 1414 | return ''; |
||
| 1415 | } |
||
| 1416 | |||
| 1417 | if (!isset($meeting['id'])) { |
||
| 1418 | return ''; |
||
| 1419 | } |
||
| 1420 | |||
| 1421 | if (empty($recordInfo) || (!empty($recordInfo['recordId']) && !isset($recordInfo['recordId']))) { |
||
| 1422 | return ''; |
||
| 1423 | } |
||
| 1424 | |||
| 1425 | return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams(). |
||
| 1426 | '&action=regenerate_record&id='.$meeting['id'].'&record_id='.$recordInfo['recordId']; |
||
| 1427 | } |
||
| 1428 | |||
| 1429 | /** |
||
| 1430 | * @param array $meeting |
||
| 1431 | * |
||
| 1432 | * @return string |
||
| 1433 | */ |
||
| 1434 | public function regenerateRecordUrlFromMeeting($meeting) |
||
| 1435 | { |
||
| 1436 | if ($this->plugin->get('allow_regenerate_recording') !== 'true') { |
||
| 1437 | return ''; |
||
| 1438 | } |
||
| 1439 | |||
| 1440 | if (!isset($meeting['id'])) { |
||
| 1441 | return ''; |
||
| 1442 | } |
||
| 1443 | |||
| 1444 | return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams(). |
||
| 1445 | '&action=regenerate_record&id='.$meeting['id']; |
||
| 1446 | } |
||
| 1447 | |||
| 1448 | /** |
||
| 1449 | * @param array $meeting |
||
| 1450 | * |
||
| 1451 | * @return string |
||
| 1452 | */ |
||
| 1453 | public function deleteRecordUrl($meeting) |
||
| 1454 | { |
||
| 1455 | if (!isset($meeting['id'])) { |
||
| 1456 | return ''; |
||
| 1457 | } |
||
| 1458 | |||
| 1459 | return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams( |
||
| 1460 | ).'&action=delete_record&id='.$meeting['id']; |
||
| 1461 | } |
||
| 1462 | |||
| 1463 | /** |
||
| 1464 | * @param array $meeting |
||
| 1465 | * |
||
| 1466 | * @return string |
||
| 1467 | */ |
||
| 1468 | public function copyToRecordToLinkTool($meeting) |
||
| 1469 | { |
||
| 1470 | if (!isset($meeting['id'])) { |
||
| 1471 | return ''; |
||
| 1472 | } |
||
| 1473 | |||
| 1474 | return api_get_path(WEB_PLUGIN_PATH). |
||
| 1475 | 'bbb/listing.php?'.$this->getUrlParams().'&action=copy_record_to_link_tool&id='.$meeting['id']; |
||
| 1476 | } |
||
| 1477 | |||
| 1478 | /** |
||
| 1479 | * Function disabled |
||
| 1480 | */ |
||
| 1481 | public function publishMeeting($id) |
||
| 1482 | { |
||
| 1483 | //return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt); |
||
| 1484 | if (empty($id)) { |
||
| 1485 | return false; |
||
| 1486 | } |
||
| 1487 | $id = intval($id); |
||
| 1488 | Database::update($this->table, array('visibility' => 1), array('id = ? ' => $id)); |
||
| 1489 | |||
| 1490 | return true; |
||
| 1491 | } |
||
| 1492 | |||
| 1493 | /** |
||
| 1494 | * Function disabled |
||
| 1495 | */ |
||
| 1496 | public function unpublishMeeting($id) |
||
| 1497 | { |
||
| 1498 | //return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt); |
||
| 1499 | if (empty($id)) { |
||
| 1500 | return false; |
||
| 1501 | } |
||
| 1502 | $id = intval($id); |
||
| 1503 | Database::update($this->table, array('visibility' => 0), array('id = ?' => $id)); |
||
| 1504 | |||
| 1505 | return true; |
||
| 1506 | } |
||
| 1507 | |||
| 1508 | /** |
||
| 1509 | * Get users online in the current course room. |
||
| 1510 | * |
||
| 1511 | * @return int The number of users currently connected to the videoconference |
||
| 1512 | * @assert () > -1 |
||
| 1513 | */ |
||
| 1514 | public function getUsersOnlineInCurrentRoom() |
||
| 1515 | { |
||
| 1516 | $courseId = api_get_course_int_id(); |
||
| 1517 | $sessionId = api_get_session_id(); |
||
| 1518 | |||
| 1519 | $conditions = array( |
||
| 1520 | 'where' => array( |
||
| 1521 | 'c_id = ? AND session_id = ? AND status = 1 AND access_url = ?' => array( |
||
| 1522 | $courseId, |
||
| 1523 | $sessionId, |
||
| 1524 | $this->accessUrl, |
||
| 1525 | ), |
||
| 1526 | ), |
||
| 1527 | ); |
||
| 1528 | |||
| 1529 | if ($this->hasGroupSupport()) { |
||
| 1530 | $groupId = api_get_group_id(); |
||
| 1531 | $conditions = array( |
||
| 1532 | 'where' => array( |
||
| 1533 | 'c_id = ? AND session_id = ? AND group_id = ? AND status = 1 AND access_url = ?' => array( |
||
| 1534 | $courseId, |
||
| 1535 | $sessionId, |
||
| 1536 | $groupId, |
||
| 1537 | $this->accessUrl, |
||
| 1538 | ), |
||
| 1539 | ), |
||
| 1540 | ); |
||
| 1541 | } |
||
| 1542 | |||
| 1543 | if ($this->isGlobalConferencePerUserEnabled()) { |
||
| 1544 | $conditions = array( |
||
| 1545 | 'where' => array( |
||
| 1546 | 'user_id = ? AND status = 1 AND access_url = ?' => array( |
||
| 1547 | $this->userId, |
||
| 1548 | $this->accessUrl, |
||
| 1549 | ), |
||
| 1550 | ), |
||
| 1551 | ); |
||
| 1552 | } |
||
| 1553 | |||
| 1554 | $meetingData = Database::select( |
||
| 1555 | '*', |
||
| 1556 | $this->table, |
||
| 1557 | $conditions, |
||
| 1558 | 'first' |
||
| 1559 | ); |
||
| 1560 | |||
| 1561 | if (empty($meetingData)) { |
||
| 1562 | return 0; |
||
| 1563 | } |
||
| 1564 | $pass = $meetingData['moderator_pw']; |
||
| 1565 | $info = $this->getMeetingInfo(array('meetingId' => $meetingData['remote_id'], 'password' => $pass)); |
||
| 1566 | if ($info === false) { |
||
| 1567 | //checking with the remote_id didn't work, so just in case and |
||
| 1568 | // to provide backwards support, check with the id |
||
| 1569 | $params = array( |
||
| 1570 | 'meetingId' => $meetingData['id'], |
||
| 1571 | // -- REQUIRED - The unique id for the meeting |
||
| 1572 | 'password' => $pass |
||
| 1573 | // -- REQUIRED - The moderator password for the meeting |
||
| 1574 | ); |
||
| 1575 | $info = $this->getMeetingInfo($params); |
||
| 1576 | } |
||
| 1577 | |||
| 1578 | if (!empty($info) && isset($info['participantCount'])) { |
||
| 1579 | return $info['participantCount']; |
||
| 1580 | } |
||
| 1581 | |||
| 1582 | return 0; |
||
| 1583 | } |
||
| 1584 | |||
| 1585 | /** |
||
| 1586 | * @param int $id |
||
| 1587 | * @param string $recordId |
||
| 1588 | * |
||
| 1589 | * @return bool |
||
| 1590 | */ |
||
| 1591 | public function regenerateRecording($id, $recordId = '') |
||
| 1592 | { |
||
| 1593 | if ($this->plugin->get('allow_regenerate_recording') !== 'true') { |
||
| 1594 | return false; |
||
| 1595 | } |
||
| 1596 | |||
| 1597 | if (empty($id)) { |
||
| 1598 | return false; |
||
| 1599 | } |
||
| 1600 | |||
| 1601 | $meetingData = Database::select( |
||
| 1602 | '*', |
||
| 1603 | $this->table, |
||
| 1604 | array('where' => array('id = ?' => array($id))), |
||
| 1605 | 'first' |
||
| 1606 | ); |
||
| 1607 | |||
| 1608 | Event::addEvent( |
||
| 1609 | 'bbb_regenerate_record', |
||
| 1610 | 'record_id', |
||
| 1611 | (int) $recordId, |
||
| 1612 | null, |
||
| 1613 | api_get_user_id(), |
||
| 1614 | api_get_course_int_id(), |
||
| 1615 | api_get_session_id() |
||
| 1616 | ); |
||
| 1617 | |||
| 1618 | // Check if there are recordings for this meeting |
||
| 1619 | $recordings = $this->api->getRecordings(['meetingId' => $meetingData['remote_id']]); |
||
| 1620 | if (!empty($recordings) && isset($recordings['messageKey']) && $recordings['messageKey'] === 'noRecordings') { |
||
| 1621 | // Regenerate the meeting id |
||
| 1622 | if (!empty($meetingData['internal_meeting_id'])) { |
||
| 1623 | return $this->api->generateRecording(['recordId' => $meetingData['internal_meeting_id']]); |
||
| 1624 | } |
||
| 1625 | |||
| 1626 | /*$pass = $this->getModMeetingPassword(); |
||
| 1627 | $info = $this->getMeetingInfo(['meetingId' => $meetingData['remote_id'], 'password' => $pass]); |
||
| 1628 | if (!empty($info) && isset($info['internalMeetingID'])) { |
||
| 1629 | return $this->api->generateRecording(['recordId' => $meetingData['internal_meeting_id']]); |
||
| 1630 | }*/ |
||
| 1631 | |||
| 1632 | return false; |
||
| 1633 | } else { |
||
| 1634 | if (!empty($recordings['records'])) { |
||
| 1635 | $recordExists = false; |
||
| 1636 | foreach ($recordings['records'] as $record) { |
||
| 1637 | if ($recordId == $record['recordId']) { |
||
| 1638 | $recordExists = true; |
||
| 1639 | break; |
||
| 1640 | } |
||
| 1641 | } |
||
| 1642 | |||
| 1643 | if ($recordExists) { |
||
| 1644 | return $this->api->generateRecording(['recordId' => $recordId]); |
||
| 1645 | } |
||
| 1646 | } |
||
| 1647 | } |
||
| 1648 | |||
| 1649 | return false; |
||
| 1650 | } |
||
| 1651 | |||
| 1652 | /** |
||
| 1653 | * Deletes a recording of a meeting |
||
| 1654 | * |
||
| 1655 | * @param int $id ID of the recording |
||
| 1656 | * |
||
| 1657 | * @return bool |
||
| 1658 | * |
||
| 1659 | * @assert () === false |
||
| 1660 | * @todo Also delete links and agenda items created from this recording |
||
| 1661 | */ |
||
| 1662 | public function deleteRecording($id) |
||
| 1663 | { |
||
| 1664 | if (empty($id)) { |
||
| 1665 | return false; |
||
| 1666 | } |
||
| 1667 | |||
| 1668 | $meetingData = Database::select( |
||
| 1669 | '*', |
||
| 1670 | $this->table, |
||
| 1671 | array('where' => array('id = ?' => array($id))), |
||
| 1672 | 'first' |
||
| 1673 | ); |
||
| 1674 | |||
| 1675 | Event::addEvent( |
||
| 1676 | 'bbb_delete_record', |
||
| 1677 | 'meeting_id', |
||
| 1678 | $id, |
||
| 1679 | null, |
||
| 1680 | api_get_user_id(), |
||
| 1681 | api_get_course_int_id(), |
||
| 1682 | api_get_session_id() |
||
| 1683 | ); |
||
| 1684 | |||
| 1685 | $delete = false; |
||
| 1686 | $recordings = []; |
||
| 1687 | // Check if there are recordings for this meeting |
||
| 1688 | if (!empty($meetingData['remote_id'])) { |
||
| 1689 | Event::addEvent( |
||
| 1690 | 'bbb_delete_record', |
||
| 1691 | 'remote_id', |
||
| 1692 | $meetingData['remote_id'], |
||
| 1693 | null, |
||
| 1694 | api_get_user_id(), |
||
| 1695 | api_get_course_int_id(), |
||
| 1696 | api_get_session_id() |
||
| 1697 | ); |
||
| 1698 | $recordings = $this->api->getRecordings(['meetingId' => $meetingData['remote_id']]); |
||
| 1699 | } |
||
| 1700 | if (!empty($recordings) && isset($recordings['messageKey']) && $recordings['messageKey'] == 'noRecordings') { |
||
| 1701 | $delete = true; |
||
| 1702 | } else { |
||
| 1703 | if (!empty($recordings['records'])) { |
||
| 1704 | $recordsToDelete = []; |
||
| 1705 | foreach ($recordings['records'] as $record) { |
||
| 1706 | $recordsToDelete[] = $record['recordId']; |
||
| 1707 | } |
||
| 1708 | $delete = true; |
||
| 1709 | if (!empty($recordsToDelete)) { |
||
| 1710 | $recordingParams = ['recordId' => implode(',', $recordsToDelete)]; |
||
| 1711 | Event::addEvent( |
||
| 1712 | 'bbb_delete_record', |
||
| 1713 | 'record_id_list', |
||
| 1714 | implode(',', $recordsToDelete), |
||
| 1715 | null, |
||
| 1716 | api_get_user_id(), |
||
| 1717 | api_get_course_int_id(), |
||
| 1718 | api_get_session_id() |
||
| 1719 | ); |
||
| 1720 | $result = $this->api->deleteRecordingsWithXmlResponseArray($recordingParams); |
||
| 1721 | if (!empty($result) && isset($result['deleted']) && $result['deleted'] === 'true') { |
||
| 1722 | $delete = true; |
||
| 1723 | } |
||
| 1724 | } |
||
| 1725 | } |
||
| 1726 | } |
||
| 1727 | |||
| 1728 | if ($delete) { |
||
| 1729 | Database::delete( |
||
| 1730 | 'plugin_bbb_room', |
||
| 1731 | array('meeting_id = ?' => array($id)) |
||
| 1732 | ); |
||
| 1733 | |||
| 1734 | Database::delete( |
||
| 1735 | $this->table, |
||
| 1736 | array('id = ?' => array($id)) |
||
| 1737 | ); |
||
| 1738 | } |
||
| 1739 | |||
| 1740 | return $delete; |
||
| 1741 | } |
||
| 1742 | |||
| 1743 | /** |
||
| 1744 | * Creates a link in the links tool from the given videoconference recording |
||
| 1745 | * |
||
| 1746 | * @param int $id ID of the item in the plugin_bbb_meeting table |
||
| 1747 | * @param string Hash identifying the recording, as provided by the API |
||
| 1748 | * |
||
| 1749 | * @return mixed ID of the newly created link, or false on error |
||
| 1750 | * @assert (null, null) === false |
||
| 1751 | * @assert (1, null) === false |
||
| 1752 | * @assert (null, 'abcdefabcdefabcdefabcdef') === false |
||
| 1753 | */ |
||
| 1754 | public function copyRecordingToLinkTool($id) |
||
| 1755 | { |
||
| 1756 | if (empty($id)) { |
||
| 1757 | return false; |
||
| 1758 | } |
||
| 1759 | //$records = BigBlueButtonBN::getRecordingsUrl($id); |
||
| 1760 | $meetingData = Database::select( |
||
| 1761 | '*', |
||
| 1762 | $this->table, |
||
| 1763 | array('where' => array('id = ?' => array($id))), |
||
| 1764 | 'first' |
||
| 1765 | ); |
||
| 1766 | |||
| 1767 | $records = $this->api->getRecordingsWithXmlResponseArray( |
||
| 1768 | array('meetingId' => $meetingData['remote_id']) |
||
| 1769 | ); |
||
| 1770 | |||
| 1771 | if (!empty($records)) { |
||
| 1772 | if (isset($records['message']) && !empty($records['message'])) { |
||
| 1773 | if ($records['messageKey'] == 'noRecordings') { |
||
| 1774 | $recordArray[] = $this->plugin->get_lang('NoRecording'); |
||
| 1775 | } else { |
||
| 1776 | //$recordArray[] = $records['message']; |
||
| 1777 | } |
||
| 1778 | |||
| 1779 | return false; |
||
| 1780 | } else { |
||
| 1781 | $record = $records[0]; |
||
| 1782 | if (is_array($record) && isset($record['recordId'])) { |
||
| 1783 | $url = $record['playbackFormatUrl']; |
||
| 1784 | $link = new Link(); |
||
| 1785 | $params['url'] = $url; |
||
| 1786 | $params['title'] = $meetingData['meeting_name']; |
||
| 1787 | $id = $link->save($params); |
||
| 1788 | |||
| 1789 | return $id; |
||
| 1790 | } |
||
| 1791 | } |
||
| 1792 | } |
||
| 1793 | |||
| 1794 | return false; |
||
| 1795 | } |
||
| 1796 | |||
| 1797 | /** |
||
| 1798 | * Checks if the video conference server is running. |
||
| 1799 | * Function currently disabled (always returns 1) |
||
| 1800 | * @return bool True if server is running, false otherwise |
||
| 1801 | * @assert () === false |
||
| 1802 | */ |
||
| 1803 | public function isServerRunning() |
||
| 1804 | { |
||
| 1805 | return true; |
||
| 1806 | //return BigBlueButtonBN::isServerRunning($this->protocol.$this->url); |
||
| 1807 | } |
||
| 1808 | |||
| 1809 | /** |
||
| 1810 | * Checks if the video conference plugin is properly configured |
||
| 1811 | * @return bool True if plugin has a host and a salt, false otherwise |
||
| 1812 | * @assert () === false |
||
| 1813 | */ |
||
| 1814 | public function isServerConfigured() |
||
| 1815 | { |
||
| 1816 | $host = $this->plugin->get('host'); |
||
| 1817 | |||
| 1818 | if (empty($host)) { |
||
| 1819 | return false; |
||
| 1820 | } |
||
| 1821 | |||
| 1822 | $salt = $this->plugin->get('salt'); |
||
| 1823 | |||
| 1824 | if (empty($salt)) { |
||
| 1825 | return false; |
||
| 1826 | } |
||
| 1827 | |||
| 1828 | return true; |
||
| 1829 | //return BigBlueButtonBN::isServerRunning($this->protocol.$this->url); |
||
| 1830 | } |
||
| 1831 | |||
| 1832 | /** |
||
| 1833 | * Get active session in the all platform |
||
| 1834 | */ |
||
| 1835 | public function getActiveSessionsCount() |
||
| 1836 | { |
||
| 1837 | $meetingList = Database::select( |
||
| 1838 | 'count(id) as count', |
||
| 1839 | $this->table, |
||
| 1840 | array('where' => array('status = ? AND access_url = ?' => array(1, $this->accessUrl))), |
||
| 1841 | 'first' |
||
| 1842 | ); |
||
| 1843 | |||
| 1844 | return $meetingList['count']; |
||
| 1845 | } |
||
| 1846 | |||
| 1847 | /** |
||
| 1848 | * Get active session in the all platform |
||
| 1849 | */ |
||
| 1850 | public function getActiveSessions() |
||
| 1859 | } |
||
| 1860 | |||
| 1861 | /** |
||
| 1862 | * @param string $url |
||
| 1863 | */ |
||
| 1864 | public function redirectToBBB($url) |
||
| 1865 | { |
||
| 1866 | if (file_exists(__DIR__.'/../config.vm.php')) { |
||
| 1867 | // Using VM |
||
| 1868 | echo Display::url($this->plugin->get_lang('ClickToContinue'), $url); |
||
| 1869 | exit; |
||
| 1870 | } else { |
||
| 1871 | // Classic |
||
| 1872 | header("Location: $url"); |
||
| 1873 | exit; |
||
| 1874 | } |
||
| 1875 | } |
||
| 1876 | |||
| 1877 | /** |
||
| 1878 | * @return string |
||
| 1879 | */ |
||
| 1880 | public function getConferenceUrl() |
||
| 1881 | { |
||
| 1882 | return api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?launch=1&'.$this->getUrlParams(); |
||
| 1883 | } |
||
| 1884 | |||
| 1885 | /** |
||
| 1886 | * Get the meeting info from DB by its name |
||
| 1887 | * |
||
| 1888 | * @param string $name |
||
| 1889 | * |
||
| 1890 | * @return array |
||
| 1891 | */ |
||
| 1892 | public function findMeetingByName($name) |
||
| 1893 | { |
||
| 1894 | $meetingData = Database::select( |
||
| 1895 | '*', |
||
| 1896 | 'plugin_bbb_meeting', |
||
| 1897 | array('where' => array('meeting_name = ? AND status = 1 ' => $name)), |
||
| 1898 | 'first' |
||
| 1899 | ); |
||
| 1900 | |||
| 1901 | return $meetingData; |
||
| 1902 | } |
||
| 1903 | |||
| 1904 | /** |
||
| 1905 | * Get the meeting info from DB by its name |
||
| 1906 | * |
||
| 1907 | * @param int $id |
||
| 1908 | * |
||
| 1909 | * @return array |
||
| 1910 | */ |
||
| 1911 | public function getMeeting($id) |
||
| 1912 | { |
||
| 1913 | $meetingData = Database::select( |
||
| 1914 | '*', |
||
| 1915 | 'plugin_bbb_meeting', |
||
| 1916 | array('where' => array('id = ?' => $id)), |
||
| 1917 | 'first' |
||
| 1918 | ); |
||
| 1919 | |||
| 1920 | return $meetingData; |
||
| 1921 | } |
||
| 1922 | |||
| 1923 | /** |
||
| 1924 | * Get the meeting info. |
||
| 1925 | * |
||
| 1926 | * @param int $id |
||
| 1927 | * |
||
| 1928 | * @return array |
||
| 1929 | */ |
||
| 1930 | public function getMeetingByRemoteId($id) |
||
| 1931 | { |
||
| 1932 | $meetingData = Database::select( |
||
| 1933 | '*', |
||
| 1934 | 'plugin_bbb_meeting', |
||
| 1935 | array('where' => array('remote_id = ?' => $id)), |
||
| 1936 | 'first' |
||
| 1937 | ); |
||
| 1938 | |||
| 1939 | return $meetingData; |
||
| 1940 | } |
||
| 1941 | |||
| 1942 | /** |
||
| 1943 | * @param int $meetingId |
||
| 1944 | * |
||
| 1945 | * @return array |
||
| 1946 | */ |
||
| 1947 | public function findConnectedMeetingParticipants($meetingId) |
||
| 1974 | } |
||
| 1975 | |||
| 1976 | /** |
||
| 1977 | * Check if the meeting has a capture.m4v video file. If exists then the has_video_m4v field is updated |
||
| 1978 | * |
||
| 1979 | * @param int $meetingId |
||
| 1980 | * |
||
| 1981 | * @return bool |
||
| 1982 | */ |
||
| 1983 | public function checkDirectMeetingVideoUrl($meetingId) |
||
| 1984 | { |
||
| 1985 | $meetingInfo = Database::select( |
||
| 1986 | '*', |
||
| 1987 | 'plugin_bbb_meeting', |
||
| 1988 | [ |
||
| 1989 | 'where' => ['id = ?' => intval($meetingId)], |
||
| 1990 | ], |
||
| 1991 | 'first' |
||
| 1992 | ); |
||
| 1993 | |||
| 1994 | if (!isset($meetingInfo['video_url'])) { |
||
| 1995 | return false; |
||
| 1996 | } |
||
| 1997 | |||
| 1998 | $hasCapture = SocialManager::verifyUrl($meetingInfo['video_url'].'/capture.m4v'); |
||
| 1999 | |||
| 2000 | if ($hasCapture) { |
||
| 2001 | return Database::update( |
||
| 2002 | 'plugin_bbb_meeting', |
||
| 2003 | ['has_video_m4v' => true], |
||
| 2004 | ['id = ?' => intval($meetingId)] |
||
| 2005 | ); |
||
| 2006 | } |
||
| 2007 | |||
| 2008 | return $hasCapture; |
||
| 2009 | } |
||
| 2010 | } |
||
| 2011 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.