Completed
Push — 1.11.x ( 915cfc...7955a5 )
by José
98:44 queued 55:06
created
main/webservices/registration.soap.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -2617,6 +2617,9 @@
 block discarded – undo
2617 2617
     )
2618 2618
 );
2619 2619
 
2620
+/**
2621
+ * @param string $type
2622
+ */
2620 2623
 function WSHelperActionOnUsers($params, $type) {
2621 2624
     if(!WSHelperVerifyKey($params)) {
2622 2625
         return returnError(WS_ERROR_SECRET_KEY);
Please login to merge, or discard this patch.
Spacing   +460 added lines, -460 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     }
82 82
 
83 83
     if ($debug) {
84
-        error_log("checkip " . intval($check_ip));
84
+        error_log("checkip ".intval($check_ip));
85 85
     }
86 86
 
87 87
     if ($check_ip) {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     '',
141 141
     'SOAP-ENC:Array',
142 142
     array(),
143
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),
143
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:extras[]')),
144 144
     'tns:extras'
145 145
 );
146 146
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     '',
174 174
     'SOAP-ENC:Array',
175 175
     array(),
176
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:usersParams[]')),
176
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:usersParams[]')),
177 177
     'tns:usersParams'
178 178
 );
179 179
 
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
 );
220 220
 
221 221
 // Register the method to expose
222
-$server->register('WSCreateUsers',                 // method name
223
-    array('createUsers' => 'tns:createUsers'),     // input parameters
224
-    array('return' => 'tns:results_createUsers'),  // output parameters
225
-    'urn:WSRegistration',                          // namespace
226
-    'urn:WSRegistration#WSCreateUsers',            // soapaction
227
-    'rpc',                                         // style
228
-    'encoded',                                     // use
222
+$server->register('WSCreateUsers', // method name
223
+    array('createUsers' => 'tns:createUsers'), // input parameters
224
+    array('return' => 'tns:results_createUsers'), // output parameters
225
+    'urn:WSRegistration', // namespace
226
+    'urn:WSRegistration#WSCreateUsers', // soapaction
227
+    'rpc', // style
228
+    'encoded', // use
229 229
     'This service adds a user'                     // documentation
230 230
 );
231 231
 
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
             continue;
407 407
         }
408 408
 
409
-        $results[] =  $userId;
409
+        $results[] = $userId;
410 410
 
411 411
     } // end principal foreach
412 412
 
@@ -452,13 +452,13 @@  discard block
 block discarded – undo
452 452
 
453 453
 
454 454
 // Register the method to expose
455
-$server->register('WSCreateUser',                // method name
456
-    array('createUser' => 'tns:createUser'),     // input parameters
457
-    array('return' => 'xsd:string'),             // output parameters
458
-    'urn:WSRegistration',                        // namespace
459
-    'urn:WSRegistration#WSCreateUser',           // soapaction
460
-    'rpc',                                       // style
461
-    'encoded',                                   // use
455
+$server->register('WSCreateUser', // method name
456
+    array('createUser' => 'tns:createUser'), // input parameters
457
+    array('return' => 'xsd:string'), // output parameters
458
+    'urn:WSRegistration', // namespace
459
+    'urn:WSRegistration#WSCreateUser', // soapaction
460
+    'rpc', // style
461
+    'encoded', // use
462 462
     'This service adds a user'                   // documentation
463 463
 );
464 464
 
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
     }
562 562
 
563 563
     if (isset($original_user_id_name) && isset($original_user_id_value)) {
564
-        $_SESSION['ws_' . $original_user_id_name] = $original_user_id_value;
564
+        $_SESSION['ws_'.$original_user_id_name] = $original_user_id_value;
565 565
     }
566 566
 
567 567
     /** @var User $user */
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
         );
610 610
 
611 611
         if (isset($original_user_id_name) && isset($original_user_id_value)) {
612
-            unset($_SESSION['ws_' . $original_user_id_name]);
612
+            unset($_SESSION['ws_'.$original_user_id_name]);
613 613
         }
614 614
 
615 615
         if (is_array($extra_list) && count($extra_list) > 0) {
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
         'language'              => array('name' => 'language', 'type' => 'xsd:string'),
662 662
         'phone'                 => array('name' => 'phone', 'type' => 'xsd:string'),
663 663
         'expiration_date'       => array('name' => 'expiration_date', 'type' => 'xsd:string'),
664
-        'official_code'         => array('name' => 'official_code',    'type' => 'xsd:string'),
664
+        'official_code'         => array('name' => 'official_code', 'type' => 'xsd:string'),
665 665
         'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
666 666
         'original_user_id_value'=> array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
667 667
         'extra'                 => array('name' => 'extra', 'type' => 'tns:extrasList')
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
     'all',
690 690
     '',
691 691
     array(
692
-        'users'         => array('name' => 'users',      'type' => 'tns:createUsersPassEncryptParamsList'),
692
+        'users'         => array('name' => 'users', 'type' => 'tns:createUsersPassEncryptParamsList'),
693 693
         'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
694 694
     )
695 695
 );
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 );
720 720
 
721 721
 // Register the method to expose
722
-$server->register('WSCreateUsersPasswordCrypted',                            // method name
722
+$server->register('WSCreateUsersPasswordCrypted', // method name
723 723
     array('createUsersPasswordCrypted' => 'tns:createUsersPasswordCrypted'), // input parameters
724
-    array('return' => 'tns:results_createUsersPassEncrypt'),                 // output parameters
725
-    'urn:WSRegistration',                                                    // namespace
726
-    'urn:WSRegistration#WSCreateUsersPasswordCrypted',                       // soapaction
727
-    'rpc',                                                                   // style
728
-    'encoded',                                                               // use
724
+    array('return' => 'tns:results_createUsersPassEncrypt'), // output parameters
725
+    'urn:WSRegistration', // namespace
726
+    'urn:WSRegistration#WSCreateUsersPasswordCrypted', // soapaction
727
+    'rpc', // style
728
+    'encoded', // use
729 729
     'This service adds users to the system'                                  // documentation
730 730
 );
731 731
 
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 
796 796
         if (is_array($extra_list) && count($extra_list) > 0) {
797 797
             foreach ($extra_list as $extra) {
798
-                if($extra['field_name'] == 'salt') {
798
+                if ($extra['field_name'] == 'salt') {
799 799
                     $salt = $extra['field_value'];
800 800
                     break;
801 801
                 }
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
                         active='1',
851 851
                         hr_dept_id=".intval($hr_dept_id);
852 852
 
853
-                $sql .=  " WHERE user_id='".$r_check_user[0]."'";
853
+                $sql .= " WHERE user_id='".$r_check_user[0]."'";
854 854
                 Database::query($sql);
855 855
 
856 856
                 if (is_array($extra_list) && count($extra_list) > 0) {
@@ -989,9 +989,9 @@  discard block
 block discarded – undo
989 989
     'all',
990 990
     '',
991 991
     array(
992
-        'user_id' => array('name' => 'course',     'type' => 'xsd:string'), // Chamilo user Id
993
-        'session_id' => array('name' => 'user_id',    'type' => 'xsd:string'), // Current Session course ID
994
-        'course_id' =>array('name' => 'courseId',      'type' => 'xsd:string'), // Course Real Id
992
+        'user_id' => array('name' => 'course', 'type' => 'xsd:string'), // Chamilo user Id
993
+        'session_id' => array('name' => 'user_id', 'type' => 'xsd:string'), // Current Session course ID
994
+        'course_id' =>array('name' => 'courseId', 'type' => 'xsd:string'), // Course Real Id
995 995
         'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
996 996
 
997 997
         // optional
@@ -1049,9 +1049,9 @@  discard block
 block discarded – undo
1049 1049
         );
1050 1050
     }
1051 1051
 
1052
-    if ($debug) error_log('$userId found: '. $userId);
1053
-    if ($debug) error_log('$courseId found: '. $courseId);
1054
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1052
+    if ($debug) error_log('$userId found: '.$userId);
1053
+    if ($debug) error_log('$courseId found: '.$courseId);
1054
+    if ($debug) error_log('$sessionId found: '.$sessionId);
1055 1055
 
1056 1056
     return [
1057 1057
         'user_id' => $userId,
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
         return returnError(WS_ERROR_SECRET_KEY);
1088 1088
     }
1089 1089
 
1090
-    if ($debug) error_log('Params '. print_r($params, 1));
1090
+    if ($debug) error_log('Params '.print_r($params, 1));
1091 1091
 
1092 1092
     $params = parseCourseSessionUserParams($params);
1093 1093
 
@@ -1100,13 +1100,13 @@  discard block
 block discarded – undo
1100 1100
     $result = 0;
1101 1101
 
1102 1102
     if (!empty($coaches)) {
1103
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1103
+        if ($debug) error_log('Coaches:  '.print_r($coaches, 1));
1104 1104
         if (in_array($userId, $coaches)) {
1105 1105
             $result = 1;
1106 1106
         }
1107 1107
     }
1108 1108
 
1109
-    if ($debug) error_log('Result:  '. $result);
1109
+    if ($debug) error_log('Result:  '.$result);
1110 1110
 
1111 1111
     return $result;
1112 1112
 }
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
         return returnError(WS_ERROR_SECRET_KEY);
1139 1139
     }
1140 1140
 
1141
-    if ($debug) error_log('Params '. print_r($params, 1));
1141
+    if ($debug) error_log('Params '.print_r($params, 1));
1142 1142
 
1143 1143
     $params = parseCourseSessionUserParams($params);
1144 1144
 
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
     $result = 0;
1153 1153
 
1154 1154
     if (!empty($coaches)) {
1155
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1155
+        if ($debug) error_log('Coaches:  '.print_r($coaches, 1));
1156 1156
         if (!in_array($userId, $coaches)) {
1157 1157
             $result = 1;
1158 1158
         }
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
         $result = 1;
1161 1161
     }
1162 1162
 
1163
-    if ($debug) error_log('Final Result: '. $result);
1163
+    if ($debug) error_log('Final Result: '.$result);
1164 1164
 
1165 1165
     return $result;
1166 1166
 }
@@ -1178,32 +1178,32 @@  discard block
 block discarded – undo
1178 1178
     'all',
1179 1179
     '',
1180 1180
     array(
1181
-        'firstname'                 => array('name' => 'firstname',                 'type' => 'xsd:string'),
1182
-        'lastname'                  => array('name' => 'lastname',                  'type' => 'xsd:string'),
1183
-        'status'                    => array('name' => 'status',                    'type' => 'xsd:string'),
1184
-        'email'                     => array('name' => 'email',                     'type' => 'xsd:string'),
1185
-        'loginname'                 => array('name' => 'loginname',                 'type' => 'xsd:string'),
1186
-        'password'                  => array('name' => 'password',                  'type' => 'xsd:string'), //encripted password using the encrypt_method
1187
-        'encrypt_method'            => array('name' => 'encrypt_method',            'type' => 'xsd:string'),
1188
-        'language'                  => array('name' => 'language',                  'type' => 'xsd:string'),
1189
-        'phone'                     => array('name' => 'phone',                     'type' => 'xsd:string'),
1190
-        'expiration_date'           => array('name' => 'expiration_date',           'type' => 'xsd:string'),
1191
-        'official_code'             => array('name' => 'official_code',             'type' => 'xsd:string'),
1192
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
1193
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
1194
-        'extra'                     => array('name' => 'extra',                     'type' => 'tns:extrasList'),
1195
-        'secret_key'                => array('name' => 'secret_key',                'type' => 'xsd:string')
1181
+        'firstname'                 => array('name' => 'firstname', 'type' => 'xsd:string'),
1182
+        'lastname'                  => array('name' => 'lastname', 'type' => 'xsd:string'),
1183
+        'status'                    => array('name' => 'status', 'type' => 'xsd:string'),
1184
+        'email'                     => array('name' => 'email', 'type' => 'xsd:string'),
1185
+        'loginname'                 => array('name' => 'loginname', 'type' => 'xsd:string'),
1186
+        'password'                  => array('name' => 'password', 'type' => 'xsd:string'), //encripted password using the encrypt_method
1187
+        'encrypt_method'            => array('name' => 'encrypt_method', 'type' => 'xsd:string'),
1188
+        'language'                  => array('name' => 'language', 'type' => 'xsd:string'),
1189
+        'phone'                     => array('name' => 'phone', 'type' => 'xsd:string'),
1190
+        'expiration_date'           => array('name' => 'expiration_date', 'type' => 'xsd:string'),
1191
+        'official_code'             => array('name' => 'official_code', 'type' => 'xsd:string'),
1192
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
1193
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
1194
+        'extra'                     => array('name' => 'extra', 'type' => 'tns:extrasList'),
1195
+        'secret_key'                => array('name' => 'secret_key', 'type' => 'xsd:string')
1196 1196
     )
1197 1197
 );
1198 1198
 
1199 1199
 // Register the method to expose
1200
-$server->register('WSCreateUserPasswordCrypted',                            // method name
1201
-    array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'),  // input parameters
1202
-    array('return' => 'xsd:string'),                                        // output parameters
1203
-    'urn:WSRegistration',                                                   // namespace
1204
-    'urn:WSRegistration#WSCreateUserPasswordCrypted',                       // soapaction
1205
-    'rpc',                                                                  // style
1206
-    'encoded',                                                              // use
1200
+$server->register('WSCreateUserPasswordCrypted', // method name
1201
+    array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'), // input parameters
1202
+    array('return' => 'xsd:string'), // output parameters
1203
+    'urn:WSRegistration', // namespace
1204
+    'urn:WSRegistration#WSCreateUserPasswordCrypted', // soapaction
1205
+    'rpc', // style
1206
+    'encoded', // use
1207 1207
     'This service adds users'                                               // documentation
1208 1208
 );
1209 1209
 
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
     global $_user, $_configuration, $debug;
1214 1214
     $debug = 1;
1215 1215
     if ($debug) error_log('WSCreateUserPasswordCrypted');
1216
-    if ($debug) error_log(print_r($params,1));
1216
+    if ($debug) error_log(print_r($params, 1));
1217 1217
 
1218 1218
     if (!WSHelperVerifyKey($params)) {
1219 1219
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
     $extra_list = isset($params['extra']) ? $params['extra'] : '';
1243 1243
 
1244 1244
     if (!empty($_configuration['password_encryption'])) {
1245
-        if ($_configuration['password_encryption'] === $encrypt_method ) {
1245
+        if ($_configuration['password_encryption'] === $encrypt_method) {
1246 1246
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1247 1247
                 $msg = "Encryption $encrypt_method is invalid";
1248 1248
                 if ($debug) error_log($msg);
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
             if (!is_null($auth_source)) {
1305 1305
                 $sql .= " auth_source='".Database::escape_string($auth_source)."',";
1306 1306
             }
1307
-            $sql .=    "
1307
+            $sql .= "
1308 1308
                     password='".Database::escape_string($password)."',
1309 1309
                     email='".Database::escape_string($email)."',
1310 1310
                     status='".Database::escape_string($status)."',
@@ -1495,13 +1495,13 @@  discard block
 block discarded – undo
1495 1495
 );
1496 1496
 
1497 1497
 // Register the method to expose
1498
-$server->register('WSEditUserCredentials',                      // method name
1499
-    array('editUserCredentials' => 'tns:editUserCredentials'),  // input parameters
1500
-    array('return' => 'xsd:string'),                            // output parameters
1501
-    'urn:WSRegistration',                                       // namespace
1502
-    'urn:WSRegistration#WSEditUserCredentials',                 // soapaction
1503
-    'rpc',                                                      // style
1504
-    'encoded',                                                  // use
1498
+$server->register('WSEditUserCredentials', // method name
1499
+    array('editUserCredentials' => 'tns:editUserCredentials'), // input parameters
1500
+    array('return' => 'xsd:string'), // output parameters
1501
+    'urn:WSRegistration', // namespace
1502
+    'urn:WSRegistration#WSEditUserCredentials', // soapaction
1503
+    'rpc', // style
1504
+    'encoded', // use
1505 1505
     'This service edits the username and password of a user'    // documentation
1506 1506
 );
1507 1507
 
@@ -1600,13 +1600,13 @@  discard block
 block discarded – undo
1600 1600
 );
1601 1601
 
1602 1602
 // Register the method to expose
1603
-$server->register('WSEditUsers',                // method name
1604
-    array('editUsers' => 'tns:editUsers'),      // input parameters
1603
+$server->register('WSEditUsers', // method name
1604
+    array('editUsers' => 'tns:editUsers'), // input parameters
1605 1605
     array('return' => 'tns:results_editUsers'), // output parameters
1606
-    'urn:WSRegistration',                       // namespace
1607
-    'urn:WSRegistration#WSEditUsers',           // soapaction
1608
-    'rpc',                                      // style
1609
-    'encoded',                                  // use
1606
+    'urn:WSRegistration', // namespace
1607
+    'urn:WSRegistration#WSEditUsers', // soapaction
1608
+    'rpc', // style
1609
+    'encoded', // use
1610 1610
     'This service edits a user from wiener'     // documentation
1611 1611
 );
1612 1612
 
@@ -1791,13 +1791,13 @@  discard block
 block discarded – undo
1791 1791
 );
1792 1792
 
1793 1793
 // Register the method to expose
1794
-$server->register('WSEditUser',              // method name
1795
-    array('editUser' => 'tns:editUser'),     // input parameters
1796
-    array('return' => 'xsd:string'),         // output parameters
1797
-    'urn:WSRegistration',                    // namespace
1798
-    'urn:WSRegistration#WSEditUser',         // soapaction
1799
-    'rpc',                                   // style
1800
-    'encoded',                               // use
1794
+$server->register('WSEditUser', // method name
1795
+    array('editUser' => 'tns:editUser'), // input parameters
1796
+    array('return' => 'xsd:string'), // output parameters
1797
+    'urn:WSRegistration', // namespace
1798
+    'urn:WSRegistration#WSEditUser', // soapaction
1799
+    'rpc', // style
1800
+    'encoded', // use
1801 1801
     'This service edits a user from wiener'  // documentation
1802 1802
 );
1803 1803
 
@@ -1964,13 +1964,13 @@  discard block
 block discarded – undo
1964 1964
 );
1965 1965
 
1966 1966
 // Register the method to expose
1967
-$server->register('WSEditUserWithPicture',              // method name
1968
-    array('editUserWithPicture' => 'tns:editUserWithPicture'),     // input parameters
1969
-    array('return' => 'xsd:string'),                    // output parameters
1970
-    'urn:WSRegistration',                               // namespace
1971
-    'urn:WSRegistration#WSEditUserWithPicture',         // soapaction
1972
-    'rpc',                                              // style
1973
-    'encoded',                                          // use
1967
+$server->register('WSEditUserWithPicture', // method name
1968
+    array('editUserWithPicture' => 'tns:editUserWithPicture'), // input parameters
1969
+    array('return' => 'xsd:string'), // output parameters
1970
+    'urn:WSRegistration', // namespace
1971
+    'urn:WSRegistration#WSEditUserWithPicture', // soapaction
1972
+    'rpc', // style
1973
+    'encoded', // use
1974 1974
     'This service edits a user from wiener'             // documentation
1975 1975
 );
1976 1976
 
@@ -2024,8 +2024,8 @@  discard block
 block discarded – undo
2024 2024
     $tempDir = api_get_path(SYS_ARCHIVE_PATH);
2025 2025
     // Make sure the file download was OK by checking the HTTP headers for OK
2026 2026
     if (strpos(get_headers($picture_url)[0], "OK")) {
2027
-        file_put_contents($tempDir . $filename, file_get_contents($picture_url));
2028
-        $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir . $filename);
2027
+        file_put_contents($tempDir.$filename, file_get_contents($picture_url));
2028
+        $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir.$filename);
2029 2029
     }
2030 2030
 
2031 2031
     if ($user_id == 0) {
@@ -2187,13 +2187,13 @@  discard block
 block discarded – undo
2187 2187
 );
2188 2188
 
2189 2189
 // Register the method to expose
2190
-$server->register('WSEditUsersPasswordCrypted',                           // method name
2191
-    array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'),  // input parameters
2192
-    array('return' => 'tns:results_editUsersPasswordCrypted'),            // output parameters
2193
-    'urn:WSRegistration',                                                 // namespace
2194
-    'urn:WSRegistration#WSEditUsersPasswordCrypted',                      // soapaction
2195
-    'rpc',                                                                // style
2196
-    'encoded',                                                            // use
2190
+$server->register('WSEditUsersPasswordCrypted', // method name
2191
+    array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'), // input parameters
2192
+    array('return' => 'tns:results_editUsersPasswordCrypted'), // output parameters
2193
+    'urn:WSRegistration', // namespace
2194
+    'urn:WSRegistration#WSEditUsersPasswordCrypted', // soapaction
2195
+    'rpc', // style
2196
+    'encoded', // use
2197 2197
     'This service edits a user'                                           // documentation
2198 2198
 );
2199 2199
 
@@ -2237,7 +2237,7 @@  discard block
 block discarded – undo
2237 2237
 
2238 2238
             $password = $user_param['password'];
2239 2239
             $encrypt_method = $user_param['encrypt_method'];
2240
-            if ($_configuration['password_encryption'] === $encrypt_method ) {
2240
+            if ($_configuration['password_encryption'] === $encrypt_method) {
2241 2241
                 if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
2242 2242
                     $msg = "Encryption $encrypt_method is invalid";
2243 2243
                     $results[] = $msg;
@@ -2252,11 +2252,11 @@  discard block
 block discarded – undo
2252 2252
                 $results[] = $msg;
2253 2253
                 continue;
2254 2254
             }
2255
-        } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])){
2255
+        } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])) {
2256 2256
             $msg = "If password is not empty the encrypt_method param is required ";
2257 2257
             $results[] = $msg;
2258 2258
             continue;
2259
-        } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])){
2259
+        } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])) {
2260 2260
             $msg = "If encrypt_method is not empty the password param is required ";
2261 2261
             $results[] = $msg;
2262 2262
             continue;
@@ -2392,13 +2392,13 @@  discard block
 block discarded – undo
2392 2392
 );
2393 2393
 
2394 2394
 // Register the method to expose
2395
-$server->register('WSEditUserPasswordCrypted',                         // method name
2395
+$server->register('WSEditUserPasswordCrypted', // method name
2396 2396
     array('editUserPasswordCrypted' => 'tns:editUserPasswordCrypted'), // input parameters
2397
-    array('return' => 'xsd:string'),                                   // output parameters
2398
-    'urn:WSRegistration',                                              // namespace
2399
-    'urn:WSRegistration#WSEditUserPasswordCrypted',                    // soapaction
2400
-    'rpc',                                                             // style
2401
-    'encoded',                                                         // use
2397
+    array('return' => 'xsd:string'), // output parameters
2398
+    'urn:WSRegistration', // namespace
2399
+    'urn:WSRegistration#WSEditUserPasswordCrypted', // soapaction
2400
+    'rpc', // style
2401
+    'encoded', // use
2402 2402
     'This service edits a user'                                        // documentation
2403 2403
 );
2404 2404
 
@@ -2442,7 +2442,7 @@  discard block
 block discarded – undo
2442 2442
     if (!empty($params['password']) && !empty($params['encrypt_method'])) {
2443 2443
         $password = $params['password'];
2444 2444
         $encrypt_method = $params['encrypt_method'];
2445
-        if ($_configuration['password_encryption'] === $encrypt_method ) {
2445
+        if ($_configuration['password_encryption'] === $encrypt_method) {
2446 2446
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
2447 2447
                 $msg = "Encryption $encrypt_method is invalid";
2448 2448
                 return $msg;
@@ -2612,7 +2612,7 @@  discard block
 block discarded – undo
2612 2612
     '',
2613 2613
     'SOAP-ENC:Array',
2614 2614
     array(),
2615
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:user_id[]')),'tns:user_id'
2615
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_id[]')), 'tns:user_id'
2616 2616
 );
2617 2617
 
2618 2618
 $server->wsdl->addComplexType(
@@ -2636,7 +2636,7 @@  discard block
 block discarded – undo
2636 2636
     $orig_user_id_value = array();
2637 2637
 
2638 2638
     $original_user_ids = $params['ids'];
2639
-    foreach($original_user_ids as $original_user_id) {
2639
+    foreach ($original_user_ids as $original_user_id) {
2640 2640
         $result = false;
2641 2641
         $orig_user_id_value[] = $original_user_id['original_user_id_value'];
2642 2642
         $user_id = UserManager::get_user_id_from_original_id(
@@ -2646,13 +2646,13 @@  discard block
 block discarded – undo
2646 2646
         if ($user_id > 0) {
2647 2647
             if ($type == "delete") {
2648 2648
                 $result = UserManager::delete_user($user_id);
2649
-            } else if($type == "disable") {
2649
+            } else if ($type == "disable") {
2650 2650
                 $result = UserManager::disable($user_id);
2651
-            } else if($type == "enable") {
2651
+            } else if ($type == "enable") {
2652 2652
                 $result = UserManager::enable($user_id);
2653 2653
             }
2654 2654
         }
2655
-        $results[] = $result?1:0;
2655
+        $results[] = $result ? 1 : 0;
2656 2656
     }
2657 2657
 
2658 2658
 
@@ -2668,13 +2668,13 @@  discard block
 block discarded – undo
2668 2668
     return $output;
2669 2669
 }
2670 2670
 
2671
-$server->register('WSDeleteUsers',                         // method name
2672
-    array('user_ids' => 'tns:user_ids'),                   // input parameters
2673
-    array('return' => 'tns:results_actionUsers'),          // output parameters
2674
-    'urn:WSRegistration',                                  // namespace
2675
-    'urn:WSRegistration#WSDeleteUsers',                    // soapaction
2676
-    'rpc',                                                 // style
2677
-    'encoded',                                             // use
2671
+$server->register('WSDeleteUsers', // method name
2672
+    array('user_ids' => 'tns:user_ids'), // input parameters
2673
+    array('return' => 'tns:results_actionUsers'), // output parameters
2674
+    'urn:WSRegistration', // namespace
2675
+    'urn:WSRegistration#WSDeleteUsers', // soapaction
2676
+    'rpc', // style
2677
+    'encoded', // use
2678 2678
     'Deletes users provided as parameters from the system' // documentation
2679 2679
 );
2680 2680
 
@@ -2683,13 +2683,13 @@  discard block
 block discarded – undo
2683 2683
 }
2684 2684
 
2685 2685
 /** WSDisableUsers **/
2686
-$server->register('WSDisableUsers',                         // method name
2687
-    array('user_ids' => 'tns:user_ids'),                    // input parameters
2688
-    array('return' => 'tns:results_actionUsers'),           // output parameters
2689
-    'urn:WSRegistration',                                   // namespace
2690
-    'urn:WSRegistration#WSDisableUsers',                    // soapaction
2691
-    'rpc',                                                  // style
2692
-    'encoded',                                              // use
2686
+$server->register('WSDisableUsers', // method name
2687
+    array('user_ids' => 'tns:user_ids'), // input parameters
2688
+    array('return' => 'tns:results_actionUsers'), // output parameters
2689
+    'urn:WSRegistration', // namespace
2690
+    'urn:WSRegistration#WSDisableUsers', // soapaction
2691
+    'rpc', // style
2692
+    'encoded', // use
2693 2693
     'Disables users provided as parameters from the system' // documentation
2694 2694
 );
2695 2695
 
@@ -2698,13 +2698,13 @@  discard block
 block discarded – undo
2698 2698
 }
2699 2699
 
2700 2700
 /** WSEnableUsers **/
2701
-$server->register('WSEnableUsers',            // method name
2702
-    array('user_ids' => 'tns:user_ids'),      // input parameters
2703
-    array('return' => 'tns:results_actionUsers'),      // output parameters
2704
-    'urn:WSRegistration',                     // namespace
2705
-    'urn:WSRegistration#WSEnableUsers',       // soapaction
2706
-    'rpc',                                    // style
2707
-    'encoded',                                // use
2701
+$server->register('WSEnableUsers', // method name
2702
+    array('user_ids' => 'tns:user_ids'), // input parameters
2703
+    array('return' => 'tns:results_actionUsers'), // output parameters
2704
+    'urn:WSRegistration', // namespace
2705
+    'urn:WSRegistration#WSEnableUsers', // soapaction
2706
+    'rpc', // style
2707
+    'encoded', // use
2708 2708
     'Enables users provided as parameters'    // documentation
2709 2709
 );
2710 2710
 
@@ -2757,7 +2757,7 @@  discard block
 block discarded – undo
2757 2757
     '',
2758 2758
     'SOAP-ENC:Array',
2759 2759
     array(),
2760
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:createCourseParams[]')),'tns:createCourseParams'
2760
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createCourseParams[]')), 'tns:createCourseParams'
2761 2761
 );
2762 2762
 
2763 2763
 // Register the data structures used by the service
@@ -2798,13 +2798,13 @@  discard block
 block discarded – undo
2798 2798
 );
2799 2799
 
2800 2800
 // Register the method to expose
2801
-$server->register('WSCreateCourse',                // method name
2802
-    array('createCourse' => 'tns:createCourse'),   // input parameters
2801
+$server->register('WSCreateCourse', // method name
2802
+    array('createCourse' => 'tns:createCourse'), // input parameters
2803 2803
     array('return' => 'tns:results_createCourse'), // output parameters
2804
-    'urn:WSRegistration',                          // namespace
2805
-    'urn:WSRegistration#WSCreateCourse',           // soapaction
2806
-    'rpc',                                         // style
2807
-    'encoded',                                     // use
2804
+    'urn:WSRegistration', // namespace
2805
+    'urn:WSRegistration#WSCreateCourse', // soapaction
2806
+    'rpc', // style
2807
+    'encoded', // use
2808 2808
     'This service adds a course'                   // documentation
2809 2809
 );
2810 2810
 
@@ -2862,7 +2862,7 @@  discard block
 block discarded – undo
2862 2862
                             category_code='".Database::escape_string($category_code)."',
2863 2863
                             tutor_name='".Database::escape_string($tutor_name)."',
2864 2864
                             visual_code='".Database::escape_string($wanted_code)."'";
2865
-                if($visibility !== null) {
2865
+                if ($visibility !== null) {
2866 2866
                     $sql .= ", visibility = '$visibility' ";
2867 2867
                 }
2868 2868
                 $sql .= " WHERE id='".$courseInfo['real_id']."'";
@@ -2895,7 +2895,7 @@  discard block
 block discarded – undo
2895 2895
         $params['title'] = $title;
2896 2896
         $params['wanted_code'] = $wanted_code;
2897 2897
         $params['category_code'] = $category_code;
2898
-        $params['course_category']    = $category_code;
2898
+        $params['course_category'] = $category_code;
2899 2899
         $params['tutor_name'] = $tutor_name;
2900 2900
         $params['course_language'] = $course_language;
2901 2901
         $params['user_id'] = api_get_user_id();
@@ -3033,13 +3033,13 @@  discard block
 block discarded – undo
3033 3033
 
3034 3034
 
3035 3035
 // Register the method to expose
3036
-$server->register('WSCreateCourseByTitle',                     // method name
3036
+$server->register('WSCreateCourseByTitle', // method name
3037 3037
     array('createCourseByTitle' => 'tns:createCourseByTitle'), // input parameters
3038
-    array('return' => 'tns:results_createCourseByTitle'),      // output parameters
3039
-    'urn:WSRegistration',                                      // namespace
3040
-    'urn:WSRegistration#WSCreateCourseByTitle',                // soapaction
3041
-    'rpc',                                                     // style
3042
-    'encoded',                                                 // use
3038
+    array('return' => 'tns:results_createCourseByTitle'), // output parameters
3039
+    'urn:WSRegistration', // namespace
3040
+    'urn:WSRegistration#WSCreateCourseByTitle', // soapaction
3041
+    'rpc', // style
3042
+    'encoded', // use
3043 3043
     'This service adds a course by title'                      // documentation
3044 3044
 );
3045 3045
 
@@ -3270,18 +3270,18 @@  discard block
 block discarded – undo
3270 3270
 );
3271 3271
 
3272 3272
 // Register the method to expose
3273
-$server->register('WSEditCourse',                // method name
3274
-    array('editCourse' => 'tns:editCourse'),     // input parameters
3273
+$server->register('WSEditCourse', // method name
3274
+    array('editCourse' => 'tns:editCourse'), // input parameters
3275 3275
     array('return' => 'tns:results_editCourse'), // output parameters
3276
-    'urn:WSRegistration',                        // namespace
3277
-    'urn:WSRegistration#WSEditCourse',           // soapaction
3278
-    'rpc',                                       // style
3279
-    'encoded',                                   // use
3276
+    'urn:WSRegistration', // namespace
3277
+    'urn:WSRegistration#WSEditCourse', // soapaction
3278
+    'rpc', // style
3279
+    'encoded', // use
3280 3280
     'This service edits a course'                // documentation
3281 3281
 );
3282 3282
 
3283 3283
 // Define the method WSEditCourse
3284
-function WSEditCourse($params){
3284
+function WSEditCourse($params) {
3285 3285
 
3286 3286
     global $_configuration;
3287 3287
     if (!WSHelperVerifyKey($params)) {
@@ -3436,13 +3436,13 @@  discard block
 block discarded – undo
3436 3436
 
3437 3437
 
3438 3438
 // Register the method to expose
3439
-$server->register('WSCourseDescription',                    // method name
3440
-    array('courseDescription' => 'tns:courseDescription'),  // input parameters
3441
-    array('return' => 'tns:fields_course_desc_list'),       // output parameters
3442
-    'urn:WSRegistration',                                   // namespace
3443
-    'urn:WSRegistration#WSCourseDescription',               // soapaction
3444
-    'rpc',                                                  // style
3445
-    'encoded',                                              // use
3439
+$server->register('WSCourseDescription', // method name
3440
+    array('courseDescription' => 'tns:courseDescription'), // input parameters
3441
+    array('return' => 'tns:fields_course_desc_list'), // output parameters
3442
+    'urn:WSRegistration', // namespace
3443
+    'urn:WSRegistration#WSCourseDescription', // soapaction
3444
+    'rpc', // style
3445
+    'encoded', // use
3446 3446
     'This service edits a course description'               // documentation
3447 3447
 );
3448 3448
 
@@ -3492,7 +3492,7 @@  discard block
 block discarded – undo
3492 3492
     }
3493 3493
 
3494 3494
     while ($row = Database::fetch_array($result)) {
3495
-        $ind = (int)$row['id'];
3495
+        $ind = (int) $row['id'];
3496 3496
         $array_course_desc_title[$ind] = $row['title'];
3497 3497
         $array_course_desc_content[$ind] = $row['content'];
3498 3498
     }
@@ -3579,13 +3579,13 @@  discard block
 block discarded – undo
3579 3579
 
3580 3580
 
3581 3581
 // Register the method to expose
3582
-$server->register('WSEditCourseDescription',                       // method name
3582
+$server->register('WSEditCourseDescription', // method name
3583 3583
     array('editCourseDescription' => 'tns:editCourseDescription'), // input parameters
3584
-    array('return' => 'tns:results_editCourseDescription'),        // output parameters
3585
-    'urn:WSRegistration',                                          // namespace
3586
-    'urn:WSRegistration#WSEditCourseDescription',                  // soapaction
3587
-    'rpc',                                                         // style
3588
-    'encoded',                                                     // use
3584
+    array('return' => 'tns:results_editCourseDescription'), // output parameters
3585
+    'urn:WSRegistration', // namespace
3586
+    'urn:WSRegistration#WSEditCourseDescription', // soapaction
3587
+    'rpc', // style
3588
+    'encoded', // use
3589 3589
     'This service edits a course description'                      // documentation
3590 3590
 );
3591 3591
 
@@ -3627,7 +3627,7 @@  discard block
 block discarded – undo
3627 3627
         $course_desc_title = Database::escape_string($course_desc_title);
3628 3628
         $course_desc_content = Database::escape_string($course_desc_content);
3629 3629
 
3630
-        $course_desc_id = (int)$course_desc_id;
3630
+        $course_desc_id = (int) $course_desc_id;
3631 3631
         if ($course_desc_id > 8 && $course_desc_id < 1) {
3632 3632
             $results[] = 0; // course_desc_id invalid.
3633 3633
             continue;
@@ -3656,7 +3656,7 @@  discard block
 block discarded – undo
3656 3656
             $result = $courseDescription->insert();
3657 3657
         }
3658 3658
 
3659
-        $results[] = $result?1:0;
3659
+        $results[] = $result ? 1 : 0;
3660 3660
     } // end principal foreach
3661 3661
 
3662 3662
     $count_results = count($results);
@@ -3734,13 +3734,13 @@  discard block
 block discarded – undo
3734 3734
     'tns:result_deleteCourse'
3735 3735
 );
3736 3736
 
3737
-$server->register('WSDeleteCourse',                // method name
3738
-    array('deleteCourse' => 'tns:deleteCourse'),   // input parameters
3737
+$server->register('WSDeleteCourse', // method name
3738
+    array('deleteCourse' => 'tns:deleteCourse'), // input parameters
3739 3739
     array('return' => 'tns:results_deleteCourse'), // output parameters
3740
-    'urn:WSRegistration',                          // namespace
3741
-    'urn:WSRegistration#WSDeleteCourse',           // soapaction
3742
-    'rpc',                                         // style
3743
-    'encoded',                                     // use
3740
+    'urn:WSRegistration', // namespace
3741
+    'urn:WSRegistration#WSDeleteCourse', // soapaction
3742
+    'rpc', // style
3743
+    'encoded', // use
3744 3744
     'This service deletes a course '               // documentation
3745 3745
 );
3746 3746
 
@@ -3867,13 +3867,13 @@  discard block
 block discarded – undo
3867 3867
 );
3868 3868
 
3869 3869
 // Register the method to expose
3870
-$server->register('WSCreateSession',                // method name
3871
-    array('createSession' => 'tns:createSession'),  // input parameters
3870
+$server->register('WSCreateSession', // method name
3871
+    array('createSession' => 'tns:createSession'), // input parameters
3872 3872
     array('return' => 'tns:results_createSession'), // output parameters
3873
-    'urn:WSRegistration',                           // namespace
3874
-    'urn:WSRegistration#WSCreateSession',           // soapaction
3875
-    'rpc',                                          // style
3876
-    'encoded',                                      // use
3873
+    'urn:WSRegistration', // namespace
3874
+    'urn:WSRegistration#WSCreateSession', // soapaction
3875
+    'rpc', // style
3876
+    'encoded', // use
3877 3877
     'This service edits a session'                  // documentation
3878 3878
 );
3879 3879
 
@@ -3927,8 +3927,8 @@  discard block
 block discarded – undo
3927 3927
         }
3928 3928
 
3929 3929
         if (empty($nolimit)) {
3930
-            $date_start = "$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start) . ' 00:00:00';
3931
-            $date_end = "$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end) . ' 23:59:59';
3930
+            $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start).' 00:00:00';
3931
+            $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end).' 23:59:59';
3932 3932
         } else {
3933 3933
             $date_start = "";
3934 3934
             $date_end = "";
@@ -3952,7 +3952,7 @@  discard block
 block discarded – undo
3952 3952
             }
3953 3953
             $results[] = 0;
3954 3954
             continue;
3955
-        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end,  $day_end, $year_end))) {
3955
+        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) {
3956 3956
             $results[] = 0;
3957 3957
             if ($debug) {
3958 3958
                 error_log("There's an error with the end date: $month_end - $day_end - $year_end");
@@ -4141,13 +4141,13 @@  discard block
 block discarded – undo
4141 4141
 
4142 4142
 
4143 4143
 // Register the method to expose
4144
-$server->register('WSEditSession',                // method name
4145
-    array('editSession' => 'tns:editSession'),    // input parameters
4144
+$server->register('WSEditSession', // method name
4145
+    array('editSession' => 'tns:editSession'), // input parameters
4146 4146
     array('return' => 'tns:results_editSession'), // output parameters
4147
-    'urn:WSRegistration',                         // namespace
4148
-    'urn:WSRegistration#WSEditSession',           // soapaction
4149
-    'rpc',                                        // style
4150
-    'encoded',                                    // use
4147
+    'urn:WSRegistration', // namespace
4148
+    'urn:WSRegistration#WSEditSession', // soapaction
4149
+    'rpc', // style
4150
+    'encoded', // use
4151 4151
     'This service edits a session'                // documentation
4152 4152
 );
4153 4153
 
@@ -4267,7 +4267,7 @@  discard block
 block discarded – undo
4267 4267
                 }
4268 4268
             }
4269 4269
 
4270
-            $results[] = $editResult?1:0;
4270
+            $results[] = $editResult ? 1 : 0;
4271 4271
             continue;
4272 4272
         }
4273 4273
 
@@ -4346,13 +4346,13 @@  discard block
 block discarded – undo
4346 4346
     'tns:result_deleteSession'
4347 4347
 );
4348 4348
 
4349
-$server->register('WSDeleteSession',                // method name
4350
-    array('deleteSession' => 'tns:deleteSession'),  // input parameters
4349
+$server->register('WSDeleteSession', // method name
4350
+    array('deleteSession' => 'tns:deleteSession'), // input parameters
4351 4351
     array('return' => 'tns:results_deleteSession'), // output parameters
4352
-    'urn:WSRegistration',                           // namespace
4353
-    'urn:WSRegistration#WSDeleteSession',           // soapaction
4354
-    'rpc',                                          // style
4355
-    'encoded',                                      // use
4352
+    'urn:WSRegistration', // namespace
4353
+    'urn:WSRegistration#WSDeleteSession', // soapaction
4354
+    'rpc', // style
4355
+    'encoded', // use
4356 4356
     'This service deletes a session '               // documentation
4357 4357
 );
4358 4358
 
@@ -4433,10 +4433,10 @@  discard block
 block discarded – undo
4433 4433
     'struct',
4434 4434
     'all',
4435 4435
     '',
4436
-    array (
4436
+    array(
4437 4437
         'course_id' => array('name' => 'course_id', 'type' => 'tns:course_id'),
4438
-        'user_id'   => array('name' => 'user_id',   'type' => 'tns:user_id'),
4439
-        'status'    => array('name' => 'status',    'type' => 'xsd:int')
4438
+        'user_id'   => array('name' => 'user_id', 'type' => 'tns:user_id'),
4439
+        'status'    => array('name' => 'status', 'type' => 'xsd:int')
4440 4440
     )
4441 4441
 );
4442 4442
 
@@ -4446,9 +4446,9 @@  discard block
 block discarded – undo
4446 4446
     'struct',
4447 4447
     'all',
4448 4448
     '',
4449
-    array (
4450
-        'userscourses'  => array('name' => 'userscourses',  'type' => 'tns:user_course_status_array'), //removed []
4451
-        'secret_key'    => array('name' => 'secret_key',    'type' => 'xsd:string')
4449
+    array(
4450
+        'userscourses'  => array('name' => 'userscourses', 'type' => 'tns:user_course_status_array'), //removed []
4451
+        'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
4452 4452
     )
4453 4453
 );
4454 4454
 
@@ -4473,9 +4473,9 @@  discard block
 block discarded – undo
4473 4473
     'all',
4474 4474
     '',
4475 4475
     array(
4476
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
4477
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
4478
-        'result'                    => array('name' => 'result',                    'type' => 'xsd:int')
4476
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
4477
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
4478
+        'result'                    => array('name' => 'result', 'type' => 'xsd:int')
4479 4479
     )
4480 4480
 );
4481 4481
 
@@ -4491,13 +4491,13 @@  discard block
 block discarded – undo
4491 4491
 );
4492 4492
 
4493 4493
 // Register the method to expose
4494
-$server->register('WSSubscribeUserToCourse',                            // method name
4495
-    array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'),  // input parameters
4494
+$server->register('WSSubscribeUserToCourse', // method name
4495
+    array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'), // input parameters
4496 4496
     array('return' => 'tns:subscribeUserToCourse_return_global'),
4497
-    'urn:WSRegistration',                                               // namespace
4498
-    'urn:WSRegistration#WSSubscribeUserToCourse',                       // soapaction
4499
-    'rpc',                                                              // style
4500
-    'encoded',                                                          // use
4497
+    'urn:WSRegistration', // namespace
4498
+    'urn:WSRegistration#WSSubscribeUserToCourse', // soapaction
4499
+    'rpc', // style
4500
+    'encoded', // use
4501 4501
     'This service subscribes a user to a course'                        // documentation
4502 4502
 );
4503 4503
 
@@ -4507,7 +4507,7 @@  discard block
 block discarded – undo
4507 4507
     if (!WSHelperVerifyKey($params)) {
4508 4508
         return returnError(WS_ERROR_SECRET_KEY);
4509 4509
     }
4510
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4510
+    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params, 1));
4511 4511
 
4512 4512
     $results = array();
4513 4513
     $userscourses = $params['userscourses'];
@@ -4575,9 +4575,9 @@  discard block
 block discarded – undo
4575 4575
     'all',
4576 4576
     '',
4577 4577
     array(
4578
-        'course'       => array('name' => 'course',     'type' => 'xsd:string'), //Course string code
4579
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'), //Chamilo user_id
4580
-        'status'       => array('name' => 'status',     'type' => 'xsd:int'),
4578
+        'course'       => array('name' => 'course', 'type' => 'xsd:string'), //Course string code
4579
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id
4580
+        'status'       => array('name' => 'status', 'type' => 'xsd:int'),
4581 4581
         'secret_key'   => array('name' => 'secret_key', 'type' => 'xsd:string')
4582 4582
     )
4583 4583
 );
