Completed
Push — master ( 63aa89...ef28c1 )
by Jesus
02:13
created
bbb_view.php 1 patch
Switch Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -47,119 +47,119 @@
 block discarded – undo
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("meta_bn-origin" => $bbbsession['origin'],
80
-                            "meta_bbb-origin-version" => $bbbsession['originVersion'],
81
-                            "meta_bbb-origin-server-name" => $bbbsession['originServerName'],
82
-                            "meta_bbb-origin-server-common-name" => $bbbsession['originServerCommonName'],
83
-                            "meta_bbb-origin-tag" => $bbbsession['originTag'],
84
-                            "meta_bbb-context" => $bbbsession['course']->fullname,
85
-                            "meta_bbb-recording-name" => (isset($name) && $name != '')? $name: $bbbsession['contextActivityName'],
86
-                            "meta_bbb-recording-description" => (isset($description) && $description != '')? $description: $bbbsession['contextActivityDescription'],
87
-                            "meta_bbb-recording-tags" => (isset($tags) && $tags != '')? $tags: $bbbsession['contextActivityTags'],
88
-                    );
89
-
90
-                    if ( bigbluebuttonbn_server_offers_bn_capabilities() && bigbluebuttonbn_get_cfg_recordingready_enabled() ) {
91
-                        $metadata["meta_bn-recording-ready-url"] = $bbbsession['recordingReadyURL'];
92
-                    }
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);
93 74
 
