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