@@ -4590,18 +4590,18 @@  discard block
 block discarded – undo
4590 4590
     'struct',
4591 4591
     'all',
4592 4592
     '',
4593
-    array('message' => array('name' => 'message',    'type' => 'xsd:string'))
4593
+    array('message' => array('name' => 'message', 'type' => 'xsd:string'))
4594 4594
 );
4595 4595
 
4596 4596
 
4597 4597
 // Register the method to expose
4598
-$server->register('WSSubscribeUserToCourseSimple',                                 // method name
4598
+$server->register('WSSubscribeUserToCourseSimple', // method name
4599 4599
     array('subscribeUserToCourseSimple' => 'tns:subscribeUserToCourseSimple_arg'), // input parameters
4600
-    array('return' => 'xsd:string'),                                               // output parameters
4601
-    'urn:WSRegistration',                                                          // namespace
4602
-    'urn:WSRegistration#WSSubscribeUserToCourseSimple',                            // soapaction
4603
-    'rpc',                                                                         // style
4604
-    'encoded',                                                                     // use
4600
+    array('return' => 'xsd:string'), // output parameters
4601
+    'urn:WSRegistration', // namespace
4602
+    'urn:WSRegistration#WSSubscribeUserToCourseSimple', // soapaction
4603
+    'rpc', // style
4604
+    'encoded', // use
4605 4605
     'This service subscribes a user to a course in a simple way'                   // documentation
4606 4606
 );
4607 4607
 
@@ -4610,7 +4610,7 @@  discard block
 block discarded – undo
4610 4610
     global $debug;
4611 4611
 
4612 4612
     if ($debug) error_log('WSSubscribeUserToCourseSimple');
4613
-    if ($debug) error_log('Params '. print_r($params, 1));
4613
+    if ($debug) error_log('Params '.print_r($params, 1));
4614 4614
     if (!WSHelperVerifyKey($params)) {
4615 4615
         return returnError(WS_ERROR_SECRET_KEY);
4616 4616
     }
@@ -4661,9 +4661,9 @@  discard block
 block discarded – undo
4661 4661
     'all',
4662 4662
     '',
4663 4663
     array(
4664
-        'original_user_id_value'      => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
4665
-        'original_user_id_name'       => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
4666
-        'secret_key'                  => array('name' => 'secret_key',                'type' => 'xsd:string')
4664
+        'original_user_id_value'      => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
4665
+        'original_user_id_name'       => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
4666
+        'secret_key'                  => array('name' => 'secret_key', 'type' => 'xsd:string')
4667 4667
     )
4668 4668
 );
4669 4669
 
@@ -4674,21 +4674,21 @@  discard block
 block discarded – undo
4674 4674
     'struct',
4675 4675
     'all',
4676 4676
     '',
4677
-    array (
4678
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'),
4679
-        'firstname'    => array('name' => 'firstname',  'type' => 'xsd:string'),
4680
-        'lastname'     => array('name' => 'lastname',   'type' => 'xsd:string'),
4677
+    array(
4678
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'),
4679
+        'firstname'    => array('name' => 'firstname', 'type' => 'xsd:string'),
4680
+        'lastname'     => array('name' => 'lastname', 'type' => 'xsd:string'),
4681 4681
     )
4682 4682
 );
4683 4683
 
4684 4684
 // Register the method to expose
4685
-$server->register('WSGetUser',                   // method name
4686
-    array('GetUser' => 'tns:GetUserArg'),        // input parameters
4687
-    array('return' => 'tns:User'),               // output parameters
4688
-    'urn:WSRegistration',                        // namespace
4689
-    'urn:WSRegistration#WSGetUser',              // soapaction
4690
-    'rpc',                                       // style
4691
-    'encoded',                                   // use
4685
+$server->register('WSGetUser', // method name
4686
+    array('GetUser' => 'tns:GetUserArg'), // input parameters
4687
+    array('return' => 'tns:User'), // output parameters
4688
+    'urn:WSRegistration', // namespace
4689
+    'urn:WSRegistration#WSGetUser', // soapaction
4690
+    'rpc', // style
4691
+    'encoded', // use
4692 4692
     'This service get user information by id'    // documentation
4693 4693
 );
4694 4694
 
@@ -4733,17 +4733,17 @@  discard block
 block discarded – undo
4733 4733
     '',
4734 4734
     array(
4735 4735
         'username'      => array('name' => 'username', 'type' => 'xsd:string'),
4736
-        'secret_key'    => array('name' => 'secret_key','type' => 'xsd:string')
4736
+        'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
4737 4737
     )
4738 4738
 );
4739 4739
 // Register the method to expose
4740
-$server->register('WSGetUserFromUsername',                     // method name
4741
-    array('GetUserFromUsername' => 'tns:GetUserArgUsername'),  // input params
4742
-    array('return' => 'tns:User'),                             // output parameters
4743
-    'urn:WSRegistration',                                      // namespace
4744
-    'urn:WSRegistration#WSGetUserFromUsername',                // soapaction
4745
-    'rpc',                                                     // style
4746
-    'encoded',                                                 // use
4740
+$server->register('WSGetUserFromUsername', // method name
4741
+    array('GetUserFromUsername' => 'tns:GetUserArgUsername'), // input params
4742
+    array('return' => 'tns:User'), // output parameters
4743
+    'urn:WSRegistration', // namespace
4744
+    'urn:WSRegistration#WSGetUserFromUsername', // soapaction
4745
+    'rpc', // style
4746
+    'encoded', // use
4747 4747
     'This service get user information by username'            // documentation
4748 4748
 );
4749 4749
 
@@ -4785,10 +4785,10 @@  discard block
 block discarded – undo
4785 4785
     'all',
4786 4786
     '',
4787 4787
     array(
4788
-        'original_user_id_values'   => array('name' => 'original_user_id_values',   'type' => 'tns:originalUsersList'),
4789
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
4790
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
4791
-        'original_course_id_name'   => array('name' => 'original_course_id_name',   'type' => 'xsd:string'),
4788
+        'original_user_id_values'   => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'),
4789
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
4790
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
4791
+        'original_course_id_name'   => array('name' => 'original_course_id_name', 'type' => 'xsd:string'),
4792 4792
     )
4793 4793
 );
4794 4794
 
@@ -4841,13 +4841,13 @@  discard block
 block discarded – undo
4841 4841
 );
4842 4842
 
4843 4843
 // Register the method to expose
4844
-$server->register('WSUnsubscribeUserFromCourse',                         // method name
4844
+$server->register('WSUnsubscribeUserFromCourse', // method name
4845 4845
     array('unsuscribeUserFromCourse' => 'tns:unsuscribeUserFromCourse'), // input parameters
4846
-    array('return' => 'tns:results_unsuscribeUserFromCourse'),           // output parameters
4847
-    'urn:WSRegistration',                                                // namespace
4848
-    'urn:WSRegistration#WSUnsubscribeUserFromCourse',                    // soapaction
4849
-    'rpc',                                                               // style
4850
-    'encoded',                                                           // use
4846
+    array('return' => 'tns:results_unsuscribeUserFromCourse'), // output parameters
4847
+    'urn:WSRegistration', // namespace
4848
+    'urn:WSRegistration#WSUnsubscribeUserFromCourse', // soapaction
4849
+    'rpc', // style
4850
+    'encoded', // use
4851 4851
     'This service unsubscribes a user from a course'                     // documentation
4852 4852
 );
4853 4853
 
@@ -4893,7 +4893,7 @@  discard block
 block discarded – undo
4893 4893
             $usersList[] = $user_id;
4894 4894
         }
4895 4895
 
4896
-        $orig_user_id_value[] = implode(',',$usersList);
4896
+        $orig_user_id_value[] = implode(',', $usersList);
4897 4897
 
4898 4898
         $courseInfo = CourseManager::getCourseInfoFromOriginalId(
4899 4899
             $original_course_id_value,
@@ -4960,20 +4960,20 @@  discard block
 block discarded – undo
4960 4960
     'all',
4961 4961
     '',
4962 4962
     array(
4963
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
4964
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
4965
-        'result'                    => array('name' => 'result',                    'type' => 'xsd:int')
4963
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
4964
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
4965
+        'result'                    => array('name' => 'result', 'type' => 'xsd:int')
4966 4966
     )
4967 4967
 );
4968 4968
 
4969 4969
 // Register the method to expose
