@@ -47,129 +47,129 @@ |
||
47 | 47 | $bbbsession = $SESSION->bigbluebuttonbn_bbbsession; |
48 | 48 | } |
49 | 49 | switch (strtolower($action)) { |
50 | - case 'logout': |
|
51 | - if (isset($errors) && $errors != '') { |
|
52 | - bigbluebutton_bbb_view_errors($errors, $id); |
|
50 | + case 'logout': |
|
51 | + if (isset($errors) && $errors != '') { |
|
52 | + bigbluebutton_bbb_view_errors($errors, $id); |
|
53 | 53 | |
54 | - } else if (isset($bbbsession) && !is_null($bbbsession)) { |
|
55 | - // Moodle event logger: Create an event for meeting left. |
|
56 | - bigbluebuttonbn_event_log(BIGBLUEBUTTON_EVENT_MEETING_LEFT, $bigbluebuttonbn, $context, $cm); |
|
54 | + } else if (isset($bbbsession) && !is_null($bbbsession)) { |
|
55 | + // Moodle event logger: Create an event for meeting left. |
|
56 | + bigbluebuttonbn_event_log(BIGBLUEBUTTON_EVENT_MEETING_LEFT, $bigbluebuttonbn, $context, $cm); |
|
57 | 57 | |
58 | - // Update the cache. |
|
59 | - $meeting_info = bigbluebuttonbn_bbb_broker_get_meeting_info($bbbsession['meetingid'], $bbbsession['modPW'], BIGBLUEBUTTONBN_FORCED); |
|
58 | + // Update the cache. |
|
59 | + $meeting_info = bigbluebuttonbn_bbb_broker_get_meeting_info($bbbsession['meetingid'], $bbbsession['modPW'], BIGBLUEBUTTONBN_FORCED); |
|
60 | 60 | |
61 | - // Close the tab or window where BBB was opened. |
|
62 | - bigbluebutton_bbb_view_close_window(); |
|
63 | - |
|
64 | - } else { |
|
65 | - bigbluebutton_bbb_view_close_window_manually(); |
|
66 | - } |
|
67 | - break; |
|
68 | - case 'join': |
|
69 | - if (isset($bbbsession) && !is_null($bbbsession)) { |
|
70 | - // See if the session is in progress. |
|
71 | - if (bigbluebuttonbn_isMeetingRunning($bbbsession['meetingid'], $bbbsession['endpoint'], $bbbsession['shared_secret'])) { |
|
72 | - // Since the meeting is already running, we just join the session. |
|
73 | - bigbluebutton_bbb_view_execute_join($bbbsession, $cm, $context, $bigbluebuttonbn); |
|
61 | + // Close the tab or window where BBB was opened. |
|
62 | + bigbluebutton_bbb_view_close_window(); |
|
74 | 63 | |
75 | 64 | } else { |
76 | - // If user is administrator, moderator or if is viewer and no waiting is required. |
|
77 | - if ($bbbsession['administrator'] || $bbbsession['moderator'] || !$bbbsession['wait']) { |
|
78 | - // Prepare the metadata. |
|
79 | - $metadata = array( |
|
80 | - "meta_bbb-origin" => $bbbsession['origin'], |
|
81 | - "meta_bbb-origin-version" => $bbbsession['originVersion'], |
|
82 | - "meta_bbb-origin-server-name" => $bbbsession['originServerName'], |
|
83 | - "meta_bbb-origin-server-common-name" => $bbbsession['originServerCommonName'], |
|
84 | - "meta_bbb-origin-tag" => $bbbsession['originTag'], |
|
85 | - "meta_bbb-context" => $bbbsession['course']->fullname, |
|
86 | - "meta_bbb-recording-name" => (isset($name) && $name != '') ? $name : $bbbsession['contextActivityName'], |
|
87 | - "meta_bbb-recording-description" => (isset($description) && $description != '') ? $description : $bbbsession['contextActivityDescription'], |
|
88 | - "meta_bbb-recording-tags" => (isset($tags) && $tags != '') ? $tags : $bbbsession['contextActivityTags'], |
|
89 | - ); |
|
90 | - |
|
91 | - if (bigbluebuttonbn_get_cfg_recordingstatus_enabled()) { |
|
92 | - $metadata["meta_bn-recording-status"] = json_encode( |
|
93 | - array( |
|
94 | - 'email' => array('"' . fullname($USER) . '" <' . $USER->email . '>'), |
|
95 | - 'context' => $bbbsession['bigbluebuttonbnURL'] |
|
96 | - ) |
|
97 | - ); |
|
98 | - } |
|
65 | + bigbluebutton_bbb_view_close_window_manually(); |
|
66 | + } |
|
67 | + break; |
|
68 | + case 'join': |
|
69 | + if (isset($bbbsession) && !is_null($bbbsession)) { |
|
70 | + // See if the session is in progress. |
|
71 | + if (bigbluebuttonbn_isMeetingRunning($bbbsession['meetingid'], $bbbsession['endpoint'], $bbbsession['shared_secret'])) { |
|
72 | + // Since the meeting is already running, we just join the session. |
|
73 | + bigbluebutton_bbb_view_execute_join($bbbsession, $cm, $context, $bigbluebuttonbn); |
|
99 | 74 | |
100 | - if (bigbluebuttonbn_get_cfg_recordingready_enabled()) { |
|
101 | - $metadata["meta_bn-recording-ready-url"] = $bbbsession['recordingReadyURL']; |
|
102 | - } |
|
75 | + } else { |
|
76 | + // If user is administrator, moderator or if is viewer and no waiting is required. |
|
77 | + if ($bbbsession['administrator'] || $bbbsession['moderator'] || !$bbbsession['wait']) { |
|
78 | + // Prepare the metadata. |
|
79 | + $metadata = array( |
|
80 | + "meta_bbb-origin" => $bbbsession['origin'], |
|
81 | + "meta_bbb-origin-version" => $bbbsession['originVersion'], |
|
82 | + "meta_bbb-origin-server-name" => $bbbsession['originServerName'], |
|
83 | + "meta_bbb-origin-server-common-name" => $bbbsession['originServerCommonName'], |
|
84 | + "meta_bbb-origin-tag" => $bbbsession['originTag'], |
|
85 | + "meta_bbb-context" => $bbbsession['course']->fullname, |
|
86 | + "meta_bbb-recording-name" => (isset($name) && $name != '') ? $name : $bbbsession['contextActivityName'], |
|
87 | + "meta_bbb-recording-description" => (isset($description) && $description != '') ? $description : $bbbsession['contextActivityDescription'], |
|
88 | + "meta_bbb-recording-tags" => (isset($tags) && $tags != '') ? $tags : $bbbsession['contextActivityTags'], |
|
89 | + ); |
|
90 | + |
|
91 | + if (bigbluebuttonbn_get_cfg_recordingstatus_enabled()) { |
|
92 | + $metadata["meta_bn-recording-status"] = json_encode( |
|
93 | + array( |
|
94 | + 'email' => array('"' . fullname($USER) . '" <' . $USER->email . '>'), |
|
95 | + 'context' => $bbbsession['bigbluebuttonbnURL'] |
|
96 | + ) |
|
97 | + ); |
|
98 | + } |
|
103 | 99 | |
104 | - // Set the duration for the meeting. |
|
105 | - if (bigbluebuttonbn_get_cfg_scheduled_duration_enabled()) { |
|
106 | - $durationtime = bigbluebuttonbn_get_duration($bigbluebuttonbn->openingtime, $bigbluebuttonbn->closingtime); |
|
107 | - if ($durationtime > 0) |
|
108 | - $bbbsession['welcome'] .= '<br><br>' . str_replace("%duration%", '' . $durationtime, get_string('bbbdurationwarning', 'bigbluebuttonbn')); |
|
109 | - } else { |
|
110 | - $durationtime = 0; |
|
111 | - } |
|
112 | - // Execute the create command. |
|
113 | - $response = bigbluebuttonbn_getCreateMeetingArray( |
|
114 | - $bbbsession['meetingname'], |
|
115 | - $bbbsession['meetingid'], |
|
116 | - $bbbsession['welcome'], |
|
117 | - $bbbsession['modPW'], |
|
118 | - $bbbsession['viewerPW'], |
|
119 | - $bbbsession['shared_secret'], |
|
120 | - $bbbsession['endpoint'], |
|
121 | - $bbbsession['logoutURL'], |
|
122 | - $bbbsession['record'] ? 'true' : 'false', |
|
123 | - $durationtime, |
|
124 | - $bbbsession['voicebridge'], |
|
125 | - $bbbsession['userlimit'], |
|
126 | - $metadata, |
|
127 | - $bbbsession['presentation']['name'], |
|
128 | - $bbbsession['presentation']['url'] |
|
129 | - ); |
|
130 | - |
|
131 | - if (!$response) { |
|
132 | - // If the server is unreachable, then prompts the user of the necessary action. |
|
133 | - if ($bbbsession['administrator']) { |
|
134 | - print_error('view_error_unable_join', 'bigbluebuttonbn', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn'); |
|
135 | - } else if ($bbbsession['moderator']) { |
|
136 | - print_error('view_error_unable_join_teacher', 'bigbluebuttonbn', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn'); |
|
137 | - } else { |
|
138 | - print_error('view_error_unable_join_student', 'bigbluebuttonbn', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn'); |
|
100 | + if (bigbluebuttonbn_get_cfg_recordingready_enabled()) { |
|
101 | + $metadata["meta_bn-recording-ready-url"] = $bbbsession['recordingReadyURL']; |
|
139 | 102 | } |
140 | 103 | |
141 | - } else if ($response['returncode'] == "FAILED") { |
|
142 | - // The meeting was not created. |
|
143 | - $error_key = bigbluebuttonbn_get_error_key($response['messageKey'], 'view_error_create'); |
|
144 | - if (!$error_key) { |
|
145 | - print_error($response['message'], 'bigbluebuttonbn'); |
|
104 | + // Set the duration for the meeting. |
|
105 | + if (bigbluebuttonbn_get_cfg_scheduled_duration_enabled()) { |
|
106 | + $durationtime = bigbluebuttonbn_get_duration($bigbluebuttonbn->openingtime, $bigbluebuttonbn->closingtime); |
|
107 | + if ($durationtime > 0) |
|
108 | + $bbbsession['welcome'] .= '<br><br>' . str_replace("%duration%", '' . $durationtime, get_string('bbbdurationwarning', 'bigbluebuttonbn')); |
|
146 | 109 | } else { |
147 | - print_error($error_key, 'bigbluebuttonbn'); |
|
110 | + $durationtime = 0; |
|
148 | 111 | } |
112 | + // Execute the create command. |
|
113 | + $response = bigbluebuttonbn_getCreateMeetingArray( |
|
114 | + $bbbsession['meetingname'], |
|
115 | + $bbbsession['meetingid'], |
|
116 | + $bbbsession['welcome'], |
|
117 | + $bbbsession['modPW'], |
|
118 | + $bbbsession['viewerPW'], |
|
119 | + $bbbsession['shared_secret'], |
|
120 | + $bbbsession['endpoint'], |
|
121 | + $bbbsession['logoutURL'], |
|
122 | + $bbbsession['record'] ? 'true' : 'false', |
|
123 | + $durationtime, |
|
124 | + $bbbsession['voicebridge'], |
|
125 | + $bbbsession['userlimit'], |
|
126 | + $metadata, |
|
127 | + $bbbsession['presentation']['name'], |
|
128 | + $bbbsession['presentation']['url'] |
|
129 | + ); |
|
130 | + |
|
131 | + if (!$response) { |
|
132 | + // If the server is unreachable, then prompts the user of the necessary action. |
|
133 | + if ($bbbsession['administrator']) { |
|
134 | + print_error('view_error_unable_join', 'bigbluebuttonbn', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn'); |
|
135 | + } else if ($bbbsession['moderator']) { |
|
136 | + print_error('view_error_unable_join_teacher', 'bigbluebuttonbn', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn'); |
|
137 | + } else { |
|
138 | + print_error('view_error_unable_join_student', 'bigbluebuttonbn', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn'); |
|
139 | + } |
|
140 | + |
|
141 | + } else if ($response['returncode'] == "FAILED") { |
|
142 | + // The meeting was not created. |
|
143 | + $error_key = bigbluebuttonbn_get_error_key($response['messageKey'], 'view_error_create'); |
|
144 | + if (!$error_key) { |
|
145 | + print_error($response['message'], 'bigbluebuttonbn'); |
|
146 | + } else { |
|
147 | + print_error($error_key, 'bigbluebuttonbn'); |
|
148 | + } |
|
149 | + |
|
150 | + } else if ($response['hasBeenForciblyEnded'] == "true") { |
|
151 | + print_error(get_string('index_error_forciblyended', 'bigbluebuttonbn')); |
|
149 | 152 | |
150 | - } else if ($response['hasBeenForciblyEnded'] == "true") { |
|
151 | - print_error(get_string('index_error_forciblyended', 'bigbluebuttonbn')); |
|
153 | + } else { |
|
154 | + // Moodle event logger: Create an event for meeting created. |
|
155 | + bigbluebuttonbn_event_log(BIGBLUEBUTTON_EVENT_MEETING_CREATED, $bigbluebuttonbn, $context, $cm); |
|
156 | + // Internal logger: Instert a record with the meeting created. |
|
157 | + bigbluebuttonbn_logs($bbbsession, BIGBLUEBUTTONBN_LOG_EVENT_CREATE); |
|
158 | + // Since the meeting is already running, we just join the session. |
|
159 | + bigbluebutton_bbb_view_execute_join($bbbsession, $cm, $context, $bigbluebuttonbn); |
|
160 | + } |
|
152 | 161 | |
153 | 162 | } else { |
154 | - // Moodle event logger: Create an event for meeting created. |
|
155 | - bigbluebuttonbn_event_log(BIGBLUEBUTTON_EVENT_MEETING_CREATED, $bigbluebuttonbn, $context, $cm); |
|
156 | - // Internal logger: Instert a record with the meeting created. |
|
157 | - bigbluebuttonbn_logs($bbbsession, BIGBLUEBUTTONBN_LOG_EVENT_CREATE); |
|
158 | - // Since the meeting is already running, we just join the session. |
|
159 | - bigbluebutton_bbb_view_execute_join($bbbsession, $cm, $context, $bigbluebuttonbn); |
|
163 | + header('Location: ' . $bbbsession['logoutURL']); |
|
160 | 164 | } |
161 | - |
|
162 | - } else { |
|
163 | - header('Location: ' . $bbbsession['logoutURL']); |
|
164 | 165 | } |
165 | - } |
|
166 | 166 | |
167 | - } else { |
|
168 | - print_error('view_error_unable_join', 'bigbluebuttonbn'); |
|
169 | - } |
|
170 | - break; |
|
171 | - default: |
|
172 | - bigbluebutton_bbb_view_close_window(); |
|
167 | + } else { |
|
168 | + print_error('view_error_unable_join', 'bigbluebuttonbn'); |
|
169 | + } |
|
170 | + break; |
|
171 | + default: |
|
172 | + bigbluebutton_bbb_view_close_window(); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | function bigbluebutton_bbb_view_close_window() { |