94
-                    /// Set the duration for the meeting
95
-                    if ( bigbluebuttonbn_get_cfg_scheduled_duration_enabled() ) {
96
-                        $durationtime = bigbluebuttonbn_get_duration($bigbluebuttonbn->openingtime, $bigbluebuttonbn->closingtime);
97
-                        if( $durationtime > 0 )
98
-                            $bbbsession['welcome'] .= '<br><br>'.str_replace("%duration%", ''.$durationtime, get_string('bbbdurationwarning', 'bigbluebuttonbn'));
99
-                    } else {
100
-                        $durationtime = 0;
101
-                    }
102
-                    /// Execute the create command
103
-                    $response = bigbluebuttonbn_getCreateMeetingArray(
104
-                            $bbbsession['meetingname'],
105
-                            $bbbsession['meetingid'],
106
-                            $bbbsession['welcome'],
107
-                            $bbbsession['modPW'],
108
-                            $bbbsession['viewerPW'],
109
-                            $bbbsession['shared_secret'],
110
-                            $bbbsession['endpoint'],
111
-                            $bbbsession['logoutURL'],
112
-                            $bbbsession['record']? 'true': 'false',
113
-                            $durationtime,
114
-                            $bbbsession['voicebridge'],
115
-                            $bbbsession['userlimit'],
116
-                            $metadata,
117
-                            $bbbsession['presentation']['name'],
118
-                            $bbbsession['presentation']['url']
119
-                    );
120
-
121
-                    if (!$response) {
122
-                        // If the server is unreachable, then prompts the user of the necessary action
123
-                        if ( $bbbsession['administrator'] ) {
124
-                            print_error( 'view_error_unable_join', 'bigbluebuttonbn', $CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn' );
125
-                        } else if ( $bbbsession['moderator'] ) {
126
-                            print_error( 'view_error_unable_join_teacher', 'bigbluebuttonbn', $CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn' );
127
-                        } else {
128
-                            print_error( 'view_error_unable_join_student', 'bigbluebuttonbn', $CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn' );
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("meta_bn-origin" => $bbbsession['origin'],
80
+                                "meta_bbb-origin-version" => $bbbsession['originVersion'],
81
+                                "meta_bbb-origin-server-name" => $bbbsession['originServerName'],
82
+                                "meta_bbb-origin-server-common-name" => $bbbsession['originServerCommonName'],
83
+                                "meta_bbb-origin-tag" => $bbbsession['originTag'],
84
+                                "meta_bbb-context" => $bbbsession['course']->fullname,
85
+                                "meta_bbb-recording-name" => (isset($name) && $name != '')? $name: $bbbsession['contextActivityName'],
86
+                                "meta_bbb-recording-description" => (isset($description) && $description != '')? $description: $bbbsession['contextActivityDescription'],
87
+                                "meta_bbb-recording-tags" => (isset($tags) && $tags != '')? $tags: $bbbsession['contextActivityTags'],
88
+                        );
89
+
90
+                        if ( bigbluebuttonbn_server_offers_bn_capabilities() && bigbluebuttonbn_get_cfg_recordingready_enabled() ) {
91
+                            $metadata["meta_bn-recording-ready-url"] = $bbbsession['recordingReadyURL'];
129 92
                         }
130 93
 
131
-                    } else if( $response['returncode'] == "FAILED" ) {
132
-                        // The meeting was not created
133
-                        $error_key = bigbluebuttonbn_get_error_key( $response['messageKey'], 'view_error_create' );
134
-                        if( !$error_key ) {
135
-                            print_error( $response['message'], 'bigbluebuttonbn' );
94
+                        /// Set the duration for the meeting
95
+                        if ( bigbluebuttonbn_get_cfg_scheduled_duration_enabled() ) {
96
+                            $durationtime = bigbluebuttonbn_get_duration($bigbluebuttonbn->openingtime, $bigbluebuttonbn->closingtime);
97
+                            if( $durationtime > 0 )
98
+                                $bbbsession['welcome'] .= '<br><br>'.str_replace("%duration%", ''.$durationtime, get_string('bbbdurationwarning', 'bigbluebuttonbn'));
136 99
                         } else {
137
-                            print_error( $error_key, 'bigbluebuttonbn' );
100
+                            $durationtime = 0;
101
+                        }
102
+                        /// Execute the create command
103
+                        $response = bigbluebuttonbn_getCreateMeetingArray(
104
+                                $bbbsession['meetingname'],
105
+                                $bbbsession['meetingid'],
106
+                                $bbbsession['welcome'],
107
+                                $bbbsession['modPW'],
108
+                                $bbbsession['viewerPW'],
109
+                                $bbbsession['shared_secret'],
110
+                                $bbbsession['endpoint'],
111
+                                $bbbsession['logoutURL'],
112
+                                $bbbsession['record']? 'true': 'false',
113
+                                $durationtime,
114
+                                $bbbsession['voicebridge'],
115
+                                $bbbsession['userlimit'],
116
+                                $metadata,
117
+                                $bbbsession['presentation']['name'],
118
+                                $bbbsession['presentation']['url']
119
+                        );
120
+
121
+                        if (!$response) {
122
+                            // If the server is unreachable, then prompts the user of the necessary action
123
+                            if ( $bbbsession['administrator'] ) {
124
+                                print_error( 'view_error_unable_join', 'bigbluebuttonbn', $CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn' );
125
+                            } else if ( $bbbsession['moderator'] ) {
126
+                                print_error( 'view_error_unable_join_teacher', 'bigbluebuttonbn', $CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn' );
127
+                            } else {
128
+                                print_error( 'view_error_unable_join_student', 'bigbluebuttonbn', $CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn' );
129
+                            }
130
+
131
+                        } else if( $response['returncode'] == "FAILED" ) {
132
+                            // The meeting was not created
133
+                            $error_key = bigbluebuttonbn_get_error_key( $response['messageKey'], 'view_error_create' );
134
+                            if( !$error_key ) {
135
+                                print_error( $response['message'], 'bigbluebuttonbn' );
136
+                            } else {
137
+                                print_error( $error_key, 'bigbluebuttonbn' );
138
+                            }
139
+
140
+                        } else if ($response['hasBeenForciblyEnded'] == "true"){
141
+                            print_error( get_string( 'index_error_forciblyended', 'bigbluebuttonbn' ));
142
+
143
+                        } else { ///////////////Everything is ok /////////////////////
144
+                            /// Moodle event logger: Create an event for meeting created
145
+                            bigbluebuttonbn_event_log(BIGBLUEBUTTON_EVENT_MEETING_CREATED, $bigbluebuttonbn, $context, $cm);
146
+                            /// Internal logger: Instert a record with the meeting created
147
+                            bigbluebuttonbn_logs($bbbsession, BIGBLUEBUTTONBN_LOG_EVENT_CREATE);
148
+                            /// Since the meeting is already running, we just join the session
149
+                            bigbluebutton_bbb_view_execute_join($bbbsession, $cm, $context, $bigbluebuttonbn);
138 150
                         }
139 151
 
140
-                    } else if ($response['hasBeenForciblyEnded'] == "true"){
141
-                        print_error( get_string( 'index_error_forciblyended', 'bigbluebuttonbn' ));
142
-
143
-                    } else { ///////////////Everything is ok /////////////////////
144
-                        /// Moodle event logger: Create an event for meeting created
145
-                        bigbluebuttonbn_event_log(BIGBLUEBUTTON_EVENT_MEETING_CREATED, $bigbluebuttonbn, $context, $cm);
146
-                        /// Internal logger: Instert a record with the meeting created
147
-                        bigbluebuttonbn_logs($bbbsession, BIGBLUEBUTTONBN_LOG_EVENT_CREATE);
148
-                        /// Since the meeting is already running, we just join the session
149
-                        bigbluebutton_bbb_view_execute_join($bbbsession, $cm, $context, $bigbluebuttonbn);
152
+                    } else {
153
+                        header('Location: '.$bbbsession['logoutURL'] );
150 154
                     }
151
-
152
-                } else {
153
-                    header('Location: '.$bbbsession['logoutURL'] );
154 155
                 }
155
-            }
156 156
 
157
-        } else {
158
-            print_error( 'view_error_unable_join', 'bigbluebuttonbn' );
159
-        }
160
-        break;
161
-    default:
162
-        bigbluebutton_bbb_view_close_window();
157
+            } else {
158
+                print_error( 'view_error_unable_join', 'bigbluebuttonbn' );
159
+            }
160
+            break;
161
+        default:
162
+            bigbluebutton_bbb_view_close_window();
163 163
 }
164 164
 
165 165
 
Please login to merge, or discard this patch.