4970
-$server->register('WSUnSubscribeUserFromCourseSimple',                         // method name
4970
+$server->register('WSUnSubscribeUserFromCourseSimple', // method name
4971 4971
     array('unSubscribeUserFromCourseSimple' => 'tns:unSubscribeUserFromCourseSimple'), // input parameters
4972
-    array('return' => 'tns:unSubscribeUserToCourseSimple_return'),           // output parameters
4973
-    'urn:WSRegistration',                                                // namespace
4974
-    'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple',                    // soapaction
4975
-    'rpc',                                                               // style
4976
-    'encoded',                                                           // use
4972
+    array('return' => 'tns:unSubscribeUserToCourseSimple_return'), // output parameters
4973
+    'urn:WSRegistration', // namespace
4974
+    'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple', // soapaction
4975
+    'rpc', // style
4976
+    'encoded', // use
4977 4977
     'This service unsubscribe a user from a course'                     // documentation
4978 4978
 );
4979 4979
 /**
@@ -5044,10 +5044,10 @@  discard block
 block discarded – undo
5044 5044
     'all',
5045 5045
     '',
5046 5046
     array(
5047
-        'original_user_id_values'   => array('name' => 'original_user_id_values',   'type' => 'tns:originalUsersList'),
5048
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
5049
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
5050
-        'original_course_id_name'   => array('name' => 'original_course_id_value',  'type' => 'xsd:string')
5047
+        'original_user_id_values'   => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'),
5048
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
5049
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
5050
+        'original_course_id_name'   => array('name' => 'original_course_id_value', 'type' => 'xsd:string')
5051 5051
     )
5052 5052
 );
5053 5053
 
@@ -5140,13 +5140,13 @@  discard block
 block discarded – undo
5140 5140
 );
5141 5141
 
5142 5142
 // Register the method to expose
5143
-$server->register('WSSuscribeUsersToSession',                          // method name
5143
+$server->register('WSSuscribeUsersToSession', // method name
5144 5144
     array('subscribeUsersToSession' => 'tns:subscribeUsersToSession'), // input parameters
5145
-    array('return' => 'tns:results_subscribeUsersToSession'),          // output parameters
5146
-    'urn:WSRegistration',                                              // namespace
5147
-    'urn:WSRegistration#WSSuscribeUsersToSession',                     // soapaction
5148
-    'rpc',                                                             // style
5149
-    'encoded',                                                         // use
5145
+    array('return' => 'tns:results_subscribeUsersToSession'), // output parameters
5146
+    'urn:WSRegistration', // namespace
5147
+    'urn:WSRegistration#WSSuscribeUsersToSession', // soapaction
5148
+    'rpc', // style
5149
+    'encoded', // use
5150 5150
     'This service subscribes a user to a session'                      // documentation
5151 5151
 );
5152 5152
 
@@ -5246,25 +5246,25 @@  discard block
 block discarded – undo
5246 5246
     'all',
5247 5247
     '',
5248 5248
     array(
5249
-        'session'    => array('name' => 'session',    'type' => 'xsd:string'), // Session ID
5250
-        'user_id'    => array('name' => 'user_id',    'type' => 'xsd:string'), // Chamilo user_id
5249
+        'session'    => array('name' => 'session', 'type' => 'xsd:string'), // Session ID
5250
+        'user_id'    => array('name' => 'user_id', 'type' => 'xsd:string'), // Chamilo user_id
5251 5251
         'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string')
5252 5252
     )
5253 5253
 );
5254
-$server->register('WSSubscribeUserToSessionSimple',                                   // method name
5255
-    array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'),  // input parameters
5256
-    array('return' => 'xsd:string'),                                                  // output parameters
5257
-    'urn:WSRegistration',                                                             // namespace
5258
-    'urn:WSRegistration#WSSubscribeUserToSessionSimple',                              // soapaction
5259
-    'rpc',                                                                            // style
5260
-    'encoded',                                                                        // use
5254
+$server->register('WSSubscribeUserToSessionSimple', // method name
5255
+    array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'), // input parameters
5256
+    array('return' => 'xsd:string'), // output parameters
5257
+    'urn:WSRegistration', // namespace
5258
+    'urn:WSRegistration#WSSubscribeUserToSessionSimple', // soapaction
5259
+    'rpc', // style
5260
+    'encoded', // use
5261 5261
     'This service subscribes a user to a session in a simple way'                     // documentation
5262 5262
 );
5263 5263
 function WSSubscribeUserToSessionSimple($params) {
5264 5264
     global $debug;
5265 5265
 
5266 5266
     if ($debug) {
5267
-        error_log('WSSubscribeUserToSessionSimple with params=[' . serialize($params). ']');
5267
+        error_log('WSSubscribeUserToSessionSimple with params=['.serialize($params).']');
5268 5268
     }
5269 5269
 
5270 5270
     // Check security key
@@ -5273,8 +5273,8 @@  discard block
 block discarded – undo
5273 5273
     }
5274 5274
 
5275 5275
     // Get input parameters
5276
-    $session_id = intval($params['session']);  // Session ID
5277
-    $user_id    = intval($params['user_id']);  // Chamilo user id
5276
+    $session_id = intval($params['session']); // Session ID
5277
+    $user_id    = intval($params['user_id']); // Chamilo user id
5278 5278
 
5279 5279
     // Get user id
5280 5280
     $user_data = api_get_user_info($user_id);
@@ -5375,13 +5375,13 @@  discard block
 block discarded – undo
5375 5375
 );
5376 5376
 
5377 5377
 // Register the method to expose
5378
-$server->register('WSUnsuscribeUsersFromSession',                              // method name
5378
+$server->register('WSUnsuscribeUsersFromSession', // method name
5379 5379
     array('unsubscribeUsersFromSession' => 'tns:unsubscribeUsersFromSession'), // input parameters
5380
-    array('return' => 'tns:results_unsubscribeUsersFromSession'),              // output parameters
5381
-    'urn:WSRegistration',                                                      // namespace
5382
-    'urn:WSRegistration#WSUnsuscribeUsersFromSession',                         // soapaction
5383
-    'rpc',                                                                     // style
5384
-    'encoded',                                                                 // use
5380
+    array('return' => 'tns:results_unsubscribeUsersFromSession'), // output parameters
5381
+    'urn:WSRegistration', // namespace
5382
+    'urn:WSRegistration#WSUnsuscribeUsersFromSession', // soapaction
5383
+    'rpc', // style
5384
+    'encoded', // use
5385 5385
     'This service unsubscribes a user to a session'                            // documentation
5386 5386
 );
5387 5387
 
@@ -5395,7 +5395,7 @@  discard block
 block discarded – undo
5395 5395
     global $debug;
5396 5396
 
5397 5397
     if ($debug) {
5398
-        error_log('WSUnsuscribeUsersFromSession with params=[' . serialize($params). ']');
5398
+        error_log('WSUnsuscribeUsersFromSession with params=['.serialize($params).']');
5399 5399
     }
5400 5400
 
5401 5401
     $user_table = Database::get_main_table(TABLE_MAIN_USER);
@@ -5489,7 +5489,7 @@  discard block
 block discarded – undo
5489 5489
     'all',
5490 5490
     '',
5491 5491
     array(
5492
-        'course_code'   => array('name' => 'course_code',   'type' => 'xsd:string'),
5492
+        'course_code'   => array('name' => 'course_code', 'type' => 'xsd:string'),
5493 5493
     )
5494 5494
 );
5495 5495
 
@@ -5524,9 +5524,9 @@  discard block
 block discarded – undo
5524 5524
     '',
5525 5525
     array(
5526 5526
         'original_course_id_values' => array('name' => 'original_course_id_values', 'type' => 'tns:originalCoursesList'),
5527
-        'original_course_id_name'   => array('name' => 'original_course_id_name',   'type' => 'xsd:string'),
5527
+        'original_course_id_name'   => array('name' => 'original_course_id_name', 'type' => 'xsd:string'),
5528 5528
         'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'),
5529
-        'original_session_id_name'  => array('name' => 'original_session_id_name',  'type' => 'xsd:string')
5529
+        'original_session_id_name'  => array('name' => 'original_session_id_name', 'type' => 'xsd:string')
5530 5530
     )
5531 5531
 );
5532 5532
 
@@ -5579,13 +5579,13 @@  discard block
 block discarded – undo
5579 5579
 );
5580 5580
 
5581 5581
 // Register the method to expose
5582
-$server->register('WSSuscribeCoursesToSession',                            // method name
5582
+$server->register('WSSuscribeCoursesToSession', // method name
5583 5583
     array('subscribeCoursesToSession' => 'tns:subscribeCoursesToSession'), // input parameters
5584
-    array('return' => 'tns:results_subscribeCoursesToSession'),            // output parameters
5585
-    'urn:WSRegistration',                                                  // namespace
5586
-    'urn:WSRegistration#WSSuscribeCoursesToSession',                       // soapaction
5587
-    'rpc',                                                                 // style
5588
-    'encoded',                                                             // use
5584
+    array('return' => 'tns:results_subscribeCoursesToSession'), // output parameters
5585
+    'urn:WSRegistration', // namespace
5586
+    'urn:WSRegistration#WSSuscribeCoursesToSession', // soapaction
5587
+    'rpc', // style
5588
+    'encoded', // use
5589 5589
     'This service subscribes a course to a session'                        // documentation
5590 5590
 );
5591 5591
 
@@ -5730,13 +5730,13 @@  discard block
 block discarded – undo
5730 5730
 
5731 5731
 
5732 5732
 // Register the method to expose
5733
-$server->register('WSUnsuscribeCoursesFromSession',                                // method name
5733
+$server->register('WSUnsuscribeCoursesFromSession', // method name
5734 5734
     array('unsubscribeCoursesFromSession' => 'tns:unsubscribeCoursesFromSession'), // input parameters
5735
-    array('return' => 'tns:results_unsubscribeCoursesFromSession'),                // output parameters
5736
-    'urn:WSRegistration',                                                          // namespace
5737
-    'urn:WSRegistration#WSUnsuscribeCoursesFromSession',                           // soapaction
5738
-    'rpc',                                                                         // style
5739
-    'encoded',                                                                     // use
5735
+    array('return' => 'tns:results_unsubscribeCoursesFromSession'), // output parameters
5736
+    'urn:WSRegistration', // namespace
5737
+    'urn:WSRegistration#WSUnsuscribeCoursesFromSession', // soapaction
5738
+    'rpc', // style
5739
+    'encoded', // use
5740 5740
     'This service subscribes a course to a session'                                // documentation
5741 5741
 );
5742 5742
 
@@ -5900,13 +5900,13 @@  discard block
 block discarded – undo
5900 5900
 
5901 5901
 
5902 5902
 // Register the method to expose
5903
-$server->register('WSListCourses',                                                  // method name
5903
+$server->register('WSListCourses', // method name
5904 5904
     array('listCourseInput' => 'tns:listCourseInput'), // input parameters
5905
-    array('return' => 'tns:courses'),                                               // output parameters
5906
-    'urn:WSRegistration',                                                           // namespace
5907
-    'urn:WSRegistration#WSListCourses',                                             // soapaction
5908
-    'rpc',                                                                          // style
5909
-    'encoded',                                                                      // use
5905
+    array('return' => 'tns:courses'), // output parameters
5906
+    'urn:WSRegistration', // namespace
5907
+    'urn:WSRegistration#WSListCourses', // soapaction
5908
+    'rpc', // style
5909
+    'encoded', // use
5910 5910
     'This service list courses available on the system'                             // documentation
5911 5911
 );
5912 5912
 
@@ -5986,21 +5986,21 @@  discard block
 block discarded – undo
5986 5986
     'all',
5987 5987
     '',
5988 5988
     array(
5989
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
5990
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
5991
-        'chamilo_username'          => array('name' => 'chamilo_username',          'type' => 'xsd:string'),
5992
-        'secret_key'                => array('name' => 'secret_key',                'type' => 'xsd:string')
5989
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
5990
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
5991
+        'chamilo_username'          => array('name' => 'chamilo_username', 'type' => 'xsd:string'),
5992
+        'secret_key'                => array('name' => 'secret_key', 'type' => 'xsd:string')
5993 5993
     )
5994 5994
 );
5995 5995
 
5996 5996
 // Register the method to expose
5997
-$server->register('WSUpdateUserApiKey',      // method name
5997
+$server->register('WSUpdateUserApiKey', // method name
5998 5998
     array('userApiKey' => 'tns:userApiKey'), // input parameters
5999
-    array('return' => 'xsd:string'),         // output parameters
6000
-    'urn:WSRegistration',                    // namespace
6001
-    'urn:WSRegistration#WSListCourses',      // soapaction
6002
-    'rpc',                                   // style
6003
-    'encoded',                               // use
5999
+    array('return' => 'xsd:string'), // output parameters
6000
+    'urn:WSRegistration', // namespace
6001
+    'urn:WSRegistration#WSListCourses', // soapaction
6002
+    'rpc', // style
6003
+    'encoded', // use
6004 6004
     'This service return user api key'       // documentation
6005 6005
 );
6006 6006
 
@@ -6056,11 +6056,11 @@  discard block
 block discarded – undo
6056 6056
     'all',
6057 6057
     '',
6058 6058
     array(
6059
-        'from'  => array('name' => 'from',  'type' => 'xsd:int'),
6060
-        'to'    => array('name' => 'to',    'type' => 'xsd:int'),
6061
-        'date_start'  => array('name' => 'date_start',  'type' => 'xsd:string'),
6062
-        'date_end'    => array('name' => 'date_end',    'type' => 'xsd:string'),
6063
-        'secret_key'  => array('name' => 'secret_key',  'type' => 'xsd:string')
6059
+        'from'  => array('name' => 'from', 'type' => 'xsd:int'),
6060
+        'to'    => array('name' => 'to', 'type' => 'xsd:int'),
6061
+        'date_start'  => array('name' => 'date_start', 'type' => 'xsd:string'),
6062
+        'date_end'    => array('name' => 'date_end', 'type' => 'xsd:string'),
6063
+        'secret_key'  => array('name' => 'secret_key', 'type' => 'xsd:string')
6064 6064
     )
6065 6065
 );
6066 6066
 
@@ -6071,11 +6071,11 @@  discard block
 block discarded – undo
6071 6071
     'all',
6072 6072
     '',
6073 6073
     array(
6074
-        'id' => array ('name' => 'id'  , 'type' => 'xsd:int'),
6075
-        'title' => array ('name' => 'title', 'type' => 'xsd:string'),
6076
-        'url' => array ('name' => 'url', 'type' => 'xsd:string'),
6077
-        'date_start' => array ('name' => 'date_start', 'type' => 'xsd:string'),
6078
-        'date_end' => array ('name' => 'date_end', 'type' => 'xsd:string'),
6074
+        'id' => array('name' => 'id', 'type' => 'xsd:int'),
6075
+        'title' => array('name' => 'title', 'type' => 'xsd:string'),
6076
+        'url' => array('name' => 'url', 'type' => 'xsd:string'),
6077
+        'date_start' => array('name' => 'date_start', 'type' => 'xsd:string'),
6078
+        'date_end' => array('name' => 'date_end', 'type' => 'xsd:string'),
6079 6079
     )
6080 6080
 );
6081 6081
 
@@ -6094,13 +6094,13 @@  discard block
 block discarded – undo
6094 6094
 );
6095 6095
 
6096 6096
 // Register the method to expose
6097
-$server->register('WSListSessions',           // method name
6098
-    array('input'  => 'tns:session_arg'),     // input parameters
6099
-    array('return' => 'tns:sessions'),        // output parameters
6100
-    'urn:WSRegistration',                     // namespace
6101
-    'urn:WSRegistration#WSListSessions',      // soapaction
6102
-    'rpc',                                    // style
6103
-    'encoded',                                // use
6097
+$server->register('WSListSessions', // method name
6098
+    array('input'  => 'tns:session_arg'), // input parameters
6099
+    array('return' => 'tns:sessions'), // output parameters
6100
+    'urn:WSRegistration', // namespace
6101
+    'urn:WSRegistration#WSListSessions', // soapaction
6102
+    'rpc', // style
6103
+    'encoded', // use
6104 6104
     'This service returns a list of sessions' // documentation
6105 6105
 );
6106 6106
 
@@ -6158,20 +6158,20 @@  discard block
 block discarded – undo
6158 6158
     'all',
6159 6159
     '',
6160 6160
     array(
6161
-        'course'       => array('name' => 'course',     'type' => 'xsd:string'), //Course string code
6162
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'), //Chamilo user_id
6161
+        'course'       => array('name' => 'course', 'type' => 'xsd:string'), //Course string code
6162
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id
6163 6163
         'secret_key'   => array('name' => 'secret_key', 'type' => 'xsd:string')
6164 6164
     )
6165 6165
 );
6166 6166
 
6167 6167
 // Register the method to expose
6168
-$server->register('WSUserSubscribedInCourse',                            // method name
6169
-    array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'),    // input parameters
6170
-    array('return' => 'xsd:string'),                                        // output parameters
6171
-    'urn:WSRegistration',                                                    // namespace
6172
-    'urn:WSRegistration#WSUserSubscribedInCourse',                       // soapaction
6173
-    'rpc',                                                                    // style
6174
-    'encoded',                                                                // use
6168
+$server->register('WSUserSubscribedInCourse', // method name
6169
+    array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'), // input parameters
6170
+    array('return' => 'xsd:string'), // output parameters
6171
+    'urn:WSRegistration', // namespace
6172
+    'urn:WSRegistration#WSUserSubscribedInCourse', // soapaction
6173
+    'rpc', // style
6174
+    'encoded', // use
6175 6175
     'This service checks if user assigned to course'    // documentation
6176 6176
 );
6177 6177
 
@@ -6197,7 +6197,7 @@  discard block
 block discarded – undo
6197 6197
     $courseCode = $params['course']; //Course code
6198 6198
     $userId = $params['user_id']; //chamilo user id
6199 6199
 
6200
-    return CourseManager::is_user_subscribed_in_course($userId,$courseCode);
6200
+    return CourseManager::is_user_subscribed_in_course($userId, $courseCode);
6201 6201
 }
6202 6202
 
6203 6203
 
@@ -6225,8 +6225,8 @@  discard block
 block discarded – undo
6225 6225
     'all',
6226 6226
     '',
6227 6227
     array(
6228
-        'variable' => array('name'=>'variable','type'=>'xsd:string'),
6229
-        'value' => array('name'=>'value','type'=>'xsd:string')
6228
+        'variable' => array('name'=>'variable', 'type'=>'xsd:string'),
6229
+        'value' => array('name'=>'value', 'type'=>'xsd:string')
6230 6230
     )
6231 6231
 );
6232 6232
 
@@ -6288,12 +6288,12 @@  discard block
 block discarded – undo
6288 6288
 //Reister WSSearchSession
6289 6289
 $server->register(
6290 6290
     'WSSearchSession',
6291
-    array('SearchSession' => 'tns:SearchSession'),      // input parameters
6292
-    array('return' => 'tns:searchedSessionList'),       // output parameters
6293
-    'urn:WSRegistration',                               // namespace
6294
-    'urn:WSRegistration#WSSearchSession',               // soapaction
6295
-    'rpc',                                              // style
6296
-    'encoded',                                          // use
6291
+    array('SearchSession' => 'tns:SearchSession'), // input parameters
6292
+    array('return' => 'tns:searchedSessionList'), // output parameters
6293
+    'urn:WSRegistration', // namespace
6294
+    'urn:WSRegistration#WSSearchSession', // soapaction
6295
+    'rpc', // style
6296
+    'encoded', // use
6297 6297
     'This service to get a session list filtered by name, description or short description extra field'    // documentation
6298 6298
 );
6299 6299
 
@@ -6348,12 +6348,12 @@  discard block
 block discarded – undo
6348 6348
 //Reister WSFetchSession
6349 6349
 $server->register(
6350 6350
     'WSFetchSession',
6351
-    array('SearchSession' => 'tns:FetchSession'),                    // input parameters
6352
-    array('return' => 'tns:searchedSessionList'),       // output parameters
6353
-    'urn:WSRegistration',                               // namespace
6354
-    'urn:WSRegistration#WSFetchSession',                // soapaction
6355
-    'rpc',                                              // style
6356
-    'encoded',                                          // use
6351
+    array('SearchSession' => 'tns:FetchSession'), // input parameters
6352
+    array('return' => 'tns:searchedSessionList'), // output parameters
6353
+    'urn:WSRegistration', // namespace
6354
+    'urn:WSRegistration#WSFetchSession', // soapaction
6355
+    'rpc', // style
6356
+    'encoded', // use
6357 6357
     'This service get a session by its id. Optionally can get its extra fields values'    // documentation
6358 6358
 );
6359 6359
 
@@ -6430,16 +6430,16 @@  discard block
 block discarded – undo
6430 6430
 );
6431 6431
 // Register the method to expose
6432 6432
 $server->register(
6433
-    'WSCertificatesList',                           // method name
6433
+    'WSCertificatesList', // method name
6434 6434
     array(
6435
-        'startingDate' => 'xsd:string',             // input parameters
6435
+        'startingDate' => 'xsd:string', // input parameters
6436 6436
         'endingDate' => 'xsd:string'
6437 6437
     ),
6438
-    array('return' => 'tns:certificatesList'),      // output parameters
6439
-    'urn:WSRegistration',                           // namespace
6440
-    'urn:WSRegistration#WSCertificatesList',        // soapaction
6441
-    'rpc',                                          // style
6442
-    'encoded',                                      // use
6438
+    array('return' => 'tns:certificatesList'), // output parameters
6439
+    'urn:WSRegistration', // namespace
6440
+    'urn:WSRegistration#WSCertificatesList', // soapaction
6441
+    'rpc', // style
6442
+    'encoded', // use
6443 6443
     'This service returns a list of certificates'   // documentation
6444 6444
 );
6445 6445
 
@@ -6505,13 +6505,13 @@  discard block
 block discarded – undo
6505 6505
 );
6506 6506
 
6507 6507
 // Register the method to expose
6508
-$server->register('WSCreateGroup',              // method name
6509
-    array('createGroup' => 'tns:createGroup'),  // input parameters
6510
-    array('return' => 'xsd:string'),            // output parameters
6511
-    'urn:WSRegistration',                       // namespace
6512
-    'urn:WSRegistration#WSCreateGroup',         // soapaction
6513
-    'rpc',                                      // style
6514
-    'encoded',                                  // use
6508
+$server->register('WSCreateGroup', // method name
6509
+    array('createGroup' => 'tns:createGroup'), // input parameters
6510
+    array('return' => 'xsd:string'), // output parameters
6511
+    'urn:WSRegistration', // namespace
6512
+    'urn:WSRegistration#WSCreateGroup', // soapaction
6513
+    'rpc', // style
6514
+    'encoded', // use
6515 6515
     'This service adds a group'                 // documentation
6516 6516
 );
6517 6517
 
@@ -6553,13 +6553,13 @@  discard block
 block discarded – undo
6553 6553
 );
6554 6554
 
6555 6555
 // Register the method to expose
6556
-$server->register('WSUpdateGroup',              // method name
6557
-    array('updateGroup' => 'tns:updateGroup'),  // input parameters
6558
-    array('return' => 'xsd:string'),            // output parameters
6559
-    'urn:WSRegistration',                       // namespace
6560
-    'urn:WSRegistration#WSUpdateGroup',         // soapaction
6561
-    'rpc',                                      // style
6562
-    'encoded',                                  // use
6556
+$server->register('WSUpdateGroup', // method name
6557
+    array('updateGroup' => 'tns:updateGroup'), // input parameters
6558
+    array('return' => 'xsd:string'), // output parameters
6559
+    'urn:WSRegistration', // namespace
6560
+    'urn:WSRegistration#WSUpdateGroup', // soapaction
6561
+    'rpc', // style
6562
+    'encoded', // use
6563 6563
     'This service updates a group'              // documentation
6564 6564
 );
6565 6565
 
@@ -6594,13 +6594,13 @@  discard block
 block discarded – undo
6594 6594
 );
6595 6595
 
6596 6596
 // Register the method to expose
6597
-$server->register('WSDeleteGroup',              // method name
6598
-    array('deleteGroup' => 'tns:deleteGroup'),  // input parameters
6599
-    array('return' => 'xsd:string'),            // output parameters
6600
-    'urn:WSRegistration',                       // namespace
6601
-    'urn:WSRegistration#WSDeleteGroup',         // soapaction
6602
-    'rpc',                                      // style
6603
-    'encoded',                                  // use
6597
+$server->register('WSDeleteGroup', // method name
6598
+    array('deleteGroup' => 'tns:deleteGroup'), // input parameters
6599
+    array('return' => 'xsd:string'), // output parameters
6600
+    'urn:WSRegistration', // namespace
6601
+    'urn:WSRegistration#WSDeleteGroup', // soapaction
6602
+    'rpc', // style
6603
+    'encoded', // use
6604 6604
     'This service deletes a group'              // documentation
6605 6605
 );
6606 6606
 
@@ -6635,13 +6635,13 @@  discard block
 block discarded – undo
6635 6635
 );
6636 6636
 
6637 6637
 // Register the method to expose
6638
-$server->register('GroupBindToParent',                      // method name
6639
-    array('groupBindToParent' => 'tns:groupBindToParent'),  // input parameters
6640
-    array('return' => 'xsd:string'),                        // output parameters
6641
-    'urn:WSRegistration',                                   // namespace
6642
-    'urn:WSRegistration#GroupBindToParent',                 // soapaction
6643
-    'rpc',                                                  // style
6644
-    'encoded',                                              // use
6638
+$server->register('GroupBindToParent', // method name
6639
+    array('groupBindToParent' => 'tns:groupBindToParent'), // input parameters
6640
+    array('return' => 'xsd:string'), // output parameters
6641
+    'urn:WSRegistration', // namespace
6642
+    'urn:WSRegistration#GroupBindToParent', // soapaction
6643
+    'rpc', // style
6644
+    'encoded', // use
6645 6645
     'This service binds a group to a parent'                // documentation
6646 6646
 );
6647 6647
 
@@ -6675,13 +6675,13 @@  discard block
 block discarded – undo
6675 6675
 );
6676 6676
 
6677 6677
 // Register the method to expose
6678
-$server->register('GroupUnbindFromParent',                          // method name
6679
-    array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'),  // input parameters
6680
-    array('return' => 'xsd:string'),                                // output parameters
6681
-    'urn:WSRegistration',                                           // namespace
6682
-    'urn:WSRegistration#GroupUnbindFromParent',                     // soapaction
6683
-    'rpc',                                                          // style
6684
-    'encoded',                                                      // use
6678
+$server->register('GroupUnbindFromParent', // method name
6679
+    array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'), // input parameters
6680
+    array('return' => 'xsd:string'), // output parameters
6681
+    'urn:WSRegistration', // namespace
6682
+    'urn:WSRegistration#GroupUnbindFromParent', // soapaction
6683
+    'rpc', // style
6684
+    'encoded', // use
6685 6685
     'This service unbinds a group from its parent'                  // documentation
6686 6686
 );
6687 6687
 
@@ -6715,13 +6715,13 @@  discard block
 block discarded – undo
6715 6715
 );
6716 6716
 
6717 6717
 // Register the method to expose
6718
-$server->register('WSAddUserToGroup',                   // method name
6719
-    array('addUserToGroup' => 'tns:addUserToGroup'),    // input parameters
6720
-    array('return' => 'xsd:string'),                    // output parameters
6721
-    'urn:WSRegistration',                               // namespace
6722
-    'urn:WSRegistration#WSAddUserToGroup',              // soapaction
6723
-    'rpc',                                              // style
6724
-    'encoded',                                          // use
6718
+$server->register('WSAddUserToGroup', // method name
6719
+    array('addUserToGroup' => 'tns:addUserToGroup'), // input parameters
6720
+    array('return' => 'xsd:string'), // output parameters
6721
+    'urn:WSRegistration', // namespace
6722
+    'urn:WSRegistration#WSAddUserToGroup', // soapaction
6723
+    'rpc', // style
6724
+    'encoded', // use
6725 6725
     'This service adds a user to a group'               // documentation
6726 6726
 );
6727 6727
 
@@ -6758,13 +6758,13 @@  discard block
 block discarded – undo
6758 6758
 );
6759 6759
 
6760 6760
 // Register the method to expose
6761
-$server->register('WSUpdateUserRoleInGroup',                        // method name
6762
-    array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'),  // input parameters
6763
-    array('return' => 'xsd:string'),                                // output parameters
6764
-    'urn:WSRegistration',                                           // namespace
6765
-    'urn:WSRegistration#WSUpdateUserRoleInGroup',                   // soapaction
6766
-    'rpc',                                                          // style
6767
-    'encoded',                                                      // use
6761
+$server->register('WSUpdateUserRoleInGroup', // method name
6762
+    array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'), // input parameters
6763
+    array('return' => 'xsd:string'), // output parameters
6764
+    'urn:WSRegistration', // namespace
6765
+    'urn:WSRegistration#WSUpdateUserRoleInGroup', // soapaction
6766
+    'rpc', // style
6767
+    'encoded', // use
6768 6768
     'This service updates a user role in group'                     // documentation
6769 6769
 );
6770 6770
 
@@ -6803,13 +6803,13 @@  discard block
 block discarded – undo
6803 6803
 );
6804 6804
 
6805 6805
 // Register the method to expose
6806
-$server->register('WSDeleteUserFromGroup',                      // method name
6807
-    array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'),  // input parameters
6808
-    array('return' => 'xsd:string'),                            // output parameters
6809
-    'urn:WSRegistration',                                       // namespace
6810
-    'urn:WSRegistration#WSDeleteUserFromGroup',                 // soapaction
6811
-    'rpc',                                                      // style
6812
-    'encoded',                                                  // use
6806
+$server->register('WSDeleteUserFromGroup', // method name
6807
+    array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'), // input parameters
6808
+    array('return' => 'xsd:string'), // output parameters
6809
+    'urn:WSRegistration', // namespace
6810
+    'urn:WSRegistration#WSDeleteUserFromGroup', // soapaction
6811
+    'rpc', // style
6812
+    'encoded', // use
6813 6813
     'This service deletes a user from a group'                  // documentation
6814 6814
 );
6815 6815
 
@@ -6842,10 +6842,10 @@  discard block
 block discarded – undo
6842 6842
     'struct',
6843 6843
     'all',
6844 6844
     '',
6845
-    array (
6845
+    array(
6846 6846
         'course_id' => array('name' => 'course_id', 'type' => 'tns:course_id'),
6847
-        'user_id'   => array('name' => 'user_id',   'type' => 'tns:user_id'),
6848
-        'visible'   => array('name' => 'status',    'type' => 'xsd:int')
6847
+        'user_id'   => array('name' => 'user_id', 'type' => 'tns:user_id'),
6848
+        'visible'   => array('name' => 'status', 'type' => 'xsd:int')
6849 6849
     )
6850 6850
 );
6851 6851
 
@@ -6868,9 +6868,9 @@  discard block
 block discarded – undo
6868 6868
     'struct',
6869 6869
     'all',
6870 6870
     '',
6871
-    array (
6872
-        'userscourses'  => array('name' => 'userscourses',  'type' => 'tns:user_course_visibility_array'),
6873
-        'secret_key'    => array('name' => 'secret_key',    'type' => 'xsd:string')
6871
+    array(
6872
+        'userscourses'  => array('name' => 'userscourses', 'type' => 'tns:user_course_visibility_array'),
6873
+        'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
6874 6874
     )
6875 6875
 );
6876 6876
 
@@ -6882,10 +6882,10 @@  discard block
 block discarded – undo
6882 6882
     'all',
6883 6883
     '',
6884 6884
     array(
6885
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
6886
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
6887
-        'visible'                   => array('name' => 'visible',                   'type' => 'xsd:int'),
6888
-        'result'                    => array('name' => 'result',                    'type' => 'xsd:int')
6885
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
6886
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
6887
+        'visible'                   => array('name' => 'visible', 'type' => 'xsd:int'),
6888
+        'result'                    => array('name' => 'result', 'type' => 'xsd:int')
6889 6889
     )
6890 6890
 );
6891 6891
 
@@ -6901,13 +6901,13 @@  discard block
 block discarded – undo
6901 6901
 );
6902 6902
 
6903 6903
 // Register the method to expose
6904
-$server->register('WSAddUserVisibilityToCourseInCatalogue',          // method name
6905
-    array('registerUserToCourseCatalogue' => 'tns:registerUserToCourseCatalogue_arg'),  // input parameters
6904
+$server->register('WSAddUserVisibilityToCourseInCatalogue', // method name
6905
+    array('registerUserToCourseCatalogue' => 'tns:registerUserToCourseCatalogue_arg'), // input parameters
6906 6906
     array('return' => 'tns:registerUserToCourseCatalogue_return_global'),
6907
-    'urn:WSRegistration',                                               // namespace
6908
-    'urn:WSRegistration#WSRegisterUserVisibilityToCourseCatalogue',     // soapaction
6909
-    'rpc',                                                              // style
6910
-    'encoded',                                                          // use
6907
+    'urn:WSRegistration', // namespace
6908
+    'urn:WSRegistration#WSRegisterUserVisibilityToCourseCatalogue', // soapaction
6909
+    'rpc', // style
6910
+    'encoded', // use
6911 6911
     'This service registers the visibility of users to course in catalogue' // documentation
6912 6912
 );
6913 6913
 
@@ -6973,13 +6973,13 @@  discard block
 block discarded – undo
6973 6973
 }
6974 6974
 
6975 6975
 // Register the method to expose
6976
-$server->register('WSRemoveUserVisibilityToCourseInCatalogue',          // method name
6977
-    array('registerUserToCourseCatalogue' => 'tns:registerUserToCourseCatalogue_arg'),  // input parameters
6976
+$server->register('WSRemoveUserVisibilityToCourseInCatalogue', // method name
6977
+    array('registerUserToCourseCatalogue' => 'tns:registerUserToCourseCatalogue_arg'), // input parameters
6978 6978
     array('return' => 'tns:registerUserToCourseCatalogue_return_global'),
6979
-    'urn:WSRegistration',                                               // namespace
6980
-    'urn:WSRegistration#WSRegisterUserVisibilityToCourseCatalogue',     // soapaction
6981
-    'rpc',                                                              // style
6982
-    'encoded',                                                          // use
6979
+    'urn:WSRegistration', // namespace
6980
+    'urn:WSRegistration#WSRegisterUserVisibilityToCourseCatalogue', // soapaction
6981
+    'rpc', // style
6982
+    'encoded', // use
6983 6983
     'This service removes the visibility of users to course in catalogue' // documentation
6984 6984
 );
6985 6985
 
Please login to merge, or discard this patch.
Braces   +186 added lines, -64 removed lines patch added patch discarded remove patch
@@ -63,14 +63,16 @@  discard block
 block discarded – undo
63 63
         list($ip1) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
64 64
         $ip = trim($ip1);
65 65
     }
66
-    if ($debug)
67
-        error_log("ip: $ip");
66
+    if ($debug) {
67
+            error_log("ip: $ip");
68
+    }
68 69
     // Check if a file that limits access from webservices exists and contains
69 70
     // the restraining check
70 71
     if (is_file('webservice-auth-ip.conf.php')) {
71 72
         include 'webservice-auth-ip.conf.php';
72
-        if ($debug)
73
-            error_log("webservice-auth-ip.conf.php file included");
73
+        if ($debug) {
74
+                    error_log("webservice-auth-ip.conf.php file included");
75
+        }
74 76
         if (!empty($ws_auth_ip)) {
75 77
             $check_ip = true;
76 78
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
@@ -554,7 +556,9 @@  discard block
 block discarded – undo
554 556
 
555 557
     // First check wether the login already exists
556 558
     if (!UserManager::is_username_available($loginName)) {
557
-        if ($debug) error_log("Username $loginName is not available");
559
+        if ($debug) {
560
+            error_log("Username $loginName is not available");
561
+        }
558 562
         return 0;
559 563
     }
560 564
 
@@ -1045,9 +1049,15 @@  discard block
 block discarded – undo
1045 1049
         );
1046 1050
     }
1047 1051
 
1048
-    if ($debug) error_log('$userId found: '. $userId);
1049
-    if ($debug) error_log('$courseId found: '. $courseId);
1050
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1052
+    if ($debug) {
1053
+        error_log('$userId found: '. $userId);
1054
+    }
1055
+    if ($debug) {
1056
+        error_log('$courseId found: '. $courseId);
1057
+    }
1058
+    if ($debug) {
1059
+        error_log('$sessionId found: '. $sessionId);
1060
+    }
1051 1061
 
1052 1062
     return [
1053 1063
         'user_id' => $userId,
@@ -1077,13 +1087,17 @@  discard block
 block discarded – undo
1077 1087
 {
1078 1088
     global $debug;
1079 1089
 
1080
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1090
+    if ($debug) {
1091
+        error_log('WSSubscribeTeacherToSessionCourse');
1092
+    }
1081 1093
 
1082 1094
     if (!WSHelperVerifyKey($params)) {
1083 1095
         return returnError(WS_ERROR_SECRET_KEY);
1084 1096
     }
1085 1097
 
1086
-    if ($debug) error_log('Params '. print_r($params, 1));
1098
+    if ($debug) {
1099
+        error_log('Params '. print_r($params, 1));
1100
+    }
1087 1101
 
1088 1102
     $params = parseCourseSessionUserParams($params);
1089 1103
 
@@ -1096,13 +1110,17 @@  discard block
 block discarded – undo
1096 1110
     $result = 0;
1097 1111
 
1098 1112
     if (!empty($coaches)) {
1099
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1113
+        if ($debug) {
1114
+            error_log('Coaches:  '. print_r($coaches, 1));
1115
+        }
1100 1116
         if (in_array($userId, $coaches)) {
1101 1117
             $result = 1;
1102 1118
         }
1103 1119
     }
1104 1120
 
1105
-    if ($debug) error_log('Result:  '. $result);
1121
+    if ($debug) {
1122
+        error_log('Result:  '. $result);
1123
+    }
1106 1124
 
1107 1125
     return $result;
1108 1126
 }
@@ -1128,13 +1146,17 @@  discard block
 block discarded – undo
1128 1146
 {
1129 1147
     global $debug;
1130 1148
 
1131
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1149
+    if ($debug) {
1150
+        error_log('WSSubscribeTeacherToSessionCourse');
1151
+    }
1132 1152
 
1133 1153
     if (!WSHelperVerifyKey($params)) {
1134 1154
         return returnError(WS_ERROR_SECRET_KEY);
1135 1155
     }
1136 1156
 
1137
-    if ($debug) error_log('Params '. print_r($params, 1));
1157
+    if ($debug) {
1158
+        error_log('Params '. print_r($params, 1));
1159
+    }
1138 1160
 
1139 1161
     $params = parseCourseSessionUserParams($params);
1140 1162
 
@@ -1148,7 +1170,9 @@  discard block
 block discarded – undo
1148 1170
     $result = 0;
1149 1171
 
1150 1172
     if (!empty($coaches)) {
1151
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1173
+        if ($debug) {
1174
+            error_log('Coaches:  ' . print_r($coaches, 1));
1175
+        }
1152 1176
         if (!in_array($userId, $coaches)) {
1153 1177
             $result = 1;
1154 1178
         }
@@ -1156,7 +1180,9 @@  discard block
 block discarded – undo
1156 1180
         $result = 1;
1157 1181
     }
1158 1182
 
1159
-    if ($debug) error_log('Final Result: '. $result);
1183
+    if ($debug) {
1184
+        error_log('Final Result: '. $result);
1185
+    }
1160 1186
 
1161 1187
     return $result;
1162 1188
 }
@@ -1208,8 +1234,12 @@  discard block
 block discarded – undo
1208 1234
 {
1209 1235
     global $_user, $_configuration, $debug;
1210 1236
     $debug = 1;
1211
-    if ($debug) error_log('WSCreateUserPasswordCrypted');
1212
-    if ($debug) error_log(print_r($params,1));
1237
+    if ($debug) {
1238
+        error_log('WSCreateUserPasswordCrypted');
1239
+    }
1240
+    if ($debug) {
1241
+        error_log(print_r($params,1));
1242
+    }
1213 1243
 
1214 1244
     if (!WSHelperVerifyKey($params)) {
1215 1245
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1241,22 +1271,30 @@  discard block
 block discarded – undo
1241 1271
         if ($_configuration['password_encryption'] === $encrypt_method ) {
1242 1272
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1243 1273
                 $msg = "Encryption $encrypt_method is invalid";
1244
-                if ($debug) error_log($msg);
1274
+                if ($debug) {
1275
+                    error_log($msg);
1276
+                }
1245 1277
                 return $msg;
1246 1278
 
1247 1279
             } else if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
1248 1280
                 $msg = "Encryption $encrypt_method is invalid";
1249
-                if ($debug) error_log($msg);
1281
+                if ($debug) {
1282
+                    error_log($msg);
1283
+                }
1250 1284
                 return $msg;
1251 1285
             }
1252 1286
         } else {
1253 1287
             $msg = "This encryption $encrypt_method is not configured";
1254
-            if ($debug) error_log($msg);
1288
+            if ($debug) {
1289
+                error_log($msg);
1290
+            }
1255 1291
             return $msg;
1256 1292
         }
1257 1293
     } else {
1258 1294
         $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured';
1259
-        if ($debug) error_log($msg);
1295
+        if ($debug) {
1296
+            error_log($msg);
1297
+        }
1260 1298
         return $msg;
1261 1299
     }
1262 1300
 
@@ -1276,10 +1314,14 @@  discard block
 block discarded – undo
1276 1314
         $original_user_id_name
1277 1315
     );
1278 1316
 
1279
-    if ($debug) error_log('Ready to create user');
1317
+    if ($debug) {
1318
+        error_log('Ready to create user');
1319
+    }
1280 1320
 
1281 1321
     if ($user_id > 0) {
1282
-        if ($debug) error_log('User found with id: '.$user_id);
1322
+        if ($debug) {
1323
+            error_log('User found with id: '.$user_id);
1324
+        }
1283 1325
 
1284 1326
         // Check whether user is not active
1285 1327
         //@todo why this condition exists??
@@ -1290,7 +1332,9 @@  discard block
 block discarded – undo
1290 1332
         $count_check_user = Database::num_rows($resu);
1291 1333
         if ($count_check_user > 0) {
1292 1334
 
1293
-            if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1335
+            if ($debug) {
1336
+                error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1337
+            }
1294 1338
 
1295 1339
             $sql = "UPDATE $table_user SET
1296 1340
                     lastname='".Database::escape_string($lastName)."',
@@ -1311,7 +1355,9 @@  discard block
 block discarded – undo
1311 1355
                     hr_dept_id=".intval($hr_dept_id)." 
1312 1356
                 WHERE user_id='".$r_check_user[0]."'";
1313 1357
 
1314
-            if ($debug) error_log($sql);
1358
+            if ($debug) {
1359
+                error_log($sql);
1360
+            }
1315 1361
             Database::query($sql);
1316 1362
 
1317 1363
             if (is_array($extra_list) && count($extra_list) > 0) {
@@ -1328,11 +1374,15 @@  discard block
 block discarded – undo
1328 1374
             }
1329 1375
             return $r_check_user[0];
1330 1376
         } else {
1331
-            if ($debug) error_log('User exists but is active. Cant be updated');
1377
+            if ($debug) {
1378
+                error_log('User exists but is active. Cant be updated');
1379
+            }
1332 1380
             return 0;
1333 1381
         }
1334 1382
     } else {
1335
-        if ($debug) error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1383
+        if ($debug) {
1384
+            error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1385
+        }
1336 1386
     }
1337 1387
 
1338 1388
     // Default language.
@@ -1348,12 +1398,16 @@  discard block
 block discarded – undo
1348 1398
 
1349 1399
     // First check wether the login already exists
1350 1400
     if (!UserManager::is_username_available($loginName)) {
1351
-        if ($debug) error_log("Username $loginName is not available");
1401
+        if ($debug) {
1402
+            error_log("Username $loginName is not available");
1403
+        }
1352 1404
         return 0;
1353 1405
     }
1354 1406
 
1355 1407
     $queryExpirationDate = '';
1356
-    if (!empty($params['expiration_date'])) $queryExpirationDate = "expiration_date     = '".Database::escape_string($expiration_date)."', ";
1408
+    if (!empty($params['expiration_date'])) {
1409
+        $queryExpirationDate = "expiration_date     = '".Database::escape_string($expiration_date)."', ";
1410
+    }
1357 1411
 
1358 1412
     $sql = "INSERT INTO $table_user SET
1359 1413
             lastname            = '".Database::escape_string(trim($lastName))."',
@@ -1373,7 +1427,9 @@  discard block
 block discarded – undo
1373 1427
             ".$queryExpirationDate."
1374 1428
             hr_dept_id          = '".Database::escape_string($hr_dept_id)."',
1375 1429
             active              = '".Database::escape_string($active)."'";
1376
-    if ($debug) error_log($sql);
1430
+    if ($debug) {
1431
+        error_log($sql);
1432
+    }
1377 1433
 
1378 1434
     Database::query($sql);
1379 1435
     $return = Database::insert_id();
@@ -1385,7 +1441,9 @@  discard block
 block discarded – undo
1385 1441
 
1386 1442
         $url_id = api_get_current_access_url_id();
1387 1443
         UrlManager::add_user_to_url($return, $url_id);
1388
-        if ($debug) error_log("Adding user_id = $return to URL id $url_id ");
1444
+        if ($debug) {
1445
+            error_log("Adding user_id = $return to URL id $url_id ");
1446
+        }
1389 1447
 
1390 1448
         // Create extra field for the original_user_id_name
1391 1449
         UserManager::create_extra_field(
@@ -1422,7 +1480,9 @@  discard block
 block discarded – undo
1422 1480
             }
1423 1481
         }
1424 1482
     } else {
1425
-        if ($debug) error_log('Error while inserting a user');
1483
+        if ($debug) {
1484
+            error_log('Error while inserting a user');
1485
+        }
1426 1486
 
1427 1487
         return 0;
1428 1488
     }
@@ -4504,7 +4564,9 @@  discard block
 block discarded – undo
4504 4564
     if (!WSHelperVerifyKey($params)) {
4505 4565
         return returnError(WS_ERROR_SECRET_KEY);
4506 4566
     }
4507
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4567
+    if ($debug) {
4568
+        error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4569
+    }
4508 4570
 
4509 4571
     $results = array();
4510 4572
     $userscourses = $params['userscourses'];
@@ -4523,7 +4585,9 @@  discard block
 block discarded – undo
4523 4585
             $original_user_id['original_user_id_value'],
4524 4586
             $original_user_id['original_user_id_name']
4525 4587
         );
4526
-        if ($debug) error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4588
+        if ($debug) {
4589
+            error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4590
+        }
4527 4591
 
4528 4592
         if ($user_id == 0) {
4529 4593
             // If user was not found, there was a problem
@@ -4541,13 +4605,19 @@  discard block
 block discarded – undo
4541 4605
                 // Course was not found
4542 4606
                 $resultValue = 0;
4543 4607
             } else {
4544
-                if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4608
+                if ($debug) {
4609
+                    error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4610
+                }
4545 4611
                 $result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false);
4546 4612
                 if ($result) {
4547 4613
                     $resultValue = 1;
4548
-                    if ($debug) error_log('WSSubscribeUserToCourse subscribed');
4614
+                    if ($debug) {
4615
+                        error_log('WSSubscribeUserToCourse subscribed');
4616
+                    }
4549 4617
                 } else {
4550
-                    if ($debug) error_log('WSSubscribeUserToCourse NOT subscribed: ');
4618
+                    if ($debug) {
4619
+                        error_log('WSSubscribeUserToCourse NOT subscribed: ');
4620
+                    }
4551 4621
                 }
4552 4622
             }
4553 4623
         }
@@ -4606,8 +4676,12 @@  discard block
 block discarded – undo
4606 4676
 function WSSubscribeUserToCourseSimple($params) {
4607 4677
     global $debug;
4608 4678
 
4609
-    if ($debug) error_log('WSSubscribeUserToCourseSimple');
4610
-    if ($debug) error_log('Params '. print_r($params, 1));
4679
+    if ($debug) {
4680
+        error_log('WSSubscribeUserToCourseSimple');
4681
+    }
4682
+    if ($debug) {
4683
+        error_log('Params '. print_r($params, 1));
4684
+    }
4611 4685
     if (!WSHelperVerifyKey($params)) {
4612 4686
         return returnError(WS_ERROR_SECRET_KEY);
4613 4687
     }
@@ -4625,7 +4699,9 @@  discard block
 block discarded – undo
4625 4699
     if (empty($user_data)) {
4626 4700
         // If user was not found, there was a problem
4627 4701
         $result = "User $user_id does not exist";
4628
-        if ($debug) error_log($result);
4702
+        if ($debug) {
4703
+            error_log($result);
4704
+        }
4629 4705
         return $result;
4630 4706
     }
4631 4707
     if (!empty($course_code)) {
@@ -4633,14 +4709,22 @@  discard block
 block discarded – undo
4633 4709
         if (empty($course_data)) {
4634 4710
             // Course was not found
4635 4711
             $result = "Course $course_code does not exist in the platform ";
4636
-            if ($debug) error_log($result);
4712
+            if ($debug) {
4713
+                error_log($result);
4714
+            }
4637 4715
         } else {
4638
-            if ($debug) error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4716
+            if ($debug) {
4717
+                error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4718
+            }
4639 4719
             if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status)) {
4640 4720
                 $result = 'User was not registered possible reasons: User already registered to the course, Course visibility doesnt allow user subscriptions ';
4641
-                if ($debug) error_log($result);
4721
+                if ($debug) {
4722
+                    error_log($result);
4723
+                }
4642 4724
             } else {
4643
-                if ($debug) error_log('User registered to the course: '.$course_data['code']);
4725
+                if ($debug) {
4726
+                    error_log('User registered to the course: '.$course_data['code']);
4727
+                }
4644 4728
                 $result = 1;
4645 4729
             }
4646 4730
         }
@@ -4693,8 +4777,12 @@  discard block
 block discarded – undo
4693 4777
 function WSGetUser($params)
4694 4778
 {
4695 4779
     global $debug;
4696
-    if ($debug) error_log('WSGetUser');
4697
-    if ($debug) error_log('$params: '.print_r($params, 1));
4780
+    if ($debug) {
4781
+        error_log('WSGetUser');
4782
+    }
4783
+    if ($debug) {
4784
+        error_log('$params: '.print_r($params, 1));
4785
+    }
4698 4786
 
4699 4787
     if (!WSHelperVerifyKey($params)) {
4700 4788
         return returnError(WS_ERROR_SECRET_KEY);
@@ -4748,8 +4836,12 @@  discard block
 block discarded – undo
4748 4836
 function WSGetUserFromUsername($params)
4749 4837
 {
4750 4838
     global $debug;
4751
-    if ($debug) error_log('WSGetUserFromUsername');
4752
-    if ($debug) error_log('$params: '.print_r($params, 1));
4839
+    if ($debug) {
4840
+        error_log('WSGetUserFromUsername');
4841
+    }
4842
+    if ($debug) {
4843
+        error_log('$params: '.print_r($params, 1));
4844
+    }
4753 4845
 
4754 4846
     if (!WSHelperVerifyKey($params)) {
4755 4847
         return returnError(WS_ERROR_SECRET_KEY);
@@ -5216,7 +5308,9 @@  discard block
 block discarded – undo
5216 5308
                 SessionManager::suscribe_users_to_session($sessionId, array($user_id), SESSION_VISIBLE_READ_ONLY, false);
5217 5309
                 $results[] = 1;
5218 5310
 
5219
-                if ($debug) error_log("subscribe user:$user_id to session $sessionId");
5311
+                if ($debug) {
5312
+                    error_log("subscribe user:$user_id to session $sessionId");
5313
+                }
5220 5314
             }
5221 5315
         }
5222 5316
     } // end principal foreach
@@ -5300,7 +5394,9 @@  discard block
 block discarded – undo
5300 5394
                 SESSION_VISIBLE_READ_ONLY,
5301 5395
                 false
5302 5396
             );
5303
-            if ($debug) error_log('User registered to the course: '.$session_id);
5397
+            if ($debug) {
5398
+                error_log('User registered to the course: '.$session_id);
5399
+            }
5304 5400
             $result = 1;
5305 5401
         }
5306 5402
     }
@@ -5448,7 +5544,9 @@  discard block
 block discarded – undo
5448 5544
 
5449 5545
                 $results[] = 1;
5450 5546
 
5451
-                if ($debug) error_log("Unsubscribe user:$user_id to session:$id_session");
5547
+                if ($debug) {
5548
+                    error_log("Unsubscribe user:$user_id to session:$id_session");
5549
+                }
5452 5550
             }
5453 5551
         }
5454 5552
     } // end principal foreach
@@ -5595,7 +5693,9 @@  discard block
 block discarded – undo
5595 5693
         return returnError(WS_ERROR_SECRET_KEY);
5596 5694
     }
5597 5695
 
5598
-    if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5696
+    if ($debug) {
5697
+        error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5698
+    }
5599 5699
 
5600 5700
     $coursessessions_params = $params['coursessessions'];
5601 5701
     $results = array();
@@ -5641,7 +5741,9 @@  discard block
 block discarded – undo
5641 5741
                     array($courseInfo['real_id']),
5642 5742
                     false
5643 5743
                 );
5644
-                if ($debug) error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5744
+                if ($debug) {
5745
+                    error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5746
+                }
5645 5747
 
5646 5748
                 $results[] = 1;
5647 5749
             }
@@ -6914,7 +7016,9 @@  discard block
 block discarded – undo
6914 7016
     if (!WSHelperVerifyKey($params)) {
6915 7017
         return returnError(WS_ERROR_SECRET_KEY);
6916 7018
     }
6917
-    if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue params: '.print_r($params, 1));
7019
+    if ($debug) {
7020
+        error_log('WSAddUserVisibilityToCourseCatalogue params: '.print_r($params, 1));
7021
+    }
6918 7022
 
6919 7023
     $results = array();
6920 7024
     $userscourses = $params['userscourses'];
@@ -6930,7 +7034,9 @@  discard block
 block discarded – undo
6930 7034
             $original_user_id['original_user_id_value'],
6931 7035
             $original_user_id['original_user_id_name']
6932 7036
         );
6933
-        if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue userId: '.$userId);
7037
+        if ($debug) {
7038
+            error_log('WSAddUserVisibilityToCourseCatalogue userId: '.$userId);
7039
+        }
6934 7040
 
6935 7041
         if ($userId == 0) {
6936 7042
             // If user was not found, there was a problem
@@ -6947,13 +7053,19 @@  discard block
 block discarded – undo
6947 7053
                 // Course was not found
6948 7054
                 $resultValue = 0;
6949 7055
             } else {
6950
-                if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue courseCode: '.$courseCode);
7056
+                if ($debug) {
7057
+                    error_log('WSAddUserVisibilityToCourseCatalogue courseCode: '.$courseCode);
7058
+                }
6951 7059
                 $result = CourseManager::addUserVisibilityToCourseInCatalogue($userId, $courseCode, $visible);
6952 7060
                 if ($result) {
6953 7061
                     $resultValue = 1;
6954
-                    if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue registered');
7062
+                    if ($debug) {
7063
+                        error_log('WSAddUserVisibilityToCourseCatalogue registered');
7064
+                    }
6955 7065
                 } else {
6956
-                    if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue NOT registered: ');
7066
+                    if ($debug) {
7067
+                        error_log('WSAddUserVisibilityToCourseCatalogue NOT registered: ');
7068
+                    }
6957 7069
                 }
6958 7070
             }
6959 7071
         }
@@ -6986,7 +7098,9 @@  discard block
 block discarded – undo
6986 7098
     if (!WSHelperVerifyKey($params)) {
6987 7099
         return returnError(WS_ERROR_SECRET_KEY);
6988 7100
     }
6989
-    if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue params: '.print_r($params, 1));
7101
+    if ($debug) {
7102
+        error_log('WSRemoveUserVisibilityToCourseInCatalogue params: '.print_r($params, 1));
7103
+    }
6990 7104
 
6991 7105
     $results = array();
6992 7106
     $userscourses = $params['userscourses'];
@@ -7002,7 +7116,9 @@  discard block
 block discarded – undo
7002 7116
             $original_user_id['original_user_id_value'],
7003 7117
             $original_user_id['original_user_id_name']
7004 7118
         );
7005
-        if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue user_id: '.$userId);
7119
+        if ($debug) {
7120
+            error_log('WSRemoveUserVisibilityToCourseInCatalogue user_id: '.$userId);
7121
+        }
7006 7122
 
7007 7123
         if ($userId == 0) {
7008 7124
             // If user was not found, there was a problem
@@ -7020,13 +7136,19 @@  discard block
 block discarded – undo
7020 7136
                 // Course was not found
7021 7137
                 $resultValue = 0;
7022 7138
             } else {
7023
-                if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue courseCode: '.$courseCode);
7139
+                if ($debug) {
7140
+                    error_log('WSRemoveUserVisibilityToCourseInCatalogue courseCode: '.$courseCode);
7141
+                }
7024 7142
                 $result = CourseManager::removeUserVisibilityToCourseInCatalogue($userId, $courseCode, $visible);
7025 7143
                 if ($result) {
7026 7144
                     $resultValue = 1;
7027
-                    if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue removed');
7145
+                    if ($debug) {
7146
+                        error_log('WSRemoveUserVisibilityToCourseInCatalogue removed');
7147
+                    }
7028 7148
                 } else {
7029
-                    if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue NOT removed: ');
7149
+                    if ($debug) {
7150
+                        error_log('WSRemoveUserVisibilityToCourseInCatalogue NOT removed: ');
7151
+                    }
7030 7152
                 }
7031 7153
             }
7032 7154
         }
Please login to merge, or discard this patch.
main/webservices/webservice.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,6 +37,8 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param int Error code
39 39
 	 * @param string Error message
40
+	 * @param integer $code
41
+	 * @param string $message
40 42
 	 */
41 43
 	public function __construct($code, $message) {
42 44
 		$this->code = $code;
@@ -47,6 +49,7 @@  discard block
 block discarded – undo
47 49
 	 * Sets the error handler
48 50
 	 *
49 51
 	 * @param WSErrorHandler Error handler
52
+	 * @param WSSoapErrorHandler $handler
50 53
 	 */
51 54
 	public static function setErrorHandler($handler) {
52 55
 		if($handler instanceof WSErrorHandler) {
@@ -81,6 +84,7 @@  discard block
 block discarded – undo
81 84
 	 * Handle method
82 85
 	 *
83 86
 	 * @param WSError Error
87
+	 * @return void
84 88
 	 */
85 89
 	public function handle($error);
86 90
 }
@@ -107,7 +111,7 @@  discard block
 block discarded – undo
107 111
 	 * Verifies the API key
108 112
 	 *
109 113
 	 * @param string Secret key
110
-	 * @return mixed WSError in case of failure, null in case of success
114
+	 * @return WSError|null WSError in case of failure, null in case of success
111 115
 	 */
112 116
 	protected function verifyKey($secret_key) {
113 117
 		$ip = trim($_SERVER['REMOTE_ADDR']);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param WSErrorHandler Error handler
50 50
 	 */
51 51
 	public static function setErrorHandler($handler) {
52
-		if($handler instanceof WSErrorHandler) {
52
+		if ($handler instanceof WSErrorHandler) {
53 53
 			self::$_handler = $handler;
54 54
 		}
55 55
 	}
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 		// if we are behind a reverse proxy, assume it will send the
115 115
 		// HTTP_X_FORWARDED_FOR header and use this IP instead
116 116
 		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
-			list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
117
+			list($ip1, $ip2) = preg_split('/,/', $_SERVER['HTTP_X_FORWARDED_FOR']);
118 118
 			$ip = trim($ip1);
119 119
 		}
120 120
 		$security_key = $ip.$this->_configuration['security_key'];
121 121
 
122
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
122
+		if (!api_is_valid_secret_key($secret_key, $security_key)) {
123 123
 			return new WSError(1, "API key is invalid");
124 124
 		} else {
125 125
 			return null;
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 	 * @return mixed System user id if the user was found, WSError otherwise
137 137
 	 */
138 138
 	protected function getUserId($user_id_field_name, $user_id_value) {
139
-		if($user_id_field_name == "chamilo_user_id") {
140
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
139
+		if ($user_id_field_name == "chamilo_user_id") {
140
+			if (UserManager::is_user_id_valid(intval($user_id_value))) {
141 141
 				return intval($user_id_value);
142 142
 			} else {
143 143
 				return new WSError(100, "User not found");
144 144
 			}
145 145
 		} else {
146 146
 			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
-			if($user_id == 0) {
147
+			if ($user_id == 0) {
148 148
 				return new WSError(100, "User not found");
149 149
 			} else {
150 150
 				return $user_id;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	protected function getSessionId($session_id_field_name, $session_id_value)
198 198
 	{
199 199
 		if ($session_id_field_name == "chamilo_session_id") {
200
-			$session = SessionManager::fetch((int)$session_id_value);
200
+			$session = SessionManager::fetch((int) $session_id_value);
201 201
 			if (!empty($session)) {
202 202
 				return intval($session_id_value);
203 203
 			} else {
Please login to merge, or discard this patch.
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -11,237 +11,237 @@
 block discarded – undo
11 11
  */
12 12
 class WSError
13 13
 {
14
-	/**
15
-	 * Error handler. This needs to be a class that implements the interface WSErrorHandler
16
-	 *
17
-	 * @var WSErrorHandler
18
-	 */
19
-	protected static $_handler;
20
-
21
-	/**
22
-	 * Error code
23
-	 *
24
-	 * @var int
25
-	 */
26
-	public $code;
27
-
28
-	/**
29
-	 * Error message
30
-	 *
31
-	 * @var string
32
-	 */
33
-	public $message;
34
-
35
-	/**
36
-	 * Constructor
37
-	 *
38
-	 * @param int Error code
39
-	 * @param string Error message
40
-	 */
41
-	public function __construct($code, $message) {
42
-		$this->code = $code;
43
-		$this->message = $message;
44
-	}
45
-
46
-	/**
47
-	 * Sets the error handler
48
-	 *
49
-	 * @param WSErrorHandler Error handler
50
-	 */
51
-	public static function setErrorHandler($handler) {
52
-		if($handler instanceof WSErrorHandler) {
53
-			self::$_handler = $handler;
54
-		}
55
-	}
56
-
57
-	/**
58
-	 * Returns the error handler
59
-	 *
60
-	 * @return WSErrorHandler Error handler
61
-	 */
62
-	public static function getErrorHandler() {
63
-		return self::$_handler;
64
-	}
65
-
66
-	/**
67
-	 * Transforms the error into an array
68
-	 *
69
-	 * @return array Associative array with code and message
70
-	 */
71
-	public function toArray() {
72
-		return array('code' => $this->code, 'message' => $this->message);
73
-	}
14
+    /**
15
+     * Error handler. This needs to be a class that implements the interface WSErrorHandler
16
+     *
17
+     * @var WSErrorHandler
18
+     */
19
+    protected static $_handler;
20
+
21
+    /**
22
+     * Error code
23
+     *
24
+     * @var int
25
+     */
26
+    public $code;
27
+
28
+    /**
29
+     * Error message
30
+     *
31
+     * @var string
32
+     */
33
+    public $message;
34
+
35
+    /**
36
+     * Constructor
37
+     *
38
+     * @param int Error code
39
+     * @param string Error message
40
+     */
41
+    public function __construct($code, $message) {
42
+        $this->code = $code;
43
+        $this->message = $message;
44
+    }
45
+
46
+    /**
47
+     * Sets the error handler
48
+     *
49
+     * @param WSErrorHandler Error handler
50
+     */
51
+    public static function setErrorHandler($handler) {
52
+        if($handler instanceof WSErrorHandler) {
53
+            self::$_handler = $handler;
54
+        }
55
+    }
56
+
57
+    /**
58
+     * Returns the error handler
59
+     *
60
+     * @return WSErrorHandler Error handler
61
+     */
62
+    public static function getErrorHandler() {
63
+        return self::$_handler;
64
+    }
65
+
66
+    /**
67
+     * Transforms the error into an array
68
+     *
69
+     * @return array Associative array with code and message
70
+     */
71
+    public function toArray() {
72
+        return array('code' => $this->code, 'message' => $this->message);
73
+    }
74 74
 }
75 75
 
76 76
 /**
77 77
  * Interface that must be implemented by any error handler
78 78
  */
79 79
 interface WSErrorHandler {
80
-	/**
81
-	 * Handle method
82
-	 *
83
-	 * @param WSError Error
84
-	 */
85
-	public function handle($error);
80
+    /**
81
+     * Handle method
82
+     *
83
+     * @param WSError Error
84
+     */
85
+    public function handle($error);
86 86
 }
87 87
 
88 88
 /**
89 89
  * Main class of the webservice. Webservice classes extend this class
90 90
  */
91 91
 class WS {
92
-	/**
93
-	 * Chamilo configuration
94
-	 *
95
-	 * @var array
96
-	 */
97
-	protected $_configuration;
98
-
99
-	/**
100
-	 * Constructor
101
-	 */
102
-	public function __construct() {
103
-		$this->_configuration = $GLOBALS['_configuration'];
104
-	}
105
-
106
-	/**
107
-	 * Verifies the API key
108
-	 *
109
-	 * @param string Secret key
110
-	 * @return mixed WSError in case of failure, null in case of success
111
-	 */
112
-	protected function verifyKey($secret_key) {
113
-		$ip = trim($_SERVER['REMOTE_ADDR']);
114
-		// if we are behind a reverse proxy, assume it will send the
115
-		// HTTP_X_FORWARDED_FOR header and use this IP instead
116
-		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
-			list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
118
-			$ip = trim($ip1);
119
-		}
120
-		$security_key = $ip.$this->_configuration['security_key'];
121
-
122
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
123
-			return new WSError(1, "API key is invalid");
124
-		} else {
125
-			return null;
126
-		}
127
-	}
128
-
129
-	/**
130
-	 * Gets the real user id based on the user id field name and value.
131
-	 * Note that if the user id field name is "chamilo_user_id", it will use the user id
132
-	 * in the system database
133
-	 *
134
-	 * @param string User id field name
135
-	 * @param string User id value
136
-	 * @return mixed System user id if the user was found, WSError otherwise
137
-	 */
138
-	protected function getUserId($user_id_field_name, $user_id_value) {
139
-		if($user_id_field_name == "chamilo_user_id") {
140
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
141
-				return intval($user_id_value);
142
-			} else {
143
-				return new WSError(100, "User not found");
144
-			}
145
-		} else {
146
-			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
-			if($user_id == 0) {
148
-				return new WSError(100, "User not found");
149
-			} else {
150
-				return $user_id;
151
-			}
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * Gets the real course id based on the course id field name and value.
157
-	 * Note that if the course id field name is "chamilo_course_id", it will use the course id
158
-	 * in the system database
159
-	 *
160
-	 * @param string Course id field name
161
-	 * @param string Course id value
162
-	 * @return mixed System course id if the course was found, WSError otherwise
163
-	 */
164
-	protected function getCourseId($course_id_field_name, $course_id_value)
165
-	{
166
-		if ($course_id_field_name == "chamilo_course_id") {
167
-			if (CourseManager::get_course_code_from_course_id(
168
-					intval($course_id_value)
169
-				) != null
170
-			) {
171
-				return intval($course_id_value);
172
-			} else {
173
-				return new WSError(200, "Course not found");
174
-			}
175
-		} else {
176
-			$courseId = CourseManager::get_course_code_from_original_id(
177
-				$course_id_value,
178
-				$course_id_field_name
179
-			);
180
-			if (!empty($courseId)) {
181
-				return $courseId;
182
-			} else {
183
-				return new WSError(200, "Course not found");
184
-			}
185
-		}
186
-	}
187
-
188
-	/**
189
-	 * Gets the real session id based on the session id field name and value.
190
-	 * Note that if the session id field name is "chamilo_session_id", it will use the session id
191
-	 * in the system database
192
-	 *
193
-	 * @param string Session id field name
194
-	 * @param string Session id value
195
-	 * @return mixed System session id if the session was found, WSError otherwise
196
-	 */
197
-	protected function getSessionId($session_id_field_name, $session_id_value)
198
-	{
199
-		if ($session_id_field_name == "chamilo_session_id") {
200
-			$session = SessionManager::fetch((int)$session_id_value);
201
-			if (!empty($session)) {
202
-				return intval($session_id_value);
203
-			} else {
204
-				return new WSError(300, "Session not found");
205
-			}
206
-		} else {
207
-			$session_id = SessionManager::getSessionIdFromOriginalId(
208
-				$session_id_value,
209
-				$session_id_field_name
210
-			);
211
-			if ($session_id == 0) {
212
-				return new WSError(300, "Session not found");
213
-			} else {
214
-				return $session_id;
215
-			}
216
-		}
217
-	}
218
-
219
-	/**
220
-	 * Handles an error by calling the WSError error handler
221
-	 *
222
-	 * @param WSError Error
223
-	 */
224
-	protected function handleError($error) {
225
-		$handler = WSError::getErrorHandler();
226
-		$handler->handle($error);
227
-	}
228
-
229
-	/**
230
-	 * Gets a successful result
231
-	 *
232
-	 * @return array Array with a code of 0 and a message 'Operation was successful'
233
-	 */
234
-	protected function getSuccessfulResult() {
235
-		return array('code' => 0, 'message' => 'Operation was successful');
236
-	}
237
-
238
-	/**
239
-	 * Test function. Returns the string success
240
-	 *
241
-	 * @return string Success
242
-	 */
243
-	public function test() {
244
-		return "success";
245
-	}
92
+    /**
93
+     * Chamilo configuration
94
+     *
95
+     * @var array
96
+     */
97
+    protected $_configuration;
98
+
99
+    /**
100
+     * Constructor
101
+     */
102
+    public function __construct() {
103
+        $this->_configuration = $GLOBALS['_configuration'];
104
+    }
105
+
106
+    /**
107
+     * Verifies the API key
108
+     *
109
+     * @param string Secret key
110
+     * @return mixed WSError in case of failure, null in case of success
111
+     */
112
+    protected function verifyKey($secret_key) {
113
+        $ip = trim($_SERVER['REMOTE_ADDR']);
114
+        // if we are behind a reverse proxy, assume it will send the
115
+        // HTTP_X_FORWARDED_FOR header and use this IP instead
116
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
+            list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
118
+            $ip = trim($ip1);
119
+        }
120
+        $security_key = $ip.$this->_configuration['security_key'];
121
+
122
+        if(!api_is_valid_secret_key($secret_key, $security_key)) {
123
+            return new WSError(1, "API key is invalid");
124
+        } else {
125
+            return null;
126
+        }
127
+    }
128
+
129
+    /**
130
+     * Gets the real user id based on the user id field name and value.
131
+     * Note that if the user id field name is "chamilo_user_id", it will use the user id
132
+     * in the system database
133
+     *
134
+     * @param string User id field name
135
+     * @param string User id value
136
+     * @return mixed System user id if the user was found, WSError otherwise
137
+     */
138
+    protected function getUserId($user_id_field_name, $user_id_value) {
139
+        if($user_id_field_name == "chamilo_user_id") {
140
+            if(UserManager::is_user_id_valid(intval($user_id_value))) {
141
+                return intval($user_id_value);
142
+            } else {
143
+                return new WSError(100, "User not found");
144
+            }
145
+        } else {
146
+            $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
+            if($user_id == 0) {
148
+                return new WSError(100, "User not found");
149
+            } else {
150
+                return $user_id;
151
+            }
152
+        }
153
+    }
154
+
155
+    /**
156
+     * Gets the real course id based on the course id field name and value.
157
+     * Note that if the course id field name is "chamilo_course_id", it will use the course id
158
+     * in the system database
159
+     *
160
+     * @param string Course id field name
161
+     * @param string Course id value
162
+     * @return mixed System course id if the course was found, WSError otherwise
163
+     */
164
+    protected function getCourseId($course_id_field_name, $course_id_value)
165
+    {
166
+        if ($course_id_field_name == "chamilo_course_id") {
167
+            if (CourseManager::get_course_code_from_course_id(
168
+                    intval($course_id_value)
169
+                ) != null
170
+            ) {
171
+                return intval($course_id_value);
172
+            } else {
173
+                return new WSError(200, "Course not found");
174
+            }
175
+        } else {
176
+            $courseId = CourseManager::get_course_code_from_original_id(
177
+                $course_id_value,
178
+                $course_id_field_name
179
+            );
180
+            if (!empty($courseId)) {
181
+                return $courseId;
182
+            } else {
183
+                return new WSError(200, "Course not found");
184
+            }
185
+        }
186
+    }
187
+
188
+    /**
189
+     * Gets the real session id based on the session id field name and value.
190
+     * Note that if the session id field name is "chamilo_session_id", it will use the session id
191
+     * in the system database
192
+     *
193
+     * @param string Session id field name
194
+     * @param string Session id value
195
+     * @return mixed System session id if the session was found, WSError otherwise
196
+     */
197
+    protected function getSessionId($session_id_field_name, $session_id_value)
198
+    {
199
+        if ($session_id_field_name == "chamilo_session_id") {
200
+            $session = SessionManager::fetch((int)$session_id_value);
201
+            if (!empty($session)) {
202
+                return intval($session_id_value);
203
+            } else {
204
+                return new WSError(300, "Session not found");
205
+            }
206
+        } else {
207
+            $session_id = SessionManager::getSessionIdFromOriginalId(
208
+                $session_id_value,
209
+                $session_id_field_name
210
+            );
211
+            if ($session_id == 0) {
212
+                return new WSError(300, "Session not found");
213
+            } else {
214
+                return $session_id;
215
+            }
216
+        }
217
+    }
218
+
219
+    /**
220
+     * Handles an error by calling the WSError error handler
221
+     *
222
+     * @param WSError Error
223
+     */
224
+    protected function handleError($error) {
225
+        $handler = WSError::getErrorHandler();
226
+        $handler->handle($error);
227
+    }
228
+
229
+    /**
230
+     * Gets a successful result
231
+     *
232
+     * @return array Array with a code of 0 and a message 'Operation was successful'
233
+     */
234
+    protected function getSuccessfulResult() {
235
+        return array('code' => 0, 'message' => 'Operation was successful');
236
+    }
237
+
238
+    /**
239
+     * Test function. Returns the string success
240
+     *
241
+     * @return string Success
242
+     */
243
+    public function test() {
244
+        return "success";
245
+    }
246 246
 }
247 247
 
Please login to merge, or discard this patch.
main/webservices/webservice_session.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -453,6 +453,7 @@
 block discarded – undo
453 453
 	 * @param string Session id field name
454 454
 	 * @param string Session id value
455 455
 	 * @param int State (1 to subscribe, 0 to unsubscribe)
456
+	 * @param integer $state
456 457
 	 * @return mixed True on success, WSError otherwise
457 458
 	 */
458 459
 	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
Please login to merge, or discard this patch.
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -14,177 +14,177 @@  discard block
 block discarded – undo
14 14
 class WSSession extends WS
15 15
 {
16 16
 
17
-	/**
18
-	 * Creates a session (helper method)
19
-	 *
20
-	 * @param string Name of the session
21
-	 * @param string Start date, use the 'YYYY-MM-DD' format
22
-	 * @param string End date, use the 'YYYY-MM-DD' format
23
-	 * @param int Access delays of the coach (days before)
24
-	 * @param int Access delays of the coach (days after)
25
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
26
-	 * @param int Visibility
27
-	 * @param string User id field name for the coach
28
-	 * @param string User id value for the coach
29
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
30
-	 * @param string Original session id value
31
-	 * @param array Array of extra fields
32
-	 * @return mixed Generated id in case of success, WSError otherwise
33
-	 */
34
-	protected function createSessionHelper(
35
-		$name,
36
-		$start_date,
37
-		$end_date,
38
-		$nb_days_access_before,
39
-		$nb_days_access_after,
40
-		$nolimit,
41
-		$visibility,
42
-		$user_id_field_name,
43
-		$user_id_value,
44
-		$session_id_field_name,
45
-		$session_id_value,
46
-		$extras
47
-	) {
48
-		// Verify that coach exists and get its id
49
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
50
-		if ($user_id instanceof WSError) {
51
-			return $user_id;
52
-		}
17
+    /**
18
+     * Creates a session (helper method)
19
+     *
20
+     * @param string Name of the session
21
+     * @param string Start date, use the 'YYYY-MM-DD' format
22
+     * @param string End date, use the 'YYYY-MM-DD' format
23
+     * @param int Access delays of the coach (days before)
24
+     * @param int Access delays of the coach (days after)
25
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
26
+     * @param int Visibility
27
+     * @param string User id field name for the coach
28
+     * @param string User id value for the coach
29
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
30
+     * @param string Original session id value
31
+     * @param array Array of extra fields
32
+     * @return mixed Generated id in case of success, WSError otherwise
33
+     */
34
+    protected function createSessionHelper(
35
+        $name,
36
+        $start_date,
37
+        $end_date,
38
+        $nb_days_access_before,
39
+        $nb_days_access_after,
40
+        $nolimit,
41
+        $visibility,
42
+        $user_id_field_name,
43
+        $user_id_value,
44
+        $session_id_field_name,
45
+        $session_id_value,
46
+        $extras
47
+    ) {
48
+        // Verify that coach exists and get its id
49
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
50
+        if ($user_id instanceof WSError) {
51
+            return $user_id;
52
+        }
53 53
 
54
-		$coachStartDate = null;
55
-		if (!empty($nb_days_access_before)) {
56
-			$day = intval($nb_days_access_before);
57
-			$coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
58
-		}
54
+        $coachStartDate = null;
55
+        if (!empty($nb_days_access_before)) {
56
+            $day = intval($nb_days_access_before);
57
+            $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
58
+        }
59 59
 
60
-		$coachEndDate = null;
61
-		if (!empty($nb_days_access_after)) {
62
-			$day = intval($nb_days_access_after);
63
-			$coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
64
-		}
60
+        $coachEndDate = null;
61
+        if (!empty($nb_days_access_after)) {
62
+            $day = intval($nb_days_access_after);
63
+            $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
64
+        }
65 65
 
66
-		// Try to create the session
67
-		$session_id = SessionManager::create_session(
68
-			$name,
69
-			$start_date,
70
-			$end_date,
71
-			$start_date,
72
-			$end_date,
73
-			$coachStartDate,
74
-			$coachEndDate,
75
-			$user_id,
76
-			0,
77
-			$visibility
78
-		);
79
-		if(!is_int($session_id)) {
80
-			return new WSError(301, 'Could not create the session');
81
-		} else {
82
-			// Add the Original session id to the extra fields
83
-			$extras_associative = array();
84
-			if($session_id_field_name != "chamilo_session_id") {
85
-				$extras_associative[$session_id_field_name] = $session_id_value;
86
-			}
87
-			foreach($extras as $extra) {
88
-				$extras_associative[$extra['field_name']] = $extra['field_value'];
89
-			}
90
-			// Create the extra fields
91
-			foreach($extras_associative as $fname => $fvalue) {
92
-				SessionManager::create_session_extra_field($fname, 1, $fname);
93
-				SessionManager::update_session_extra_field_value(
94
-					$session_id,
95
-					$fname,
96
-					$fvalue
97
-				);
98
-			}
99
-			return $session_id;
100
-		}
101
-	}
66
+        // Try to create the session
67
+        $session_id = SessionManager::create_session(
68
+            $name,
69
+            $start_date,
70
+            $end_date,
71
+            $start_date,
72
+            $end_date,
73
+            $coachStartDate,
74
+            $coachEndDate,
75
+            $user_id,
76
+            0,
77
+            $visibility
78
+        );
79
+        if(!is_int($session_id)) {
80
+            return new WSError(301, 'Could not create the session');
81
+        } else {
82
+            // Add the Original session id to the extra fields
83
+            $extras_associative = array();
84
+            if($session_id_field_name != "chamilo_session_id") {
85
+                $extras_associative[$session_id_field_name] = $session_id_value;
86
+            }
87
+            foreach($extras as $extra) {
88
+                $extras_associative[$extra['field_name']] = $extra['field_value'];
89
+            }
90
+            // Create the extra fields
91
+            foreach($extras_associative as $fname => $fvalue) {
92
+                SessionManager::create_session_extra_field($fname, 1, $fname);
93
+                SessionManager::update_session_extra_field_value(
94
+                    $session_id,
95
+                    $fname,
96
+                    $fvalue
97
+                );
98
+            }
99
+            return $session_id;
100
+        }
101
+    }
102 102
 
103
-	/**
104
-	 * Creates a session
105
-	 *
106
-	 * @param string API secret key
107
-	 * @param string Name of the session
108
-	 * @param string Start date, use the 'YYYY-MM-DD' format
109
-	 * @param string End date, use the 'YYYY-MM-DD' format
110
-	 * @param int Access delays of the coach (days before)
111
-	 * @param int Access delays of the coach (days after)
112
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
113
-	 * @param int Visibility
114
-	 * @param string User id field name for the coach
115
-	 * @param string User id value for the coach
116
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
117
-	 * @param string Original session id value
118
-	 * @param array Array of extra fields
119
-	 * @return int Session id generated
120
-	 */
121
-	public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122
-		$verifKey = $this->verifyKey($secret_key);
123
-		if($verifKey instanceof WSError) {
124
-			$this->handleError($verifKey);
125
-		} else {
126
-			$session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
-			if($session_id instanceof WSError) {
128
-				$this->handleError($session_id);
129
-			} else {
130
-				return $session_id;
131
-			}
132
-		}
133
-	}
103
+    /**
104
+     * Creates a session
105
+     *
106
+     * @param string API secret key
107
+     * @param string Name of the session
108
+     * @param string Start date, use the 'YYYY-MM-DD' format
109
+     * @param string End date, use the 'YYYY-MM-DD' format
110
+     * @param int Access delays of the coach (days before)
111
+     * @param int Access delays of the coach (days after)
112
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
113
+     * @param int Visibility
114
+     * @param string User id field name for the coach
115
+     * @param string User id value for the coach
116
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
117
+     * @param string Original session id value
118
+     * @param array Array of extra fields
119
+     * @return int Session id generated
120
+     */
121
+    public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122
+        $verifKey = $this->verifyKey($secret_key);
123
+        if($verifKey instanceof WSError) {
124
+            $this->handleError($verifKey);
125
+        } else {
126
+            $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
+            if($session_id instanceof WSError) {
128
+                $this->handleError($session_id);
129
+            } else {
130
+                return $session_id;
131
+            }
132
+        }
133
+    }
134 134
 
135
-	/**
136
-	 * Deletes a session (helper method)
137
-	 *
138
-	 * @param string Session id field name
139
-	 * @param string Session id value
140
-	 * @return mixed True in case of success, WSError otherwise
141
-	 */
142
-	protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
-		if($session_id instanceof WSError) {
145
-			return $session_id;
146
-		} else {
147
-			SessionManager::delete($session_id, true);
148
-			return true;
149
-		}
150
-	}
135
+    /**
136
+     * Deletes a session (helper method)
137
+     *
138
+     * @param string Session id field name
139
+     * @param string Session id value
140
+     * @return mixed True in case of success, WSError otherwise
141
+     */
142
+    protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
+        if($session_id instanceof WSError) {
145
+            return $session_id;
146
+        } else {
147
+            SessionManager::delete($session_id, true);
148
+            return true;
149
+        }
150
+    }
151 151
 
152
-	/**
153
-	 * Deletes a session
154
-	 *
155
-	 * @param string API secret key
156
-	 * @param string Session id field name
157
-	 * @param string Session id value
158
-	 */
159
-	public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160
-		$verifKey = $this->verifyKey($secret_key);
161
-		if($verifKey instanceof WSError) {
162
-			$this->handleError($verifKey);
163
-		} else {
164
-			$result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
-			if($result instanceof WSError) {
166
-				$this->handleError($result);
167
-			}
168
-		}
169
-	}
152
+    /**
153
+     * Deletes a session
154
+     *
155
+     * @param string API secret key
156
+     * @param string Session id field name
157
+     * @param string Session id value
158
+     */
159
+    public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160
+        $verifKey = $this->verifyKey($secret_key);
161
+        if($verifKey instanceof WSError) {
162
+            $this->handleError($verifKey);
163
+        } else {
164
+            $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
+            if($result instanceof WSError) {
166
+                $this->handleError($result);
167
+            }
168
+        }
169
+    }
170 170
 
171
-	/**
172
-	 * Edits a session (helper method)
173
-	 *
174
-	 * @param string Name of the session
175
-	 * @param string Start date, use the 'YYYY-MM-DD' format
176
-	 * @param string End date, use the 'YYYY-MM-DD' format
177
-	 * @param int Access delays of the coach (days before)
178
-	 * @param int Access delays of the coach (days after)
179
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
180
-	 * @param int Visibility
181
-	 * @param string User id field name for the coach
182
-	 * @param string User id value for the coach
183
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
184
-	 * @param string Original session id value
185
-	 * @param array Array of extra fields
186
-	 * @return mixed True on success, WSError otherwise
187
-	 */
171
+    /**
172
+     * Edits a session (helper method)
173
+     *
174
+     * @param string Name of the session
175
+     * @param string Start date, use the 'YYYY-MM-DD' format
176
+     * @param string End date, use the 'YYYY-MM-DD' format
177
+     * @param int Access delays of the coach (days before)
178
+     * @param int Access delays of the coach (days after)
179
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
180
+     * @param int Visibility
181
+     * @param string User id field name for the coach
182
+     * @param string User id value for the coach
183
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
184
+     * @param string Original session id value
185
+     * @param array Array of extra fields
186
+     * @return mixed True on success, WSError otherwise
187
+     */
188 188
     protected function editSessionHelper(
189 189
         $name,
190 190
         $start_date,
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
         $session_id_value,
200 200
         $extras
201 201
     ) {
202
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
-		if($session_id instanceof WSError) {
204
-			return $session_id;
205
-		} else {
206
-			// Verify that coach exists and get its id
207
-			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
208
-			if ($user_id instanceof WSError) {
209
-				return $user_id;
210
-			}
202
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
+        if($session_id instanceof WSError) {
204
+            return $session_id;
205
+        } else {
206
+            // Verify that coach exists and get its id
207
+            $user_id = $this->getUserId($user_id_field_name, $user_id_value);
208
+            if ($user_id instanceof WSError) {
209
+                return $user_id;
210
+            }
211 211
 
212 212
             $coachStartDate = null;
213 213
             if (!empty($nb_days_access_before)) {
@@ -234,127 +234,127 @@  discard block
 block discarded – undo
234 234
                 0,
235 235
                 (int)$visibility
236 236
             );
237
-			if(!is_int($result_id)) {
238
-				return new WSError(302, 'Could not edit the session');
239
-			} else {
240
-				if(!empty($extras)) {
241
-					$extras_associative = array();
242
-					foreach($extras as $extra) {
243
-						$extras_associative[$extra['field_name']] = $extra['field_value'];
244
-					}
245
-					// Create the extra fields
246
-					foreach($extras_associative as $fname => $fvalue) {
247
-						SessionManager::create_session_extra_field($fname, 1, $fname);
248
-						SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249
-					}
250
-				}
251
-				return true;
252
-			}
253
-		}
254
-	}
237
+            if(!is_int($result_id)) {
238
+                return new WSError(302, 'Could not edit the session');
239
+            } else {
240
+                if(!empty($extras)) {
241
+                    $extras_associative = array();
242
+                    foreach($extras as $extra) {
243
+                        $extras_associative[$extra['field_name']] = $extra['field_value'];
244
+                    }
245
+                    // Create the extra fields
246
+                    foreach($extras_associative as $fname => $fvalue) {
247
+                        SessionManager::create_session_extra_field($fname, 1, $fname);
248
+                        SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249
+                    }
250
+                }
251
+                return true;
252
+            }
253
+        }
254
+    }
255 255
 
256
-	/**
257
-	 * Edits a session
258
-	 *
259
-	 * @param string API secret key
260
-	 * @param string Name of the session
261
-	 * @param string Start date, use the 'YYYY-MM-DD' format
262
-	 * @param string End date, use the 'YYYY-MM-DD' format
263
-	 * @param int Access delays of the coach (days before)
264
-	 * @param int Access delays of the coach (days after)
265
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
266
-	 * @param int Visibility
267
-	 * @param string User id field name for the coach
268
-	 * @param string User id value for the coach
269
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
270
-	 * @param string Original session id value
271
-	 * @param array Array of extra fields
272
-	 */
273
-	public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274
-		$verifKey = $this->verifyKey($secret_key);
275
-		if($verifKey instanceof WSError) {
276
-			$this->handleError($verifKey);
277
-		} else {
278
-			$result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
-			if($session_id_value instanceof WSError) {
280
-				$this->handleError($result);
281
-			}
282
-		}
283
-	}
256
+    /**
257
+     * Edits a session
258
+     *
259
+     * @param string API secret key
260
+     * @param string Name of the session
261
+     * @param string Start date, use the 'YYYY-MM-DD' format
262
+     * @param string End date, use the 'YYYY-MM-DD' format
263
+     * @param int Access delays of the coach (days before)
264
+     * @param int Access delays of the coach (days after)
265
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
266
+     * @param int Visibility
267
+     * @param string User id field name for the coach
268
+     * @param string User id value for the coach
269
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
270
+     * @param string Original session id value
271
+     * @param array Array of extra fields
272
+     */
273
+    public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274
+        $verifKey = $this->verifyKey($secret_key);
275
+        if($verifKey instanceof WSError) {
276
+            $this->handleError($verifKey);
277
+        } else {
278
+            $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
+            if($session_id_value instanceof WSError) {
280
+                $this->handleError($result);
281
+            }
282
+        }
283
+    }
284 284
 
285
-	/**
286
-	 * Change user subscription (helper method)
287
-	 *
288
-	 * @param string User id field name
289
-	 * @param string User id value
290
-	 * @param string Session id field name
291
-	 * @param string Session id value
292
-	 * @param int State (1 to subscribe, 0 to unsubscribe)
293
-	 * @return mixed True on success, WSError otherwise
294
-	 */
295
-	protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
-		if($session_id instanceof WSError) {
298
-			return $session_id;
299
-		} else {
300
-			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
-			if($user_id instanceof WSError) {
302
-				return $user_id;
303
-			} else {
304
-				if($state  == 1) {
305
-					SessionManager::suscribe_users_to_session($session_id, array($user_id));
306
-				} else {
307
-					$result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
308
-					if (!$result) {
309
-						return new WSError(303, 'There was an error unsubscribing this user from the session');
310
-					}
311
-				}
312
-				return true;
313
-			}
314
-		}
315
-	}
285
+    /**
286
+     * Change user subscription (helper method)
287
+     *
288
+     * @param string User id field name
289
+     * @param string User id value
290
+     * @param string Session id field name
291
+     * @param string Session id value
292
+     * @param int State (1 to subscribe, 0 to unsubscribe)
293
+     * @return mixed True on success, WSError otherwise
294
+     */
295
+    protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
+        if($session_id instanceof WSError) {
298
+            return $session_id;
299
+        } else {
300
+            $user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
+            if($user_id instanceof WSError) {
302
+                return $user_id;
303
+            } else {
304
+                if($state  == 1) {
305
+                    SessionManager::suscribe_users_to_session($session_id, array($user_id));
306
+                } else {
307
+                    $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
308
+                    if (!$result) {
309
+                        return new WSError(303, 'There was an error unsubscribing this user from the session');
310
+                    }
311
+                }
312
+                return true;
313
+            }
314
+        }
315
+    }
316 316
 
317
-	/**
318
-	 * Subscribe user to a session
319
-	 *
320
-	 * @param string API secret key
321
-	 * @param string User id field name
322
-	 * @param string User id value
323
-	 * @param string Session id field name
324
-	 * @param string Session id value
325
-	 */
326
-	public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327
-		$verifKey = $this->verifyKey($secret_key);
328
-		if($verifKey instanceof WSError) {
329
-			$this->handleError($verifKey);
330
-		} else {
331
-			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
-			if($result instanceof WSError) {
333
-				$this->handleError($result);
334
-			}
335
-		}
336
-	}
317
+    /**
318
+     * Subscribe user to a session
319
+     *
320
+     * @param string API secret key
321
+     * @param string User id field name
322
+     * @param string User id value
323
+     * @param string Session id field name
324
+     * @param string Session id value
325
+     */
326
+    public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327
+        $verifKey = $this->verifyKey($secret_key);
328
+        if($verifKey instanceof WSError) {
329
+            $this->handleError($verifKey);
330
+        } else {
331
+            $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
+            if($result instanceof WSError) {
333
+                $this->handleError($result);
334
+            }
335
+        }
336
+    }
337 337
 
338
-	/**
339
-	 * Subscribe user to a session
340
-	 *
341
-	 * @param string API secret key
342
-	 * @param string User id field name
343
-	 * @param string User id value
344
-	 * @param string Session id field name
345
-	 * @param string Session id value
346
-	 */
347
-	public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348
-		$verifKey = $this->verifyKey($secret_key);
349
-		if($verifKey instanceof WSError) {
350
-			$this->handleError($verifKey);
351
-		} else {
352
-			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
-			if($result instanceof WSError) {
354
-				$this->handleError($result);
355
-			}
356
-		}
357
-	}
338
+    /**
339
+     * Subscribe user to a session
340
+     *
341
+     * @param string API secret key
342
+     * @param string User id field name
343
+     * @param string User id value
344
+     * @param string Session id field name
345
+     * @param string Session id value
346
+     */
347
+    public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348
+        $verifKey = $this->verifyKey($secret_key);
349
+        if($verifKey instanceof WSError) {
350
+            $this->handleError($verifKey);
351
+        } else {
352
+            $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
+            if($result instanceof WSError) {
354
+                $this->handleError($result);
355
+            }
356
+        }
357
+    }
358 358
     
359 359
     /**
360 360
      * Change Teacher subscription (helper method)
@@ -446,79 +446,79 @@  discard block
 block discarded – undo
446 446
     }
447 447
 
448 448
     /**
449
-	 * Change course subscription
450
-	 *
451
-	 * @param string Course id field name
452
-	 * @param string Course id value
453
-	 * @param string Session id field name
454
-	 * @param string Session id value
455
-	 * @param int State (1 to subscribe, 0 to unsubscribe)
456
-	 * @return mixed True on success, WSError otherwise
457
-	 */
458
-	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
-		if($session_id instanceof WSError) {
461
-			return $session_id;
462
-		} else {
463
-			$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
-			if($course_id instanceof WSError) {
465
-				return $course_id;
466
-			} else {
467
-				if($state  == 1) {
468
-					SessionManager::add_courses_to_session($session_id, array($course_id));
469
-					return true;
470
-				} else {
471
-					$result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
472
-					if ($result) {
473
-						return true;
474
-					} else {
475
-						return new WSError(304, 'Error unsubscribing course from session');
476
-					}
477
-				}
478
-			}
479
-		}
449
+     * Change course subscription
450
+     *
451
+     * @param string Course id field name
452
+     * @param string Course id value
453
+     * @param string Session id field name
454
+     * @param string Session id value
455
+     * @param int State (1 to subscribe, 0 to unsubscribe)
456
+     * @return mixed True on success, WSError otherwise
457
+     */
458
+    protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
+        if($session_id instanceof WSError) {
461
+            return $session_id;
462
+        } else {
463
+            $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
+            if($course_id instanceof WSError) {
465
+                return $course_id;
466
+            } else {
467
+                if($state  == 1) {
468
+                    SessionManager::add_courses_to_session($session_id, array($course_id));
469
+                    return true;
470
+                } else {
471
+                    $result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
472
+                    if ($result) {
473
+                        return true;
474
+                    } else {
475
+                        return new WSError(304, 'Error unsubscribing course from session');
476
+                    }
477
+                }
478
+            }
479
+        }
480 480
     }
481 481
 
482
-	/**
483
-	 * Subscribe course to session
484
-	 *
485
-	 * @param string API secret key
486
-	 * @param string Course id field name
487
-	 * @param string Course id value
488
-	 * @param string Session id field name
489
-	 * @param string Session id value
490
-	 */
491
-	public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492
-		$verifKey = $this->verifyKey($secret_key);
493
-		if($verifKey instanceof WSError) {
494
-			$this->handleError($verifKey);
495
-		} else {
496
-			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
-			if($result instanceof WSError) {
498
-				$this->handleError($result);
499
-			}
500
-		}
501
-	}
482
+    /**
483
+     * Subscribe course to session
484
+     *
485
+     * @param string API secret key
486
+     * @param string Course id field name
487
+     * @param string Course id value
488
+     * @param string Session id field name
489
+     * @param string Session id value
490
+     */
491
+    public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492
+        $verifKey = $this->verifyKey($secret_key);
493
+        if($verifKey instanceof WSError) {
494
+            $this->handleError($verifKey);
495
+        } else {
496
+            $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
+            if($result instanceof WSError) {
498
+                $this->handleError($result);
499
+            }
500
+        }
501
+    }
502 502
 
503
-	/**
504
-	 * Unsubscribe course from session
505
-	 *
506
-	 * @param string API secret key
507
-	 * @param string Course id field name
508
-	 * @param string Course id value
509
-	 * @param string Session id field name
510
-	 * @param string Session id value
511
-	 */
512
-	public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513
-		$verifKey = $this->verifyKey($secret_key);
514
-		if($verifKey instanceof WSError) {
515
-			$this->handleError($verifKey);
516
-		} else {
517
-			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
-			if($result instanceof WSError) {
519
-				$this->handleError($result);
520
-			}
521
-		}
522
-	}
503
+    /**
504
+     * Unsubscribe course from session
505
+     *
506
+     * @param string API secret key
507
+     * @param string Course id field name
508
+     * @param string Course id value
509
+     * @param string Session id field name
510
+     * @param string Session id value
511
+     */
512
+    public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513
+        $verifKey = $this->verifyKey($secret_key);
514
+        if($verifKey instanceof WSError) {
515
+            $this->handleError($verifKey);
516
+        } else {
517
+            $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
+            if($result instanceof WSError) {
519
+                $this->handleError($result);
520
+            }
521
+        }
522
+    }
523 523
 
524 524
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 		$coachStartDate = null;
55 55
 		if (!empty($nb_days_access_before)) {
56 56
 			$day = intval($nb_days_access_before);
57
-			$coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
57
+			$coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days'));
58 58
 		}
59 59
 
60 60
 		$coachEndDate = null;
61 61
 		if (!empty($nb_days_access_after)) {
62 62
 			$day = intval($nb_days_access_after);
63
-			$coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
63
+			$coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days'));
64 64
 		}
65 65
 
66 66
 		// Try to create the session
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 			0,
77 77
 			$visibility
78 78
 		);
79
-		if(!is_int($session_id)) {
79
+		if (!is_int($session_id)) {
80 80
 			return new WSError(301, 'Could not create the session');
81 81
 		} else {
82 82
 			// Add the Original session id to the extra fields
83 83
 			$extras_associative = array();
84
-			if($session_id_field_name != "chamilo_session_id") {
84
+			if ($session_id_field_name != "chamilo_session_id") {
85 85
 				$extras_associative[$session_id_field_name] = $session_id_value;
86 86
 			}
87
-			foreach($extras as $extra) {
87
+			foreach ($extras as $extra) {
88 88
 				$extras_associative[$extra['field_name']] = $extra['field_value'];
89 89
 			}
90 90
 			// Create the extra fields
91
-			foreach($extras_associative as $fname => $fvalue) {
91
+			foreach ($extras_associative as $fname => $fvalue) {
92 92
 				SessionManager::create_session_extra_field($fname, 1, $fname);
93 93
 				SessionManager::update_session_extra_field_value(
94 94
 					$session_id,
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122 122
 		$verifKey = $this->verifyKey($secret_key);
123
-		if($verifKey instanceof WSError) {
123
+		if ($verifKey instanceof WSError) {
124 124
 			$this->handleError($verifKey);
125 125
 		} else {
126 126
 			$session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
-			if($session_id instanceof WSError) {
127
+			if ($session_id instanceof WSError) {
128 128
 				$this->handleError($session_id);
129 129
 			} else {
130 130
 				return $session_id;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143 143
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
-		if($session_id instanceof WSError) {
144
+		if ($session_id instanceof WSError) {
145 145
 			return $session_id;
146 146
 		} else {
147 147
 			SessionManager::delete($session_id, true);
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160 160
 		$verifKey = $this->verifyKey($secret_key);
161
-		if($verifKey instanceof WSError) {
161
+		if ($verifKey instanceof WSError) {
162 162
 			$this->handleError($verifKey);
163 163
 		} else {
164 164
 			$result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
-			if($result instanceof WSError) {
165
+			if ($result instanceof WSError) {
166 166
 				$this->handleError($result);
167 167
 			}
168 168
 		}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         $extras
201 201
     ) {
202 202
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
-		if($session_id instanceof WSError) {
203
+		if ($session_id instanceof WSError) {
204 204
 			return $session_id;
205 205
 		} else {
206 206
 			// Verify that coach exists and get its id
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
             $coachStartDate = null;
213 213
             if (!empty($nb_days_access_before)) {
214 214
                 $day = intval($nb_days_access_before);
215
-                $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
215
+                $coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days'));
216 216
             }
217 217
 
218 218
             $coachEndDate = null;
219 219
             if (!empty($nb_days_access_after)) {
220 220
                 $day = intval($nb_days_access_after);
221
-                $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
221
+                $coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days'));
222 222
             }
223 223
 
224 224
             $result_id = SessionManager::edit_session(
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
                 $coachEndDate,
233 233
                 $user_id,
234 234
                 0,
235
-                (int)$visibility
235
+                (int) $visibility
236 236
             );
237
-			if(!is_int($result_id)) {
237
+			if (!is_int($result_id)) {
238 238
 				return new WSError(302, 'Could not edit the session');
239 239
 			} else {
240
-				if(!empty($extras)) {
240
+				if (!empty($extras)) {
241 241
 					$extras_associative = array();
242
-					foreach($extras as $extra) {
242
+					foreach ($extras as $extra) {
243 243
 						$extras_associative[$extra['field_name']] = $extra['field_value'];
244 244
 					}
245 245
 					// Create the extra fields
246
-					foreach($extras_associative as $fname => $fvalue) {
246
+					foreach ($extras_associative as $fname => $fvalue) {
247 247
 						SessionManager::create_session_extra_field($fname, 1, $fname);
248 248
 						SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249 249
 					}
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274 274
 		$verifKey = $this->verifyKey($secret_key);
275
-		if($verifKey instanceof WSError) {
275
+		if ($verifKey instanceof WSError) {
276 276
 			$this->handleError($verifKey);
277 277
 		} else {
278 278
 			$result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
-			if($session_id_value instanceof WSError) {
279
+			if ($session_id_value instanceof WSError) {
280 280
 				$this->handleError($result);
281 281
 			}
282 282
 		}
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296 296
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
-		if($session_id instanceof WSError) {
297
+		if ($session_id instanceof WSError) {
298 298
 			return $session_id;
299 299
 		} else {
300 300
 			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
-			if($user_id instanceof WSError) {
301
+			if ($user_id instanceof WSError) {
302 302
 				return $user_id;
303 303
 			} else {
304
-				if($state  == 1) {
304
+				if ($state == 1) {
305 305
 					SessionManager::suscribe_users_to_session($session_id, array($user_id));
306 306
 				} else {
307 307
 					$result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	 */
326 326
 	public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327 327
 		$verifKey = $this->verifyKey($secret_key);
328
-		if($verifKey instanceof WSError) {
328
+		if ($verifKey instanceof WSError) {
329 329
 			$this->handleError($verifKey);
330 330
 		} else {
331 331
 			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
-			if($result instanceof WSError) {
332
+			if ($result instanceof WSError) {
333 333
 				$this->handleError($result);
334 334
 			}
335 335
 		}
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
 	 */
347 347
 	public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348 348
 		$verifKey = $this->verifyKey($secret_key);
349
-		if($verifKey instanceof WSError) {
349
+		if ($verifKey instanceof WSError) {
350 350
 			$this->handleError($verifKey);
351 351
 		} else {
352 352
 			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
-			if($result instanceof WSError) {
353
+			if ($result instanceof WSError) {
354 354
 				$this->handleError($result);
355 355
 			}
356 356
 		}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                     if ($state == 1) {
386 386
                         SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id);
387 387
                     } else {
388
-                        $user_id = array (0 => $user_id);
388
+                        $user_id = array(0 => $user_id);
389 389
                         $result = SessionManager::removeUsersFromCourseSession($user_id, $session_id, $course_id);
390 390
                         if (!$result) {
391 391
                             return new WSError(303, 'There was an error unsubscribing this Teacher from the session');
@@ -457,14 +457,14 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459 459
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
-		if($session_id instanceof WSError) {
460
+		if ($session_id instanceof WSError) {
461 461
 			return $session_id;
462 462
 		} else {
463 463
 			$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
-			if($course_id instanceof WSError) {
464
+			if ($course_id instanceof WSError) {
465 465
 				return $course_id;
466 466
 			} else {
467
-				if($state  == 1) {
467
+				if ($state == 1) {
468 468
 					SessionManager::add_courses_to_session($session_id, array($course_id));
469 469
 					return true;
470 470
 				} else {
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 	 */
491 491
 	public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492 492
 		$verifKey = $this->verifyKey($secret_key);
493
-		if($verifKey instanceof WSError) {
493
+		if ($verifKey instanceof WSError) {
494 494
 			$this->handleError($verifKey);
495 495
 		} else {
496 496
 			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
-			if($result instanceof WSError) {
497
+			if ($result instanceof WSError) {
498 498
 				$this->handleError($result);
499 499
 			}
500 500
 		}
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 	 */
512 512
 	public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513 513
 		$verifKey = $this->verifyKey($secret_key);
514
-		if($verifKey instanceof WSError) {
514
+		if ($verifKey instanceof WSError) {
515 515
 			$this->handleError($verifKey);
516 516
 		} else {
517 517
 			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
-			if($result instanceof WSError) {
518
+			if ($result instanceof WSError) {
519 519
 				$this->handleError($result);
520 520
 			}
521 521
 		}
Please login to merge, or discard this patch.
main/webservices/webservice_user.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -36,6 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param array Users
38 38
 	 * @param int Set to 1 to enable and to 0 to disable
39
+	 * @param integer $state
39 40
 	 * @return array Array of results
40 41
 	 */
41 42
 	protected function changeUsersActiveState($users, $state) {
@@ -217,6 +218,11 @@  discard block
 block discarded – undo
217 218
 	 * @param string Phone.
218 219
 	 * @param string Expiration date
219 220
 	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
221
+	 * @param integer|null $visibility
222
+	 * @param string|null $email
223
+	 * @param string|null $language
224
+	 * @param string|null $phone
225
+	 * @param string|null $expiration_date
220 226
 	 * @return mixed New user id generated by the system, WSError otherwise
221 227
 	 */
222 228
 	protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
Please login to merge, or discard this patch.
Indentation   +416 added lines, -416 removed lines patch added patch discarded remove patch
@@ -11,232 +11,232 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class WSUser extends WS {
13 13
 
14
-	/**
15
-	 * Enables or disables a user
16
-	 *
17
-	 * @param string User id field name
18
-	 * @param string User id value
19
-	 * @param int Set to 1 to enable and to 0 to disable
20
-	 */
21
-	protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
22
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
23
-		if($user_id instanceof WSError) {
24
-			return $user_id;
25
-		} else {
26
-			if($state == 0) {
27
-				UserManager::disable($user_id);
28
-			} else if($state == 1) {
29
-				UserManager::enable($user_id);
30
-			}
31
-		}
32
-	}
14
+    /**
15
+     * Enables or disables a user
16
+     *
17
+     * @param string User id field name
18
+     * @param string User id value
19
+     * @param int Set to 1 to enable and to 0 to disable
20
+     */
21
+    protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
22
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
23
+        if($user_id instanceof WSError) {
24
+            return $user_id;
25
+        } else {
26
+            if($state == 0) {
27
+                UserManager::disable($user_id);
28
+            } else if($state == 1) {
29
+                UserManager::enable($user_id);
30
+            }
31
+        }
32
+    }
33 33
 
34
-	/**
35
-	 * Enables or disables multiple users
36
-	 *
37
-	 * @param array Users
38
-	 * @param int Set to 1 to enable and to 0 to disable
39
-	 * @return array Array of results
40
-	 */
41
-	protected function changeUsersActiveState($users, $state) {
42
-		$results = array();
43
-		foreach($users as $user) {
44
-			$result_tmp = array();
45
-			$result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
46
-			$result_tmp['user_id_value'] = $user['user_id_value'];
47
-			if($result_op instanceof WSError) {
48
-				// Return the error in the results
49
-				$result_tmp['result'] = $result_op->toArray();
50
-			} else {
51
-				$result_tmp['result'] = $this->getSuccessfulResult();
52
-			}
53
-			$results[] = $result_tmp;
54
-		}
55
-		return $results;
56
-	}
34
+    /**
35
+     * Enables or disables multiple users
36
+     *
37
+     * @param array Users
38
+     * @param int Set to 1 to enable and to 0 to disable
39
+     * @return array Array of results
40
+     */
41
+    protected function changeUsersActiveState($users, $state) {
42
+        $results = array();
43
+        foreach($users as $user) {
44
+            $result_tmp = array();
45
+            $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
46
+            $result_tmp['user_id_value'] = $user['user_id_value'];
47
+            if($result_op instanceof WSError) {
48
+                // Return the error in the results
49
+                $result_tmp['result'] = $result_op->toArray();
50
+            } else {
51
+                $result_tmp['result'] = $this->getSuccessfulResult();
52
+            }
53
+            $results[] = $result_tmp;
54
+        }
55
+        return $results;
56
+    }
57 57
 
58
-	/**
59
-	 * Disables a user
60
-	 *
61
-	 * @param string API secret key
62
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
63
-	 * @param string User id value
64
-	 */
65
-	public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
66
-		$verifKey = $this->verifyKey($secret_key);
67
-		if($verifKey instanceof WSError) {
68
-			// Let the implementation handle it
69
-			$this->handleError($verifKey);
70
-		} else {
71
-			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
72
-			if($result instanceof WSError) {
73
-				$this->handleError($result);
74
-			}
75
-		}
76
-	}
58
+    /**
59
+     * Disables a user
60
+     *
61
+     * @param string API secret key
62
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
63
+     * @param string User id value
64
+     */
65
+    public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
66
+        $verifKey = $this->verifyKey($secret_key);
67
+        if($verifKey instanceof WSError) {
68
+            // Let the implementation handle it
69
+            $this->handleError($verifKey);
70
+        } else {
71
+            $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
72
+            if($result instanceof WSError) {
73
+                $this->handleError($result);
74
+            }
75
+        }
76
+    }
77 77
 
78
-	/**
79
-	 * Disables multiple users
80
-	 *
81
-	 * @param string API secret key
82
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
83
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
84
-	 * than 0, an error occured
85
-	 */
86
-	public function DisableUsers($secret_key, $users) {
87
-		$verifKey = $this->verifyKey($secret_key);
88
-		if($verifKey instanceof WSError) {
89
-			// Let the implementation handle it
90
-			$this->handleError($verifKey);
91
-		} else {
92
-			return $this->changeUsersActiveState($users, 0);
93
-		}
94
-	}
78
+    /**
79
+     * Disables multiple users
80
+     *
81
+     * @param string API secret key
82
+     * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
83
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
84
+     * than 0, an error occured
85
+     */
86
+    public function DisableUsers($secret_key, $users) {
87
+        $verifKey = $this->verifyKey($secret_key);
88
+        if($verifKey instanceof WSError) {
89
+            // Let the implementation handle it
90
+            $this->handleError($verifKey);
91
+        } else {
92
+            return $this->changeUsersActiveState($users, 0);
93
+        }
94
+    }
95 95
 
96
-	/**
97
-	 * Enables a user
98
-	 *
99
-	 * @param string API secret key
100
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
101
-	 * @param string User id value
102
-	 */
103
-	public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
104
-		$verifKey = $this->verifyKey($secret_key);
105
-		if($verifKey instanceof WSError) {
106
-			$this->handleError($verifKey);
107
-		} else {
108
-			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
109
-			if($result instanceof WSError) {
110
-				$this->handleError($result);
111
-			}
112
-		}
113
-	}
96
+    /**
97
+     * Enables a user
98
+     *
99
+     * @param string API secret key
100
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
101
+     * @param string User id value
102
+     */
103
+    public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
104
+        $verifKey = $this->verifyKey($secret_key);
105
+        if($verifKey instanceof WSError) {
106
+            $this->handleError($verifKey);
107
+        } else {
108
+            $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
109
+            if($result instanceof WSError) {
110
+                $this->handleError($result);
111
+            }
112
+        }
113
+    }
114 114
 
115
-	/**
116
-	 * Enables multiple users
117
-	 *
118
-	 * @param string API secret key
119
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
120
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
121
-	 * than 0, an error occured
122
-	 */
123
-	public function EnableUsers($secret_key, $users) {
124
-		$verifKey = $this->verifyKey($secret_key);
125
-		if($verifKey instanceof WSError) {
126
-			// Let the implementation handle it
127
-			$this->handleError($verifKey);
128
-		} else {
129
-			return $this->changeUsersActiveState($users, 1);
130
-		}
131
-	}
115
+    /**
116
+     * Enables multiple users
117
+     *
118
+     * @param string API secret key
119
+     * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
120
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
121
+     * than 0, an error occured
122
+     */
123
+    public function EnableUsers($secret_key, $users) {
124
+        $verifKey = $this->verifyKey($secret_key);
125
+        if($verifKey instanceof WSError) {
126
+            // Let the implementation handle it
127
+            $this->handleError($verifKey);
128
+        } else {
129
+            return $this->changeUsersActiveState($users, 1);
130
+        }
131
+    }
132 132
 
133
-	/**
134
-	 * Deletes a user (helper method)
135
-	 *
136
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
137
-	 * @param string User id value
138
-	 * @return mixed True if user was successfully deleted, WSError otherwise
139
-	 */
140
-	protected function deleteUserHelper($user_id_field_name, $user_id_value) {
141
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
142
-		if($user_id instanceof WSError) {
143
-			return $user_id;
144
-		} else {
145
-			if(!UserManager::delete_user($user_id)) {
146
-				return new WSError(101, "There was a problem while deleting this user");
147
-			} else {
148
-				return true;
149
-			}
150
-		}
151
-	}
133
+    /**
134
+     * Deletes a user (helper method)
135
+     *
136
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
137
+     * @param string User id value
138
+     * @return mixed True if user was successfully deleted, WSError otherwise
139
+     */
140
+    protected function deleteUserHelper($user_id_field_name, $user_id_value) {
141
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
142
+        if($user_id instanceof WSError) {
143
+            return $user_id;
144
+        } else {
145
+            if(!UserManager::delete_user($user_id)) {
146
+                return new WSError(101, "There was a problem while deleting this user");
147
+            } else {
148
+                return true;
149
+            }
150
+        }
151
+    }
152 152
 
153
-	/**
154
-	 * Deletes a user
155
-	 *
156
-	 * @param string API secret key
157
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
158
-	 * @param string User id value
159
-	 */
160
-	public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
161
-		$verifKey = $this->verifyKey($secret_key);
162
-		if($verifKey instanceof WSError) {
163
-			$this->handleError($verifKey);
164
-		} else {
165
-			$result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
166
-			if($result instanceof WSError) {
167
-				$this->handleError($result);
168
-			}
169
-		}
170
-	}
153
+    /**
154
+     * Deletes a user
155
+     *
156
+     * @param string API secret key
157
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
158
+     * @param string User id value
159
+     */
160
+    public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
161
+        $verifKey = $this->verifyKey($secret_key);
162
+        if($verifKey instanceof WSError) {
163
+            $this->handleError($verifKey);
164
+        } else {
165
+            $result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
166
+            if($result instanceof WSError) {
167
+                $this->handleError($result);
168
+            }
169
+        }
170
+    }
171 171
 
172
-	/**
173
-	 * Deletes multiple users
174
-	 *
175
-	 * @param string API secret key
176
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
177
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
178
-	 * than 0, an error occured
179
-	 */
180
-	public function DeleteUsers($secret_key, $users) {
181
-		$verifKey = $this->verifyKey($secret_key);
182
-		if($verifKey instanceof WSError) {
183
-			$this->handleError($verifKey);
184
-		} else {
185
-			$results = array();
186
-			foreach($users as $user) {
187
-				$result_tmp = array();
188
-				$result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
189
-				$result_tmp['user_id_value'] = $user['user_id_value'];
190
-				if($result_op instanceof WSError) {
191
-					// Return the error in the results
192
-					$result_tmp['result'] = $result_op->toArray();
193
-				} else {
194
-					$result_tmp['result'] = $this->getSuccessfulResult();
195
-				}
196
-				$results[] = $result_tmp;
197
-			}
198
-			return $results;
199
-		}
200
-	}
172
+    /**
173
+     * Deletes multiple users
174
+     *
175
+     * @param string API secret key
176
+     * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
177
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
178
+     * than 0, an error occured
179
+     */
180
+    public function DeleteUsers($secret_key, $users) {
181
+        $verifKey = $this->verifyKey($secret_key);
182
+        if($verifKey instanceof WSError) {
183
+            $this->handleError($verifKey);
184
+        } else {
185
+            $results = array();
186
+            foreach($users as $user) {
187
+                $result_tmp = array();
188
+                $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
189
+                $result_tmp['user_id_value'] = $user['user_id_value'];
190
+                if($result_op instanceof WSError) {
191
+                    // Return the error in the results
192
+                    $result_tmp['result'] = $result_op->toArray();
193
+                } else {
194
+                    $result_tmp['result'] = $this->getSuccessfulResult();
195
+                }
196
+                $results[] = $result_tmp;
197
+            }
198
+            return $results;
199
+        }
200
+    }
201 201
 
202
-	/**
203
-	 * Creates a user (helper method)
204
-	 *
205
-	 * @param string User first name
206
-	 * @param string User last name
207
-	 * @param int User status
208
-	 * @param string Login name
209
-	 * @param string Password (encrypted or not)
210
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
211
-	 * to include the salt in the extra fields if you are encrypting the password
212
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
213
-	 * @param string User id value. Leave blank if you are using the internal user_id
214
-	 * @param int Visibility.
215
-	 * @param string User email.
216
-	 * @param string Language.
217
-	 * @param string Phone.
218
-	 * @param string Expiration date
219
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
220
-	 * @return mixed New user id generated by the system, WSError otherwise
221
-	 */
222
-	protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
202
+    /**
203
+     * Creates a user (helper method)
204
+     *
205
+     * @param string User first name
206
+     * @param string User last name
207
+     * @param int User status
208
+     * @param string Login name
209
+     * @param string Password (encrypted or not)
210
+     * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
211
+     * to include the salt in the extra fields if you are encrypting the password
212
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
213
+     * @param string User id value. Leave blank if you are using the internal user_id
214
+     * @param int Visibility.
215
+     * @param string User email.
216
+     * @param string Language.
217
+     * @param string Phone.
218
+     * @param string Expiration date
219
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
220
+     * @return mixed New user id generated by the system, WSError otherwise
221
+     */
222
+    protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
223 223
 
224
-		// Add the original user id field name and value to the extra fields if needed
225
-		$extras_associative = array();
226
-		if($user_id_field_name != "chamilo_user_id") {
227
-			$extras_associative[$user_id_field_name] = $user_id_value;
228
-		}
224
+        // Add the original user id field name and value to the extra fields if needed
225
+        $extras_associative = array();
226
+        if($user_id_field_name != "chamilo_user_id") {
227
+            $extras_associative[$user_id_field_name] = $user_id_value;
228
+        }
229 229
                 if (!empty($extras)) {
230 230
                     foreach($extras as $extra) {
231 231
                         $extras_associative[$extra['field_name']] = $extra['field_value'];
232 232
                     }
233 233
                 }
234
-		$result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
235
-		if (!$result) {
234
+        $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
235
+        if (!$result) {
236 236
 
237
-		    return new WSError(104, 'There was an error creating the user');
237
+            return new WSError(104, 'There was an error creating the user');
238 238
 
239
-			/*$failure = $api_failureList[0];
239
+            /*$failure = $api_failureList[0];
240 240
 			if($failure == 'login-pass already taken') {
241 241
 				return new WSError(102, 'This username is already taken');
242 242
 			} else if($failure == 'encrypt_method invalid') {
@@ -244,227 +244,227 @@  discard block
 block discarded – undo
244 244
 			} else {
245 245
 				return new WSError(104, 'There was an error creating the user');
246 246
 			}*/
247
-		} else {
248
-			return $result;
249
-		}
250
-	}
247
+        } else {
248
+            return $result;
249
+        }
250
+    }
251 251
 
252
-	/**
253
-	 * Creates a user
254
-	 *
255
-	 * @param string API secret key
256
-	 * @param string User first name
257
-	 * @param string User last name
258
-	 * @param int User status
259
-	 * @param string Login name
260
-	 * @param string Password (encrypted or not)
261
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
262
-	 * to include the salt in the extra fields if you are encrypting the password
263
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
264
-	 * @param string User id value. Leave blank if you are using the internal user_id
265
-	 * @param int Visibility. Set by default to 1
266
-	 * @param string User email. Set by default to an empty string
267
-	 * @param string Language. Set by default to english
268
-	 * @param string Phone. Set by default to an empty string
269
-	 * @param string Expiration date. Set to null by default
270
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default
271
-	 * @return int New user id generated by the system
272
-	 */
273
-	public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
274
-		// First, verify the secret key
275
-		$verifKey = $this->verifyKey($secret_key);
276
-		if($verifKey instanceof WSError) {
277
-			$this->handleError($verifKey);
278
-		} else {
279
-			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
280
-			if($result instanceof WSError) {
281
-				$this->handleError($result);
282
-			} else {
283
-				return $result;
284
-			}
285
-		}
286
-	}
252
+    /**
253
+     * Creates a user
254
+     *
255
+     * @param string API secret key
256
+     * @param string User first name
257
+     * @param string User last name
258
+     * @param int User status
259
+     * @param string Login name
260
+     * @param string Password (encrypted or not)
261
+     * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
262
+     * to include the salt in the extra fields if you are encrypting the password
263
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
264
+     * @param string User id value. Leave blank if you are using the internal user_id
265
+     * @param int Visibility. Set by default to 1
266
+     * @param string User email. Set by default to an empty string
267
+     * @param string Language. Set by default to english
268
+     * @param string Phone. Set by default to an empty string
269
+     * @param string Expiration date. Set to null by default
270
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default
271
+     * @return int New user id generated by the system
272
+     */
273
+    public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
274
+        // First, verify the secret key
275
+        $verifKey = $this->verifyKey($secret_key);
276
+        if($verifKey instanceof WSError) {
277
+            $this->handleError($verifKey);
278
+        } else {
279
+            $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
280
+            if($result instanceof WSError) {
281
+                $this->handleError($result);
282
+            } else {
283
+                return $result;
284
+            }
285
+        }
286
+    }
287 287
 
288
-	/**
289
-	 * Creates multiple users
290
-	 *
291
-	 * @param string API secret key
292
-	 * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
293
-	 * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
294
-	 */
295
-	public function CreateUsers($secret_key, $users) {
296
-		$verifKey = $this->verifyKey($secret_key);
297
-		if($verifKey instanceof WSError) {
298
-			$this->handleError($verifKey);
299
-		} else {
300
-			$results = array();
301
-			foreach($users as $user) {
302
-				$result_tmp = array();
288
+    /**
289
+     * Creates multiple users
290
+     *
291
+     * @param string API secret key
292
+     * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
293
+     * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
294
+     */
295
+    public function CreateUsers($secret_key, $users) {
296
+        $verifKey = $this->verifyKey($secret_key);
297
+        if($verifKey instanceof WSError) {
298
+            $this->handleError($verifKey);
299
+        } else {
300
+            $results = array();
301
+            foreach($users as $user) {
302
+                $result_tmp = array();
303 303
                 // re-initialize variables just in case
304 304
                 $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null;
305
-				extract($user);
306
-				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
307
-				if($result instanceof WSError) {
308
-					$result_tmp['result'] = $result->toArray();
309
-					$result_tmp['user_id_value'] = $user_id_value;
310
-					$result_tmp['user_id_generated'] = 0;
311
-				} else {
312
-					$result_tmp['result'] = $this->getSuccessfulResult();
313
-					$result_tmp['user_id_value'] = $user_id_value;
314
-					$result_tmp['user_id_generated'] = $result;
315
-				}
316
-				$results[] = $result_tmp;
317
-			}
318
-			return $results;
319
-		}
320
-	}
305
+                extract($user);
306
+                $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
307
+                if($result instanceof WSError) {
308
+                    $result_tmp['result'] = $result->toArray();
309
+                    $result_tmp['user_id_value'] = $user_id_value;
310
+                    $result_tmp['user_id_generated'] = 0;
311
+                } else {
312
+                    $result_tmp['result'] = $this->getSuccessfulResult();
313
+                    $result_tmp['user_id_value'] = $user_id_value;
314
+                    $result_tmp['user_id_generated'] = $result;
315
+                }
316
+                $results[] = $result_tmp;
317
+            }
318
+            return $results;
319
+        }
320
+    }
321 321
 
322
-	/**
323
-	 * Edits user info (helper method)
324
-	 *
325
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
326
-	 * @param string User id value
327
-	 * @param string First name
328
-	 * @param string Last name
329
-	 * @param int User status
330
-	 * @param string Login name
331
-	 * @param string Password. Leave blank if you don't want to update it
332
-	 * @param string Encrypt method
333
-	 * @param string User email
334
-	 * @param string Language. Set by default to english
335
-	 * @param string Phone. Set by default to an empty string
336
-	 * @param string Expiration date. Set to null by default
337
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
338
-	 * @return mixed True if user was successfully updated, WSError otherwise
339
-	 */
340
-	protected function editUserHelper(
341
-		$user_id_field_name,
342
-		$user_id_value,
343
-		$firstname,
344
-		$lastname,
345
-		$status,
346
-		$loginname,
347
-		$password,
348
-		$encrypt_method,
349
-		$email,
350
-		$language,
351
-		$phone,
352
-		$expiration_date,
353
-		$extras
354
-	) {
355
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
356
-		if($user_id instanceof WSError) {
357
-			return $user_id;
358
-		} else {
359
-			if($password == '') {
360
-				$password = null;
361
-			}
362
-			$user_info = api_get_user_info($user_id);
363
-			if (count($extras) == 0) {
364
-				$extras = null;
365
-			}
322
+    /**
323
+     * Edits user info (helper method)
324
+     *
325
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
326
+     * @param string User id value
327
+     * @param string First name
328
+     * @param string Last name
329
+     * @param int User status
330
+     * @param string Login name
331
+     * @param string Password. Leave blank if you don't want to update it
332
+     * @param string Encrypt method
333
+     * @param string User email
334
+     * @param string Language. Set by default to english
335
+     * @param string Phone. Set by default to an empty string
336
+     * @param string Expiration date. Set to null by default
337
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
338
+     * @return mixed True if user was successfully updated, WSError otherwise
339
+     */
340
+    protected function editUserHelper(
341
+        $user_id_field_name,
342
+        $user_id_value,
343
+        $firstname,
344
+        $lastname,
345
+        $status,
346
+        $loginname,
347
+        $password,
348
+        $encrypt_method,
349
+        $email,
350
+        $language,
351
+        $phone,
352
+        $expiration_date,
353
+        $extras
354
+    ) {
355
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
356
+        if($user_id instanceof WSError) {
357
+            return $user_id;
358
+        } else {
359
+            if($password == '') {
360
+                $password = null;
361
+            }
362
+            $user_info = api_get_user_info($user_id);
363
+            if (count($extras) == 0) {
364
+                $extras = null;
365
+            }
366 366
 
367
-			$result = UserManager::update_user(
368
-				$user_id,
369
-				$firstname,
370
-				$lastname,
371
-				$loginname,
372
-				$password,
373
-				PLATFORM_AUTH_SOURCE,
374
-				$email,
375
-				$status,
376
-				'',
377
-				$phone,
378
-				$user_info['picture_uri'],
379
-				$expiration_date,
380
-				$user_info['active'],
381
-				null,
382
-				$user_info['hr_dept_id'],
383
-				$extras,
384
-				$encrypt_method
385
-			);
386
-			if (!$result) {
387
-				/*if($failure == 'encrypt_method invalid') {
367
+            $result = UserManager::update_user(
368
+                $user_id,
369
+                $firstname,
370
+                $lastname,
371
+                $loginname,
372
+                $password,
373
+                PLATFORM_AUTH_SOURCE,
374
+                $email,
375
+                $status,
376
+                '',
377
+                $phone,
378
+                $user_info['picture_uri'],
379
+                $expiration_date,
380
+                $user_info['active'],
381
+                null,
382
+                $user_info['hr_dept_id'],
383
+                $extras,
384
+                $encrypt_method
385
+            );
386
+            if (!$result) {
387
+                /*if($failure == 'encrypt_method invalid') {
388 388
 					return new WSError(103, 'The encryption of the password is invalid');
389 389
 				} else {
390 390
 					return new WSError(105, 'There was an error updating the user');
391 391
 				}*/
392
-				return new WSError(105, 'There was an error updating the user');
393
-			} else {
394
-				return $result;
395
-			}
396
-		}
397
-	}
392
+                return new WSError(105, 'There was an error updating the user');
393
+            } else {
394
+                return $result;
395
+            }
396
+        }
397
+    }
398 398
 
399
-	/**
400
-	 * Edits user info
401
-	 *
402
-	 * @param string API secret key
403
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
404
-	 * @param string User id value
405
-	 * @param string First name
406
-	 * @param string Last name
407
-	 * @param int User status
408
-	 * @param string Login name
409
-	 * @param string Password. Leave blank if you don't want to update it
410
-	 * @param string Encrypt method
411
-	 * @param string User email
412
-	 * @param string Language. Set by default to english
413
-	 * @param string Phone. Set by default to an empty string
414
-	 * @param string Expiration date. Set to null by default
415
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
416
-	 */
417
-	public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
418
-		// First, verify the secret key
419
-		$verifKey = $this->verifyKey($secret_key);
420
-		if($verifKey instanceof WSError) {
421
-			$this->handleError($verifKey);
422
-		} else {
399
+    /**
400
+     * Edits user info
401
+     *
402
+     * @param string API secret key
403
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
404
+     * @param string User id value
405
+     * @param string First name
406
+     * @param string Last name
407
+     * @param int User status
408
+     * @param string Login name
409
+     * @param string Password. Leave blank if you don't want to update it
410
+     * @param string Encrypt method
411
+     * @param string User email
412
+     * @param string Language. Set by default to english
413
+     * @param string Phone. Set by default to an empty string
414
+     * @param string Expiration date. Set to null by default
415
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
416
+     */
417
+    public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
418
+        // First, verify the secret key
419
+        $verifKey = $this->verifyKey($secret_key);
420
+        if($verifKey instanceof WSError) {
421
+            $this->handleError($verifKey);
422
+        } else {
423 423
 
424
-			$extras_associative = array();
425
-			if (!empty($extras)) {
426
-				foreach($extras as $extra) {
427
-					$extras_associative[$extra['field_name']] = $extra['field_value'];
428
-				}
429
-			}
424
+            $extras_associative = array();
425
+            if (!empty($extras)) {
426
+                foreach($extras as $extra) {
427
+                    $extras_associative[$extra['field_name']] = $extra['field_value'];
428
+                }
429
+            }
430 430
 
431
-			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
432
-			if($result instanceof WSError) {
433
-				$this->handleError($result);
434
-			}
435
-		}
436
-	}
431
+            $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
432
+            if($result instanceof WSError) {
433
+                $this->handleError($result);
434
+            }
435
+        }
436
+    }
437 437
 
438
-	/**
439
-	 * Edits multiple users
440
-	 *
441
-	 * @param string API secret key
442
-	 * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
443
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
444
-	 * than 0, an error occured
445
-	 */
446
-	public function EditUsers($secret_key, $users) {
447
-		$verifKey = $this->verifyKey($secret_key);
448
-		if($verifKey instanceof WSError) {
449
-			$this->handleError($verifKey);
450
-		} else {
451
-			$results = array();
452
-			foreach($users as $user) {
453
-				$result_tmp = array();
438
+    /**
439
+     * Edits multiple users
440
+     *
441
+     * @param string API secret key
442
+     * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
443
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
444
+     * than 0, an error occured
445
+     */
446
+    public function EditUsers($secret_key, $users) {
447
+        $verifKey = $this->verifyKey($secret_key);
448
+        if($verifKey instanceof WSError) {
449
+            $this->handleError($verifKey);
450
+        } else {
451
+            $results = array();
452
+            foreach($users as $user) {
453
+                $result_tmp = array();
454 454
                 // re-initialize variables just in case
455 455
                 $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null;
456
-				extract($user);
457
-				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
458
-				$result_tmp['user_id_value'] = $user['user_id_value'];
459
-				if($result_op instanceof WSError) {
460
-					// Return the error in the results
461
-					$result_tmp['result'] = $result_op->toArray();
462
-				} else {
463
-					$result_tmp['result'] = $this->getSuccessfulResult();
464
-				}
465
-				$results[] = $result_tmp;
466
-			}
467
-			return $results;
468
-		}
469
-	}
456
+                extract($user);
457
+                $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
458
+                $result_tmp['user_id_value'] = $user['user_id_value'];
459
+                if($result_op instanceof WSError) {
460
+                    // Return the error in the results
461
+                    $result_tmp['result'] = $result_op->toArray();
462
+                } else {
463
+                    $result_tmp['result'] = $this->getSuccessfulResult();
464
+                }
465
+                $results[] = $result_tmp;
466
+            }
467
+            return $results;
468
+        }
469
+    }
470 470
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
22 22
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
23
-		if($user_id instanceof WSError) {
23
+		if ($user_id instanceof WSError) {
24 24
 			return $user_id;
25 25
 		} else {
26
-			if($state == 0) {
26
+			if ($state == 0) {
27 27
 				UserManager::disable($user_id);
28
-			} else if($state == 1) {
28
+			} else if ($state == 1) {
29 29
 				UserManager::enable($user_id);
30 30
 			}
31 31
 		}
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	protected function changeUsersActiveState($users, $state) {
42 42
 		$results = array();
43
-		foreach($users as $user) {
43
+		foreach ($users as $user) {
44 44
 			$result_tmp = array();
45 45
 			$result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
46 46
 			$result_tmp['user_id_value'] = $user['user_id_value'];
47
-			if($result_op instanceof WSError) {
47
+			if ($result_op instanceof WSError) {
48 48
 				// Return the error in the results
49 49
 				$result_tmp['result'] = $result_op->toArray();
50 50
 			} else {
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
66 66
 		$verifKey = $this->verifyKey($secret_key);
67
-		if($verifKey instanceof WSError) {
67
+		if ($verifKey instanceof WSError) {
68 68
 			// Let the implementation handle it
69 69
 			$this->handleError($verifKey);
70 70
 		} else {
71 71
 			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
72
-			if($result instanceof WSError) {
72
+			if ($result instanceof WSError) {
73 73
 				$this->handleError($result);
74 74
 			}
75 75
 		}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function DisableUsers($secret_key, $users) {
87 87
 		$verifKey = $this->verifyKey($secret_key);
88
-		if($verifKey instanceof WSError) {
88
+		if ($verifKey instanceof WSError) {
89 89
 			// Let the implementation handle it
90 90
 			$this->handleError($verifKey);
91 91
 		} else {
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
104 104
 		$verifKey = $this->verifyKey($secret_key);
105
-		if($verifKey instanceof WSError) {
105
+		if ($verifKey instanceof WSError) {
106 106
 			$this->handleError($verifKey);
107 107
 		} else {
108 108
 			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
109
-			if($result instanceof WSError) {
109
+			if ($result instanceof WSError) {
110 110
 				$this->handleError($result);
111 111
 			}
112 112
 		}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function EnableUsers($secret_key, $users) {
124 124
 		$verifKey = $this->verifyKey($secret_key);
125
-		if($verifKey instanceof WSError) {
125
+		if ($verifKey instanceof WSError) {
126 126
 			// Let the implementation handle it
127 127
 			$this->handleError($verifKey);
128 128
 		} else {
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	protected function deleteUserHelper($user_id_field_name, $user_id_value) {
141 141
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
142
-		if($user_id instanceof WSError) {
142
+		if ($user_id instanceof WSError) {
143 143
 			return $user_id;
144 144
 		} else {
145
-			if(!UserManager::delete_user($user_id)) {
145
+			if (!UserManager::delete_user($user_id)) {
146 146
 				return new WSError(101, "There was a problem while deleting this user");
147 147
 			} else {
148 148
 				return true;
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
161 161
 		$verifKey = $this->verifyKey($secret_key);
162
-		if($verifKey instanceof WSError) {
162
+		if ($verifKey instanceof WSError) {
163 163
 			$this->handleError($verifKey);
164 164
 		} else {
165 165
 			$result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
166
-			if($result instanceof WSError) {
166
+			if ($result instanceof WSError) {
167 167
 				$this->handleError($result);
168 168
 			}
169 169
 		}
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	public function DeleteUsers($secret_key, $users) {
181 181
 		$verifKey = $this->verifyKey($secret_key);
182
-		if($verifKey instanceof WSError) {
182
+		if ($verifKey instanceof WSError) {
183 183
 			$this->handleError($verifKey);
184 184
 		} else {
185 185
 			$results = array();
186
-			foreach($users as $user) {
186
+			foreach ($users as $user) {
187 187
 				$result_tmp = array();
188 188
 				$result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
189 189
 				$result_tmp['user_id_value'] = $user['user_id_value'];
190
-				if($result_op instanceof WSError) {
190
+				if ($result_op instanceof WSError) {
191 191
 					// Return the error in the results
192 192
 					$result_tmp['result'] = $result_op->toArray();
193 193
 				} else {
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
 
224 224
 		// Add the original user id field name and value to the extra fields if needed
225 225
 		$extras_associative = array();
226
-		if($user_id_field_name != "chamilo_user_id") {
226
+		if ($user_id_field_name != "chamilo_user_id") {
227 227
 			$extras_associative[$user_id_field_name] = $user_id_value;
228 228
 		}
229 229
                 if (!empty($extras)) {
230
-                    foreach($extras as $extra) {
230
+                    foreach ($extras as $extra) {
231 231
                         $extras_associative[$extra['field_name']] = $extra['field_value'];
232 232
                     }
233 233
                 }
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
 	public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
274 274
 		// First, verify the secret key
275 275
 		$verifKey = $this->verifyKey($secret_key);
276
-		if($verifKey instanceof WSError) {
276
+		if ($verifKey instanceof WSError) {
277 277
 			$this->handleError($verifKey);
278 278
 		} else {
279 279
 			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
280
-			if($result instanceof WSError) {
280
+			if ($result instanceof WSError) {
281 281
 				$this->handleError($result);
282 282
 			} else {
283 283
 				return $result;
@@ -294,17 +294,17 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	public function CreateUsers($secret_key, $users) {
296 296
 		$verifKey = $this->verifyKey($secret_key);
297
-		if($verifKey instanceof WSError) {
297
+		if ($verifKey instanceof WSError) {
298 298
 			$this->handleError($verifKey);
299 299
 		} else {
300 300
 			$results = array();
301
-			foreach($users as $user) {
301
+			foreach ($users as $user) {
302 302
 				$result_tmp = array();
303 303
                 // re-initialize variables just in case
304 304
                 $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null;
305 305
 				extract($user);
306 306
 				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
307
-				if($result instanceof WSError) {
307
+				if ($result instanceof WSError) {
308 308
 					$result_tmp['result'] = $result->toArray();
309 309
 					$result_tmp['user_id_value'] = $user_id_value;
310 310
 					$result_tmp['user_id_generated'] = 0;
@@ -353,10 +353,10 @@  discard block
 block discarded – undo
353 353
 		$extras
354 354
 	) {
355 355
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
356
-		if($user_id instanceof WSError) {
356
+		if ($user_id instanceof WSError) {
357 357
 			return $user_id;
358 358
 		} else {
359
-			if($password == '') {
359
+			if ($password == '') {
360 360
 				$password = null;
361 361
 			}
362 362
 			$user_info = api_get_user_info($user_id);
@@ -417,19 +417,19 @@  discard block
 block discarded – undo
417 417
 	public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
418 418
 		// First, verify the secret key
419 419
 		$verifKey = $this->verifyKey($secret_key);
420
-		if($verifKey instanceof WSError) {
420
+		if ($verifKey instanceof WSError) {
421 421
 			$this->handleError($verifKey);
422 422
 		} else {
423 423
 
424 424
 			$extras_associative = array();
425 425
 			if (!empty($extras)) {
426
-				foreach($extras as $extra) {
426
+				foreach ($extras as $extra) {
427 427
 					$extras_associative[$extra['field_name']] = $extra['field_value'];
428 428
 				}
429 429
 			}
430 430
 
431 431
 			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
432
-			if($result instanceof WSError) {
432
+			if ($result instanceof WSError) {
433 433
 				$this->handleError($result);
434 434
 			}
435 435
 		}
@@ -445,18 +445,18 @@  discard block
 block discarded – undo
445 445
 	 */
446 446
 	public function EditUsers($secret_key, $users) {
447 447
 		$verifKey = $this->verifyKey($secret_key);
448
-		if($verifKey instanceof WSError) {
448
+		if ($verifKey instanceof WSError) {
449 449
 			$this->handleError($verifKey);
450 450
 		} else {
451 451
 			$results = array();
452
-			foreach($users as $user) {
452
+			foreach ($users as $user) {
453 453
 				$result_tmp = array();
454 454
                 // re-initialize variables just in case
455 455
                 $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null;
456 456
 				extract($user);
457 457
 				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
458 458
 				$result_tmp['user_id_value'] = $user['user_id_value'];
459
-				if($result_op instanceof WSError) {
459
+				if ($result_op instanceof WSError) {
460 460
 					// Return the error in the results
461 461
 					$result_tmp['result'] = $result_op->toArray();
462 462
 				} else {
Please login to merge, or discard this patch.
main/work/downloadfolder.inc.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@
 block discarded – undo
212 212
  * @param array $arr1 first array
213 213
  * @param array $arr2 second array
214 214
  *
215
- * @return array difference between the two arrays
215
+ * @return string difference between the two arrays
216 216
  */
217 217
 function diff($arr1, $arr2)
218 218
 {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 $work_id = $_GET['id'];
11 11
 require_once '../inc/global.inc.php';
12
-$current_course_tool  = TOOL_STUDENTPUBLICATION;
12
+$current_course_tool = TOOL_STUDENTPUBLICATION;
13 13
 $_course = api_get_course_info();
14 14
 
15 15
 // Protection
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 if (!empty($files)) {
179 179
     $fileName = api_replace_dangerous_char($work_data['title']);
180 180
     // Logging
181
-    Event::event_download($fileName .'.zip (folder)');
181
+    Event::event_download($fileName.'.zip (folder)');
182 182
 
183 183
     //start download of created file
184
-    $name = $fileName .'.zip';
184
+    $name = $fileName.'.zip';
185 185
     if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) {
186 186
         DocumentManager::file_send_for_download($temp_zip_file, true, $name);
187 187
         @unlink($temp_zip_file);
Please login to merge, or discard this patch.
plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php 3 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
      * Register a user into a queue for a session
371 371
      * @param $userId
372 372
      * @param $sessionId
373
-     * @return bool|int
373
+     * @return false|string
374 374
      */
375 375
     public function addToQueue($userId, $sessionId)
376 376
     {
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
      * Register message with type and status
397 397
      * @param $mailId
398 398
      * @param $userId
399
-     * @param $sessionId
399
+     * @param integer $sessionId
400 400
      * @return bool|int
401 401
      */
402 402
     public function saveLastMessage($mailId, $userId, $sessionId)
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 
510 510
     /**
511 511
      * Check if session is open for subscription
512
-     * @param $sessionId
512
+     * @param integer $sessionId
513 513
      * @param string $fieldVariable
514 514
      * @return bool
515 515
      */
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 
532 532
     /**
533 533
      * Check if user is in the session's target group based on its area
534
-     * @param $userId
535
-     * @param $sessionId
534
+     * @param integer $userId
535
+     * @param integer $sessionId
536 536
      * @param string $userFieldVariable
537 537
      * @param string $sessionFieldVariable
538 538
      * @return bool
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
     /**
1003 1003
      * Return the session details data from a session ID (including the extra
1004 1004
      * fields used for the advanced subscription mechanism)
1005
-     * @param $sessionId
1005
+     * @param integer $sessionId
1006 1006
      * @return bool|mixed
1007 1007
      */
1008 1008
     public function getSessionDetails($sessionId)
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 
1103 1103
     /**
1104 1104
      * Return the url to go to session
1105
-     * @param $sessionId
1105
+     * @param integer $sessionId
1106 1106
      *
1107 1107
      * @return string
1108 1108
      */
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1069,7 +1069,7 @@
 block discarded – undo
1069 1069
      */
1070 1070
     public function getStatusMessage($status, $isAble = true)
1071 1071
     {
1072
-	$message = '';
1072
+    $message = '';
1073 1073
         switch ($status) {
1074 1074
             case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE:
1075 1075
                 if ($isAble) {
Please login to merge, or discard this patch.
Spacing   +41 added lines, -42 removed lines patch added patch discarded remove patch
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $advancedSubscriptionQueueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE);
108 108
 
109
-        $sql = "CREATE TABLE IF NOT EXISTS $advancedSubscriptionQueueTable (" .
110
-            "id int UNSIGNED NOT NULL AUTO_INCREMENT, " .
111
-            "session_id int UNSIGNED NOT NULL, " .
112
-            "user_id int UNSIGNED NOT NULL, " .
113
-            "status int UNSIGNED NOT NULL, " .
114
-            "last_message_id int UNSIGNED NOT NULL, " .
115
-            "created_at datetime NOT NULL, " .
116
-            "updated_at datetime NULL, " .
117
-            "PRIMARY KEY PK_advanced_subscription_queue (id), " .
109
+        $sql = "CREATE TABLE IF NOT EXISTS $advancedSubscriptionQueueTable (".
110
+            "id int UNSIGNED NOT NULL AUTO_INCREMENT, ".
111
+            "session_id int UNSIGNED NOT NULL, ".
112
+            "user_id int UNSIGNED NOT NULL, ".
113
+            "status int UNSIGNED NOT NULL, ".
114
+            "last_message_id int UNSIGNED NOT NULL, ".
115
+            "created_at datetime NOT NULL, ".
116
+            "updated_at datetime NULL, ".
117
+            "PRIMARY KEY PK_advanced_subscription_queue (id), ".
118 118
             "UNIQUE KEY UK_advanced_subscription_queue (user_id, session_id)); ";
119 119
         Database::query($sql);
120 120
     }
@@ -265,11 +265,10 @@  discard block
 block discarded – undo
265 265
         $now = new DateTime(api_get_utc_datetime());
266 266
         $newYearDate = $plugin->get('course_session_credit_year_start_date');
267 267
         $newYearDate = !empty($newYearDate) ?
268
-            new \DateTime($newYearDate . $now->format('/Y')) :
269
-            $now;
268
+            new \DateTime($newYearDate.$now->format('/Y')) : $now;
270 269
         $extra = new ExtraFieldValue('session');
271
-        $joinSessionTable = Database::get_main_table(TABLE_MAIN_SESSION_USER) . ' su INNER JOIN ' .
272
-            Database::get_main_table(TABLE_MAIN_SESSION) . ' s ON s.id = su.session_id';
270
+        $joinSessionTable = Database::get_main_table(TABLE_MAIN_SESSION_USER).' su INNER JOIN '.
271
+            Database::get_main_table(TABLE_MAIN_SESSION).' s ON s.id = su.session_id';
273 272
         $whereSessionParams = 'su.relation_type = ? AND s.access_start_date >= ? AND su.user_id = ?';
274 273
         $whereSessionParamsValues = array(
275 274
             0,
@@ -734,14 +733,14 @@  discard block
 block discarded – undo
734 733
                     $tpl->assign('termsContent', $termsAndConditions);
735 734
                     $termsAndConditions = $tpl->fetch('/advanced_subscription/views/terms_and_conditions_to_pdf.tpl');
736 735
                     $pdf = new PDF();
737
-                    $filename = 'terms' . sha1(rand(0,99999));
736
+                    $filename = 'terms'.sha1(rand(0, 99999));
738 737
                     $pdf->content_to_pdf($termsAndConditions, null, $filename, null, 'F');
739 738
                     $fileAttachments['file'][] = array(
740
-                        'name' => $filename . '.pdf',
741
-                        'application/pdf' => $filename . '.pdf',
742
-                        'tmp_name' => api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf',
739
+                        'name' => $filename.'.pdf',
740
+                        'application/pdf' => $filename.'.pdf',
741
+                        'tmp_name' => api_get_path(SYS_ARCHIVE_PATH).$filename.'.pdf',
743 742
                         'error' => UPLOAD_ERR_OK,
744
-                        'size' => filesize(api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf'),
743
+                        'size' => filesize(api_get_path(SYS_ARCHIVE_PATH).$filename.'.pdf'),
745 744
                     );
746 745
                     $fileAttachments['comments'][] = get_lang('TermsAndConditions');
747 746
                 }
@@ -1032,7 +1031,7 @@  discard block
 block discarded – undo
1032 1031
 
1033 1032
             $mergedArray = array_merge(array($sessionId), array_keys($fields));
1034 1033
 
1035
-            $sql = "SELECT * FROM " . Database::get_main_table(TABLE_EXTRA_FIELD_VALUES) ."
1034
+            $sql = "SELECT * FROM ".Database::get_main_table(TABLE_EXTRA_FIELD_VALUES)."
1036 1035
                     WHERE item_id = %d AND field_id IN (%d, %d, %d, %d, %d, %d, %d)";
1037 1036
             $sql = vsprintf($sql, $mergedArray);
1038 1037
             $sessionFieldValueList = Database::query($sql);
@@ -1048,10 +1047,10 @@  discard block
 block discarded – undo
1048 1047
             $sessionArray['description'] = SessionManager::getDescriptionFromSessionId($sessionId);
1049 1048
 
1050 1049
             if (isset($sessionArray['brochure'])) {
1051
-                $sessionArray['brochure'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['brochure'];
1050
+                $sessionArray['brochure'] = api_get_path(WEB_UPLOAD_PATH).$sessionArray['brochure'];
1052 1051
             }
1053 1052
             if (isset($sessionArray['banner'])) {
1054
-                $sessionArray['banner'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['banner'];
1053
+                $sessionArray['banner'] = api_get_path(WEB_UPLOAD_PATH).$sessionArray['banner'];
1055 1054
             }
1056 1055
 
1057 1056
             return $sessionArray;
@@ -1108,7 +1107,7 @@  discard block
 block discarded – undo
1108 1107
      */
1109 1108
     public function getSessionUrl($sessionId)
1110 1109
     {
1111
-        $url = api_get_path(WEB_CODE_PATH) . 'session/?session_id=' . intval($sessionId);
1110
+        $url = api_get_path(WEB_CODE_PATH).'session/?session_id='.intval($sessionId);
1112 1111
 
1113 1112
         return $url;
1114 1113
     }
@@ -1157,16 +1156,16 @@  discard block
 block discarded – undo
1157 1156
      */
1158 1157
     public function getQueueUrl($params)
1159 1158
     {
1160
-        $url = api_get_path(WEB_PLUGIN_PATH) . 'advanced_subscription/ajax/advanced_subscription.ajax.php?' .
1161
-            'a=' . Security::remove_XSS($params['action']) . '&' .
1162
-            's=' . intval($params['sessionId']) . '&' .
1163
-            'current_user_id=' . intval($params['currentUserId']) . '&' .
1164
-            'e=' . intval($params['newStatus']) . '&' .
1165
-            'u=' . intval($params['studentUserId']) . '&' .
1166
-            'q=' . intval($params['queueId']) . '&' .
1167
-            'is_connected=' . 1 . '&' .
1168
-            'profile_completed=' . intval($params['profile_completed']) . '&' .
1169
-            'v=' . $this->generateHash($params);
1159
+        $url = api_get_path(WEB_PLUGIN_PATH).'advanced_subscription/ajax/advanced_subscription.ajax.php?'.
1160
+            'a='.Security::remove_XSS($params['action']).'&'.
1161
+            's='.intval($params['sessionId']).'&'.
1162
+            'current_user_id='.intval($params['currentUserId']).'&'.
1163
+            'e='.intval($params['newStatus']).'&'.
1164
+            'u='.intval($params['studentUserId']).'&'.
1165
+            'q='.intval($params['queueId']).'&'.
1166
+            'is_connected='.1.'&'.
1167
+            'profile_completed='.intval($params['profile_completed']).'&'.
1168
+            'v='.$this->generateHash($params);
1170 1169
 
1171 1170
         return $url;
1172 1171
     }
@@ -1219,7 +1218,7 @@  discard block
 block discarded – undo
1219 1218
         }
1220 1219
         $queueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE);
1221 1220
         $userTable = Database::get_main_table(TABLE_MAIN_USER);
1222
-        $userJoinTable = $queueTable . ' q INNER JOIN ' . $userTable . ' u ON q.user_id = u.user_id';
1221
+        $userJoinTable = $queueTable.' q INNER JOIN '.$userTable.' u ON q.user_id = u.user_id';
1223 1222
         $where = array(
1224 1223
             'where' => array(
1225 1224
                 'q.session_id = ?' => array(
@@ -1232,7 +1231,7 @@  discard block
 block discarded – undo
1232 1231
         $students = Database::select($select, $userJoinTable, $where);
1233 1232
         foreach ($students as &$student) {
1234 1233
             $status = intval($student['status']);
1235
-            switch($status) {
1234
+            switch ($status) {
1236 1235
                 case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE:
1237 1236
                 case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_START:
1238 1237
                     $student['validation'] = '';
@@ -1246,7 +1245,7 @@  discard block
 block discarded – undo
1246 1245
                     $student['validation'] = 'Yes';
1247 1246
                     break;
1248 1247
                 default:
1249
-                    error_log(__FILE__ . ' ' . __FUNCTION__ . ' Student status no detected');
1248
+                    error_log(__FILE__.' '.__FUNCTION__.' Student status no detected');
1250 1249
             }
1251 1250
         }
1252 1251
         $return = array(
@@ -1295,7 +1294,7 @@  discard block
 block discarded – undo
1295 1294
         $dataPrepared['queueId'] = intval($data['queueId']);
1296 1295
         $dataPrepared['newStatus'] = intval($data['newStatus']);
1297 1296
         $dataPrepared = serialize($dataPrepared);
1298
-        return sha1($dataPrepared . $key);
1297
+        return sha1($dataPrepared.$key);
1299 1298
     }
1300 1299
 
1301 1300
     /**
@@ -1350,12 +1349,12 @@  discard block
 block discarded – undo
1350 1349
                 break;
1351 1350
         }
1352 1351
 
1353
-        $url = api_get_path(WEB_PLUGIN_PATH) . "advanced_subscription/src/terms_and_conditions.php?";
1352
+        $url = api_get_path(WEB_PLUGIN_PATH)."advanced_subscription/src/terms_and_conditions.php?";
1354 1353
         $url .= http_build_query($urlParams);
1355 1354
 
1356 1355
         // Launch popup
1357 1356
         if ($mode == ADVANCED_SUBSCRIPTION_TERMS_MODE_POPUP) {
1358
-            $url = 'javascript:void(window.open(\'' . $url .'\',\'AdvancedSubscriptionTerms\', \'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700px,height=600px\', \'100\' ))';
1357
+            $url = 'javascript:void(window.open(\''.$url.'\',\'AdvancedSubscriptionTerms\', \'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700px,height=600px\', \'100\' ))';
1359 1358
         }
1360 1359
         return $url;
1361 1360
     }
@@ -1367,9 +1366,9 @@  discard block
 block discarded – undo
1367 1366
      */
1368 1367
     public function getRenderMailUrl($params)
1369 1368
     {
1370
-        $url = api_get_path(WEB_PLUGIN_PATH) . 'advanced_subscription/src/render_mail.php?' .
1371
-            'q=' . $params['queueId'] . '&' .
1372
-            'v=' . $this->generateHash($params);
1369
+        $url = api_get_path(WEB_PLUGIN_PATH).'advanced_subscription/src/render_mail.php?'.
1370
+            'q='.$params['queueId'].'&'.
1371
+            'v='.$this->generateHash($params);
1373 1372
         return $url;
1374 1373
     }
1375 1374
 
@@ -1440,7 +1439,7 @@  discard block
 block discarded – undo
1440 1439
                 sf.extra_field_type = $extraFieldType AND
1441 1440
                 sf.variable = 'is_induction_session' AND
1442 1441
                 su.relation_type = 0 AND
1443
-                su.user_id = " . intval($userId);
1442
+                su.user_id = ".intval($userId);
1444 1443
 
1445 1444
         $result = Database::query($sql);
1446 1445
 
Please login to merge, or discard this patch.
plugin/bbb/lib/bbb.lib.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     /**
241 241
      * Returns a meeting "join" URL
242 242
      * @param string The name of the meeting (usually the course code)
243
-     * @return mixed The URL to join the meeting, or false on error
243
+     * @return false|string The URL to join the meeting, or false on error
244 244
      * @todo implement moderator pass
245 245
      * @assert ('') === false
246 246
      * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
      * Closes a meeting (usually when the user click on the close button from
648 648
      * the conferences listing.
649 649
      * @param string The internal ID of the meeting (id field for this meeting)
650
-     * @return void
650
+     * @return false|null
651 651
      * @assert (0) === false
652 652
      */
653 653
     public function endMeeting($id)
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
         $params['record'] = api_get_course_setting('big_blue_button_record_and_store', $courseCode) == 1 ? true : false;
212 212
         $max = api_get_course_setting('big_blue_button_max_students_allowed', $courseCode);
213
-        $max =  isset($max) ? $max : -1;
213
+        $max = isset($max) ? $max : -1;
214 214
 
215 215
         $params['status'] = 1;
216 216
         // Generate a pseudo-global-unique-id to avoid clash of conferences on
@@ -243,23 +243,23 @@  discard block
 block discarded – undo
243 243
             $duration = 300;
244 244
 
245 245
             $bbbParams = array(
246
-                'meetingId' => $params['remote_id'], 					// REQUIRED
247
-                'meetingName' => $meetingName, 	// REQUIRED
248
-                'attendeePw' => $attendeePassword, 					// Match this value in getJoinMeetingURL() to join as attendee.
249
-                'moderatorPw' => $moderatorPassword, 					// Match this value in getJoinMeetingURL() to join as moderator.
250
-                'welcomeMsg' => $welcomeMessage, 					// ''= use default. Change to customize.
251
-                'dialNumber' => '', 					// The main number to call into. Optional.
252
-                'voiceBridge' => $params['voice_bridge'], 					// PIN to join voice. Required.
253
-                'webVoice' => '', 						// Alphanumeric to join voice. Optional.
246
+                'meetingId' => $params['remote_id'], // REQUIRED
247
+                'meetingName' => $meetingName, // REQUIRED
248
+                'attendeePw' => $attendeePassword, // Match this value in getJoinMeetingURL() to join as attendee.
249
+                'moderatorPw' => $moderatorPassword, // Match this value in getJoinMeetingURL() to join as moderator.
250
+                'welcomeMsg' => $welcomeMessage, // ''= use default. Change to customize.
251
+                'dialNumber' => '', // The main number to call into. Optional.
252
+                'voiceBridge' => $params['voice_bridge'], // PIN to join voice. Required.
253
+                'webVoice' => '', // Alphanumeric to join voice. Optional.
254 254
                 'logoutUrl' =>  $this->logoutUrl,
255
-                'maxParticipants' => $max, 				// Optional. -1 = unlimitted. Not supported in BBB. [number]
256
-                'record' => $record, 					// New. 'true' will tell BBB to record the meeting.
257
-                'duration' => $duration, 				// Default = 0 which means no set duration in minutes. [number]
255
+                'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number]
256
+                'record' => $record, // New. 'true' will tell BBB to record the meeting.
257
+                'duration' => $duration, // Default = 0 which means no set duration in minutes. [number]
258 258
                 //'meta_category' => '', 				// Use to pass additional info to BBB server. See API docs.
259 259
             );
260 260
 
261 261
             if ($this->debug) {
262
-                error_log("create_meeting params: ".print_r($bbbParams,1));
262
+                error_log("create_meeting params: ".print_r($bbbParams, 1));
263 263
             }
264 264
 
265 265
             $status = false;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                 if (isset($result) && strval($result['returncode']) == 'SUCCESS') {
273 273
                     if ($this->debug) {
274 274
                         error_log(
275
-                            "create_meeting result: " . print_r($result, 1)
275
+                            "create_meeting result: ".print_r($result, 1)
276 276
                         );
277 277
                     }
278 278
                     $meeting = $this->joinMeeting($meetingName, true);
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 
304 304
         $courseId = api_get_course_int_id();
305 305
         $sessionId = api_get_session_id();
306
-        $conditions =  array(
306
+        $conditions = array(
307 307
             'where' => array(
308 308
                 'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 AND access_url = ?' =>
309 309
                     array($courseId, $sessionId, $meetingName, $this->accessUrl)
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
         if ($this->hasGroupSupport()) {
314 314
             $groupId = api_get_group_id();
315
-            $conditions =  array(
315
+            $conditions = array(
316 316
                 'where' => array(
317 317
                     'c_id = ? AND session_id = ? AND meeting_name = ? AND group_id = ? AND status = 1 AND access_url = ?' =>
318 318
                         array($courseId, $sessionId, $meetingName, $groupId, $this->accessUrl)
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 
410 410
             if ($this->debug) {
411 411
                 error_log(
412
-                    "meeting is running: " . intval($meetingInfoExists)
412
+                    "meeting is running: ".intval($meetingInfoExists)
413 413
                 );
414 414
             }
415 415
 
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
 
427 427
         if ($meetingInfoExists) {
428 428
             $joinParams = array(
429
-                'meetingId' => $meetingData['remote_id'],	//	-- REQUIRED - A unique id for the meeting
430
-                'username' => $this->userCompleteName,	//-- REQUIRED - The name that will display for the user in the meeting
431
-                'password' => $pass,			//-- REQUIRED - The attendee or moderator password, depending on what's passed here
429
+                'meetingId' => $meetingData['remote_id'], //	-- REQUIRED - A unique id for the meeting
430
+                'username' => $this->userCompleteName, //-- REQUIRED - The name that will display for the user in the meeting
431
+                'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
432 432
                 //'createTime' => api_get_utc_datetime(),			//-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
433
-                'userID' => api_get_user_id(),				//-- OPTIONAL - string
433
+                'userID' => api_get_user_id(), //-- OPTIONAL - string
434 434
                 'webVoiceConf' => ''	//	-- OPTIONAL - string
435 435
             );
436 436
             $url = $this->api->getJoinMeetingURL($joinParams);
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             $url = $this->logoutUrl;
440 440
         }
441 441
         if ($this->debug) {
442
-            error_log("return url :" . $url);
442
+            error_log("return url :".$url);
443 443
         }
444 444
 
445 445
         return $url;
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
      */
481 481
     public function getAllMeetingsInCourse($courseId, $sessionId, $status)
482 482
     {
483
-        $conditions =  array(
483
+        $conditions = array(
484 484
             'where' => array(
485 485
                 'status = ? AND c_id = ? AND session_id = ? ' => array(
486 486
                     $status,
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         $courseId = api_get_course_int_id();
513 513
         $sessionId = api_get_session_id();
514 514
 
515
-        $conditions =  array(
515
+        $conditions = array(
516 516
             'where' => array(
517 517
                 'c_id = ? AND session_id = ? AND access_url = ?' => array(
518 518
                     $courseId,
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 
525 525
         if ($this->hasGroupSupport()) {
526 526
             $groupId = api_get_group_id();
527
-            $conditions =  array(
527
+            $conditions = array(
528 528
                 'where' => array(
529 529
                     'c_id = ? AND session_id = ? AND group_id = ? AND access_url = ?' =>
530 530
                         array($courseId, $sessionId, $groupId, $this->accessUrl)
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
         }
534 534
 
535 535
         if ($isGlobalPerUser) {
536
-            $conditions =  array(
536
+            $conditions = array(
537 537
                 'where' => array(
538 538
                     'user_id = ? AND access_url = ?' =>
539 539
                         array($this->userId, $this->accessUrl)
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
             }
569 569
             $meetingBBB['end_url'] = $this->endUrl($meetingDB);
570 570
 
571
-            if (isset($meetingBBB['returncode']) && (string)$meetingBBB['returncode'] == 'FAILED') {
571
+            if (isset($meetingBBB['returncode']) && (string) $meetingBBB['returncode'] == 'FAILED') {
572 572
                 if ($meetingDB['status'] == 1 && $this->isConferenceManager()) {
573 573
                     $this->endMeeting($meetingDB['id']);
574 574
                 }
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
                     $actionLinksArray[] = $actionLinks;
738 738
                     $item['action_links'] = implode('<br />', $actionLinksArray);
739 739
                 }
740
-                $item['show_links']  = implode('<br />', $recordArray);
740
+                $item['show_links'] = implode('<br />', $recordArray);
741 741
                 $item['action_links'] = implode('<br />', $actionLinksArray);
742 742
             }
743 743
 
@@ -750,11 +750,11 @@  discard block
 block discarded – undo
750 750
 
751 751
             if ($meetingDB['status'] == 1) {
752 752
                 $joinParams = array(
753
-                    'meetingId' => $meetingDB['remote_id'],		//-- REQUIRED - A unique id for the meeting
754
-                    'username' => $this->userCompleteName,	//-- REQUIRED - The name that will display for the user in the meeting
755
-                    'password' => $pass,			//-- REQUIRED - The attendee or moderator password, depending on what's passed here
756
-                    'createTime' => '',			//-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
757
-                    'userID' => '',			//	-- OPTIONAL - string
753
+                    'meetingId' => $meetingDB['remote_id'], //-- REQUIRED - A unique id for the meeting
754
+                    'username' => $this->userCompleteName, //-- REQUIRED - The name that will display for the user in the meeting
755
+                    'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
756
+                    'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
757
+                    'userID' => '', //	-- OPTIONAL - string
758 758
                     'webVoiceConf' => ''	//	-- OPTIONAL - string
759 759
                 );
760 760
                 $item['go_url'] = $this->protocol.$this->api->getJoinMeetingURL($joinParams);
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
         $pass = $this->getUserMeetingPassword();
816 816
 
817 817
         $endParams = array(
818
-            'meetingId' => $meetingData['remote_id'],   // REQUIRED - We have to know which meeting to end.
819
-            'password' => $pass,        // REQUIRED - Must match moderator pass for meeting.
818
+            'meetingId' => $meetingData['remote_id'], // REQUIRED - We have to know which meeting to end.
819
+            'password' => $pass, // REQUIRED - Must match moderator pass for meeting.
820 820
         );
821 821
         $this->api->endMeetingWithXmlResponseArray($endParams);
822 822
         Database::update(
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
      */
1068 1068
     public function redirectToBBB($url)
1069 1069
     {
1070
-        if (file_exists(__DIR__ . '/../config.vm.php')) {
1070
+        if (file_exists(__DIR__.'/../config.vm.php')) {
1071 1071
             // Using VM
1072 1072
             echo Display::url(get_lang('ClickToContinue'), $url);
1073 1073
             exit;
Please login to merge, or discard this patch.
plugin/bbb/lib/bbb_api.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -59,6 +59,9 @@
 block discarded – undo
59 59
 		$this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;
60 60
 	}
61 61
 
62
+	/**
63
+	 * @param string $url
64
+	 */
62 65
 	private function _processXmlResponse($url){
63 66
 	/*
64 67
 	A private utility method used by other public methods to process XML responses.
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -55,25 +55,25 @@  discard block
 block discarded – undo
55 55
 	*/
56 56
 		// BASE CONFIGS - set these for your BBB server in config.php and they will
57 57
 		// simply flow in here via the constants:
58
-		$this->_securitySalt 		= CONFIG_SECURITY_SALT;
59
-		$this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;
58
+		$this->_securitySalt = CONFIG_SECURITY_SALT;
59
+		$this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL;
60 60
 	}
61 61
 
62
-	private function _processXmlResponse($url){
62
+	private function _processXmlResponse($url) {
63 63
 	/*
64 64
 	A private utility method used by other public methods to process XML responses.
65 65
 	*/
66 66
 		if (extension_loaded('curl')) {
67
-			$ch = curl_init() or die ( curl_error($ch) );
67
+			$ch = curl_init() or die (curl_error($ch));
68 68
 			$timeout = 10;
69
-			curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
70
-			curl_setopt( $ch, CURLOPT_URL, $url );
71
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
72
-			curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
73
-			$data = curl_exec( $ch );
74
-			curl_close( $ch );
75
-
76
-			if($data)
69
+			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
70
+			curl_setopt($ch, CURLOPT_URL, $url);
71
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
72
+			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
73
+			$data = curl_exec($ch);
74
+			curl_close($ch);
75
+
76
+			if ($data)
77 77
 				return (new SimpleXMLElement($data));
78 78
 			else
79 79
 				return false;
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 		'&duration='.urlencode($creationParams['duration']);
138 138
 		//'&meta_category='.urlencode($creationParams['meta_category']);
139 139
 		$welcomeMessage = $creationParams['welcomeMsg'];
140
-		if(trim($welcomeMessage))
140
+		if (trim($welcomeMessage))
141 141
 			$params .= '&welcome='.urlencode($welcomeMessage);
142 142
 		// Return the complete URL:
143
-		return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
143
+		return ($creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt));
144 144
 	}
145 145
 
146 146
 	public function createMeetingWithXmlResponseArray($creationParams) {
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
166 166
 
167 167
         if ($xml) {
168
-			if($xml->meetingID)
168
+			if ($xml->meetingID)
169 169
 				return array(
170 170
 					'returncode' => $xml->returncode,
171 171
 					'message' => $xml->message,
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 		$meetingId = '1234'		-- REQUIRED - The unique id for the meeting
284 284
 		*/
285 285
 		$xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId));
286
-		if($xml) {
286
+		if ($xml) {
287 287
 			return array(
288 288
 				'returncode' => $xml->returncode,
289 289
 				'running' => $xml->running 	// -- Returns true/false.
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		and then handle the results that we get in the XML response.
311 311
 		*/
312 312
 		$xml = $this->_processXmlResponse($this->getGetMeetingsUrl());
313
-		if($xml) {
313
+		if ($xml) {
314 314
 			// If we don't get a success code, stop processing and return just the returncode:
315 315
 			if ($xml->returncode != 'SUCCESS') {
316 316
 				$result = array(
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 		);
380 380
 		*/
381 381
 		$xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams));
382
-		if($xml) {
382
+		if ($xml) {
383 383
 			// If we don't get a success code or messageKey, find out why:
384 384
 			if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
385 385
 				$result = array(
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		probably be required in user code when 'recording' is set to true.
455 455
 		*/
456 456
 		$xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams));
457
-		if($xml) {
457
+		if ($xml) {
458 458
 			// If we don't get a success code or messageKey, find out why:
459 459
 			if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
460 460
 				$result = array(
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 		);
525 525
 		*/
526 526
 		$xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams));
527
-		if($xml) {
527
+		if ($xml) {
528 528
 			return array(
529 529
 				'returncode' => $xml->returncode,
530 530
 				'published' => $xml->published 	// -- Returns true/false.
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		*/
558 558
 
559 559
 		$xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams));
560
-		if($xml) {
560
+		if ($xml) {
561 561
 			return array(
562 562
 				'returncode' => $xml->returncode,
563 563
 				'deleted' => $xml->deleted 	// -- Returns true/false.
Please login to merge, or discard this patch.
Braces   +28 added lines, -40 removed lines patch added patch discarded remove patch
@@ -73,10 +73,11 @@  discard block
 block discarded – undo
73 73
 			$data = curl_exec( $ch );
74 74
 			curl_close( $ch );
75 75
 
76
-			if($data)
77
-				return (new SimpleXMLElement($data));
78
-			else
79
-				return false;
76
+			if($data) {
77
+							return (new SimpleXMLElement($data));
78
+			} else {
79
+							return false;
80
+			}
80 81
 		}
81 82
 		return (simplexml_load_file($url));
82 83
 	}
@@ -85,11 +86,9 @@  discard block
 block discarded – undo
85 86
 		/* Process required params and throw errors if we don't get values */
86 87
 		if ((isset($param)) && ($param != '')) {
87 88
 			return $param;
88
-		}
89
-		elseif (!isset($param)) {
89
+		} elseif (!isset($param)) {
90 90
 			throw new Exception('Missing parameter.');
91
-		}
92
-		else {
91
+		} else {
93 92
 			throw new Exception(''.$param.' is required.');
94 93
 		}
95 94
 	}
@@ -99,8 +98,7 @@  discard block
 block discarded – undo
99 98
 		/* Don't know if we'll use this one, but let's build it in case. */
100 99
 		if ((isset($param)) && ($param != '')) {
101 100
 			return $param;
102
-		}
103
-		else {
101
+		} else {
104 102
 			$param = '';
105 103
 			return $param;
106 104
 		}
@@ -137,8 +135,9 @@  discard block
 block discarded – undo
137 135
 		'&duration='.urlencode($creationParams['duration']);
138 136
 		//'&meta_category='.urlencode($creationParams['meta_category']);
139 137
 		$welcomeMessage = $creationParams['welcomeMsg'];
140
-		if(trim($welcomeMessage))
141
-			$params .= '&welcome='.urlencode($welcomeMessage);
138
+		if(trim($welcomeMessage)) {
139
+					$params .= '&welcome='.urlencode($welcomeMessage);
140
+		}
142 141
 		// Return the complete URL:
143 142
 		return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
144 143
 	}
@@ -165,8 +164,8 @@  discard block
 block discarded – undo
165 164
 		$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
166 165
 
167 166
         if ($xml) {
168
-			if($xml->meetingID)
169
-				return array(
167
+			if($xml->meetingID) {
168
+							return array(
170 169
 					'returncode' => $xml->returncode,
171 170
 					'message' => $xml->message,
172 171
 					'messageKey' => $xml->messageKey,
@@ -176,14 +175,14 @@  discard block
 block discarded – undo
176 175
 					'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded,
177 176
 					'createTime' => $xml->createTime
178 177
 					);
179
-			else
180
-				return array(
178
+			} else {
179
+							return array(
181 180
 					'returncode' => $xml->returncode,
182 181
 					'message' => $xml->message,
183 182
 					'messageKey' => $xml->messageKey
184 183
 					);
185
-		}
186
-		else {
184
+			}
185
+		} else {
187 186
 			return null;
188 187
 		}
189 188
 	}
@@ -253,8 +252,7 @@  discard block
 block discarded – undo
253 252
 				'message' => $xml->message,
254 253
 				'messageKey' => $xml->messageKey
255 254
 				);
256
-		}
257
-		else {
255
+		} else {
258 256
 			return null;
259 257
 		}
260 258
 
@@ -288,8 +286,7 @@  discard block
 block discarded – undo
288 286
 				'returncode' => $xml->returncode,
289 287
 				'running' => $xml->running 	// -- Returns true/false.
290 288
 				);
291
-		}
292
-		else {
289
+		} else {
293 290
 			return null;
294 291
 		}
295 292
 
@@ -317,8 +314,7 @@  discard block
 block discarded – undo
317 314
 					'returncode' => $xml->returncode
318 315
 				);
319 316
 				return $result;
320
-			}
321
-			elseif ($xml->messageKey == 'noMeetings') {
317
+			} elseif ($xml->messageKey == 'noMeetings') {
322 318
 				/* No meetings on server, so return just this info: */
323 319
 				$result = array(
324 320
 					'returncode' => $xml->returncode,
@@ -326,8 +322,7 @@  discard block
 block discarded – undo
326 322
 					'message' => $xml->message
327 323
 				);
328 324
 				return $result;
329
-			}
330
-			else {
325
+			} else {
331 326
 				// In this case, we have success and meetings. First return general response:
332 327
 				$result = array(
333 328
 					'returncode' => $xml->returncode,
@@ -348,8 +343,7 @@  discard block
 block discarded – undo
348 343
 					}
349 344
 				return $result;
350 345
 			}
351
-		}
352
-		else {
346
+		} else {
353 347
 			return null;
354 348
 		}
355 349
 
@@ -388,8 +382,7 @@  discard block
 block discarded – undo
388 382
 					'message' => $xml->message
389 383
 				);
390 384
 				return $result;
391
-			}
392
-			else {
385
+			} else {
393 386
 				// In this case, we have success and meeting info:
394 387
 				$result = array(
395 388
 					'returncode' => $xml->returncode,
@@ -418,8 +411,7 @@  discard block
 block discarded – undo
418 411
 					}
419 412
 				return $result;
420 413
 			}
421
-		}
422
-		else {
414
+		} else {
423 415
 			return null;
424 416
 		}
425 417
 
@@ -463,8 +455,7 @@  discard block
 block discarded – undo
463 455
 					'message' => $xml->message
464 456
 				);
465 457
 				return $result;
466
-			}
467
-			else {
458
+			} else {
468 459
 				// In this case, we have success and recording info:
469 460
 				$result = array(
470 461
 					'returncode' => $xml->returncode,
@@ -495,8 +486,7 @@  discard block
 block discarded – undo
495 486
 					}
496 487
 				return $result;
497 488
 			}
498
-		}
499
-		else {
489
+		} else {
500 490
 			return null;
501 491
 		}
502 492
 	}
@@ -529,8 +519,7 @@  discard block
 block discarded – undo
529 519
 				'returncode' => $xml->returncode,
530 520
 				'published' => $xml->published 	// -- Returns true/false.
531 521
 				);
532
-		}
533
-		else {
522
+		} else {
534 523
 			return null;
535 524
 		}
536 525
 
@@ -562,8 +551,7 @@  discard block
 block discarded – undo
562 551
 				'returncode' => $xml->returncode,
563 552
 				'deleted' => $xml->deleted 	// -- Returns true/false.
564 553
 				);
565
-		}
566
-		else {
554
+		} else {
567 555
 			return null;
568 556
 		}
569 557
 
Please login to merge, or discard this patch.
Indentation   +403 added lines, -403 removed lines patch added patch discarded remove patch
@@ -44,107 +44,107 @@  discard block
 block discarded – undo
44 44
 
45 45
 class BigBlueButtonBN {
46 46
 
47
-	private $_securitySalt;
48
-	private $_bbbServerBaseUrl;
47
+    private $_securitySalt;
48
+    private $_bbbServerBaseUrl;
49 49
 
50
-	/* ___________ General Methods for the BigBlueButton Class __________ */
50
+    /* ___________ General Methods for the BigBlueButton Class __________ */
51 51
 
52
-	function __construct() {
53
-	/*
52
+    function __construct() {
53
+    /*
54 54
 	Establish just our basic elements in the constructor:
55 55
 	*/
56
-		// BASE CONFIGS - set these for your BBB server in config.php and they will
57
-		// simply flow in here via the constants:
58
-		$this->_securitySalt 		= CONFIG_SECURITY_SALT;
59
-		$this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;
60
-	}
61
-
62
-	private function _processXmlResponse($url){
63
-	/*
56
+        // BASE CONFIGS - set these for your BBB server in config.php and they will
57
+        // simply flow in here via the constants:
58
+        $this->_securitySalt 		= CONFIG_SECURITY_SALT;
59
+        $this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;
60
+    }
61
+
62
+    private function _processXmlResponse($url){
63
+    /*
64 64
 	A private utility method used by other public methods to process XML responses.
65 65
 	*/
66
-		if (extension_loaded('curl')) {
67
-			$ch = curl_init() or die ( curl_error($ch) );
68
-			$timeout = 10;
69
-			curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
70
-			curl_setopt( $ch, CURLOPT_URL, $url );
71
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
72
-			curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
73
-			$data = curl_exec( $ch );
74
-			curl_close( $ch );
75
-
76
-			if($data)
77
-				return (new SimpleXMLElement($data));
78
-			else
79
-				return false;
80
-		}
81
-		return (simplexml_load_file($url));
82
-	}
83
-
84
-	private function _requiredParam($param) {
85
-		/* Process required params and throw errors if we don't get values */
86
-		if ((isset($param)) && ($param != '')) {
87
-			return $param;
88
-		}
89
-		elseif (!isset($param)) {
90
-			throw new Exception('Missing parameter.');
91
-		}
92
-		else {
93
-			throw new Exception(''.$param.' is required.');
94
-		}
95
-	}
96
-
97
-	private function _optionalParam($param) {
98
-		/* Pass most optional params through as set value, or set to '' */
99
-		/* Don't know if we'll use this one, but let's build it in case. */
100
-		if ((isset($param)) && ($param != '')) {
101
-			return $param;
102
-		}
103
-		else {
104
-			$param = '';
105
-			return $param;
106
-		}
107
-	}
108
-
109
-	/* __________________ BBB ADMINISTRATION METHODS _________________ */
110
-	/* The methods in the following section support the following categories of the BBB API:
66
+        if (extension_loaded('curl')) {
67
+            $ch = curl_init() or die ( curl_error($ch) );
68
+            $timeout = 10;
69
+            curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
70
+            curl_setopt( $ch, CURLOPT_URL, $url );
71
+            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
72
+            curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
73
+            $data = curl_exec( $ch );
74
+            curl_close( $ch );
75
+
76
+            if($data)
77
+                return (new SimpleXMLElement($data));
78
+            else
79
+                return false;
80
+        }
81
+        return (simplexml_load_file($url));
82
+    }
83
+
84
+    private function _requiredParam($param) {
85
+        /* Process required params and throw errors if we don't get values */
86
+        if ((isset($param)) && ($param != '')) {
87
+            return $param;
88
+        }
89
+        elseif (!isset($param)) {
90
+            throw new Exception('Missing parameter.');
91
+        }
92
+        else {
93
+            throw new Exception(''.$param.' is required.');
94
+        }
95
+    }
96
+
97
+    private function _optionalParam($param) {
98
+        /* Pass most optional params through as set value, or set to '' */
99
+        /* Don't know if we'll use this one, but let's build it in case. */
100
+        if ((isset($param)) && ($param != '')) {
101
+            return $param;
102
+        }
103
+        else {
104
+            $param = '';
105
+            return $param;
106
+        }
107
+    }
108
+
109
+    /* __________________ BBB ADMINISTRATION METHODS _________________ */
110
+    /* The methods in the following section support the following categories of the BBB API:
111 111
 	-- create
112 112
 	-- join
113 113
 	-- end
114 114
 	*/
115 115
 
116
-	public function getCreateMeetingUrl($creationParams) {
117
-		/*
116
+    public function getCreateMeetingUrl($creationParams) {
117
+        /*
118 118
 		USAGE:
119 119
 		(see $creationParams array in createMeetingArray method.)
120 120
 		*/
121
-		$this->_meetingId = $this->_requiredParam($creationParams['meetingId']);
122
-		$this->_meetingName = $this->_requiredParam($creationParams['meetingName']);
123
-		// Set up the basic creation URL:
124
-		$creationUrl = $this->_bbbServerBaseUrl."api/create?";
125
-		// Add params:
126
-		$params =
127
-		'name='.urlencode($this->_meetingName).
128
-		'&meetingID='.urlencode($this->_meetingId).
129
-		'&attendeePW='.urlencode($creationParams['attendeePw']).
130
-		'&moderatorPW='.urlencode($creationParams['moderatorPw']).
131
-		'&dialNumber='.urlencode($creationParams['dialNumber']).
132
-		'&voiceBridge='.urlencode($creationParams['voiceBridge']).
133
-		'&webVoice='.urlencode($creationParams['webVoice']).
134
-		'&logoutURL='.urlencode($creationParams['logoutUrl']).
135
-		'&maxParticipants='.urlencode($creationParams['maxParticipants']).
136
-		'&record='.urlencode($creationParams['record']).
137
-		'&duration='.urlencode($creationParams['duration']);
138
-		//'&meta_category='.urlencode($creationParams['meta_category']);
139
-		$welcomeMessage = $creationParams['welcomeMsg'];
140
-		if(trim($welcomeMessage))
141
-			$params .= '&welcome='.urlencode($welcomeMessage);
142
-		// Return the complete URL:
143
-		return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
144
-	}
145
-
146
-	public function createMeetingWithXmlResponseArray($creationParams) {
147
-		/*
121
+        $this->_meetingId = $this->_requiredParam($creationParams['meetingId']);
122
+        $this->_meetingName = $this->_requiredParam($creationParams['meetingName']);
123
+        // Set up the basic creation URL:
124
+        $creationUrl = $this->_bbbServerBaseUrl."api/create?";
125
+        // Add params:
126
+        $params =
127
+        'name='.urlencode($this->_meetingName).
128
+        '&meetingID='.urlencode($this->_meetingId).
129
+        '&attendeePW='.urlencode($creationParams['attendeePw']).
130
+        '&moderatorPW='.urlencode($creationParams['moderatorPw']).
131
+        '&dialNumber='.urlencode($creationParams['dialNumber']).
132
+        '&voiceBridge='.urlencode($creationParams['voiceBridge']).
133
+        '&webVoice='.urlencode($creationParams['webVoice']).
134
+        '&logoutURL='.urlencode($creationParams['logoutUrl']).
135
+        '&maxParticipants='.urlencode($creationParams['maxParticipants']).
136
+        '&record='.urlencode($creationParams['record']).
137
+        '&duration='.urlencode($creationParams['duration']);
138
+        //'&meta_category='.urlencode($creationParams['meta_category']);
139
+        $welcomeMessage = $creationParams['welcomeMsg'];
140
+        if(trim($welcomeMessage))
141
+            $params .= '&welcome='.urlencode($welcomeMessage);
142
+        // Return the complete URL:
143
+        return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
144
+    }
145
+
146
+    public function createMeetingWithXmlResponseArray($creationParams) {
147
+        /*
148 148
 		USAGE:
149 149
 		$creationParams = array(
150 150
 			'name' => 'Meeting Name',	-- A name for the meeting (or username)
@@ -162,34 +162,34 @@  discard block
 block discarded – undo
162 162
 			'meta_category' => '', 		-- Use to pass additional info to BBB server. See API docs to enable.
163 163
 		);
164 164
 		*/
165
-		$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
165
+        $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
166 166
 
167 167
         if ($xml) {
168
-			if($xml->meetingID)
169
-				return array(
170
-					'returncode' => $xml->returncode->__toString(),
171
-					'message' => $xml->message->__toString(),
172
-					'messageKey' => $xml->messageKey->__toString(),
173
-					'meetingId' => $xml->meetingID->__toString(),
174
-					'attendeePw' => $xml->attendeePW->__toString(),
175
-					'moderatorPw' => $xml->moderatorPW->__toString(),
176
-					'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(),
177
-					'createTime' => $xml->createTime->__toString()
178
-					);
179
-			else
180
-				return array(
181
-					'returncode' => $xml->returncode->__toString(),
182
-					'message' => $xml->message->__toString(),
183
-					'messageKey' => $xml->messageKey->__toString()
184
-					);
185
-		}
186
-		else {
187
-			return null;
188
-		}
189
-	}
190
-
191
-	public function getJoinMeetingURL($joinParams) {
192
-		/*
168
+            if($xml->meetingID)
169
+                return array(
170
+                    'returncode' => $xml->returncode->__toString(),
171
+                    'message' => $xml->message->__toString(),
172
+                    'messageKey' => $xml->messageKey->__toString(),
173
+                    'meetingId' => $xml->meetingID->__toString(),
174
+                    'attendeePw' => $xml->attendeePW->__toString(),
175
+                    'moderatorPw' => $xml->moderatorPW->__toString(),
176
+                    'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(),
177
+                    'createTime' => $xml->createTime->__toString()
178
+                    );
179
+            else
180
+                return array(
181
+                    'returncode' => $xml->returncode->__toString(),
182
+                    'message' => $xml->message->__toString(),
183
+                    'messageKey' => $xml->messageKey->__toString()
184
+                    );
185
+        }
186
+        else {
187
+            return null;
188
+        }
189
+    }
190
+
191
+    public function getJoinMeetingURL($joinParams) {
192
+        /*
193 193
 		NOTE: At this point, we don't use a corresponding joinMeetingWithXmlResponse here because the API
194 194
 		doesn't respond on success, but you can still code that method if you need it. Or, you can take the URL
195 195
 		that's returned from this method and simply send your users off to that URL in your code.
@@ -203,249 +203,249 @@  discard block
 block discarded – undo
203 203
 			'webVoiceConf' => ''		-- OPTIONAL - string
204 204
 		);
205 205
 		*/
206
-		$this->_meetingId = $this->_requiredParam($joinParams['meetingId']);
207
-		$this->_username = $this->_requiredParam($joinParams['username']);
208
-		$this->_password = $this->_requiredParam($joinParams['password']);
209
-		// Establish the basic join URL:
210
-		$joinUrl = $this->_bbbServerBaseUrl."api/join?";
211
-		// Add parameters to the URL:
212
-		$params =
213
-		'meetingID='.urlencode($this->_meetingId).
214
-		'&fullName='.urlencode($this->_username).
215
-		'&password='.urlencode($this->_password).
216
-		'&userID='.urlencode($joinParams['userID']).
217
-		'&webVoiceConf='.urlencode($joinParams['webVoiceConf']);
218
-		// Only use createTime if we really want to use it. If it's '', then don't pass it:
219
-		if (((isset($joinParams['createTime'])) && ($joinParams['createTime'] != ''))) {
220
-			$params .= '&createTime='.urlencode($joinParams['createTime']);
221
-		}
222
-		// Return the URL:
223
-		return ($joinUrl.$params.'&checksum='.sha1("join".$params.$this->_securitySalt));
224
-	}
225
-
226
-	public function getEndMeetingURL($endParams) {
227
-		/* USAGE:
206
+        $this->_meetingId = $this->_requiredParam($joinParams['meetingId']);
207
+        $this->_username = $this->_requiredParam($joinParams['username']);
208
+        $this->_password = $this->_requiredParam($joinParams['password']);
209
+        // Establish the basic join URL:
210
+        $joinUrl = $this->_bbbServerBaseUrl."api/join?";
211
+        // Add parameters to the URL:
212
+        $params =
213
+        'meetingID='.urlencode($this->_meetingId).
214
+        '&fullName='.urlencode($this->_username).
215
+        '&password='.urlencode($this->_password).
216
+        '&userID='.urlencode($joinParams['userID']).
217
+        '&webVoiceConf='.urlencode($joinParams['webVoiceConf']);
218
+        // Only use createTime if we really want to use it. If it's '', then don't pass it:
219
+        if (((isset($joinParams['createTime'])) && ($joinParams['createTime'] != ''))) {
220
+            $params .= '&createTime='.urlencode($joinParams['createTime']);
221
+        }
222
+        // Return the URL:
223
+        return ($joinUrl.$params.'&checksum='.sha1("join".$params.$this->_securitySalt));
224
+    }
225
+
226
+    public function getEndMeetingURL($endParams) {
227
+        /* USAGE:
228 228
 		$endParams = array (
229 229
 			'meetingId' => '1234',		-- REQUIRED - The unique id for the meeting
230 230
 			'password' => 'mp'			-- REQUIRED - The moderator password for the meeting
231 231
 		);
232 232
 		*/
233
-		$this->_meetingId = $this->_requiredParam($endParams['meetingId']);
234
-		$this->_password = $this->_requiredParam($endParams['password']);
235
-		$endUrl = $this->_bbbServerBaseUrl."api/end?";
236
-		$params =
237
-		'meetingID='.urlencode($this->_meetingId).
238
-		'&password='.urlencode($this->_password);
239
-		return ($endUrl.$params.'&checksum='.sha1("end".$params.$this->_securitySalt));
240
-	}
241
-
242
-	public function endMeetingWithXmlResponseArray($endParams) {
243
-		/* USAGE:
233
+        $this->_meetingId = $this->_requiredParam($endParams['meetingId']);
234
+        $this->_password = $this->_requiredParam($endParams['password']);
235
+        $endUrl = $this->_bbbServerBaseUrl."api/end?";
236
+        $params =
237
+        'meetingID='.urlencode($this->_meetingId).
238
+        '&password='.urlencode($this->_password);
239
+        return ($endUrl.$params.'&checksum='.sha1("end".$params.$this->_securitySalt));
240
+    }
241
+
242
+    public function endMeetingWithXmlResponseArray($endParams) {
243
+        /* USAGE:
244 244
 		$endParams = array (
245 245
 			'meetingId' => '1234',		-- REQUIRED - The unique id for the meeting
246 246
 			'password' => 'mp'			-- REQUIRED - The moderator password for the meeting
247 247
 		);
248 248
 		*/
249
-		$xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams));
250
-		if ($xml) {
251
-			return array(
252
-				'returncode' => $xml->returncode->__toString(),
253
-				'message' => $xml->message->__toString(),
254
-				'messageKey' => $xml->messageKey->__toString()
255
-				);
256
-		}
257
-		else {
258
-			return null;
259
-		}
260
-
261
-	}
262
-
263
-	/* __________________ BBB MONITORING METHODS _________________ */
264
-	/* The methods in the following section support the following categories of the BBB API:
249
+        $xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams));
250
+        if ($xml) {
251
+            return array(
252
+                'returncode' => $xml->returncode->__toString(),
253
+                'message' => $xml->message->__toString(),
254
+                'messageKey' => $xml->messageKey->__toString()
255
+                );
256
+        }
257
+        else {
258
+            return null;
259
+        }
260
+
261
+    }
262
+
263
+    /* __________________ BBB MONITORING METHODS _________________ */
264
+    /* The methods in the following section support the following categories of the BBB API:
265 265
 	-- isMeetingRunning
266 266
 	-- getMeetings
267 267
 	-- getMeetingInfo
268 268
 	*/
269 269
 
270
-	public function getIsMeetingRunningUrl($meetingId) {
271
-		/* USAGE:
270
+    public function getIsMeetingRunningUrl($meetingId) {
271
+        /* USAGE:
272 272
 		$meetingId = '1234'		-- REQUIRED - The unique id for the meeting
273 273
 		*/
274
-		$this->_meetingId = $this->_requiredParam($meetingId);
275
-		$runningUrl = $this->_bbbServerBaseUrl."api/isMeetingRunning?";
276
-		$params =
277
-		'meetingID='.urlencode($this->_meetingId);
278
-		return ($runningUrl.$params.'&checksum='.sha1("isMeetingRunning".$params.$this->_securitySalt));
279
-	}
280
-
281
-	public function isMeetingRunningWithXmlResponseArray($meetingId) {
282
-		/* USAGE:
274
+        $this->_meetingId = $this->_requiredParam($meetingId);
275
+        $runningUrl = $this->_bbbServerBaseUrl."api/isMeetingRunning?";
276
+        $params =
277
+        'meetingID='.urlencode($this->_meetingId);
278
+        return ($runningUrl.$params.'&checksum='.sha1("isMeetingRunning".$params.$this->_securitySalt));
279
+    }
280
+
281
+    public function isMeetingRunningWithXmlResponseArray($meetingId) {
282
+        /* USAGE:
283 283
 		$meetingId = '1234'		-- REQUIRED - The unique id for the meeting
284 284
 		*/
285
-		$xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId));
286
-		if($xml) {
287
-			return array(
288
-				'returncode' => $xml->returncode->__toString(),
289
-				'running' => $xml->running->__toString() 	// -- Returns true/false.
290
-			);
291
-		}
292
-		else {
293
-			return null;
294
-		}
295
-
296
-	}
297
-
298
-	public function getGetMeetingsUrl() {
299
-		/* Simply formulate the getMeetings URL
285
+        $xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId));
286
+        if($xml) {
287
+            return array(
288
+                'returncode' => $xml->returncode->__toString(),
289
+                'running' => $xml->running->__toString() 	// -- Returns true/false.
290
+            );
291
+        }
292
+        else {
293
+            return null;
294
+        }
295
+
296
+    }
297
+
298
+    public function getGetMeetingsUrl() {
299
+        /* Simply formulate the getMeetings URL
300 300
 		We do this in a separate function so we have the option to just get this
301 301
 		URL and print it if we want for some reason.
302 302
 		*/
303
-		$getMeetingsUrl = $this->_bbbServerBaseUrl."api/getMeetings?checksum=".sha1("getMeetings".$this->_securitySalt);
304
-		return $getMeetingsUrl;
305
-	}
303
+        $getMeetingsUrl = $this->_bbbServerBaseUrl."api/getMeetings?checksum=".sha1("getMeetings".$this->_securitySalt);
304
+        return $getMeetingsUrl;
305
+    }
306 306
 
307
-	public function getMeetingsWithXmlResponseArray() {
308
-		/* USAGE:
307
+    public function getMeetingsWithXmlResponseArray() {
308
+        /* USAGE:
309 309
 		We don't need to pass any parameters with this one, so we just send the query URL off to BBB
310 310
 		and then handle the results that we get in the XML response.
311 311
 		*/
312
-		$xml = $this->_processXmlResponse($this->getGetMeetingsUrl());
313
-		if($xml) {
314
-			// If we don't get a success code, stop processing and return just the returncode:
315
-			if ($xml->returncode != 'SUCCESS') {
316
-				$result = array(
317
-					'returncode' => $xml->returncode->__toString()
318
-				);
319
-				return $result;
320
-			}
321
-			elseif ($xml->messageKey == 'noMeetings') {
322
-				/* No meetings on server, so return just this info: */
323
-				$result = array(
324
-					'returncode' => $xml->returncode->__toString(),
325
-					'messageKey' => $xml->messageKey->__toString(),
326
-					'message' => $xml->message->__toString()
327
-				);
328
-				return $result;
329
-			}
330
-			else {
331
-				// In this case, we have success and meetings. First return general response:
332
-				$result = array(
333
-					'returncode' => $xml->returncode->__toString(),
334
-					'messageKey' => $xml->messageKey->__toString(),
335
-					'message' => $xml->message->__toString()
336
-				);
337
-				// Then interate through meeting results and return them as part of the array:
338
-				foreach ($xml->meetings->meeting as $m) {
339
-					$result[] = array(
340
-						'meetingId' => $m->meetingID->__toString(),
341
-						'meetingName' => $m->meetingName->__toString(),
342
-						'createTime' => $m->createTime->__toString(),
343
-						'attendeePw' => $m->attendeePW->__toString(),
344
-						'moderatorPw' => $m->moderatorPW->__toString(),
345
-						'hasBeenForciblyEnded' => $m->hasBeenForciblyEnded->__toString(),
346
-						'running' => $m->running->__toString()
347
-					);
348
-				}
349
-				return $result;
350
-			}
351
-		}
352
-		else {
353
-			return null;
354
-		}
355
-
356
-	}
357
-
358
-	public function getMeetingInfoUrl($infoParams) {
359
-		/* USAGE:
312
+        $xml = $this->_processXmlResponse($this->getGetMeetingsUrl());
313
+        if($xml) {
314
+            // If we don't get a success code, stop processing and return just the returncode:
315
+            if ($xml->returncode != 'SUCCESS') {
316
+                $result = array(
317
+                    'returncode' => $xml->returncode->__toString()
318
+                );
319
+                return $result;
320
+            }
321
+            elseif ($xml->messageKey == 'noMeetings') {
322
+                /* No meetings on server, so return just this info: */
323
+                $result = array(
324
+                    'returncode' => $xml->returncode->__toString(),
325
+                    'messageKey' => $xml->messageKey->__toString(),
326
+                    'message' => $xml->message->__toString()
327
+                );
328
+                return $result;
329
+            }
330
+            else {
331
+                // In this case, we have success and meetings. First return general response:
332
+                $result = array(
333
+                    'returncode' => $xml->returncode->__toString(),
334
+                    'messageKey' => $xml->messageKey->__toString(),
335
+                    'message' => $xml->message->__toString()
336
+                );
337
+                // Then interate through meeting results and return them as part of the array:
338
+                foreach ($xml->meetings->meeting as $m) {
339
+                    $result[] = array(
340
+                        'meetingId' => $m->meetingID->__toString(),
341
+                        'meetingName' => $m->meetingName->__toString(),
342
+                        'createTime' => $m->createTime->__toString(),
343
+                        'attendeePw' => $m->attendeePW->__toString(),
344
+                        'moderatorPw' => $m->moderatorPW->__toString(),
345
+                        'hasBeenForciblyEnded' => $m->hasBeenForciblyEnded->__toString(),
346
+                        'running' => $m->running->__toString()
347
+                    );
348
+                }
349
+                return $result;
350
+            }
351
+        }
352
+        else {
353
+            return null;
354
+        }
355
+
356
+    }
357
+
358
+    public function getMeetingInfoUrl($infoParams) {
359
+        /* USAGE:
360 360
 		$infoParams = array(
361 361
 			'meetingId' => '1234',		-- REQUIRED - The unique id for the meeting
362 362
 			'password' => 'mp'			-- REQUIRED - The moderator password for the meeting
363 363
 		);
364 364
 		*/
365
-		$this->_meetingId = $this->_requiredParam($infoParams['meetingId']);
366
-		$this->_password = $this->_requiredParam($infoParams['password']);
367
-		$infoUrl = $this->_bbbServerBaseUrl."api/getMeetingInfo?";
368
-		$params =
369
-		'meetingID='.urlencode($this->_meetingId).
370
-		'&password='.urlencode($this->_password);
371
-		return ($infoUrl.$params.'&checksum='.sha1("getMeetingInfo".$params.$this->_securitySalt));
372
-	}
373
-
374
-	public function getMeetingInfoWithXmlResponseArray($infoParams) {
375
-		/* USAGE:
365
+        $this->_meetingId = $this->_requiredParam($infoParams['meetingId']);
366
+        $this->_password = $this->_requiredParam($infoParams['password']);
367
+        $infoUrl = $this->_bbbServerBaseUrl."api/getMeetingInfo?";
368
+        $params =
369
+        'meetingID='.urlencode($this->_meetingId).
370
+        '&password='.urlencode($this->_password);
371
+        return ($infoUrl.$params.'&checksum='.sha1("getMeetingInfo".$params.$this->_securitySalt));
372
+    }
373
+
374
+    public function getMeetingInfoWithXmlResponseArray($infoParams) {
375
+        /* USAGE:
376 376
 		$infoParams = array(
377 377
 			'meetingId' => '1234',		-- REQUIRED - The unique id for the meeting
378 378
 			'password' => 'mp'			-- REQUIRED - The moderator password for the meeting
379 379
 		);
380 380
 		*/
381
-		$xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams));
382
-		if($xml) {
383
-			// If we don't get a success code or messageKey, find out why:
384
-			if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
385
-				$result = array(
386
-					'returncode' => $xml->returncode->__toString(),
387
-					'messageKey' => $xml->messageKey->__toString(),
388
-					'message' => $xml->message->__toString()
389
-				);
390
-				return $result;
391
-			}
392
-			else {
393
-				// In this case, we have success and meeting info:
394
-				$result = array(
395
-					'returncode' => $xml->returncode->__toString(),
396
-					'meetingName' => $xml->meetingName->__toString(),
397
-					'meetingId' => $xml->meetingID->__toString(),
398
-					'createTime' => $xml->createTime->__toString(),
399
-					'voiceBridge' => $xml->voiceBridge->__toString(),
400
-					'attendeePw' => $xml->attendeePW->__toString(),
401
-					'moderatorPw' => $xml->moderatorPW->__toString(),
402
-					'running' => $xml->running->__toString(),
403
-					'recording' => $xml->recording->__toString(),
404
-					'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(),
405
-					'startTime' => $xml->startTime->__toString(),
406
-					'endTime' => $xml->endTime->__toString(),
407
-					'participantCount' => $xml->participantCount->__toString(),
408
-					'maxUsers' => $xml->maxUsers->__toString(),
409
-					'moderatorCount' => $xml->moderatorCount->__toString(),
410
-				);
411
-				// Then interate through attendee results and return them as part of the array:
412
-				foreach ($xml->attendees->attendee as $a) {
413
-					$result[] = array(
414
-						'userId' => $a->userID->__toString(),
415
-						'fullName' => $a->fullName->__toString(),
416
-						'role' => $a->role->__toString()
417
-					);
418
-				}
419
-				return $result;
420
-			}
421
-		}
422
-		else {
423
-			return null;
424
-		}
425
-
426
-	}
427
-
428
-	/* __________________ BBB RECORDING METHODS _________________ */
429
-	/* The methods in the following section support the following categories of the BBB API:
381
+        $xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams));
382
+        if($xml) {
383
+            // If we don't get a success code or messageKey, find out why:
384
+            if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
385
+                $result = array(
386
+                    'returncode' => $xml->returncode->__toString(),
387
+                    'messageKey' => $xml->messageKey->__toString(),
388
+                    'message' => $xml->message->__toString()
389
+                );
390
+                return $result;
391
+            }
392
+            else {
393
+                // In this case, we have success and meeting info:
394
+                $result = array(
395
+                    'returncode' => $xml->returncode->__toString(),
396
+                    'meetingName' => $xml->meetingName->__toString(),
397
+                    'meetingId' => $xml->meetingID->__toString(),
398
+                    'createTime' => $xml->createTime->__toString(),
399
+                    'voiceBridge' => $xml->voiceBridge->__toString(),
400
+                    'attendeePw' => $xml->attendeePW->__toString(),
401
+                    'moderatorPw' => $xml->moderatorPW->__toString(),
402
+                    'running' => $xml->running->__toString(),
403
+                    'recording' => $xml->recording->__toString(),
404
+                    'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded->__toString(),
405
+                    'startTime' => $xml->startTime->__toString(),
406
+                    'endTime' => $xml->endTime->__toString(),
407
+                    'participantCount' => $xml->participantCount->__toString(),
408
+                    'maxUsers' => $xml->maxUsers->__toString(),
409
+                    'moderatorCount' => $xml->moderatorCount->__toString(),
410
+                );
411
+                // Then interate through attendee results and return them as part of the array:
412
+                foreach ($xml->attendees->attendee as $a) {
413
+                    $result[] = array(
414
+                        'userId' => $a->userID->__toString(),
415
+                        'fullName' => $a->fullName->__toString(),
416
+                        'role' => $a->role->__toString()
417
+                    );
418
+                }
419
+                return $result;
420
+            }
421
+        }
422
+        else {
423
+            return null;
424
+        }
425
+
426
+    }
427
+
428
+    /* __________________ BBB RECORDING METHODS _________________ */
429
+    /* The methods in the following section support the following categories of the BBB API:
430 430
 	-- getRecordings
431 431
 	-- publishRecordings
432 432
 	-- deleteRecordings
433 433
 	*/
434 434
 
435
-	public function getRecordingsUrl($recordingParams) {
436
-		/* USAGE:
435
+    public function getRecordingsUrl($recordingParams) {
436
+        /* USAGE:
437 437
 		$recordingParams = array(
438 438
 			'meetingId' => '1234',		-- OPTIONAL - comma separate if multiple ids
439 439
 		);
440 440
 		*/
441
-		$recordingsUrl = $this->_bbbServerBaseUrl."api/getRecordings?";
442
-		$params = 'meetingID='.urlencode($recordingParams['meetingId']);
443
-		return ($recordingsUrl.$params.'&checksum='.sha1("getRecordings".$params.$this->_securitySalt));
441
+        $recordingsUrl = $this->_bbbServerBaseUrl."api/getRecordings?";
442
+        $params = 'meetingID='.urlencode($recordingParams['meetingId']);
443
+        return ($recordingsUrl.$params.'&checksum='.sha1("getRecordings".$params.$this->_securitySalt));
444 444
 
445
-	}
445
+    }
446 446
 
447
-	public function getRecordingsWithXmlResponseArray($recordingParams) {
448
-		/* USAGE:
447
+    public function getRecordingsWithXmlResponseArray($recordingParams) {
448
+        /* USAGE:
449 449
 		$recordingParams = array(
450 450
 			'meetingId' => '1234',		-- OPTIONAL - comma separate if multiple ids
451 451
 		);
@@ -453,121 +453,121 @@  discard block
 block discarded – undo
453 453
 		when creating a meeting, it will kick users out after the duration. Should
454 454
 		probably be required in user code when 'recording' is set to true.
455 455
 		*/
456
-		$xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams));
457
-		if($xml) {
458
-			// If we don't get a success code or messageKey, find out why:
459
-			if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
460
-				$result = array(
461
-					'returncode' => $xml->returncode->__toString(),
462
-					'messageKey' => $xml->messageKey->__toString(),
463
-					'message' => $xml->message->__toString()
464
-				);
465
-				return $result;
466
-			}
467
-			else {
468
-				// In this case, we have success and recording info:
469
-				$result = array(
470
-					'returncode' => $xml->returncode->__toString(),
471
-					'messageKey' => $xml->messageKey->__toString(),
472
-					'message' => $xml->message->__toString()
473
-				);
474
-
475
-				foreach ($xml->recordings->recording as $r) {
476
-					$result[] = array(
477
-						'recordId' => $r->recordID->__toString(),
478
-						'meetingId' => $r->meetingID->__toString(),
479
-						'name' => $r->name->__toString(),
480
-						'published' => $r->published->__toString(),
481
-						'startTime' => $r->startTime->__toString(),
482
-						'endTime' => $r->endTime->__toString(),
483
-						'playbackFormatType' => $r->playback->format->type->__toString(),
484
-						'playbackFormatUrl' => $r->playback->format->url->__toString(),
485
-						'playbackFormatLength' => $r->playback->format->length->__toString(),
486
-						'metadataTitle' => $r->metadata->title->__toString(),
487
-						'metadataSubject' => $r->metadata->subject->__toString(),
488
-						'metadataDescription' => $r->metadata->description->__toString(),
489
-						'metadataCreator' => $r->metadata->creator->__toString(),
490
-						'metadataContributor' => $r->metadata->contributor->__toString(),
491
-						'metadataLanguage' => $r->metadata->language->__toString(),
492
-						// Add more here as needed for your app depending on your
493
-						// use of metadata when creating recordings.
494
-						);
495
-					}
496
-				return $result;
497
-			}
498
-		}
499
-		else {
500
-			return null;
501
-		}
502
-	}
503
-
504
-	public function getPublishRecordingsUrl($recordingParams) {
505
-		/* USAGE:
456
+        $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams));
457
+        if($xml) {
458
+            // If we don't get a success code or messageKey, find out why:
459
+            if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
460
+                $result = array(
461
+                    'returncode' => $xml->returncode->__toString(),
462
+                    'messageKey' => $xml->messageKey->__toString(),
463
+                    'message' => $xml->message->__toString()
464
+                );
465
+                return $result;
466
+            }
467
+            else {
468
+                // In this case, we have success and recording info:
469
+                $result = array(
470
+                    'returncode' => $xml->returncode->__toString(),
471
+                    'messageKey' => $xml->messageKey->__toString(),
472
+                    'message' => $xml->message->__toString()
473
+                );
474
+
475
+                foreach ($xml->recordings->recording as $r) {
476
+                    $result[] = array(
477
+                        'recordId' => $r->recordID->__toString(),
478
+                        'meetingId' => $r->meetingID->__toString(),
479
+                        'name' => $r->name->__toString(),
480
+                        'published' => $r->published->__toString(),
481
+                        'startTime' => $r->startTime->__toString(),
482
+                        'endTime' => $r->endTime->__toString(),
483
+                        'playbackFormatType' => $r->playback->format->type->__toString(),
484
+                        'playbackFormatUrl' => $r->playback->format->url->__toString(),
485
+                        'playbackFormatLength' => $r->playback->format->length->__toString(),
486
+                        'metadataTitle' => $r->metadata->title->__toString(),
487
+                        'metadataSubject' => $r->metadata->subject->__toString(),
488
+                        'metadataDescription' => $r->metadata->description->__toString(),
489
+                        'metadataCreator' => $r->metadata->creator->__toString(),
490
+                        'metadataContributor' => $r->metadata->contributor->__toString(),
491
+                        'metadataLanguage' => $r->metadata->language->__toString(),
492
+                        // Add more here as needed for your app depending on your
493
+                        // use of metadata when creating recordings.
494
+                        );
495
+                    }
496
+                return $result;
497
+            }
498
+        }
499
+        else {
500
+            return null;
501
+        }
502
+    }
503
+
504
+    public function getPublishRecordingsUrl($recordingParams) {
505
+        /* USAGE:
506 506
 		$recordingParams = array(
507 507
 			'recordId' => '1234',		-- REQUIRED - comma separate if multiple ids
508 508
 			'publish' => 'true',		-- REQUIRED - boolean: true/false
509 509
 		);
510 510
 		*/
511
-		$recordingsUrl = $this->_bbbServerBaseUrl."api/publishRecordings?";
512
-		$params =
513
-		'recordID='.urlencode($recordingParams['recordId']).
514
-		'&publish='.urlencode($recordingParams['publish']);
515
-		return ($recordingsUrl.$params.'&checksum='.sha1("publishRecordings".$params.$this->_securitySalt));
511
+        $recordingsUrl = $this->_bbbServerBaseUrl."api/publishRecordings?";
512
+        $params =
513
+        'recordID='.urlencode($recordingParams['recordId']).
514
+        '&publish='.urlencode($recordingParams['publish']);
515
+        return ($recordingsUrl.$params.'&checksum='.sha1("publishRecordings".$params.$this->_securitySalt));
516 516
 
517
-	}
517
+    }
518 518
 
519
-	public function publishRecordingsWithXmlResponseArray($recordingParams) {
520
-		/* USAGE:
519
+    public function publishRecordingsWithXmlResponseArray($recordingParams) {
520
+        /* USAGE:
521 521
 		$recordingParams = array(
522 522
 			'recordId' => '1234',		-- REQUIRED - comma separate if multiple ids
523 523
 			'publish' => 'true',		-- REQUIRED - boolean: true/false
524 524
 		);
525 525
 		*/
526
-		$xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams));
527
-		if($xml) {
528
-			return array(
529
-				'returncode' => $xml->returncode->__toString(),
530
-				'published' => $xml->published->__toString() 	// -- Returns true/false.
531
-			);
532
-		}
533
-		else {
534
-			return null;
535
-		}
536
-
537
-
538
-	}
539
-
540
-	public function getDeleteRecordingsUrl($recordingParams) {
541
-		/* USAGE:
526
+        $xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams));
527
+        if($xml) {
528
+            return array(
529
+                'returncode' => $xml->returncode->__toString(),
530
+                'published' => $xml->published->__toString() 	// -- Returns true/false.
531
+            );
532
+        }
533
+        else {
534
+            return null;
535
+        }
536
+
537
+
538
+    }
539
+
540
+    public function getDeleteRecordingsUrl($recordingParams) {
541
+        /* USAGE:
542 542
 		$recordingParams = array(
543 543
 			'recordId' => '1234',		-- REQUIRED - comma separate if multiple ids
544 544
 		);
545 545
 		*/
546
-		$recordingsUrl = $this->_bbbServerBaseUrl."api/deleteRecordings?";
547
-		$params =
548
-		'recordID='.urlencode($recordingParams['recordId']);
549
-		return ($recordingsUrl.$params.'&checksum='.sha1("deleteRecordings".$params.$this->_securitySalt));
550
-	}
551
-
552
-	public function deleteRecordingsWithXmlResponseArray($recordingParams) {
553
-		/* USAGE:
546
+        $recordingsUrl = $this->_bbbServerBaseUrl."api/deleteRecordings?";
547
+        $params =
548
+        'recordID='.urlencode($recordingParams['recordId']);
549
+        return ($recordingsUrl.$params.'&checksum='.sha1("deleteRecordings".$params.$this->_securitySalt));
550
+    }
551
+
552
+    public function deleteRecordingsWithXmlResponseArray($recordingParams) {
553
+        /* USAGE:
554 554
 		$recordingParams = array(
555 555
 			'recordId' => '1234',		-- REQUIRED - comma separate if multiple ids
556 556
 		);
557 557
 		*/
558 558
 
559
-		$xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams));
560
-		if($xml) {
561
-			return array(
562
-				'returncode' => $xml->returncode->__toString(),
563
-				'deleted' => $xml->deleted->__toString() 	// -- Returns true/false.
564
-			);
565
-		}
566
-		else {
567
-			return null;
568
-		}
569
-
570
-	}
559
+        $xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams));
560
+        if($xml) {
561
+            return array(
562
+                'returncode' => $xml->returncode->__toString(),
563
+                'deleted' => $xml->deleted->__toString() 	// -- Returns true/false.
564
+            );
565
+        }
566
+        else {
567
+            return null;
568
+        }
569
+
570
+    }
571 571
 
572 572
 
573 573
 
Please login to merge, or discard this patch.
plugin/buycourses/src/paypalfunctions.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -324,6 +324,8 @@
 block discarded – undo
324 324
  * @nvpStr is nvp string.
325 325
  * returns an associtive array containing the response from the server.
326 326
  *
327
+ * @param string $methodName
328
+ * @param string $nvpStr
327 329
  */
328 330
 function hash_call($methodName, $nvpStr)
329 331
 {
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
  *		phoneNum:			the phoneNum  entered on the merchant's site
112 112
  */
113 113
 function CallMarkExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL,
114
-                                 $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState,
115
-                                 $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum
114
+                                    $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState,
115
+                                    $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum
116 116
 )
117 117
 {
118 118
     // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
  */
266 266
 
267 267
 function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber,
268
-                       $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip,
269
-                       $countryCode, $currencyCode)
268
+                        $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip,
269
+                        $countryCode, $currencyCode)
270 270
 {
271 271
     //Construct the parameter string that describes DoDirectPayment
272 272
     $nvpstr = "&AMT=" . $paymentAmount;
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $extra)
68 68
 {
69 69
     // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
70
-    $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount;
71
-    $nvpstr .= "&PAYMENTREQUEST_0_ITEMAMT=" . $paymentAmount;
72
-    $nvpstr .= "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType;
73
-    $nvpstr .= "&RETURNURL=" . $returnURL;
74
-    $nvpstr .= "&CANCELURL=" . $cancelURL;
75
-    $nvpstr .= "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
70
+    $nvpstr = "&PAYMENTREQUEST_0_AMT=".$paymentAmount;
71
+    $nvpstr .= "&PAYMENTREQUEST_0_ITEMAMT=".$paymentAmount;
72
+    $nvpstr .= "&PAYMENTREQUEST_0_PAYMENTACTION=".$paymentType;
73
+    $nvpstr .= "&RETURNURL=".$returnURL;
74
+    $nvpstr .= "&CANCELURL=".$cancelURL;
75
+    $nvpstr .= "&PAYMENTREQUEST_0_CURRENCYCODE=".$currencyCodeType;
76 76
     $nvpstr .= $extra;
77 77
 
78 78
     $_SESSION["currencyCodeType"] = $currencyCodeType;
@@ -116,20 +116,20 @@  discard block
 block discarded – undo
116 116
 )
117 117
 {
118 118
     // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
119
-    $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount;
120
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType;
121
-    $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
122
-    $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
123
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
124
-    $nvpstr = $nvpstr . "&ADDROVERRIDE=1";
125
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTONAME=" . $shipToName;
126
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTREET=" . $shipToStreet;
127
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTREET2=" . $shipToStreet2;
128
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOCITY=" . $shipToCity;
129
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTATE=" . $shipToState;
130
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=" . $shipToCountryCode;
131
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOZIP=" . $shipToZip;
132
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOPHONENUM=" . $phoneNum;
119
+    $nvpstr = "&PAYMENTREQUEST_0_AMT=".$paymentAmount;
120
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_PAYMENTACTION=".$paymentType;
121
+    $nvpstr = $nvpstr."&RETURNURL=".$returnURL;
122
+    $nvpstr = $nvpstr."&CANCELURL=".$cancelURL;
123
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_CURRENCYCODE=".$currencyCodeType;
124
+    $nvpstr = $nvpstr."&ADDROVERRIDE=1";
125
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTONAME=".$shipToName;
126
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOSTREET=".$shipToStreet;
127
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOSTREET2=".$shipToStreet2;
128
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOCITY=".$shipToCity;
129
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOSTATE=".$shipToState;
130
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=".$shipToCountryCode;
131
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOZIP=".$shipToZip;
132
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOPHONENUM=".$phoneNum;
133 133
 
134 134
     $_SESSION["currencyCodeType"] = $currencyCodeType;
135 135
     $_SESSION["PaymentType"] = $paymentType;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      * Build a second API request to PayPal, using the token as the
173 173
      * ID to get the details on the payment authorization
174 174
      */
175
-    $nvpstr = "&TOKEN=" . $token;
175
+    $nvpstr = "&TOKEN=".$token;
176 176
 
177 177
     /**
178 178
      * Make the API call and store the results in an array.
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
     $payerID = urlencode($_SESSION['payer_id']);
214 214
     $serverName = urlencode($_SERVER['SERVER_NAME']);
215 215
 
216
-    $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_AMT=' . $FinalPaymentAmt;
217
-    $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName;
218
-    $nvpstr = '&' . http_build_query([
216
+    $nvpstr = '&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTREQUEST_0_PAYMENTACTION='.$paymentType.'&PAYMENTREQUEST_0_AMT='.$FinalPaymentAmt;
217
+    $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE='.$currencyCodeType.'&IPADDRESS='.$serverName;
218
+    $nvpstr = '&'.http_build_query([
219 219
         'TOKEN' => $token,
220 220
         'PAYERID' => $payerID,
221 221
         'PAYMENTACTION' => $paymentType,
@@ -269,20 +269,20 @@  discard block
 block discarded – undo
269 269
                        $countryCode, $currencyCode)
270 270
 {
271 271
     //Construct the parameter string that describes DoDirectPayment
272
-    $nvpstr = "&AMT=" . $paymentAmount;
273
-    $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCode;
274
-    $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType;
275
-    $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . $creditCardType;
276
-    $nvpstr = $nvpstr . "&ACCT=" . $creditCardNumber;
277
-    $nvpstr = $nvpstr . "&EXPDATE=" . $expDate;
278
-    $nvpstr = $nvpstr . "&CVV2=" . $cvv2;
279
-    $nvpstr = $nvpstr . "&FIRSTNAME=" . $firstName;
280
-    $nvpstr = $nvpstr . "&LASTNAME=" . $lastName;
281
-    $nvpstr = $nvpstr . "&STREET=" . $street;
282
-    $nvpstr = $nvpstr . "&CITY=" . $city;
283
-    $nvpstr = $nvpstr . "&STATE=" . $state;
284
-    $nvpstr = $nvpstr . "&COUNTRYCODE=" . $countryCode;
285
-    $nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR'];
272
+    $nvpstr = "&AMT=".$paymentAmount;
273
+    $nvpstr = $nvpstr."&CURRENCYCODE=".$currencyCode;
274
+    $nvpstr = $nvpstr."&PAYMENTACTION=".$paymentType;
275
+    $nvpstr = $nvpstr."&CREDITCARDTYPE=".$creditCardType;
276
+    $nvpstr = $nvpstr."&ACCT=".$creditCardNumber;
277
+    $nvpstr = $nvpstr."&EXPDATE=".$expDate;
278
+    $nvpstr = $nvpstr."&CVV2=".$cvv2;
279
+    $nvpstr = $nvpstr."&FIRSTNAME=".$firstName;
280
+    $nvpstr = $nvpstr."&LASTNAME=".$lastName;
281
+    $nvpstr = $nvpstr."&STREET=".$street;
282
+    $nvpstr = $nvpstr."&CITY=".$city;
283
+    $nvpstr = $nvpstr."&STATE=".$state;
284
+    $nvpstr = $nvpstr."&COUNTRYCODE=".$countryCode;
285
+    $nvpstr = $nvpstr."&IPADDRESS=".$_SERVER['REMOTE_ADDR'];
286 286
 
287 287
     $resArray = hash_call("DoDirectPayment", $nvpstr);
288 288
 
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
     //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
346 346
     //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
347 347
     if ($USE_PROXY) {
348
-        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT);
348
+        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT);
349 349
     }
350 350
 
351 351
     //NVPRequest for submitting to server
352
-    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) .
353
-        "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) .
354
-        "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);
352
+    $nvpreq = "METHOD=".urlencode($methodName)."&VERSION=".urlencode($version).
353
+        "&PWD=".urlencode($API_Password)."&USER=".urlencode($API_UserName).
354
+        "&SIGNATURE=".urlencode($API_Signature).$nvpStr."&BUTTONSOURCE=".urlencode($sBNCode);
355 355
 
356 356
     //setting the nvpreq as POST FIELD to curl
357 357
     curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 {
386 386
     global $PAYPAL_URL;
387 387
     // Redirect to paypal.com here
388
-    $payPalURL = $PAYPAL_URL . $token;
389
-    header("Location: " . $payPalURL);
388
+    $payPalURL = $PAYPAL_URL.$token;
389
+    header("Location: ".$payPalURL);
390 390
     exit;
391 391
 }
392 392
 
Please login to merge, or discard this patch.