Completed
Push — 1.10.x ( 3c9fe3...995e8b )
by Yannick
116:12 queued 73:22
created
main/webservices/additional_webservices.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 }
85 85
 
86 86
 /**
87
- * @param $directoryPath
87
+ * @param string $directoryPath
88 88
  * @return bool
89 89
  */
90 90
 function deleteDirectory($directoryPath)
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 {
20 20
     $fileData = $pptData['file_data'];
21 21
     $dataInfo = pathinfo($pptData['file_name']);
22
-    $fileName =  basename($pptData['file_name'], '.' . $dataInfo['extension']);
22
+    $fileName = basename($pptData['file_name'], '.'.$dataInfo['extension']);
23 23
     $fullFileName = $pptData['file_name'];
24 24
 
25 25
     $tempArchivePath = api_get_path(SYS_ARCHIVE_PATH);
26
-    $tempPath = $tempArchivePath . 'wsConvert/' . $fileName . '/';
27
-    $tempPathNewFiles = $tempArchivePath . 'wsConvert/' . $fileName . '-n/';
26
+    $tempPath = $tempArchivePath.'wsConvert/'.$fileName.'/';
27
+    $tempPathNewFiles = $tempArchivePath.'wsConvert/'.$fileName.'-n/';
28 28
 
29 29
     $perms = api_get_permissions_for_new_directories();
30 30
     if (!is_dir($tempPath)) {
@@ -33,28 +33,28 @@  discard block
 block discarded – undo
33 33
     if (!is_dir($tempPathNewFiles)) {
34 34
         mkdir($tempPathNewFiles, $perms, true);
35 35
     }
36
-    if (!is_dir($tempPathNewFiles . $fileName)) {
37
-        mkdir($tempPathNewFiles . $fileName, $perms, true);
36
+    if (!is_dir($tempPathNewFiles.$fileName)) {
37
+        mkdir($tempPathNewFiles.$fileName, $perms, true);
38 38
     }
39 39
 
40 40
     $file = base64_decode($fileData);
41
-    file_put_contents($tempPath . $fullFileName, $file);
41
+    file_put_contents($tempPath.$fullFileName, $file);
42 42
 
43 43
     if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php
44
-        $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png');
45
-        $classPath = $converterPath . ';' . $converterPath . '/jodconverter-2.2.2.jar;' . $converterPath . '/jodconverter-cli-2.2.2.jar';
46
-        $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $classPath . '" DokeosConverter';
44
+        $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png');
45
+        $classPath = $converterPath.';'.$converterPath.'/jodconverter-2.2.2.jar;'.$converterPath.'/jodconverter-cli-2.2.2.jar';
46
+        $cmd = 'java -Dfile.encoding=UTF-8 -cp "'.$classPath.'" DokeosConverter';
47 47
     } else {
48
-        $converterPath = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png';
48
+        $converterPath = api_get_path(SYS_PATH).'main/inc/lib/ppt2png';
49 49
         $classPath = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar';
50
-        $cmd = 'cd ' . $converterPath . ' && java ' . $classPath . ' DokeosConverter';
50
+        $cmd = 'cd '.$converterPath.' && java '.$classPath.' DokeosConverter';
51 51
     }
52 52
 
53
-    $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port');
54
-    $cmd .= ' -w 720 -h 540 -d oogie "' . $tempPath . $fullFileName.'"  "' . $tempPathNewFiles . $fileName . '.html"';
53
+    $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port');
54
+    $cmd .= ' -w 720 -h 540 -d oogie "'.$tempPath.$fullFileName.'"  "'.$tempPathNewFiles.$fileName.'.html"';
55 55
 
56 56
     $perms = api_get_permissions_for_new_files();
57
-    chmod($tempPathNewFiles . $fileName, $perms, true);
57
+    chmod($tempPathNewFiles.$fileName, $perms, true);
58 58
 
59 59
     $files = array();
60 60
     $return = 0;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $images = array();
65 65
         foreach ($files as $file) {
66 66
             $imageData = explode('||', $file);
67
-            $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles . $fileName . '/' . $imageData[1]));
67
+            $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles.$fileName.'/'.$imageData[1]));
68 68
         }
69 69
         $data = array(
70 70
             'files' => $files,
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
  */
90 90
 function deleteDirectory($directoryPath)
91 91
 {
92
-    $files = array_diff(scandir($directoryPath), array('.','..'));
92
+    $files = array_diff(scandir($directoryPath), array('.', '..'));
93 93
     foreach ($files as $file) {
94 94
         if (is_dir("$directoryPath/$file")) {
95 95
             deleteDirectory("$directoryPath/$file");
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 $webCodePath = api_get_path(WEB_CODE_PATH);
107 107
 $options = array(
108 108
     'uri' => $webPath,
109
-    'location' => $webCodePath . 'webservices/additional_webservices.php'
109
+    'location' => $webCodePath.'webservices/additional_webservices.php'
110 110
 );
111 111
 
112 112
 $soapServer = new SoapServer(NULL, $options);
Please login to merge, or discard this patch.
main/webservices/cm_webservice.php 4 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,6 +32,8 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param int Error code
34 34
 	 * @param string Error message
35
+	 * @param integer $code
36
+	 * @param string $message
35 37
 	 */
36 38
 	public function __construct($code, $message) {
37 39
 		$this->code = $code;
@@ -42,6 +44,7 @@  discard block
 block discarded – undo
42 44
 	 * Sets the error handler
43 45
 	 *
44 46
 	 * @param WSErrorHandler Error handler
47
+	 * @param WSCMSoapErrorHandler $handler
45 48
 	 */
46 49
 	public static function setErrorHandler($handler) {
47 50
 		if($handler instanceof WSErrorHandler) {
@@ -76,6 +79,7 @@  discard block
 block discarded – undo
76 79
 	 * Handle method
77 80
 	 *
78 81
 	 * @param WSError Error
82
+	 * @return void
79 83
 	 */
80 84
 	public function handle($error);
81 85
 }
@@ -102,7 +106,7 @@  discard block
 block discarded – undo
102 106
 	 * Verifies the API key
103 107
 	 *
104 108
 	 * @param string Secret key
105
-	 * @return mixed WSError in case of failure, null in case of success
109
+	 * @return WSCMError|null WSError in case of failure, null in case of success
106 110
 	 */
107 111
 	protected function verifyKey($secret_key) {
108 112
 		$ip = trim($_SERVER['REMOTE_ADDR']);
Please login to merge, or discard this patch.
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -6,120 +6,120 @@  discard block
 block discarded – undo
6 6
  * Error returned by one of the methods of the web service. Contains an error code and an error message
7 7
  */
8 8
 class WSCMError {
9
-	/**
10
-	 * Error handler. This needs to be a class that implements the interface WSErrorHandler
11
-	 *
12
-	 * @var WSErrorHandler
13
-	 */
14
-	protected static $_handler;
9
+    /**
10
+     * Error handler. This needs to be a class that implements the interface WSErrorHandler
11
+     *
12
+     * @var WSErrorHandler
13
+     */
14
+    protected static $_handler;
15 15
 
16
-	/**
17
-	 * Error code
18
-	 *
19
-	 * @var int
20
-	 */
21
-	public $code;
16
+    /**
17
+     * Error code
18
+     *
19
+     * @var int
20
+     */
21
+    public $code;
22 22
 
23
-	/**
24
-	 * Error message
25
-	 *
26
-	 * @var string
27
-	 */
28
-	public $message;
23
+    /**
24
+     * Error message
25
+     *
26
+     * @var string
27
+     */
28
+    public $message;
29 29
 
30
-	/**
31
-	 * Constructor
32
-	 *
33
-	 * @param int Error code
34
-	 * @param string Error message
35
-	 */
36
-	public function __construct($code, $message) {
37
-		$this->code = $code;
38
-		$this->message = $message;
39
-	}
30
+    /**
31
+     * Constructor
32
+     *
33
+     * @param int Error code
34
+     * @param string Error message
35
+     */
36
+    public function __construct($code, $message) {
37
+        $this->code = $code;
38
+        $this->message = $message;
39
+    }
40 40
 
41
-	/**
42
-	 * Sets the error handler
43
-	 *
44
-	 * @param WSErrorHandler Error handler
45
-	 */
46
-	public static function setErrorHandler($handler) {
47
-		if($handler instanceof WSErrorHandler) {
48
-			self::$_handler = $handler;
49
-		}
50
-	}
41
+    /**
42
+     * Sets the error handler
43
+     *
44
+     * @param WSErrorHandler Error handler
45
+     */
46
+    public static function setErrorHandler($handler) {
47
+        if($handler instanceof WSErrorHandler) {
48
+            self::$_handler = $handler;
49
+        }
50
+    }
51 51
 
52
-	/**
53
-	 * Returns the error handler
54
-	 *
55
-	 * @return WSErrorHandler Error handler
56
-	 */
57
-	public static function getErrorHandler() {
58
-		return self::$_handler;
59
-	}
52
+    /**
53
+     * Returns the error handler
54
+     *
55
+     * @return WSErrorHandler Error handler
56
+     */
57
+    public static function getErrorHandler() {
58
+        return self::$_handler;
59
+    }
60 60
 
61
-	/**
62
-	 * Transforms the error into an array
63
-	 *
64
-	 * @return array Associative array with code and message
65
-	 */
66
-	public function toArray() {
67
-		return array('code' => $this->code, 'message' => $this->message);
68
-	}
61
+    /**
62
+     * Transforms the error into an array
63
+     *
64
+     * @return array Associative array with code and message
65
+     */
66
+    public function toArray() {
67
+        return array('code' => $this->code, 'message' => $this->message);
68
+    }
69 69
 }
70 70
 
71 71
 /**
72 72
  * Interface that must be implemented by any error handler
73 73
  */
74 74
 interface WSCMErrorHandler {
75
-	/**
76
-	 * Handle method
77
-	 *
78
-	 * @param WSError Error
79
-	 */
80
-	public function handle($error);
75
+    /**
76
+     * Handle method
77
+     *
78
+     * @param WSError Error
79
+     */
80
+    public function handle($error);
81 81
 }
82 82
 
83 83
 /**
84 84
  * Main class of the webservice. Webservice classes extend this class
85 85
  */
86 86
 class WSCM {
87
-	/**
88
-	 * Chamilo configuration
89
-	 *
90
-	 * @var array
91
-	 */
92
-	protected $_configuration;
87
+    /**
88
+     * Chamilo configuration
89
+     *
90
+     * @var array
91
+     */
92
+    protected $_configuration;
93 93
 
94
-	/**
95
-	 * Constructor
96
-	 */
97
-	public function __construct() {
98
-		$this->_configuration = $GLOBALS['_configuration'];
99
-	}
94
+    /**
95
+     * Constructor
96
+     */
97
+    public function __construct() {
98
+        $this->_configuration = $GLOBALS['_configuration'];
99
+    }
100 100
 
101
-	/**
102
-	 * Verifies the API key
103
-	 *
104
-	 * @param string Secret key
105
-	 * @return mixed WSError in case of failure, null in case of success
106
-	 */
107
-	protected function verifyKey($secret_key) {
108
-		$ip = trim($_SERVER['REMOTE_ADDR']);
109
-		// if we are behind a reverse proxy, assume it will send the
110
-		// HTTP_X_FORWARDED_FOR header and use this IP instead
111
-		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
112
-		  list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
113
-		  $ip = trim($ip1);
114
-		}
115
-		$security_key = $ip.$this->_configuration['security_key'];
101
+    /**
102
+     * Verifies the API key
103
+     *
104
+     * @param string Secret key
105
+     * @return mixed WSError in case of failure, null in case of success
106
+     */
107
+    protected function verifyKey($secret_key) {
108
+        $ip = trim($_SERVER['REMOTE_ADDR']);
109
+        // if we are behind a reverse proxy, assume it will send the
110
+        // HTTP_X_FORWARDED_FOR header and use this IP instead
111
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
112
+            list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
113
+            $ip = trim($ip1);
114
+        }
115
+        $security_key = $ip.$this->_configuration['security_key'];
116 116
 
117
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
118
-			return new WSCMError(1, "API key is invalid");
119
-		} else {
120
-			return null;
121
-		}
122
-	}
117
+        if(!api_is_valid_secret_key($secret_key, $security_key)) {
118
+            return new WSCMError(1, "API key is invalid");
119
+        } else {
120
+            return null;
121
+        }
122
+    }
123 123
 
124 124
         /**
125 125
          * Verifies if the user is valid
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
             $login = $username;
135 135
             $password = $pass;
136 136
 
137
-	    //lookup the user in the main database
137
+        //lookup the user in the main database
138 138
             $user_table = Database::get_main_table(TABLE_MAIN_USER);
139
-	    $sql = "SELECT user_id, username, password, auth_source, active, expiration_date
139
+        $sql = "SELECT user_id, username, password, auth_source, active, expiration_date
140 140
 	            FROM $user_table
141 141
 	            WHERE username = '".trim(addslashes($login))."'";
142
-	    $result = Database::query($sql);
142
+        $result = Database::query($sql);
143 143
 
144 144
             if (Database::num_rows($result) > 0) {
145 145
                 $uData = Database::fetch_array($result);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
         /**
173 173
          * Return the encrypted pass
174
-		 * @deprecated
174
+         * @deprecated
175 175
          * @param <String> $pass
176 176
          * @return <String> $pass encrypted
177 177
          */
@@ -180,112 +180,112 @@  discard block
 block discarded – undo
180 180
         }*/
181 181
 
182 182
         /**
183
-	 * Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id
184
-	 * in the system database
185
-	 *
186
-	 * @param string User id field name
187
-	 * @param string User id value
188
-	 * @return mixed System user id if the user was found, WSError otherwise
189
-	 */
190
-	protected function getUserId($user_id_field_name, $user_id_value) {
191
-		if($user_id_field_name == "chamilo_user_id") {
192
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
193
-				return intval($user_id_value);
194
-			} else {
195
-				return new WSCMError(100, "User not found");
196
-			}
197
-		} else {
198
-			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
199
-			if($user_id == 0) {
200
-				return new WSCMError(100, "User not found");
201
-			} else {
202
-				return $user_id;
203
-			}
204
-		}
205
-	}
183
+         * Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id
184
+         * in the system database
185
+         *
186
+         * @param string User id field name
187
+         * @param string User id value
188
+         * @return mixed System user id if the user was found, WSError otherwise
189
+         */
190
+    protected function getUserId($user_id_field_name, $user_id_value) {
191
+        if($user_id_field_name == "chamilo_user_id") {
192
+            if(UserManager::is_user_id_valid(intval($user_id_value))) {
193
+                return intval($user_id_value);
194
+            } else {
195
+                return new WSCMError(100, "User not found");
196
+            }
197
+        } else {
198
+            $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
199
+            if($user_id == 0) {
200
+                return new WSCMError(100, "User not found");
201
+            } else {
202
+                return $user_id;
203
+            }
204
+        }
205
+    }
206 206
 
207
-	/**
208
-	 * Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
209
-	 * in the system database
210
-	 *
211
-	 * @param string Course id field name
212
-	 * @param string Course id value
213
-	 * @return mixed System course id if the course was found, WSError otherwise
214
-	 */
215
-	protected function getCourseId($course_id_field_name, $course_id_value) {
216
-		if($course_id_field_name == "chamilo_course_id") {
217
-			if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
218
-				return intval($course_id_value);
219
-			} else {
220
-				return new WSCMError(200, "Course not found");
221
-			}
222
-		} else {
223
-			$courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
224
-			if (empty($courseId)) {
225
-				return new WSCMError(200, "Course not found");
226
-			} else {
227
-				return $courseId;
228
-			}
229
-		}
230
-	}
207
+    /**
208
+     * Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
209
+     * in the system database
210
+     *
211
+     * @param string Course id field name
212
+     * @param string Course id value
213
+     * @return mixed System course id if the course was found, WSError otherwise
214
+     */
215
+    protected function getCourseId($course_id_field_name, $course_id_value) {
216
+        if($course_id_field_name == "chamilo_course_id") {
217
+            if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
218
+                return intval($course_id_value);
219
+            } else {
220
+                return new WSCMError(200, "Course not found");
221
+            }
222
+        } else {
223
+            $courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
224
+            if (empty($courseId)) {
225
+                return new WSCMError(200, "Course not found");
226
+            } else {
227
+                return $courseId;
228
+            }
229
+        }
230
+    }
231 231
 
232
-	/**
233
-	 * Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id
234
-	 * in the system database
235
-	 *
236
-	 * @param string Session id field name
237
-	 * @param string Session id value
238
-	 * @return mixed System session id if the session was found, WSError otherwise
239
-	 */
240
-	protected function getSessionId($session_id_field_name, $session_id_value)
241
-	{
242
-		if ($session_id_field_name == "chamilo_session_id") {
243
-			$session = SessionManager::fetch((int)$session_id_value);
244
-			if(!empty($session)) {
245
-				return intval($session_id_value);
246
-			} else {
247
-				return new WSCMError(300, "Session not found");
248
-			}
249
-		} else {
250
-			$session_id = SessionManager::getSessionIdFromOriginalId(
251
-				$session_id_value,
252
-				$session_id_field_name
253
-			);
254
-			if($session_id == 0) {
255
-				return new WSCMError(300, "Session not found");
256
-			} else {
257
-				return $session_id;
258
-			}
259
-		}
260
-	}
232
+    /**
233
+     * Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id
234
+     * in the system database
235
+     *
236
+     * @param string Session id field name
237
+     * @param string Session id value
238
+     * @return mixed System session id if the session was found, WSError otherwise
239
+     */
240
+    protected function getSessionId($session_id_field_name, $session_id_value)
241
+    {
242
+        if ($session_id_field_name == "chamilo_session_id") {
243
+            $session = SessionManager::fetch((int)$session_id_value);
244
+            if(!empty($session)) {
245
+                return intval($session_id_value);
246
+            } else {
247
+                return new WSCMError(300, "Session not found");
248
+            }
249
+        } else {
250
+            $session_id = SessionManager::getSessionIdFromOriginalId(
251
+                $session_id_value,
252
+                $session_id_field_name
253
+            );
254
+            if($session_id == 0) {
255
+                return new WSCMError(300, "Session not found");
256
+            } else {
257
+                return $session_id;
258
+            }
259
+        }
260
+    }
261 261
 
262
-	/**
263
-	 * Handles an error by calling the WSError error handler
264
-	 *
265
-	 * @param WSError Error
266
-	 */
267
-	protected function handleError($error) {
268
-		$handler = WSCMError::getErrorHandler();
269
-		$handler->handle($error);
270
-	}
262
+    /**
263
+     * Handles an error by calling the WSError error handler
264
+     *
265
+     * @param WSError Error
266
+     */
267
+    protected function handleError($error) {
268
+        $handler = WSCMError::getErrorHandler();
269
+        $handler->handle($error);
270
+    }
271 271
 
272
-	/**
273
-	 * Gets a successful result
274
-	 *
275
-	 * @return array Array with a code of 0 and a message 'Operation was successful'
276
-	 */
277
-	protected function getSuccessfulResult() {
278
-		return array('code' => 0, 'message' => 'Operation was successful');
279
-	}
272
+    /**
273
+     * Gets a successful result
274
+     *
275
+     * @return array Array with a code of 0 and a message 'Operation was successful'
276
+     */
277
+    protected function getSuccessfulResult() {
278
+        return array('code' => 0, 'message' => 'Operation was successful');
279
+    }
280 280
 
281
-	/**
282
-	 * Test function. Returns the string success
283
-	 *
284
-	 * @return string Success
285
-	 */
286
-	public function test() {
287
-		return "success";
288
-	}
281
+    /**
282
+     * Test function. Returns the string success
283
+     *
284
+     * @return string Success
285
+     */
286
+    public function test() {
287
+        return "success";
288
+    }
289 289
 
290 290
         /**
291 291
          * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not)
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param WSErrorHandler Error handler
45 45
 	 */
46 46
 	public static function setErrorHandler($handler) {
47
-		if($handler instanceof WSErrorHandler) {
47
+		if ($handler instanceof WSErrorHandler) {
48 48
 			self::$_handler = $handler;
49 49
 		}
50 50
 	}
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
 		// if we are behind a reverse proxy, assume it will send the
110 110
 		// HTTP_X_FORWARDED_FOR header and use this IP instead
111 111
 		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
112
-		  list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
112
+		  list($ip1, $ip2) = split(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
113 113
 		  $ip = trim($ip1);
114 114
 		}
115 115
 		$security_key = $ip.$this->_configuration['security_key'];
116 116
 
117
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
117
+		if (!api_is_valid_secret_key($secret_key, $security_key)) {
118 118
 			return new WSCMError(1, "API key is invalid");
119 119
 		} else {
120 120
 			return null;
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
                     // Check the user's password
150 150
                         if ($password == $uData['password'] AND (trim($login) == $uData['username'])) {
151 151
                         // Check if the account is active (not locked)
152
-                            if ($uData['active']=='1') {
152
+                            if ($uData['active'] == '1') {
153 153
                                 // Check if the expiration date has not been reached
154
-                                if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
154
+                                if ($uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date'] == '0000-00-00 00:00:00') {
155 155
                                     return "valid";
156 156
                                 }
157 157
                                 else
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 * @return mixed System user id if the user was found, WSError otherwise
189 189
 	 */
190 190
 	protected function getUserId($user_id_field_name, $user_id_value) {
191
-		if($user_id_field_name == "chamilo_user_id") {
192
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
191
+		if ($user_id_field_name == "chamilo_user_id") {
192
+			if (UserManager::is_user_id_valid(intval($user_id_value))) {
193 193
 				return intval($user_id_value);
194 194
 			} else {
195 195
 				return new WSCMError(100, "User not found");
196 196
 			}
197 197
 		} else {
198 198
 			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
199
-			if($user_id == 0) {
199
+			if ($user_id == 0) {
200 200
 				return new WSCMError(100, "User not found");
201 201
 			} else {
202 202
 				return $user_id;
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 * @return mixed System course id if the course was found, WSError otherwise
214 214
 	 */
215 215
 	protected function getCourseId($course_id_field_name, $course_id_value) {
216
-		if($course_id_field_name == "chamilo_course_id") {
217
-			if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
216
+		if ($course_id_field_name == "chamilo_course_id") {
217
+			if (CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
218 218
 				return intval($course_id_value);
219 219
 			} else {
220 220
 				return new WSCMError(200, "Course not found");
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	protected function getSessionId($session_id_field_name, $session_id_value)
241 241
 	{
242 242
 		if ($session_id_field_name == "chamilo_session_id") {
243
-			$session = SessionManager::fetch((int)$session_id_value);
244
-			if(!empty($session)) {
243
+			$session = SessionManager::fetch((int) $session_id_value);
244
+			if (!empty($session)) {
245 245
 				return intval($session_id_value);
246 246
 			} else {
247 247
 				return new WSCMError(300, "Session not found");
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 				$session_id_value,
252 252
 				$session_id_field_name
253 253
 			);
254
-			if($session_id == 0) {
254
+			if ($session_id == 0) {
255 255
 				return new WSCMError(300, "Session not found");
256 256
 			} else {
257 257
 				return $session_id;
Please login to merge, or discard this patch.
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -153,18 +153,18 @@
 block discarded – undo
153 153
                                 // Check if the expiration date has not been reached
154 154
                                 if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
155 155
                                     return "valid";
156
+                                } else {
157
+                                                                    return get_lang('AccountExpired');
156 158
                                 }
157
-                                else
158
-                                    return get_lang('AccountExpired');
159
+                            } else {
160
+                                                            return get_lang('AccountInactive');
159 161
                             }
160
-                            else
161
-                                return get_lang('AccountInactive');
162
+                        } else {
163
+                                                    return get_lang('InvalidId');
162 164
                         }
163
-                        else
164
-                            return get_lang('InvalidId');
165
+                    } else {
166
+                                            return get_lang('AccountURLInactive');
165 167
                     }
166
-                    else
167
-                        return get_lang('AccountURLInactive');
168 168
                 }
169 169
                 return get_lang('InvalidId');
170 170
         }
Please login to merge, or discard this patch.
main/webservices/cm_webservice_inbox.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -204,6 +204,9 @@
 block discarded – undo
204 204
 
205 205
     }
206 206
 
207
+    /**
208
+     * @param integer $user_id
209
+     */
207 210
     protected function set_message_as_read($user_id, $message_id){
208 211
         $table_message = Database::get_main_table(TABLE_MESSAGE);
209 212
         $query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".$user_id." AND id='".$message_id."';";
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
             $table_message = Database::get_main_table(TABLE_MESSAGE);
38 38
 
39 39
             $sql_query = "SELECT id FROM $table_message " .
40
-                                     " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" .
41
-                                     " ORDER BY send_date LIMIT $from,$number_of_items";
40
+                                        " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" .
41
+                                        " ORDER BY send_date LIMIT $from,$number_of_items";
42 42
 
43 43
             $sql_result = Database::query($sql_query);
44 44
             $message = "#";
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             $table_message = Database::get_main_table(TABLE_MESSAGE);
87 87
 
88 88
             $sql_query = "SELECT ".$field_table." FROM $table_message " .
89
-                                     " WHERE user_receiver_id=".$user_id." AND id=".$message_id;
89
+                                        " WHERE user_receiver_id=".$user_id." AND id=".$message_id;
90 90
 
91 91
             $sql_result = Database::query($sql_query);
92 92
             $result = Database::fetch_row($sql_result);
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
             $table_message = Database::get_main_table(TABLE_MESSAGE);
108 108
 
109 109
             $sql_query = "SELECT id FROM $table_message " .
110
-					 "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " .
111
-					 "ORDER BY send_date LIMIT $from,$number_of_items";
110
+                        "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " .
111
+                        "ORDER BY send_date LIMIT $from,$number_of_items";
112 112
 
113 113
             $sql_result = Database::query($sql_query);
114 114
             $message = "#";
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             $table_message = Database::get_main_table(TABLE_MESSAGE);
158 158
 
159 159
             $sql_query = "SELECT ".$field_table." FROM $table_message " .
160
-                                     " WHERE user_sender_id=".$user_id." AND id=".$id;
160
+                                        " WHERE user_sender_id=".$user_id." AND id=".$id;
161 161
 
162 162
             $sql_result = Database::query($sql_query);
163 163
             $result = Database::fetch_row($sql_result);
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
             $table_message = Database::get_main_table(TABLE_MESSAGE);
189 189
 
190 190
             $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ".
191
-                           " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
191
+                            " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
192 192
             $result = Database::query($query);
193 193
 
194 194
             $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ".
195
-                           " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
195
+                            " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
196 196
             $result = Database::query($query);
197 197
 
198 198
             $inbox_last_id = Database::insert_id();
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 {
13 13
     public function unreadMessage($username, $password)
14 14
     {
15
-        if($this->verifyUserPass($username, $password) == "valid")
15
+        if ($this->verifyUserPass($username, $password) == "valid")
16 16
         {
17 17
             $table_message = Database::get_main_table(TABLE_MESSAGE);
18 18
             $user_id = UserManager::get_user_id_from_username($username);
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function get_message_id($username, $password, $from, $number_of_items)
32 32
     {
33
-        if($this->verifyUserPass($username, $password) == "valid")
33
+        if ($this->verifyUserPass($username, $password) == "valid")
34 34
         {
35 35
             $user_id = UserManager::get_user_id_from_username($username);
36 36
 
37 37
             $table_message = Database::get_main_table(TABLE_MESSAGE);
38 38
 
39
-            $sql_query = "SELECT id FROM $table_message " .
40
-                                     " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" .
39
+            $sql_query = "SELECT id FROM $table_message ".
40
+                                     " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)".
41 41
                                      " ORDER BY send_date LIMIT $from,$number_of_items";
42 42
 
43 43
             $sql_result = Database::query($sql_query);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function get_message_data($username, $password, $message_id, $field)
57 57
     {
58
-        if($this->verifyUserPass($username, $password) == "valid")
58
+        if ($this->verifyUserPass($username, $password) == "valid")
59 59
         {
60 60
             $htmlcode = false;
61 61
             $user_id = UserManager::get_user_id_from_username($username);
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 
86 86
             $table_message = Database::get_main_table(TABLE_MESSAGE);
87 87
 
88
-            $sql_query = "SELECT ".$field_table." FROM $table_message " .
88
+            $sql_query = "SELECT ".$field_table." FROM $table_message ".
89 89
                                      " WHERE user_receiver_id=".$user_id." AND id=".$message_id;
90 90
 
91 91
             $sql_result = Database::query($sql_query);
92 92
             $result = Database::fetch_row($sql_result);
93 93
             return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
94 94
 
95
-        }else
95
+        } else
96 96
             return get_lang('InvalidId');
97 97
 
98 98
 
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 
101 101
     public function get_message_id_sent($username, $password, $from, $number_of_items)
102 102
     {
103
-        if($this->verifyUserPass($username, $password) == "valid")
103
+        if ($this->verifyUserPass($username, $password) == "valid")
104 104
         {
105 105
             $user_id = UserManager::get_user_id_from_username($username);
106 106
 
107 107
             $table_message = Database::get_main_table(TABLE_MESSAGE);
108 108
 
109
-            $sql_query = "SELECT id FROM $table_message " .
110
-					 "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " .
109
+            $sql_query = "SELECT id FROM $table_message ".
110
+					 "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." ".
111 111
 					 "ORDER BY send_date LIMIT $from,$number_of_items";
112 112
 
113 113
             $sql_result = Database::query($sql_query);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function get_message_data_sent($username, $password, $id, $field)
128 128
     {
129
-        if($this->verifyUserPass($username, $password) == "valid")
129
+        if ($this->verifyUserPass($username, $password) == "valid")
130 130
         {
131 131
             $htmlcode = false;
132 132
             switch ($field)
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
             $table_message = Database::get_main_table(TABLE_MESSAGE);
158 158
 
159
-            $sql_query = "SELECT ".$field_table." FROM $table_message " .
159
+            $sql_query = "SELECT ".$field_table." FROM $table_message ".
160 160
                                      " WHERE user_sender_id=".$user_id." AND id=".$id;
161 161
 
162 162
             $sql_result = Database::query($sql_query);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
             return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
166 166
 
167
-        }else
167
+        } else
168 168
             return get_lang('InvalidId');
169 169
 
170 170
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     public function message_send($username, $password, $receiver_user_id, $subject, $content)
174 174
     {
175 175
         //TODO: verificar data de envio. Esta divergindo de data!
176
-        if($this->verifyUserPass($username, $password) == "valid")
176
+        if ($this->verifyUserPass($username, $password) == "valid")
177 177
         {
178 178
             $group_id = intval(0);
179 179
             $parent_id = intval(0);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
     }
206 206
 
207
-    protected function set_message_as_read($user_id, $message_id){
207
+    protected function set_message_as_read($user_id, $message_id) {
208 208
         $table_message = Database::get_main_table(TABLE_MESSAGE);
209 209
         $query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".$user_id." AND id='".$message_id."';";
210 210
         $result = Database::query($query);
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 
49 49
             return $message;
50 50
 
51
-        } else
52
-            return get_lang('InvalidId');
51
+        } else {
52
+                    return get_lang('InvalidId');
53
+        }
53 54
 
54 55
     }
55 56
 
@@ -92,8 +93,9 @@  discard block
 block discarded – undo
92 93
             $result = Database::fetch_row($sql_result);
93 94
             return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
94 95
 
95
-        }else
96
-            return get_lang('InvalidId');
96
+        } else {
97
+                    return get_lang('InvalidId');
98
+        }
97 99
 
98 100
 
99 101
     }
@@ -118,8 +120,9 @@  discard block
 block discarded – undo
118 120
 
119 121
             return $message;
120 122
 
121
-        } else
122
-            return get_lang('InvalidId');
123
+        } else {
124
+                    return get_lang('InvalidId');
125
+        }
123 126
 
124 127
     }
125 128
 
@@ -164,8 +167,9 @@  discard block
 block discarded – undo
164 167
 
165 168
             return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
166 169
 
167
-        }else
168
-            return get_lang('InvalidId');
170
+        } else {
171
+                    return get_lang('InvalidId');
172
+        }
169 173
 
170 174
 
171 175
     }
@@ -199,8 +203,9 @@  discard block
 block discarded – undo
199 203
 
200 204
             return $inbox_last_id;
201 205
 
202
-        } else
203
-            return get_lang('InvalidId');
206
+        } else {
207
+                    return get_lang('InvalidId');
208
+        }
204 209
 
205 210
     }
206 211
 
Please login to merge, or discard this patch.
main/webservices/cm_webservice_user.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@
 block discarded – undo
137 137
     /**
138 138
     * Get a list of users of which the given conditions match with a LIKE '%cond%'
139 139
     * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
-    * @param array $order_by a list of fields on which sort
140
+    * @param string[] $order_by a list of fields on which sort
141 141
     * @return array An array with all users of the platform.
142 142
     * @todo optional course code parameter, optional sorting parameters...
143 143
      *@todo Use the UserManager class
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     {
96 96
         global $charset;
97 97
         if ($this->verifyUserPass($username, $password) == "valid") {
98
-		    $user_id = UserManager::get_user_id_from_username($username);
98
+            $user_id = UserManager::get_user_id_from_username($username);
99 99
             $message_title = get_lang('Invitation');
100 100
             $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
101 101
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 
136 136
 
137 137
     /**
138
-    * Get a list of users of which the given conditions match with a LIKE '%cond%'
139
-    * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
-    * @param array $order_by a list of fields on which sort
141
-    * @return array An array with all users of the platform.
142
-    * @todo optional course code parameter, optional sorting parameters...
138
+     * Get a list of users of which the given conditions match with a LIKE '%cond%'
139
+     * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
+     * @param array $order_by a list of fields on which sort
141
+     * @return array An array with all users of the platform.
142
+     * @todo optional course code parameter, optional sorting parameters...
143 143
      *@todo Use the UserManager class
144 144
      * @todo security filter order by
145
-    */
145
+     */
146 146
     private static function get_user_list_like_start($conditions = array(), $order_by = array())
147 147
     {
148 148
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function find_id_user($username, $password, $name)
15 15
     {
16
-        if($this->verifyUserPass($username, $password) == "valid")
16
+        if ($this->verifyUserPass($username, $password) == "valid")
17 17
         {
18 18
 
19 19
             $listResult = "#";
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
             }
41 41
 
42 42
             $listArrayResult = array_unique($listArray);
43
-            foreach($listArrayResult as $result)
43
+            foreach ($listArrayResult as $result)
44 44
             {
45
-                $listResult .= $result . "#";
45
+                $listResult .= $result."#";
46 46
             }
47 47
 
48 48
             return $listResult;
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
         if ($this->verifyUserPass($username, $password) == "valid") {
98 98
 		    $user_id = UserManager::get_user_id_from_username($username);
99 99
             $message_title = get_lang('Invitation');
100
-            $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
100
+            $count_is_true = SocialManager::send_invitation_friend($user_id, $userfriend_id, $message_title, $content_message);
101 101
 
102 102
             if ($count_is_true) {
103
-                return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false);
103
+                return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES, $charset), false);
104 104
             } else {
105
-                return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false);
105
+                return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES, $charset), false);
106 106
             }
107 107
         }
108 108
         return get_lang('InvalidId');
Please login to merge, or discard this patch.
main/webservices/lp.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -20,6 +20,9 @@
 block discarded – undo
20 20
 
21 21
 define('WS_ERROR_SECRET_KEY', 1);
22 22
 
23
+/**
24
+ * @param integer $code
25
+ */
23 26
 function return_error($code) {
24 27
     $fault = null;
25 28
     switch ($code) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -581,7 +581,7 @@
 block discarded – undo
581 581
     /*$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null;
582 582
     $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;*/
583 583
 
584
-     $courseInfo = CourseManager::getCourseInfoFromOriginalId(
584
+        $courseInfo = CourseManager::getCourseInfoFromOriginalId(
585 585
         $courseIdValue,
586 586
         $courseIdName
587 587
     );
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     }
66 66
 
67 67
     if ($debug) {
68
-        error_log("checkip " . intval($check_ip));
68
+        error_log("checkip ".intval($check_ip));
69 69
     }
70 70
 
71 71
     if ($check_ip) {
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 );
121 121
 
122 122
 // Register the method to expose
123
-$server->register('WSImportLP',                            // method name
124
-    array('params' => 'tns:params'),  // input parameters
125
-    array('return' => 'xsd:string'),                                        // output parameters
126
-    'urn:WSLP',                                                   // namespace
127
-    'urn:WSLP#WSImportLP',                       // soapaction
128
-    'rpc',                                                                  // style
129
-    'encoded',                                                              // use
123
+$server->register('WSImportLP', // method name
124
+    array('params' => 'tns:params'), // input parameters
125
+    array('return' => 'xsd:string'), // output parameters
126
+    'urn:WSLP', // namespace
127
+    'urn:WSLP#WSImportLP', // soapaction
128
+    'rpc', // style
129
+    'encoded', // use
130 130
     'This service adds users'                                               // documentation
131 131
 );
132 132
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
     $uniqueFile = uniqid();
185 185
     $userId = 1; // admin
186
-    $filePath = api_get_path(SYS_ARCHIVE_PATH) . $uniqueFile;
186
+    $filePath = api_get_path(SYS_ARCHIVE_PATH).$uniqueFile;
187 187
     file_put_contents($filePath, $fileData);
188 188
 
189 189
     $fileName = $params['filename'];
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
     'all',
258 258
     '',
259 259
     array(
260
-        'id'    => array('name' => 'id',    'type' => 'xsd:string'),
261
-        'name'  => array('name' => 'name',  'type' => 'xsd:string'),
260
+        'id'    => array('name' => 'id', 'type' => 'xsd:string'),
261
+        'name'  => array('name' => 'name', 'type' => 'xsd:string'),
262 262
     )
263 263
 );
264 264
 
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 );
275 275
 
276 276
 // Register the method to expose
277
-$server->register('WSGetLpList',                            // method name
278
-    array('params' => 'tns:paramsGetLpList'),  // input parameters
279
-    array('return' => 'tns:lpList'),                                        // output parameters
280
-    'urn:WSLP',                                                   // namespace
281
-    'urn:WSLP#WSGetLpList',                       // soapaction
282
-    'rpc',                                                                  // style
283
-    'encoded',                                                              // use
277
+$server->register('WSGetLpList', // method name
278
+    array('params' => 'tns:paramsGetLpList'), // input parameters
279
+    array('return' => 'tns:lpList'), // output parameters
280
+    'urn:WSLP', // namespace
281
+    'urn:WSLP#WSGetLpList', // soapaction
282
+    'rpc', // style
283
+    'encoded', // use
284 284
     'This service adds users'                                               // documentation
285 285
 );
286 286
 
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 );
370 370
 
371 371
 // Register the method to expose
372
-$server->register('WSDeleteLp',                            // method name
373
-    array('params' => 'tns:paramsDeleteLp'),  // input parameters
374
-    array('return' => 'xsd:string'),                                        // output parameters
375
-    'urn:WSLP',                                                   // namespace
376
-    'urn:WSLP#WSDeleteLp',                       // soapaction
377
-    'rpc',                                                                  // style
378
-    'encoded',                                                              // use
372
+$server->register('WSDeleteLp', // method name
373
+    array('params' => 'tns:paramsDeleteLp'), // input parameters
374
+    array('return' => 'xsd:string'), // output parameters
375
+    'urn:WSLP', // namespace
376
+    'urn:WSLP#WSDeleteLp', // soapaction
377
+    'rpc', // style
378
+    'encoded', // use
379 379
     'This service deletes a LP'                                               // documentation
380 380
 );
381 381
 
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
     if ($lp) {
435 435
         if ($debug) error_log("LP deleted $lpId");
436 436
 
437
-        $course_dir = $courseInfo['directory'] . '/document';
437
+        $course_dir = $courseInfo['directory'].'/document';
438 438
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
439
-        $base_work_dir = $sys_course_path . $course_dir;
439
+        $base_work_dir = $sys_course_path.$course_dir;
440 440
 
441 441
         $items = $lp->get_flat_ordered_items_list($lpId, 0, $courseId);
442 442
 
@@ -495,9 +495,9 @@  discard block
 block discarded – undo
495 495
     'all',
496 496
     '',
497 497
     array(
498
-        'data'  => array('name' => 'data',  'type' => 'xsd:string'),
499
-        'title'  => array('name' => 'title',  'type' => 'xsd:string'),
500
-        'filename'  => array('name' => 'filename',  'type' => 'xsd:string'),
498
+        'data'  => array('name' => 'data', 'type' => 'xsd:string'),
499
+        'title'  => array('name' => 'title', 'type' => 'xsd:string'),
500
+        'filename'  => array('name' => 'filename', 'type' => 'xsd:string'),
501 501
     )
502 502
 );
503 503
 
@@ -548,13 +548,13 @@  discard block
 block discarded – undo
548 548
 );
549 549
 
550 550
 // Register the method to expose
551
-$server->register('WSCreateLp',                            // method name
552
-    array('params' => 'tns:paramsCreateLp'),  // input parameters
553
-    array('return' => 'xsd:string'),                                        // output parameters
554
-    'urn:WSLP',                                                   // namespace
555
-    'urn:WSLP#WSCreateLp',                       // soapaction
556
-    'rpc',                                                                  // style
557
-    'encoded',                                                              // use
551
+$server->register('WSCreateLp', // method name
552
+    array('params' => 'tns:paramsCreateLp'), // input parameters
553
+    array('return' => 'xsd:string'), // output parameters
554
+    'urn:WSLP', // namespace
555
+    'urn:WSLP#WSCreateLp', // soapaction
556
+    'rpc', // style
557
+    'encoded', // use
558 558
     'This service creates a LP'                                               // documentation
559 559
 );
560 560
 
Please login to merge, or discard this patch.
Braces   +48 added lines, -20 removed lines patch added patch discarded remove patch
@@ -48,19 +48,22 @@  discard block
 block discarded – undo
48 48
         list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
49 49
         $ip = trim($ip1);
50 50
     }
51
-    if ($debug)
52
-        error_log("ip: $ip");
51
+    if ($debug) {
52
+            error_log("ip: $ip");
53
+    }
53 54
     // Check if a file that limits access from webservices exists and contains
54 55
     // the restraining check
55 56
     if (is_file('webservice-auth-ip.conf.php')) {
56 57
         include 'webservice-auth-ip.conf.php';
57
-        if ($debug)
58
-            error_log("webservice-auth-ip.conf.php file included");
58
+        if ($debug) {
59
+                    error_log("webservice-auth-ip.conf.php file included");
60
+        }
59 61
         if (!empty($ws_auth_ip)) {
60 62
             $check_ip = true;
61 63
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
62
-            if ($debug)
63
-                error_log("ip_matches: $ip_matches");
64
+            if ($debug) {
65
+                            error_log("ip_matches: $ip_matches");
66
+            }
64 67
         }
65 68
     }
66 69
 
@@ -76,8 +79,9 @@  discard block
 block discarded – undo
76 79
     }
77 80
     $result = api_is_valid_secret_key($secret_key, $security_key);
78 81
     //error_log($secret_key.'-'.$security_key);
79
-    if ($debug)
80
-        error_log('WSHelperVerifyKey result: '.intval($result));
82
+    if ($debug) {
83
+            error_log('WSHelperVerifyKey result: '.intval($result));
84
+    }
81 85
     return $result;
82 86
 }
83 87
 
@@ -140,7 +144,9 @@  discard block
 block discarded – undo
140 144
     if (!WSHelperVerifyKey($params)) {
141 145
         return return_error(WS_ERROR_SECRET_KEY);
142 146
     }
143
-    if ($debug) error_log('WSImportLP');
147
+    if ($debug) {
148
+        error_log('WSImportLP');
149
+    }
144 150
 
145 151
     $courseIdName = $params['course_id_name'];
146 152
     $courseIdValue = $params['course_id_value'];
@@ -156,7 +162,9 @@  discard block
 block discarded – undo
156 162
     $courseId = $courseInfo['real_id'];
157 163
 
158 164
     if (empty($courseInfo)) {
159
-        if ($debug) error_log('Course not found');
165
+        if ($debug) {
166
+            error_log('Course not found');
167
+        }
160 168
         return 'Course not found';
161 169
     }
162 170
 
@@ -169,7 +177,9 @@  discard block
 block discarded – undo
169 177
 
170 178
         if (empty($sessionId)) {
171 179
 
172
-            if ($debug) error_log('Session not found');
180
+            if ($debug) {
181
+                error_log('Session not found');
182
+            }
173 183
             return 'Session not found';
174 184
         }
175 185
     }
@@ -196,7 +206,9 @@  discard block
 block discarded – undo
196 206
     $manifest = $oScorm->import_package($fileInfo, '', $courseInfo);
197 207
 
198 208
     if (!$manifest) {
199
-        if ($debug) error_log('manifest.xml file not found');
209
+        if ($debug) {
210
+            error_log('manifest.xml file not found');
211
+        }
200 212
         //if api_set_failure
201 213
         return 'manifest.xml file not found';
202 214
     }
@@ -215,10 +227,14 @@  discard block
 block discarded – undo
215 227
         $oScorm->set_maker($maker, $courseId);
216 228
         //$oScorm->set_jslib('scorm_api.php');
217 229
 
218
-        if ($debug) error_log('scorm was added');
230
+        if ($debug) {
231
+            error_log('scorm was added');
232
+        }
219 233
         return 1;
220 234
     } else {
221
-        if ($debug) error_log('manifest data empty');
235
+        if ($debug) {
236
+            error_log('manifest data empty');
237
+        }
222 238
         return 'manifest data empty';
223 239
     }
224 240
 }
@@ -311,7 +327,9 @@  discard block
 block discarded – undo
311 327
     );
312 328
 
313 329
     if (empty($courseInfo)) {
314
-        if ($debug) error_log("Course not found: $courseIdName : $courseIdValue");
330
+        if ($debug) {
331
+            error_log("Course not found: $courseIdName : $courseIdValue");
332
+        }
315 333
         return 'Course not found';
316 334
     }
317 335
 
@@ -326,7 +344,9 @@  discard block
 block discarded – undo
326 344
 
327 345
         if (empty($sessionId)) {
328 346
 
329
-            if ($debug) error_log('Session not found');
347
+            if ($debug) {
348
+                error_log('Session not found');
349
+            }
330 350
             return 'Session not found';
331 351
         }
332 352
     }
@@ -407,7 +427,9 @@  discard block
 block discarded – undo
407 427
     );
408 428
 
409 429
     if (empty($courseInfo)) {
410
-        if ($debug) error_log("Course not found: $courseIdName : $courseIdValue");
430
+        if ($debug) {
431
+            error_log("Course not found: $courseIdName : $courseIdValue");
432
+        }
411 433
         return 'Course not found';
412 434
     }
413 435
     $courseId = $courseInfo['real_id'];
@@ -432,7 +454,9 @@  discard block
 block discarded – undo
432 454
 
433 455
     $lp = new learnpath($courseCode, $lpId, null);
434 456
     if ($lp) {
435
-        if ($debug) error_log("LP deleted $lpId");
457
+        if ($debug) {
458
+            error_log("LP deleted $lpId");
459
+        }
436 460
 
437 461
         $course_dir = $courseInfo['directory'] . '/document';
438 462
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
@@ -448,7 +472,9 @@  discard block
 block discarded – undo
448 472
                 if ($item) {
449 473
                     $documentId = $item->get_path();
450 474
 
451
-                    if ($debug) error_log("lp item id found #$itemId");
475
+                    if ($debug) {
476
+                        error_log("lp item id found #$itemId");
477
+                    }
452 478
 
453 479
                     $documentInfo = DocumentManager::get_document_data_by_id(
454 480
                         $documentId,
@@ -474,7 +500,9 @@  discard block
 block discarded – undo
474 500
                         }
475 501
                     }
476 502
                 } else {
477
-                    if ($debug) error_log("Document not found #$itemId");
503
+                    if ($debug) {
504
+                        error_log("Document not found #$itemId");
505
+                    }
478 506
                 }
479 507
             }
480 508
         }
Please login to merge, or discard this patch.
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.
Braces   +169 added lines, -62 removed lines patch added patch discarded remove patch
@@ -63,19 +63,22 @@  discard block
 block discarded – undo
63 63
         list($ip1, $ip2) = 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);
77
-            if ($debug)
78
-                error_log("ip_matches: $ip_matches");
79
+            if ($debug) {
80
+                            error_log("ip_matches: $ip_matches");
81
+            }
79 82
         }
80 83
     }
81 84
 
@@ -92,8 +95,9 @@  discard block
 block discarded – undo
92 95
 
93 96
     $result = api_is_valid_secret_key($secret_key, $security_key);
94 97
 
95
-    if ($debug)
96
-        error_log('WSHelperVerifyKey result: '.intval($result));
98
+    if ($debug) {
99
+            error_log('WSHelperVerifyKey result: '.intval($result));
100
+    }
97 101
     return $result;
98 102
 }
99 103
 
@@ -553,7 +557,9 @@  discard block
 block discarded – undo
553 557
 
554 558
     // First check wether the login already exists
555 559
     if (!UserManager::is_username_available($loginName)) {
556
-        if ($debug) error_log("Username $loginName is not available");
560
+        if ($debug) {
561
+            error_log("Username $loginName is not available");
562
+        }
557 563
         return 0;
558 564
     }
559 565
 
@@ -1012,7 +1018,9 @@  discard block
 block discarded – undo
1012 1018
     if (empty($userId) && empty($sessionId) && empty($courseId)) {
1013 1019
         // try original values
1014 1020
 
1015
-        if ($debug) error_log('try original values');
1021
+        if ($debug) {
1022
+            error_log('try original values');
1023
+        }
1016 1024
 
1017 1025
         $userIdName = isset($params['original_user_id_name']) ? $params['original_user_id_name'] : 0;
1018 1026
         $userIdValue = isset($params['original_user_id_value']) ? $params['original_user_id_value'] : 0;
@@ -1044,9 +1052,15 @@  discard block
 block discarded – undo
1044 1052
         );
1045 1053
     }
1046 1054
 
1047
-    if ($debug) error_log('$userId found: '. $userId);
1048
-    if ($debug) error_log('$courseId found: '. $courseId);
1049
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1055
+    if ($debug) {
1056
+        error_log('$userId found: '. $userId);
1057
+    }
1058
+    if ($debug) {
1059
+        error_log('$courseId found: '. $courseId);
1060
+    }
1061
+    if ($debug) {
1062
+        error_log('$sessionId found: '. $sessionId);
1063
+    }
1050 1064
 
1051 1065
     return [
1052 1066
         'user_id' => $userId,
@@ -1076,13 +1090,17 @@  discard block
 block discarded – undo
1076 1090
 {
1077 1091
     global $debug;
1078 1092
 
1079
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1093
+    if ($debug) {
1094
+        error_log('WSSubscribeTeacherToSessionCourse');
1095
+    }
1080 1096
 
1081 1097
     if (!WSHelperVerifyKey($params)) {
1082 1098
         return returnError(WS_ERROR_SECRET_KEY);
1083 1099
     }
1084 1100
 
1085
-    if ($debug) error_log('Params '. print_r($params, 1));
1101
+    if ($debug) {
1102
+        error_log('Params '. print_r($params, 1));
1103
+    }
1086 1104
 
1087 1105
     $params = parseCourseSessionUserParams($params);
1088 1106
 
@@ -1095,13 +1113,17 @@  discard block
 block discarded – undo
1095 1113
     $result = 0;
1096 1114
 
1097 1115
     if (!empty($coaches)) {
1098
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1116
+        if ($debug) {
1117
+            error_log('Coaches:  '. print_r($coaches, 1));
1118
+        }
1099 1119
         if (in_array($userId, $coaches)) {
1100 1120
             $result = 1;
1101 1121
         }
1102 1122
     }
1103 1123
 
1104
-    if ($debug) error_log('Result:  '. $result);
1124
+    if ($debug) {
1125
+        error_log('Result:  '. $result);
1126
+    }
1105 1127
 
1106 1128
     return $result;
1107 1129
 }
@@ -1127,13 +1149,17 @@  discard block
 block discarded – undo
1127 1149
 {
1128 1150
     global $debug;
1129 1151
 
1130
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1152
+    if ($debug) {
1153
+        error_log('WSSubscribeTeacherToSessionCourse');
1154
+    }
1131 1155
 
1132 1156
     if (!WSHelperVerifyKey($params)) {
1133 1157
         return returnError(WS_ERROR_SECRET_KEY);
1134 1158
     }
1135 1159
 
1136
-    if ($debug) error_log('Params '. print_r($params, 1));
1160
+    if ($debug) {
1161
+        error_log('Params '. print_r($params, 1));
1162
+    }
1137 1163
 
1138 1164
     $params = parseCourseSessionUserParams($params);
1139 1165
 
@@ -1147,7 +1173,9 @@  discard block
 block discarded – undo
1147 1173
     $result = 0;
1148 1174
 
1149 1175
     if (!empty($coaches)) {
1150
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1176
+        if ($debug) {
1177
+            error_log('Coaches:  ' . print_r($coaches, 1));
1178
+        }
1151 1179
         if (!in_array($userId, $coaches)) {
1152 1180
             $result = 1;
1153 1181
         }
@@ -1155,7 +1183,9 @@  discard block
 block discarded – undo
1155 1183
         $result = 1;
1156 1184
     }
1157 1185
 
1158
-    if ($debug) error_log('Final Result: '. $result);
1186
+    if ($debug) {
1187
+        error_log('Final Result: '. $result);
1188
+    }
1159 1189
 
1160 1190
     return $result;
1161 1191
 }
@@ -1207,8 +1237,12 @@  discard block
 block discarded – undo
1207 1237
 {
1208 1238
     global $_user, $_configuration, $debug;
1209 1239
     $debug = 1;
1210
-    if ($debug) error_log('WSCreateUserPasswordCrypted');
1211
-    if ($debug) error_log(print_r($params,1));
1240
+    if ($debug) {
1241
+        error_log('WSCreateUserPasswordCrypted');
1242
+    }
1243
+    if ($debug) {
1244
+        error_log(print_r($params,1));
1245
+    }
1212 1246
 
1213 1247
     if (!WSHelperVerifyKey($params)) {
1214 1248
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1244,22 +1278,30 @@  discard block
 block discarded – undo
1244 1278
         if ($_configuration['password_encryption'] === $encrypt_method ) {
1245 1279
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1246 1280
                 $msg = "Encryption $encrypt_method is invalid";
1247
-                if ($debug) error_log($msg);
1281
+                if ($debug) {
1282
+                    error_log($msg);
1283
+                }
1248 1284
                 return $msg;
1249 1285
 
1250 1286
             } else if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
1251 1287
                 $msg = "Encryption $encrypt_method is invalid";
1252
-                if ($debug) error_log($msg);
1288
+                if ($debug) {
1289
+                    error_log($msg);
1290
+                }
1253 1291
                 return $msg;
1254 1292
             }
1255 1293
         } else {
1256 1294
             $msg = "This encryption $encrypt_method is not configured";
1257
-            if ($debug) error_log($msg);
1295
+            if ($debug) {
1296
+                error_log($msg);
1297
+            }
1258 1298
             return $msg;
1259 1299
         }
1260 1300
     } else {
1261 1301
         $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured';
1262
-        if ($debug) error_log($msg);
1302
+        if ($debug) {
1303
+            error_log($msg);
1304
+        }
1263 1305
         return $msg;
1264 1306
     }
1265 1307
 
@@ -1279,10 +1321,14 @@  discard block
 block discarded – undo
1279 1321
         $original_user_id_name
1280 1322
     );
1281 1323
 
1282
-    if ($debug) error_log('Ready to create user');
1324
+    if ($debug) {
1325
+        error_log('Ready to create user');
1326
+    }
1283 1327
 
1284 1328
     if ($user_id > 0) {
1285
-        if ($debug) error_log('User found with id: '.$user_id);
1329
+        if ($debug) {
1330
+            error_log('User found with id: '.$user_id);
1331
+        }
1286 1332
 
1287 1333
         // Check whether user is not active
1288 1334
         //@todo why this condition exists??
@@ -1293,7 +1339,9 @@  discard block
 block discarded – undo
1293 1339
         $count_check_user = Database::num_rows($resu);
1294 1340
         if ($count_check_user > 0) {
1295 1341
 
1296
-            if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1342
+            if ($debug) {
1343
+                error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1344
+            }
1297 1345
 
1298 1346
             $sql = "UPDATE $table_user SET
1299 1347
                     lastname='".Database::escape_string($lastName)."',
@@ -1313,7 +1361,9 @@  discard block
 block discarded – undo
1313 1361
                     active='1',
1314 1362
                     hr_dept_id=".intval($hr_dept_id);
1315 1363
             $sql .=    " WHERE user_id='".$r_check_user[0]."'";
1316
-            if ($debug) error_log($sql);
1364
+            if ($debug) {
1365
+                error_log($sql);
1366
+            }
1317 1367
             Database::query($sql);
1318 1368
 
1319 1369
             if (is_array($extra_list) && count($extra_list) > 0) {
@@ -1330,11 +1380,15 @@  discard block
 block discarded – undo
1330 1380
             }
1331 1381
             return $r_check_user[0];
1332 1382
         } else {
1333
-            if ($debug) error_log('User exists but is active. Cant be updated');
1383
+            if ($debug) {
1384
+                error_log('User exists but is active. Cant be updated');
1385
+            }
1334 1386
             return 0;
1335 1387
         }
1336 1388
     } else {
1337
-        if ($debug) error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1389
+        if ($debug) {
1390
+            error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1391
+        }
1338 1392
     }
1339 1393
 
1340 1394
     // Default language.
@@ -1350,7 +1404,9 @@  discard block
 block discarded – undo
1350 1404
 
1351 1405
     // First check wether the login already exists
1352 1406
     if (!UserManager::is_username_available($loginName)) {
1353
-        if ($debug) error_log("Username $loginName is not available");
1407
+        if ($debug) {
1408
+            error_log("Username $loginName is not available");
1409
+        }
1354 1410
         return 0;
1355 1411
     }
1356 1412
 
@@ -1372,7 +1428,9 @@  discard block
 block discarded – undo
1372 1428
             expiration_date     = '".Database::escape_string($expiration_date)."',
1373 1429
             hr_dept_id          = '".Database::escape_string($hr_dept_id)."',
1374 1430
             active              = '".Database::escape_string($active)."'";
1375
-    if ($debug) error_log($sql);
1431
+    if ($debug) {
1432
+        error_log($sql);
1433
+    }
1376 1434
 
1377 1435
     Database::query($sql);
1378 1436
     $return = Database::insert_id();
@@ -1384,7 +1442,9 @@  discard block
 block discarded – undo
1384 1442
 
1385 1443
         $url_id = api_get_current_access_url_id();
1386 1444
         UrlManager::add_user_to_url($return, $url_id);
1387
-        if ($debug) error_log("Adding user_id = $return to URL id $url_id ");
1445
+        if ($debug) {
1446
+            error_log("Adding user_id = $return to URL id $url_id ");
1447
+        }
1388 1448
 
1389 1449
         // Create extra field for the original_user_id_name
1390 1450
         UserManager::create_extra_field(
@@ -1421,7 +1481,9 @@  discard block
 block discarded – undo
1421 1481
             }
1422 1482
         }
1423 1483
     } else {
1424
-        if ($debug) error_log('Error while inserting a user');
1484
+        if ($debug) {
1485
+            error_log('Error while inserting a user');
1486
+        }
1425 1487
         return 0;
1426 1488
     }
1427 1489
 
@@ -4480,7 +4542,9 @@  discard block
 block discarded – undo
4480 4542
     if (!WSHelperVerifyKey($params)) {
4481 4543
         return returnError(WS_ERROR_SECRET_KEY);
4482 4544
     }
4483
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4545
+    if ($debug) {
4546
+        error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4547
+    }
4484 4548
 
4485 4549
     $results = array();
4486 4550
     $userscourses = $params['userscourses'];
@@ -4499,7 +4563,9 @@  discard block
 block discarded – undo
4499 4563
             $original_user_id['original_user_id_value'],
4500 4564
             $original_user_id['original_user_id_name']
4501 4565
         );
4502
-        if ($debug) error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4566
+        if ($debug) {
4567
+            error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4568
+        }
4503 4569
 
4504 4570
         if ($user_id == 0) {
4505 4571
             // If user was not found, there was a problem
@@ -4517,13 +4583,19 @@  discard block
 block discarded – undo
4517 4583
                 // Course was not found
4518 4584
                 $resultValue = 0;
4519 4585
             } else {
4520
-                if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4586
+                if ($debug) {
4587
+                    error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4588
+                }
4521 4589
                 $result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false);
4522 4590
                 if ($result) {
4523 4591
                     $resultValue = 1;
4524
-                    if ($debug) error_log('WSSubscribeUserToCourse subscribed');
4592
+                    if ($debug) {
4593
+                        error_log('WSSubscribeUserToCourse subscribed');
4594
+                    }
4525 4595
                 } else {
4526
-                    if ($debug) error_log('WSSubscribeUserToCourse NOT subscribed: ');
4596
+                    if ($debug) {
4597
+                        error_log('WSSubscribeUserToCourse NOT subscribed: ');
4598
+                    }
4527 4599
                 }
4528 4600
             }
4529 4601
         }
@@ -4581,8 +4653,12 @@  discard block
 block discarded – undo
4581 4653
 function WSSubscribeUserToCourseSimple($params) {
4582 4654
     global $debug;
4583 4655
 
4584
-    if ($debug) error_log('WSSubscribeUserToCourseSimple');
4585
-    if ($debug) error_log('Params '. print_r($params, 1));
4656
+    if ($debug) {
4657
+        error_log('WSSubscribeUserToCourseSimple');
4658
+    }
4659
+    if ($debug) {
4660
+        error_log('Params '. print_r($params, 1));
4661
+    }
4586 4662
     if (!WSHelperVerifyKey($params)) {
4587 4663
         return returnError(WS_ERROR_SECRET_KEY);
4588 4664
     }
@@ -4597,7 +4673,9 @@  discard block
 block discarded – undo
4597 4673
     if (empty($user_data)) {
4598 4674
         // If user was not found, there was a problem
4599 4675
         $result = "User $user_id does not exist";
4600
-        if ($debug) error_log($result);
4676
+        if ($debug) {
4677
+            error_log($result);
4678
+        }
4601 4679
         return $result;
4602 4680
     }
4603 4681
     if (!empty($course_code)) {
@@ -4605,14 +4683,22 @@  discard block
 block discarded – undo
4605 4683
         if (empty($course_data)) {
4606 4684
             // Course was not found
4607 4685
             $result = "Course $course_code does not exist in the platform ";
4608
-            if ($debug) error_log($result);
4686
+            if ($debug) {
4687
+                error_log($result);
4688
+            }
4609 4689
         } else {
4610
-            if ($debug) error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4690
+            if ($debug) {
4691
+                error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4692
+            }
4611 4693
             if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status)) {
4612 4694
                 $result = 'User was not registered possible reasons: User already registered to the course, Course visibility doesnt allow user subscriptions ';
4613
-                if ($debug) error_log($result);
4695
+                if ($debug) {
4696
+                    error_log($result);
4697
+                }
4614 4698
             } else {
4615
-                if ($debug) error_log('User registered to the course: '.$course_data['code']);
4699
+                if ($debug) {
4700
+                    error_log('User registered to the course: '.$course_data['code']);
4701
+                }
4616 4702
                 $result = 1;
4617 4703
             }
4618 4704
         }
@@ -4664,8 +4750,12 @@  discard block
 block discarded – undo
4664 4750
 // define the method WSGetUser
4665 4751
 function WSGetUser($params) {
4666 4752
     global $debug;
4667
-    if ($debug) error_log('WSGetUser');
4668
-    if ($debug) error_log('$params: '.print_r($params, 1));
4753
+    if ($debug) {
4754
+        error_log('WSGetUser');
4755
+    }
4756
+    if ($debug) {
4757
+        error_log('$params: '.print_r($params, 1));
4758
+    }
4669 4759
 
4670 4760
     if (!WSHelperVerifyKey($params)) {
4671 4761
         return returnError(WS_ERROR_SECRET_KEY);
@@ -4718,8 +4808,12 @@  discard block
 block discarded – undo
4718 4808
 // define the method WSGetUserFromUsername
4719 4809
 function WSGetUserFromUsername($params) {
4720 4810
     global $debug;
4721
-    if ($debug) error_log('WSGetUserFromUsername');
4722
-    if ($debug) error_log('$params: '.print_r($params, 1));
4811
+    if ($debug) {
4812
+        error_log('WSGetUserFromUsername');
4813
+    }
4814
+    if ($debug) {
4815
+        error_log('$params: '.print_r($params, 1));
4816
+    }
4723 4817
 
4724 4818
     if (!WSHelperVerifyKey($params)) {
4725 4819
         return returnError(WS_ERROR_SECRET_KEY);
@@ -5169,7 +5263,9 @@  discard block
 block discarded – undo
5169 5263
                 $orig_session_id_value[] = $original_session_id_value;
5170 5264
                 $results[] = 1;
5171 5265
 
5172
-                if ($debug) error_log("subscribe user:$user_id to session $sessionId");
5266
+                if ($debug) {
5267
+                    error_log("subscribe user:$user_id to session $sessionId");
5268
+                }
5173 5269
             }
5174 5270
         }
5175 5271
     } // end principal foreach
@@ -5253,7 +5349,9 @@  discard block
 block discarded – undo
5253 5349
                 SESSION_VISIBLE_READ_ONLY,
5254 5350
                 false
5255 5351
             );
5256
-            if ($debug) error_log('User registered to the course: '.$session_id);
5352
+            if ($debug) {
5353
+                error_log('User registered to the course: '.$session_id);
5354
+            }
5257 5355
             $result = 1;
5258 5356
         }
5259 5357
     }
@@ -5399,7 +5497,9 @@  discard block
 block discarded – undo
5399 5497
                 $orig_session_id_value[] = $original_session_id_value;
5400 5498
                 $results[] = 1;
5401 5499
 
5402
-                if ($debug) error_log("Unsubscribe user:$user_id to session:$id_session");
5500
+                if ($debug) {
5501
+                    error_log("Unsubscribe user:$user_id to session:$id_session");
5502
+                }
5403 5503
             }
5404 5504
         }
5405 5505
     } // end principal foreach
@@ -5546,7 +5646,9 @@  discard block
 block discarded – undo
5546 5646
         return returnError(WS_ERROR_SECRET_KEY);
5547 5647
     }
5548 5648
 
5549
-    if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5649
+    if ($debug) {
5650
+        error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5651
+    }
5550 5652
 
5551 5653
     $coursessessions_params = $params['coursessessions'];
5552 5654
     $results = array();
@@ -5584,7 +5686,9 @@  discard block
 block discarded – undo
5584 5686
                     array($courseInfo['real_id']),
5585 5687
                     false
5586 5688
                 );
5587
-                if ($debug) error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5689
+                if ($debug) {
5690
+                    error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5691
+                }
5588 5692
 
5589 5693
                 $results[] = 1;
5590 5694
                 $orig_course_id_value[] = $original_session_id_value;
@@ -5935,8 +6039,7 @@  discard block
 block discarded – undo
5935 6039
             UserManager::create_extra_field($params['original_user_id_name'], 1, $params['original_user_id_name'], '');
5936 6040
             // Save the external system's id into user_field_value table.
5937 6041
             UserManager::update_extra_field_value($user_id, $params['original_user_id_name'], $params['original_user_id_value']);
5938
-        }
5939
-        else {
6042
+        } else {
5940 6043
             return 0;
5941 6044
         }
5942 6045
     }
@@ -6086,8 +6189,12 @@  discard block
 block discarded – undo
6086 6189
 {
6087 6190
     global $debug;
6088 6191
 
6089
-    if ($debug) error_log('WSUserSubscribedInCourse');
6090
-    if ($debug) error_log('Params '. print_r($params, 1));
6192
+    if ($debug) {
6193
+        error_log('WSUserSubscribedInCourse');
6194
+    }
6195
+    if ($debug) {
6196
+        error_log('Params '. print_r($params, 1));
6197
+    }
6091 6198
     if (!WSHelperVerifyKey($params)) {
6092 6199
 
6093 6200
         return returnError(WS_ERROR_SECRET_KEY);
Please login to merge, or discard this patch.
Spacing   +455 added lines, -455 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     }
81 81
 
82 82
     if ($debug) {
83
-        error_log("checkip " . intval($check_ip));
83
+        error_log("checkip ".intval($check_ip));
84 84
     }
85 85
 
86 86
     if ($check_ip) {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     '',
139 139
     'SOAP-ENC:Array',
140 140
     array(),
141
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),
141
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:extras[]')),
142 142
     'tns:extras'
143 143
 );
144 144
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     '',
172 172
     'SOAP-ENC:Array',
173 173
     array(),
174
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:usersParams[]')),
174
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:usersParams[]')),
175 175
     'tns:usersParams'
176 176
 );
177 177
 
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
     '',
211 211
     'SOAP-ENC:Array',
212 212
     array(),
213
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:result_createUsers[]')),'tns:result_createUsers'
213
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createUsers[]')), 'tns:result_createUsers'
214 214
 );
215 215
 
216 216
 // Register the method to expose
217
-$server->register('WSCreateUsers',                 // method name
218
-    array('createUsers' => 'tns:createUsers'),     // input parameters
219
-    array('return' => 'tns:results_createUsers'),  // output parameters
220
-    'urn:WSRegistration',                          // namespace
221
-    'urn:WSRegistration#WSCreateUsers',            // soapaction
222
-    'rpc',                                         // style
223
-    'encoded',                                     // use
217
+$server->register('WSCreateUsers', // method name
218
+    array('createUsers' => 'tns:createUsers'), // input parameters
219
+    array('return' => 'tns:results_createUsers'), // output parameters
220
+    'urn:WSRegistration', // namespace
221
+    'urn:WSRegistration#WSCreateUsers', // soapaction
222
+    'rpc', // style
223
+    'encoded', // use
224 224
     'This service adds a user'                     // documentation
225 225
 );
226 226
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             continue;
402 402
         }
403 403
 
404
-        $results[] =  $userId;
404
+        $results[] = $userId;
405 405
 
406 406
     } // end principal foreach
407 407
 
@@ -447,13 +447,13 @@  discard block
 block discarded – undo
447 447
 
448 448
 
449 449
 // Register the method to expose
450
-$server->register('WSCreateUser',                // method name
451
-    array('createUser' => 'tns:createUser'),     // input parameters
452
-    array('return' => 'xsd:string'),             // output parameters
453
-    'urn:WSRegistration',                        // namespace
454
-    'urn:WSRegistration#WSCreateUser',           // soapaction
455
-    'rpc',                                       // style
456
-    'encoded',                                   // use
450
+$server->register('WSCreateUser', // method name
451
+    array('createUser' => 'tns:createUser'), // input parameters
452
+    array('return' => 'xsd:string'), // output parameters
453
+    'urn:WSRegistration', // namespace
454
+    'urn:WSRegistration#WSCreateUser', // soapaction
455
+    'rpc', // style
456
+    'encoded', // use
457 457
     'This service adds a user'                   // documentation
458 458
 );
459 459
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     }
559 559
 
560 560
     if (isset($original_user_id_name) && isset($original_user_id_value)) {
561
-        $_SESSION['ws_' . $original_user_id_name] = $original_user_id_value;
561
+        $_SESSION['ws_'.$original_user_id_name] = $original_user_id_value;
562 562
     }
563 563
 
564 564
     /** @var User $user */
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
         );
607 607
 
608 608
         if (isset($original_user_id_name) && isset($original_user_id_value)) {
609
-            unset($_SESSION['ws_' . $original_user_id_name]);
609
+            unset($_SESSION['ws_'.$original_user_id_name]);
610 610
         }
611 611
 
612 612
         if (is_array($extra_list) && count($extra_list) > 0) {
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         'language'              => array('name' => 'language', 'type' => 'xsd:string'),
659 659
         'phone'                 => array('name' => 'phone', 'type' => 'xsd:string'),
660 660
         'expiration_date'       => array('name' => 'expiration_date', 'type' => 'xsd:string'),
661
-        'official_code'         => array('name' => 'official_code',    'type' => 'xsd:string'),
661
+        'official_code'         => array('name' => 'official_code', 'type' => 'xsd:string'),
662 662
         'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
663 663
         'original_user_id_value'=> array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
664 664
         'extra'                 => array('name' => 'extra', 'type' => 'tns:extrasList')
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
     'all',
687 687
     '',
688 688
     array(
689
-        'users'         => array('name' => 'users',      'type' => 'tns:createUsersPassEncryptParamsList'),
689
+        'users'         => array('name' => 'users', 'type' => 'tns:createUsersPassEncryptParamsList'),
690 690
         'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
691 691
     )
692 692
 );
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 );
717 717
 
718 718
 // Register the method to expose
719
-$server->register('WSCreateUsersPasswordCrypted',                            // method name
719
+$server->register('WSCreateUsersPasswordCrypted', // method name
720 720
     array('createUsersPasswordCrypted' => 'tns:createUsersPasswordCrypted'), // input parameters
721
-    array('return' => 'tns:results_createUsersPassEncrypt'),                 // output parameters
722
-    'urn:WSRegistration',                                                    // namespace
723
-    'urn:WSRegistration#WSCreateUsersPasswordCrypted',                       // soapaction
724
-    'rpc',                                                                   // style
725
-    'encoded',                                                               // use
721
+    array('return' => 'tns:results_createUsersPassEncrypt'), // output parameters
722
+    'urn:WSRegistration', // namespace
723
+    'urn:WSRegistration#WSCreateUsersPasswordCrypted', // soapaction
724
+    'rpc', // style
725
+    'encoded', // use
726 726
     'This service adds users to the system'                                  // documentation
727 727
 );
728 728
 
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $salt = '';
770 770
 
771 771
         if (!empty($_configuration['password_encryption'])) {
772
-            if ($_configuration['password_encryption'] === $encrypt_method ) {
772
+            if ($_configuration['password_encryption'] === $encrypt_method) {
773 773
                 if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
774 774
                     $msg = "Encryption $encrypt_method is invalid";
775 775
                     $results[] = $msg;
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 
793 793
         if (is_array($extra_list) && count($extra_list) > 0) {
794 794
             foreach ($extra_list as $extra) {
795
-                if($extra['field_name'] == 'salt') {
795
+                if ($extra['field_name'] == 'salt') {
796 796
                     $salt = $extra['field_value'];
797 797
                     break;
798 798
                 }
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
                         active='1',
848 848
                         hr_dept_id=".intval($hr_dept_id);
849 849
 
850
-                $sql .=  " WHERE user_id='".$r_check_user[0]."'";
850
+                $sql .= " WHERE user_id='".$r_check_user[0]."'";
851 851
                 Database::query($sql);
852 852
 
853 853
                 if (is_array($extra_list) && count($extra_list) > 0) {
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 
968 968
     $count_results = count($results);
969 969
     $output = array();
970
-    for($i = 0; $i < $count_results; $i++) {
970
+    for ($i = 0; $i < $count_results; $i++) {
971 971
         $output[] = array(
972 972
             'original_user_id_value' => $orig_user_id_value[$i],
973 973
             'result' => $results[$i],
@@ -986,9 +986,9 @@  discard block
 block discarded – undo
986 986
     'all',
987 987
     '',
988 988
     array(
989
-        'user_id' => array('name' => 'course',     'type' => 'xsd:string'), // Chamilo user Id
990
-        'session_id' => array('name' => 'user_id',    'type' => 'xsd:string'), // Current Session course ID
991
-        'course_id' =>array('name' => 'courseId',      'type' => 'xsd:string'), // Course Real Id
989
+        'user_id' => array('name' => 'course', 'type' => 'xsd:string'), // Chamilo user Id
990
+        'session_id' => array('name' => 'user_id', 'type' => 'xsd:string'), // Current Session course ID
991
+        'course_id' =>array('name' => 'courseId', 'type' => 'xsd:string'), // Course Real Id
992 992
         'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
993 993
 
994 994
         // optional
@@ -1044,9 +1044,9 @@  discard block
 block discarded – undo
1044 1044
         );
1045 1045
     }
1046 1046
 
1047
-    if ($debug) error_log('$userId found: '. $userId);
1048
-    if ($debug) error_log('$courseId found: '. $courseId);
1049
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1047
+    if ($debug) error_log('$userId found: '.$userId);
1048
+    if ($debug) error_log('$courseId found: '.$courseId);
1049
+    if ($debug) error_log('$sessionId found: '.$sessionId);
1050 1050
 
1051 1051
     return [
1052 1052
         'user_id' => $userId,
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
         return returnError(WS_ERROR_SECRET_KEY);
1083 1083
     }
1084 1084
 
1085
-    if ($debug) error_log('Params '. print_r($params, 1));
1085
+    if ($debug) error_log('Params '.print_r($params, 1));
1086 1086
 
1087 1087
     $params = parseCourseSessionUserParams($params);
1088 1088
 
@@ -1095,13 +1095,13 @@  discard block
 block discarded – undo
1095 1095
     $result = 0;
1096 1096
 
1097 1097
     if (!empty($coaches)) {
1098
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1098
+        if ($debug) error_log('Coaches:  '.print_r($coaches, 1));
1099 1099
         if (in_array($userId, $coaches)) {
1100 1100
             $result = 1;
1101 1101
         }
1102 1102
     }
1103 1103
 
1104
-    if ($debug) error_log('Result:  '. $result);
1104
+    if ($debug) error_log('Result:  '.$result);
1105 1105
 
1106 1106
     return $result;
1107 1107
 }
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
         return returnError(WS_ERROR_SECRET_KEY);
1134 1134
     }
1135 1135
 
1136
-    if ($debug) error_log('Params '. print_r($params, 1));
1136
+    if ($debug) error_log('Params '.print_r($params, 1));
1137 1137
 
1138 1138
     $params = parseCourseSessionUserParams($params);
1139 1139
 
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
     $result = 0;
1148 1148
 
1149 1149
     if (!empty($coaches)) {
1150
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1150
+        if ($debug) error_log('Coaches:  '.print_r($coaches, 1));
1151 1151
         if (!in_array($userId, $coaches)) {
1152 1152
             $result = 1;
1153 1153
         }
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
         $result = 1;
1156 1156
     }
1157 1157
 
1158
-    if ($debug) error_log('Final Result: '. $result);
1158
+    if ($debug) error_log('Final Result: '.$result);
1159 1159
 
1160 1160
     return $result;
1161 1161
 }
@@ -1173,32 +1173,32 @@  discard block
 block discarded – undo
1173 1173
     'all',
1174 1174
     '',
1175 1175
     array(
1176
-        'firstname'                 => array('name' => 'firstname',                 'type' => 'xsd:string'),
1177
-        'lastname'                  => array('name' => 'lastname',                  'type' => 'xsd:string'),
1178
-        'status'                    => array('name' => 'status',                    'type' => 'xsd:string'),
1179
-        'email'                     => array('name' => 'email',                     'type' => 'xsd:string'),
1180
-        'loginname'                 => array('name' => 'loginname',                 'type' => 'xsd:string'),
1181
-        'password'                  => array('name' => 'password',                  'type' => 'xsd:string'), //encripted password using the encrypt_method
1182
-        'encrypt_method'            => array('name' => 'encrypt_method',            'type' => 'xsd:string'),
1183
-        'language'                  => array('name' => 'language',                  'type' => 'xsd:string'),
1184
-        'phone'                     => array('name' => 'phone',                     'type' => 'xsd:string'),
1185
-        'expiration_date'           => array('name' => 'expiration_date',           'type' => 'xsd:string'),
1186
-        'official_code'             => array('name' => 'official_code',             'type' => 'xsd:string'),
1187
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
1188
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
1189
-        'extra'                     => array('name' => 'extra',                     'type' => 'tns:extrasList'),
1190
-        'secret_key'                => array('name' => 'secret_key',                'type' => 'xsd:string')
1176
+        'firstname'                 => array('name' => 'firstname', 'type' => 'xsd:string'),
1177
+        'lastname'                  => array('name' => 'lastname', 'type' => 'xsd:string'),
1178
+        'status'                    => array('name' => 'status', 'type' => 'xsd:string'),
1179
+        'email'                     => array('name' => 'email', 'type' => 'xsd:string'),
1180
+        'loginname'                 => array('name' => 'loginname', 'type' => 'xsd:string'),
1181
+        'password'                  => array('name' => 'password', 'type' => 'xsd:string'), //encripted password using the encrypt_method
1182
+        'encrypt_method'            => array('name' => 'encrypt_method', 'type' => 'xsd:string'),
1183
+        'language'                  => array('name' => 'language', 'type' => 'xsd:string'),
1184
+        'phone'                     => array('name' => 'phone', 'type' => 'xsd:string'),
1185
+        'expiration_date'           => array('name' => 'expiration_date', 'type' => 'xsd:string'),
1186
+        'official_code'             => array('name' => 'official_code', 'type' => 'xsd:string'),
1187
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
1188
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
1189
+        'extra'                     => array('name' => 'extra', 'type' => 'tns:extrasList'),
1190
+        'secret_key'                => array('name' => 'secret_key', 'type' => 'xsd:string')
1191 1191
     )
1192 1192
 );
1193 1193
 
1194 1194
 // Register the method to expose
1195
-$server->register('WSCreateUserPasswordCrypted',                            // method name
1196
-    array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'),  // input parameters
1197
-    array('return' => 'xsd:string'),                                        // output parameters
1198
-    'urn:WSRegistration',                                                   // namespace
1199
-    'urn:WSRegistration#WSCreateUserPasswordCrypted',                       // soapaction
1200
-    'rpc',                                                                  // style
1201
-    'encoded',                                                              // use
1195
+$server->register('WSCreateUserPasswordCrypted', // method name
1196
+    array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'), // input parameters
1197
+    array('return' => 'xsd:string'), // output parameters
1198
+    'urn:WSRegistration', // namespace
1199
+    'urn:WSRegistration#WSCreateUserPasswordCrypted', // soapaction
1200
+    'rpc', // style
1201
+    'encoded', // use
1202 1202
     'This service adds users'                                               // documentation
1203 1203
 );
1204 1204
 
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
     global $_user, $_configuration, $debug;
1209 1209
     $debug = 1;
1210 1210
     if ($debug) error_log('WSCreateUserPasswordCrypted');
1211
-    if ($debug) error_log(print_r($params,1));
1211
+    if ($debug) error_log(print_r($params, 1));
1212 1212
 
1213 1213
     if (!WSHelperVerifyKey($params)) {
1214 1214
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
     $extra_list = isset($params['extra']) ? $params['extra'] : '';
1242 1242
 
1243 1243
     if (!empty($_configuration['password_encryption'])) {
1244
-        if ($_configuration['password_encryption'] === $encrypt_method ) {
1244
+        if ($_configuration['password_encryption'] === $encrypt_method) {
1245 1245
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1246 1246
                 $msg = "Encryption $encrypt_method is invalid";
1247 1247
                 if ($debug) error_log($msg);
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
             if (!is_null($auth_source)) {
1304 1304
                 $sql .= " auth_source='".Database::escape_string($auth_source)."',";
1305 1305
             }
1306
-            $sql .=    "
1306
+            $sql .= "
1307 1307
                     password='".Database::escape_string($password)."',
1308 1308
                     email='".Database::escape_string($email)."',
1309 1309
                     status='".Database::escape_string($status)."',
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
                     expiration_date='".Database::escape_string($expiration_date)."',
1313 1313
                     active='1',
1314 1314
                     hr_dept_id=".intval($hr_dept_id);
1315
-            $sql .=    " WHERE user_id='".$r_check_user[0]."'";
1315
+            $sql .= " WHERE user_id='".$r_check_user[0]."'";
1316 1316
             if ($debug) error_log($sql);
1317 1317
             Database::query($sql);
1318 1318
 
@@ -1492,13 +1492,13 @@  discard block
 block discarded – undo
1492 1492
 );
1493 1493
 
1494 1494
 // Register the method to expose
1495
-$server->register('WSEditUserCredentials',                      // method name
1496
-    array('editUserCredentials' => 'tns:editUserCredentials'),  // input parameters
1497
-    array('return' => 'xsd:string'),                            // output parameters
1498
-    'urn:WSRegistration',                                       // namespace
1499
-    'urn:WSRegistration#WSEditUserCredentials',                 // soapaction
1500
-    'rpc',                                                      // style
1501
-    'encoded',                                                  // use
1495
+$server->register('WSEditUserCredentials', // method name
1496
+    array('editUserCredentials' => 'tns:editUserCredentials'), // input parameters
1497
+    array('return' => 'xsd:string'), // output parameters
1498
+    'urn:WSRegistration', // namespace
1499
+    'urn:WSRegistration#WSEditUserCredentials', // soapaction
1500
+    'rpc', // style
1501
+    'encoded', // use
1502 1502
     'This service edits the username and password of a user'    // documentation
1503 1503
 );
1504 1504
 
@@ -1597,13 +1597,13 @@  discard block
 block discarded – undo
1597 1597
 );
1598 1598
 
1599 1599
 // Register the method to expose
1600
-$server->register('WSEditUsers',                // method name
1601
-    array('editUsers' => 'tns:editUsers'),      // input parameters
1600
+$server->register('WSEditUsers', // method name
1601
+    array('editUsers' => 'tns:editUsers'), // input parameters
1602 1602
     array('return' => 'tns:results_editUsers'), // output parameters
1603
-    'urn:WSRegistration',                       // namespace
1604
-    'urn:WSRegistration#WSEditUsers',           // soapaction
1605
-    'rpc',                                      // style
1606
-    'encoded',                                  // use
1603
+    'urn:WSRegistration', // namespace
1604
+    'urn:WSRegistration#WSEditUsers', // soapaction
1605
+    'rpc', // style
1606
+    'encoded', // use
1607 1607
     'This service edits a user from wiener'     // documentation
1608 1608
 );
1609 1609
 
@@ -1795,13 +1795,13 @@  discard block
 block discarded – undo
1795 1795
 );
1796 1796
 
1797 1797
 // Register the method to expose
1798
-$server->register('WSEditUser',              // method name
1799
-    array('editUser' => 'tns:editUser'),     // input parameters
1800
-    array('return' => 'xsd:string'),         // output parameters
1801
-    'urn:WSRegistration',                    // namespace
1802
-    'urn:WSRegistration#WSEditUser',         // soapaction
1803
-    'rpc',                                   // style
1804
-    'encoded',                               // use
1798
+$server->register('WSEditUser', // method name
1799
+    array('editUser' => 'tns:editUser'), // input parameters
1800
+    array('return' => 'xsd:string'), // output parameters
1801
+    'urn:WSRegistration', // namespace
1802
+    'urn:WSRegistration#WSEditUser', // soapaction
1803
+    'rpc', // style
1804
+    'encoded', // use
1805 1805
     'This service edits a user from wiener'  // documentation
1806 1806
 );
1807 1807
 
@@ -1972,13 +1972,13 @@  discard block
 block discarded – undo
1972 1972
 );
1973 1973
 
1974 1974
 // Register the method to expose
1975
-$server->register('WSEditUserWithPicture',              // method name
1976
-    array('editUserWithPicture' => 'tns:editUserWithPicture'),     // input parameters
1977
-    array('return' => 'xsd:string'),                    // output parameters
1978
-    'urn:WSRegistration',                               // namespace
1979
-    'urn:WSRegistration#WSEditUserWithPicture',         // soapaction
1980
-    'rpc',                                              // style
1981
-    'encoded',                                          // use
1975
+$server->register('WSEditUserWithPicture', // method name
1976
+    array('editUserWithPicture' => 'tns:editUserWithPicture'), // input parameters
1977
+    array('return' => 'xsd:string'), // output parameters
1978
+    'urn:WSRegistration', // namespace
1979
+    'urn:WSRegistration#WSEditUserWithPicture', // soapaction
1980
+    'rpc', // style
1981
+    'encoded', // use
1982 1982
     'This service edits a user from wiener'             // documentation
1983 1983
 );
1984 1984
 
@@ -2036,8 +2036,8 @@  discard block
 block discarded – undo
2036 2036
     $tempDir = api_get_path(SYS_ARCHIVE_PATH);
2037 2037
     // Make sure the file download was OK by checking the HTTP headers for OK
2038 2038
     if (strpos(get_headers($picture_url)[0], "OK")) {
2039
-        file_put_contents($tempDir . $filename, file_get_contents($picture_url));
2040
-        $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir . $filename);
2039
+        file_put_contents($tempDir.$filename, file_get_contents($picture_url));
2040
+        $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir.$filename);
2041 2041
     }
2042 2042
 
2043 2043
     if ($user_id == 0) {
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
         ->setExpirationDate($expiration_date)
2109 2109
         ->setHrDeptId($hr_dept_id)
2110 2110
         ->setActive(true)
2111
-        ->setPictureUri($pictureUri);;
2111
+        ->setPictureUri($pictureUri); ;
2112 2112
 
2113 2113
     if (!is_null($creator_id)) {
2114 2114
         $user->setCreatorId($creator_id);
@@ -2205,13 +2205,13 @@  discard block
 block discarded – undo
2205 2205
 );
2206 2206
 
2207 2207
 // Register the method to expose
2208
-$server->register('WSEditUsersPasswordCrypted',                           // method name
2209
-    array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'),  // input parameters
2210
-    array('return' => 'tns:results_editUsersPasswordCrypted'),            // output parameters
2211
-    'urn:WSRegistration',                                                 // namespace
2212
-    'urn:WSRegistration#WSEditUsersPasswordCrypted',                      // soapaction
2213
-    'rpc',                                                                // style
2214
-    'encoded',                                                            // use
2208
+$server->register('WSEditUsersPasswordCrypted', // method name
2209
+    array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'), // input parameters
2210
+    array('return' => 'tns:results_editUsersPasswordCrypted'), // output parameters
2211
+    'urn:WSRegistration', // namespace
2212
+    'urn:WSRegistration#WSEditUsersPasswordCrypted', // soapaction
2213
+    'rpc', // style
2214
+    'encoded', // use
2215 2215
     'This service edits a user'                                           // documentation
2216 2216
 );
2217 2217
 
@@ -2219,7 +2219,7 @@  discard block
 block discarded – undo
2219 2219
 function WSEditUsersPasswordCrypted($params) {
2220 2220
     global $_configuration;
2221 2221
 
2222
-    if(!WSHelperVerifyKey($params)) {
2222
+    if (!WSHelperVerifyKey($params)) {
2223 2223
         return returnError(WS_ERROR_SECRET_KEY);
2224 2224
     }
2225 2225
 
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
 
2257 2257
             $password = $user_param['password'];
2258 2258
             $encrypt_method = $user_param['encrypt_method'];
2259
-            if ($_configuration['password_encryption'] === $encrypt_method ) {
2259
+            if ($_configuration['password_encryption'] === $encrypt_method) {
2260 2260
                 if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
2261 2261
                     $msg = "Encryption $encrypt_method is invalid";
2262 2262
                     $results[] = $msg;
@@ -2271,11 +2271,11 @@  discard block
 block discarded – undo
2271 2271
                 $results[] = $msg;
2272 2272
                 continue;
2273 2273
             }
2274
-        } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])){
2274
+        } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])) {
2275 2275
             $msg = "If password is not empty the encrypt_method param is required ";
2276 2276
             $results[] = $msg;
2277 2277
             continue;
2278
-        } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])){
2278
+        } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])) {
2279 2279
             $msg = "If encrypt_method is not empty the password param is required ";
2280 2280
             $results[] = $msg;
2281 2281
             continue;
@@ -2411,13 +2411,13 @@  discard block
 block discarded – undo
2411 2411
 );
2412 2412
 
2413 2413
 // Register the method to expose
2414
-$server->register('WSEditUserPasswordCrypted',                         // method name
2414
+$server->register('WSEditUserPasswordCrypted', // method name
2415 2415
     array('editUserPasswordCrypted' => 'tns:editUserPasswordCrypted'), // input parameters
2416
-    array('return' => 'xsd:string'),                                   // output parameters
2417
-    'urn:WSRegistration',                                              // namespace
2418
-    'urn:WSRegistration#WSEditUserPasswordCrypted',                    // soapaction
2419
-    'rpc',                                                             // style
2420
-    'encoded',                                                         // use
2416
+    array('return' => 'xsd:string'), // output parameters
2417
+    'urn:WSRegistration', // namespace
2418
+    'urn:WSRegistration#WSEditUserPasswordCrypted', // soapaction
2419
+    'rpc', // style
2420
+    'encoded', // use
2421 2421
     'This service edits a user'                                        // documentation
2422 2422
 );
2423 2423
 
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
     if (!empty($params['password']) && !empty($params['encrypt_method'])) {
2462 2462
         $password = $params['password'];
2463 2463
         $encrypt_method = $params['encrypt_method'];
2464
-        if ($_configuration['password_encryption'] === $encrypt_method ) {
2464
+        if ($_configuration['password_encryption'] === $encrypt_method) {
2465 2465
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
2466 2466
                 $msg = "Encryption $encrypt_method is invalid";
2467 2467
                 return $msg;
@@ -2606,7 +2606,7 @@  discard block
 block discarded – undo
2606 2606
     '',
2607 2607
     'SOAP-ENC:Array',
2608 2608
     array(),
2609
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:user_id[]')),'tns:user_id'
2609
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_id[]')), 'tns:user_id'
2610 2610
 );
2611 2611
 
2612 2612
 $server->wsdl->addComplexType(
@@ -2622,35 +2622,35 @@  discard block
 block discarded – undo
2622 2622
 );
2623 2623
 
2624 2624
 function WSHelperActionOnUsers($params, $type) {
2625
-    if(!WSHelperVerifyKey($params)) {
2625
+    if (!WSHelperVerifyKey($params)) {
2626 2626
         return returnError(WS_ERROR_SECRET_KEY);
2627 2627
     }
2628 2628
 
2629 2629
     $original_user_ids = $params['ids'];
2630
-    foreach($original_user_ids as $original_user_id) {
2630
+    foreach ($original_user_ids as $original_user_id) {
2631 2631
         $user_id = UserManager::get_user_id_from_original_id(
2632 2632
             $original_user_id['original_user_id_value'],
2633 2633
             $original_user_id['original_user_id_name']
2634 2634
         );
2635
-        if($user_id > 0) {
2636
-            if($type == "delete") {
2635
+        if ($user_id > 0) {
2636
+            if ($type == "delete") {
2637 2637
                 UserManager::delete_user($user_id);
2638
-            } else if($type == "disable") {
2638
+            } else if ($type == "disable") {
2639 2639
                 UserManager::disable($user_id);
2640
-            } else if($type == "enable") {
2640
+            } else if ($type == "enable") {
2641 2641
                 UserManager::enable($user_id);
2642 2642
             }
2643 2643
         }
2644 2644
     }
2645 2645
 }
2646 2646
 
2647
-$server->register('WSDeleteUsers',                         // method name
2648
-    array('user_ids' => 'tns:user_ids'),                   // input parameters
2649
-    array(),                                               // output parameters
2650
-    'urn:WSRegistration',                                  // namespace
2651
-    'urn:WSRegistration#WSDeleteUsers',                    // soapaction
2652
-    'rpc',                                                 // style
2653
-    'encoded',                                             // use
2647
+$server->register('WSDeleteUsers', // method name
2648
+    array('user_ids' => 'tns:user_ids'), // input parameters
2649
+    array(), // output parameters
2650
+    'urn:WSRegistration', // namespace
2651
+    'urn:WSRegistration#WSDeleteUsers', // soapaction
2652
+    'rpc', // style
2653
+    'encoded', // use
2654 2654
     'Deletes users provided as parameters from the system' // documentation
2655 2655
 );
2656 2656
 
@@ -2659,13 +2659,13 @@  discard block
 block discarded – undo
2659 2659
 }
2660 2660
 
2661 2661
 /** WSDisableUsers **/
2662
-$server->register('WSDisableUsers',                         // method name
2663
-    array('user_ids' => 'tns:user_ids'),                    // input parameters
2664
-    array(),                                                // output parameters
2665
-    'urn:WSRegistration',                                   // namespace
2666
-    'urn:WSRegistration#WSDisableUsers',                    // soapaction
2667
-    'rpc',                                                  // style
2668
-    'encoded',                                              // use
2662
+$server->register('WSDisableUsers', // method name
2663
+    array('user_ids' => 'tns:user_ids'), // input parameters
2664
+    array(), // output parameters
2665
+    'urn:WSRegistration', // namespace
2666
+    'urn:WSRegistration#WSDisableUsers', // soapaction
2667
+    'rpc', // style
2668
+    'encoded', // use
2669 2669
     'Disables users provided as parameters from the system' // documentation
2670 2670
 );
2671 2671
 
@@ -2674,13 +2674,13 @@  discard block
 block discarded – undo
2674 2674
 }
2675 2675
 
2676 2676
 /** WSEnableUsers **/
2677
-$server->register('WSEnableUsers',            // method name
2678
-    array('user_ids' => 'tns:user_ids'),      // input parameters
2679
-    array(),                                  // output parameters
2680
-    'urn:WSRegistration',                     // namespace
2681
-    'urn:WSRegistration#WSEnableUsers',       // soapaction
2682
-    'rpc',                                    // style
2683
-    'encoded',                                // use
2677
+$server->register('WSEnableUsers', // method name
2678
+    array('user_ids' => 'tns:user_ids'), // input parameters
2679
+    array(), // output parameters
2680
+    'urn:WSRegistration', // namespace
2681
+    'urn:WSRegistration#WSEnableUsers', // soapaction
2682
+    'rpc', // style
2683
+    'encoded', // use
2684 2684
     'Enables users provided as parameters'    // documentation
2685 2685
 );
2686 2686
 
@@ -2730,7 +2730,7 @@  discard block
 block discarded – undo
2730 2730
     '',
2731 2731
     'SOAP-ENC:Array',
2732 2732
     array(),
2733
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:createCourseParams[]')),'tns:createCourseParams'
2733
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createCourseParams[]')), 'tns:createCourseParams'
2734 2734
 );
2735 2735
 
2736 2736
 // Register the data structures used by the service
@@ -2771,13 +2771,13 @@  discard block
 block discarded – undo
2771 2771
 );
2772 2772
 
2773 2773
 // Register the method to expose
2774
-$server->register('WSCreateCourse',                // method name
2775
-    array('createCourse' => 'tns:createCourse'),   // input parameters
2774
+$server->register('WSCreateCourse', // method name
2775
+    array('createCourse' => 'tns:createCourse'), // input parameters
2776 2776
     array('return' => 'tns:results_createCourse'), // output parameters
2777
-    'urn:WSRegistration',                          // namespace
2778
-    'urn:WSRegistration#WSCreateCourse',           // soapaction
2779
-    'rpc',                                         // style
2780
-    'encoded',                                     // use
2777
+    'urn:WSRegistration', // namespace
2778
+    'urn:WSRegistration#WSCreateCourse', // soapaction
2779
+    'rpc', // style
2780
+    'encoded', // use
2781 2781
     'This service adds a course'                   // documentation
2782 2782
 );
2783 2783
 
@@ -2833,7 +2833,7 @@  discard block
 block discarded – undo
2833 2833
                             category_code='".Database::escape_string($category_code)."',
2834 2834
                             tutor_name='".Database::escape_string($tutor_name)."',
2835 2835
                             visual_code='".Database::escape_string($wanted_code)."'";
2836
-                if($visibility !== null) {
2836
+                if ($visibility !== null) {
2837 2837
                     $sql .= ", visibility = '$visibility' ";
2838 2838
                 }
2839 2839
                 $sql .= " WHERE id='".$courseInfo['real_id']."'";
@@ -2883,7 +2883,7 @@  discard block
 block discarded – undo
2883 2883
         $params['title'] = $title;
2884 2884
         $params['wanted_code'] = $wanted_code;
2885 2885
         $params['category_code'] = $category_code;
2886
-        $params['course_category']    = $category_code;
2886
+        $params['course_category'] = $category_code;
2887 2887
         $params['tutor_name'] = $tutor_name;
2888 2888
         $params['course_language'] = $course_language;
2889 2889
         $params['user_id'] = api_get_user_id();
@@ -3014,13 +3014,13 @@  discard block
 block discarded – undo
3014 3014
 
3015 3015
 
3016 3016
 // Register the method to expose
3017
-$server->register('WSCreateCourseByTitle',                     // method name
3017
+$server->register('WSCreateCourseByTitle', // method name
3018 3018
     array('createCourseByTitle' => 'tns:createCourseByTitle'), // input parameters
3019
-    array('return' => 'tns:results_createCourseByTitle'),      // output parameters
3020
-    'urn:WSRegistration',                                      // namespace
3021
-    'urn:WSRegistration#WSCreateCourseByTitle',                // soapaction
3022
-    'rpc',                                                     // style
3023
-    'encoded',                                                 // use
3019
+    array('return' => 'tns:results_createCourseByTitle'), // output parameters
3020
+    'urn:WSRegistration', // namespace
3021
+    'urn:WSRegistration#WSCreateCourseByTitle', // soapaction
3022
+    'rpc', // style
3023
+    'encoded', // use
3024 3024
     'This service adds a course by title'                      // documentation
3025 3025
 );
3026 3026
 
@@ -3251,18 +3251,18 @@  discard block
 block discarded – undo
3251 3251
 );
3252 3252
 
3253 3253
 // Register the method to expose
3254
-$server->register('WSEditCourse',                // method name
3255
-    array('editCourse' => 'tns:editCourse'),     // input parameters
3254
+$server->register('WSEditCourse', // method name
3255
+    array('editCourse' => 'tns:editCourse'), // input parameters
3256 3256
     array('return' => 'tns:results_editCourse'), // output parameters
3257
-    'urn:WSRegistration',                        // namespace
3258
-    'urn:WSRegistration#WSEditCourse',           // soapaction
3259
-    'rpc',                                       // style
3260
-    'encoded',                                   // use
3257
+    'urn:WSRegistration', // namespace
3258
+    'urn:WSRegistration#WSEditCourse', // soapaction
3259
+    'rpc', // style
3260
+    'encoded', // use
3261 3261
     'This service edits a course'                // documentation
3262 3262
 );
3263 3263
 
3264 3264
 // Define the method WSEditCourse
3265
-function WSEditCourse($params){
3265
+function WSEditCourse($params) {
3266 3266
 
3267 3267
     global $_configuration;
3268 3268
     if (!WSHelperVerifyKey($params)) {
@@ -3417,13 +3417,13 @@  discard block
 block discarded – undo
3417 3417
 
3418 3418
 
3419 3419
 // Register the method to expose
3420
-$server->register('WSCourseDescription',                    // method name
3421
-    array('courseDescription' => 'tns:courseDescription'),  // input parameters
3422
-    array('return' => 'tns:fields_course_desc_list'),       // output parameters
3423
-    'urn:WSRegistration',                                   // namespace
3424
-    'urn:WSRegistration#WSCourseDescription',               // soapaction
3425
-    'rpc',                                                  // style
3426
-    'encoded',                                              // use
3420
+$server->register('WSCourseDescription', // method name
3421
+    array('courseDescription' => 'tns:courseDescription'), // input parameters
3422
+    array('return' => 'tns:fields_course_desc_list'), // output parameters
3423
+    'urn:WSRegistration', // namespace
3424
+    'urn:WSRegistration#WSCourseDescription', // soapaction
3425
+    'rpc', // style
3426
+    'encoded', // use
3427 3427
     'This service edits a course description'               // documentation
3428 3428
 );
3429 3429
 
@@ -3476,14 +3476,14 @@  discard block
 block discarded – undo
3476 3476
     }
3477 3477
 
3478 3478
     while ($row = Database::fetch_array($result)) {
3479
-        $ind = (int)$row['id'];
3479
+        $ind = (int) $row['id'];
3480 3480
         $array_course_desc_title[$ind] = $row['title'];
3481 3481
         $array_course_desc_content[$ind] = $row['content'];
3482 3482
     }
3483 3483
 
3484 3484
     $count_results = count($default_titles);
3485 3485
     $output = array();
3486
-    for($i = 1; $i <= $count_results; $i++) {
3486
+    for ($i = 1; $i <= $count_results; $i++) {
3487 3487
         $output[] = array(
3488 3488
             'course_desc_id' => $array_course_desc_id[$i],
3489 3489
             'course_desc_default_title' => $array_course_desc_default_title[$i],
@@ -3563,13 +3563,13 @@  discard block
 block discarded – undo
3563 3563
 
3564 3564
 
3565 3565
 // Register the method to expose
3566
-$server->register('WSEditCourseDescription',                       // method name
3566
+$server->register('WSEditCourseDescription', // method name
3567 3567
     array('editCourseDescription' => 'tns:editCourseDescription'), // input parameters
3568
-    array('return' => 'tns:results_editCourseDescription'),        // output parameters
3569
-    'urn:WSRegistration',                                          // namespace
3570
-    'urn:WSRegistration#WSEditCourseDescription',                  // soapaction
3571
-    'rpc',                                                         // style
3572
-    'encoded',                                                     // use
3568
+    array('return' => 'tns:results_editCourseDescription'), // output parameters
3569
+    'urn:WSRegistration', // namespace
3570
+    'urn:WSRegistration#WSEditCourseDescription', // soapaction
3571
+    'rpc', // style
3572
+    'encoded', // use
3573 3573
     'This service edits a course description'                      // documentation
3574 3574
 );
3575 3575
 
@@ -3613,7 +3613,7 @@  discard block
 block discarded – undo
3613 3613
         $course_desc_title = Database::escape_string($course_desc_title);
3614 3614
         $course_desc_content = Database::escape_string($course_desc_content);
3615 3615
 
3616
-        $course_desc_id = (int)$course_desc_id;
3616
+        $course_desc_id = (int) $course_desc_id;
3617 3617
         if ($course_desc_id > 8 && $course_desc_id < 1) {
3618 3618
             $results[] = 0; // course_desc_id invalid.
3619 3619
             continue;
@@ -3647,7 +3647,7 @@  discard block
 block discarded – undo
3647 3647
 
3648 3648
     $count_results = count($results);
3649 3649
     $output = array();
3650
-    for($i = 0; $i < $count_results; $i++) {
3650
+    for ($i = 0; $i < $count_results; $i++) {
3651 3651
         $output[] = array(
3652 3652
             'original_course_id_value' => $orig_course_id_value[$i],
3653 3653
             'result' => $results[$i],
@@ -3719,13 +3719,13 @@  discard block
 block discarded – undo
3719 3719
     'tns:result_deleteCourse'
3720 3720
 );
3721 3721
 
3722
-$server->register('WSDeleteCourse',                // method name
3723
-    array('deleteCourse' => 'tns:deleteCourse'),   // input parameters
3722
+$server->register('WSDeleteCourse', // method name
3723
+    array('deleteCourse' => 'tns:deleteCourse'), // input parameters
3724 3724
     array('return' => 'tns:results_deleteCourse'), // output parameters
3725
-    'urn:WSRegistration',                          // namespace
3726
-    'urn:WSRegistration#WSDeleteCourse',           // soapaction
3727
-    'rpc',                                         // style
3728
-    'encoded',                                     // use
3725
+    'urn:WSRegistration', // namespace
3726
+    'urn:WSRegistration#WSDeleteCourse', // soapaction
3727
+    'rpc', // style
3728
+    'encoded', // use
3729 3729
     'This service deletes a course '               // documentation
3730 3730
 );
3731 3731
 
@@ -3851,13 +3851,13 @@  discard block
 block discarded – undo
3851 3851
 );
3852 3852
 
3853 3853
 // Register the method to expose
3854
-$server->register('WSCreateSession',                // method name
3855
-    array('createSession' => 'tns:createSession'),  // input parameters
3854
+$server->register('WSCreateSession', // method name
3855
+    array('createSession' => 'tns:createSession'), // input parameters
3856 3856
     array('return' => 'tns:results_createSession'), // output parameters
3857
-    'urn:WSRegistration',                           // namespace
3858
-    'urn:WSRegistration#WSCreateSession',           // soapaction
3859
-    'rpc',                                          // style
3860
-    'encoded',                                      // use
3857
+    'urn:WSRegistration', // namespace
3858
+    'urn:WSRegistration#WSCreateSession', // soapaction
3859
+    'rpc', // style
3860
+    'encoded', // use
3861 3861
     'This service edits a session'                  // documentation
3862 3862
 );
3863 3863
 
@@ -3911,8 +3911,8 @@  discard block
 block discarded – undo
3911 3911
         }
3912 3912
 
3913 3913
         if (empty($nolimit)) {
3914
-            $date_start = "$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start) . ' 00:00:00';
3915
-            $date_end = "$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end) . ' 23:59:59';
3914
+            $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start).' 00:00:00';
3915
+            $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end).' 23:59:59';
3916 3916
         } else {
3917 3917
             $date_start = "";
3918 3918
             $date_end = "";
@@ -3930,7 +3930,7 @@  discard block
 block discarded – undo
3930 3930
             }
3931 3931
             $results[] = 0;
3932 3932
             continue;
3933
-        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end,  $day_end, $year_end))) {
3933
+        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) {
3934 3934
             $results[] = 0;
3935 3935
             if ($debug) {
3936 3936
                 error_log("There's an error with the end date: $month_end - $day_end - $year_end");
@@ -4033,7 +4033,7 @@  discard block
 block discarded – undo
4033 4033
 
4034 4034
     $count_results = count($results);
4035 4035
     $output = array();
4036
-    for($i = 0; $i < $count_results; $i++) {
4036
+    for ($i = 0; $i < $count_results; $i++) {
4037 4037
         $output[] = array(
4038 4038
             'original_session_id_value' => $orig_session_id_value[$i],
4039 4039
             'result' => $results[$i],
@@ -4118,13 +4118,13 @@  discard block
 block discarded – undo
4118 4118
 
4119 4119
 
4120 4120
 // Register the method to expose
4121
-$server->register('WSEditSession',                // method name
4122
-    array('editSession' => 'tns:editSession'),    // input parameters
4121
+$server->register('WSEditSession', // method name
4122
+    array('editSession' => 'tns:editSession'), // input parameters
4123 4123
     array('return' => 'tns:results_editSession'), // output parameters
4124
-    'urn:WSRegistration',                         // namespace
4125
-    'urn:WSRegistration#WSEditSession',           // soapaction
4126
-    'rpc',                                        // style
4127
-    'encoded',                                    // use
4124
+    'urn:WSRegistration', // namespace
4125
+    'urn:WSRegistration#WSEditSession', // soapaction
4126
+    'rpc', // style
4127
+    'encoded', // use
4128 4128
     'This service edits a session'                // documentation
4129 4129
 );
4130 4130
 
@@ -4174,11 +4174,11 @@  discard block
 block discarded – undo
4174 4174
         }
4175 4175
 
4176 4176
         if (empty($nolimit)) {
4177
-            $date_start="$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start);
4178
-            $date_end="$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end);
4177
+            $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start);
4178
+            $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end);
4179 4179
         } else {
4180
-            $date_start="";
4181
-            $date_end="";
4180
+            $date_start = "";
4181
+            $date_end = "";
4182 4182
         }
4183 4183
         if (empty($name)) {
4184 4184
             $results[] = 0; //SessionNameIsRequired
@@ -4322,13 +4322,13 @@  discard block
 block discarded – undo
4322 4322
     'tns:result_deleteSession'
4323 4323
 );
4324 4324
 
4325
-$server->register('WSDeleteSession',                // method name
4326
-    array('deleteSession' => 'tns:deleteSession'),  // input parameters
4325
+$server->register('WSDeleteSession', // method name
4326
+    array('deleteSession' => 'tns:deleteSession'), // input parameters
4327 4327
     array('return' => 'tns:results_deleteSession'), // output parameters
4328
-    'urn:WSRegistration',                           // namespace
4329
-    'urn:WSRegistration#WSDeleteSession',           // soapaction
4330
-    'rpc',                                          // style
4331
-    'encoded',                                      // use
4328
+    'urn:WSRegistration', // namespace
4329
+    'urn:WSRegistration#WSDeleteSession', // soapaction
4330
+    'rpc', // style
4331
+    'encoded', // use
4332 4332
     'This service deletes a session '               // documentation
4333 4333
 );
4334 4334
 
@@ -4410,10 +4410,10 @@  discard block
 block discarded – undo
4410 4410
     'struct',
4411 4411
     'all',
4412 4412
     '',
4413
-    array (
4413
+    array(
4414 4414
         'course_id' => array('name' => 'course_id', 'type' => 'tns:course_id'),
4415
-        'user_id'   => array('name' => 'user_id',   'type' => 'tns:user_id'),
4416
-        'status'    => array('name' => 'status',    'type' => 'xsd:int')
4415
+        'user_id'   => array('name' => 'user_id', 'type' => 'tns:user_id'),
4416
+        'status'    => array('name' => 'status', 'type' => 'xsd:int')
4417 4417
     )
4418 4418
 );
4419 4419
 
@@ -4423,9 +4423,9 @@  discard block
 block discarded – undo
4423 4423
     'struct',
4424 4424
     'all',
4425 4425
     '',
4426
-    array (
4427
-        'userscourses'  => array('name' => 'userscourses',  'type' => 'tns:user_course_status_array'), //removed []
4428
-        'secret_key'    => array('name' => 'secret_key',    'type' => 'xsd:string')
4426
+    array(
4427
+        'userscourses'  => array('name' => 'userscourses', 'type' => 'tns:user_course_status_array'), //removed []
4428
+        'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
4429 4429
     )
4430 4430
 );
4431 4431
 
@@ -4450,9 +4450,9 @@  discard block
 block discarded – undo
4450 4450
     'all',
4451 4451
     '',
4452 4452
     array(
4453
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
4454
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
4455
-        'result'                    => array('name' => 'result',                    'type' => 'xsd:int')
4453
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
4454
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
4455
+        'result'                    => array('name' => 'result', 'type' => 'xsd:int')
4456 4456
     )
4457 4457
 );
4458 4458
 
@@ -4468,13 +4468,13 @@  discard block
 block discarded – undo
4468 4468
 );
4469 4469
 
4470 4470
 // Register the method to expose
4471
-$server->register('WSSubscribeUserToCourse',                            // method name
4472
-    array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'),  // input parameters
4471
+$server->register('WSSubscribeUserToCourse', // method name
4472
+    array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'), // input parameters
4473 4473
     array('return' => 'tns:subscribeUserToCourse_return_global'),
4474
-    'urn:WSRegistration',                                               // namespace
4475
-    'urn:WSRegistration#WSSubscribeUserToCourse',                       // soapaction
4476
-    'rpc',                                                              // style
4477
-    'encoded',                                                          // use
4474
+    'urn:WSRegistration', // namespace
4475
+    'urn:WSRegistration#WSSubscribeUserToCourse', // soapaction
4476
+    'rpc', // style
4477
+    'encoded', // use
4478 4478
     'This service subscribes a user to a course'                        // documentation
4479 4479
 );
4480 4480
 
@@ -4484,7 +4484,7 @@  discard block
 block discarded – undo
4484 4484
     if (!WSHelperVerifyKey($params)) {
4485 4485
         return returnError(WS_ERROR_SECRET_KEY);
4486 4486
     }
4487
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4487
+    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params, 1));
4488 4488
 
4489 4489
     $results = array();
4490 4490
     $userscourses = $params['userscourses'];
@@ -4552,8 +4552,8 @@  discard block
 block discarded – undo
4552 4552
     'all',
4553 4553
     '',
4554 4554
     array(
4555
-        'course'       => array('name' => 'course',     'type' => 'xsd:string'), //Course string code
4556
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'), //Chamilo user_id
4555
+        'course'       => array('name' => 'course', 'type' => 'xsd:string'), //Course string code
4556
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id
4557 4557
         'secret_key'   => array('name' => 'secret_key', 'type' => 'xsd:string')
4558 4558
     )
4559 4559
 );
@@ -4566,18 +4566,18 @@  discard block
 block discarded – undo
4566 4566
     'struct',
4567 4567
     'all',
4568 4568
     '',
4569
-    array('message' => array('name' => 'message',    'type' => 'xsd:string'))
4569
+    array('message' => array('name' => 'message', 'type' => 'xsd:string'))
4570 4570
 );
4571 4571
 
4572 4572
 
4573 4573
 // Register the method to expose
4574
-$server->register('WSSubscribeUserToCourseSimple',                                 // method name
4574
+$server->register('WSSubscribeUserToCourseSimple', // method name
4575 4575
     array('subscribeUserToCourseSimple' => 'tns:subscribeUserToCourseSimple_arg'), // input parameters
4576
-    array('return' => 'xsd:string'),                                               // output parameters
4577
-    'urn:WSRegistration',                                                          // namespace
4578
-    'urn:WSRegistration#WSSubscribeUserToCourseSimple',                            // soapaction
4579
-    'rpc',                                                                         // style
4580
-    'encoded',                                                                     // use
4576
+    array('return' => 'xsd:string'), // output parameters
4577
+    'urn:WSRegistration', // namespace
4578
+    'urn:WSRegistration#WSSubscribeUserToCourseSimple', // soapaction
4579
+    'rpc', // style
4580
+    'encoded', // use
4581 4581
     'This service subscribes a user to a course in a simple way'                   // documentation
4582 4582
 );
4583 4583
 
@@ -4586,7 +4586,7 @@  discard block
 block discarded – undo
4586 4586
     global $debug;
4587 4587
 
4588 4588
     if ($debug) error_log('WSSubscribeUserToCourseSimple');
4589
-    if ($debug) error_log('Params '. print_r($params, 1));
4589
+    if ($debug) error_log('Params '.print_r($params, 1));
4590 4590
     if (!WSHelperVerifyKey($params)) {
4591 4591
         return returnError(WS_ERROR_SECRET_KEY);
4592 4592
     }
@@ -4634,9 +4634,9 @@  discard block
 block discarded – undo
4634 4634
     'all',
4635 4635
     '',
4636 4636
     array(
4637
-        'original_user_id_value'      => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
4638
-        'original_user_id_name'       => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
4639
-        'secret_key'                  => array('name' => 'secret_key',                'type' => 'xsd:string')
4637
+        'original_user_id_value'      => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
4638
+        'original_user_id_name'       => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
4639
+        'secret_key'                  => array('name' => 'secret_key', 'type' => 'xsd:string')
4640 4640
     )
4641 4641
 );
4642 4642
 
@@ -4647,21 +4647,21 @@  discard block
 block discarded – undo
4647 4647
     'struct',
4648 4648
     'all',
4649 4649
     '',
4650
-    array (
4651
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'),
4652
-        'firstname'    => array('name' => 'firstname',  'type' => 'xsd:string'),
4653
-        'lastname'     => array('name' => 'lastname',   'type' => 'xsd:string'),
4650
+    array(
4651
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'),
4652
+        'firstname'    => array('name' => 'firstname', 'type' => 'xsd:string'),
4653
+        'lastname'     => array('name' => 'lastname', 'type' => 'xsd:string'),
4654 4654
     )
4655 4655
 );
4656 4656
 
4657 4657
 // Register the method to expose
4658
-$server->register('WSGetUser',                   // method name
4659
-    array('GetUser' => 'tns:GetUserArg'),        // input parameters
4660
-    array('return' => 'tns:User'),               // output parameters
4661
-    'urn:WSRegistration',                        // namespace
4662
-    'urn:WSRegistration#WSGetUser',              // soapaction
4663
-    'rpc',                                       // style
4664
-    'encoded',                                   // use
4658
+$server->register('WSGetUser', // method name
4659
+    array('GetUser' => 'tns:GetUserArg'), // input parameters
4660
+    array('return' => 'tns:User'), // output parameters
4661
+    'urn:WSRegistration', // namespace
4662
+    'urn:WSRegistration#WSGetUser', // soapaction
4663
+    'rpc', // style
4664
+    'encoded', // use
4665 4665
     'This service get user information by id'    // documentation
4666 4666
 );
4667 4667
 
@@ -4705,17 +4705,17 @@  discard block
 block discarded – undo
4705 4705
     '',
4706 4706
     array(
4707 4707
         'username'      => array('name' => 'username', 'type' => 'xsd:string'),
4708
-        'secret_key'    => array('name' => 'secret_key','type' => 'xsd:string')
4708
+        'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
4709 4709
     )
4710 4710
 );
4711 4711
 // Register the method to expose
4712
-$server->register('WSGetUserFromUsername',                     // method name
4713
-    array('GetUserFromUsername' => 'tns:GetUserArgUsername'),  // input params
4714
-    array('return' => 'tns:User'),                             // output parameters
4715
-    'urn:WSRegistration',                                      // namespace
4716
-    'urn:WSRegistration#WSGetUserFromUsername',                // soapaction
4717
-    'rpc',                                                     // style
4718
-    'encoded',                                                 // use
4712
+$server->register('WSGetUserFromUsername', // method name
4713
+    array('GetUserFromUsername' => 'tns:GetUserArgUsername'), // input params
4714
+    array('return' => 'tns:User'), // output parameters
4715
+    'urn:WSRegistration', // namespace
4716
+    'urn:WSRegistration#WSGetUserFromUsername', // soapaction
4717
+    'rpc', // style
4718
+    'encoded', // use
4719 4719
     'This service get user information by username'            // documentation
4720 4720
 );
4721 4721
 
@@ -4756,10 +4756,10 @@  discard block
 block discarded – undo
4756 4756
     'all',
4757 4757
     '',
4758 4758
     array(
4759
-        'original_user_id_values'   => array('name' => 'original_user_id_values',   'type' => 'tns:originalUsersList'),
4760
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
4761
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
4762
-        'original_course_id_name'   => array('name' => 'original_course_id_name',   'type' => 'xsd:string'),
4759
+        'original_user_id_values'   => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'),
4760
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
4761
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
4762
+        'original_course_id_name'   => array('name' => 'original_course_id_name', 'type' => 'xsd:string'),
4763 4763
     )
4764 4764
 );
4765 4765
 
@@ -4812,13 +4812,13 @@  discard block
 block discarded – undo
4812 4812
 );
4813 4813
 
4814 4814
 // Register the method to expose
4815
-$server->register('WSUnsubscribeUserFromCourse',                         // method name
4815
+$server->register('WSUnsubscribeUserFromCourse', // method name
4816 4816
     array('unsuscribeUserFromCourse' => 'tns:unsuscribeUserFromCourse'), // input parameters
4817
-    array('return' => 'tns:results_unsuscribeUserFromCourse'),           // output parameters
4818
-    'urn:WSRegistration',                                                // namespace
4819
-    'urn:WSRegistration#WSUnsubscribeUserFromCourse',                    // soapaction
4820
-    'rpc',                                                               // style
4821
-    'encoded',                                                           // use
4817
+    array('return' => 'tns:results_unsuscribeUserFromCourse'), // output parameters
4818
+    'urn:WSRegistration', // namespace
4819
+    'urn:WSRegistration#WSUnsubscribeUserFromCourse', // soapaction
4820
+    'rpc', // style
4821
+    'encoded', // use
4822 4822
     'This service unsubscribes a user from a course'                     // documentation
4823 4823
 );
4824 4824
 
@@ -4830,7 +4830,7 @@  discard block
 block discarded – undo
4830 4830
     }
4831 4831
 
4832 4832
     $user_table = Database::get_main_table(TABLE_MAIN_USER);
4833
-    $table_course     = Database :: get_main_table(TABLE_MAIN_COURSE);
4833
+    $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
4834 4834
     $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
4835 4835
 
4836 4836
     $userscourses_params = $params['userscourses'];
@@ -4840,8 +4840,8 @@  discard block
 block discarded – undo
4840 4840
     foreach ($userscourses_params as $usercourse_param) {
4841 4841
 
4842 4842
         $original_user_id_values     = $usercourse_param['original_user_id_values'];
4843
-        $original_user_id_name         = $usercourse_param['original_user_id_name'];
4844
-        $original_course_id_value     = $usercourse_param['original_course_id_value'];
4843
+        $original_user_id_name = $usercourse_param['original_user_id_name'];
4844
+        $original_course_id_value = $usercourse_param['original_course_id_value'];
4845 4845
         $original_course_id_name     = $usercourse_param['original_course_id_name'];
4846 4846
         $orig_course_id_value[] = $original_course_id_value;
4847 4847
 
@@ -4862,7 +4862,7 @@  discard block
 block discarded – undo
4862 4862
             $usersList[] = $user_id;
4863 4863
         }
4864 4864
 
4865
-        $orig_user_id_value[] = implode(',',$usersList);
4865
+        $orig_user_id_value[] = implode(',', $usersList);
4866 4866
 
4867 4867
         $courseInfo = CourseManager::getCourseInfoFromOriginalId(
4868 4868
             $original_course_id_value,
@@ -4895,7 +4895,7 @@  discard block
 block discarded – undo
4895 4895
 
4896 4896
     $count_results = count($results);
4897 4897
     $output = array();
4898
-    for($i = 0; $i < $count_results; $i++) {
4898
+    for ($i = 0; $i < $count_results; $i++) {
4899 4899
         $output[] = array(
4900 4900
             'original_user_id_values' => $orig_user_id_value[$i],
4901 4901
             'original_course_id_value' => $orig_course_id_value[$i],
@@ -4924,13 +4924,13 @@  discard block
 block discarded – undo
4924 4924
 
4925 4925
 
4926 4926
 // Register the method to expose
4927
-$server->register('WSUnSubscribeUserFromCourseSimple',                         // method name
4927
+$server->register('WSUnSubscribeUserFromCourseSimple', // method name
4928 4928
     array('unSubscribeUserFromCourseSimple' => 'tns:unSubscribeUserFromCourseSimple'), // input parameters
4929
-    array('return' => 'tns:result_createUsersPassEncrypt'),           // output parameters
4930
-    'urn:WSRegistration',                                                // namespace
4931
-    'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple',                    // soapaction
4932
-    'rpc',                                                               // style
4933
-    'encoded',                                                           // use
4929
+    array('return' => 'tns:result_createUsersPassEncrypt'), // output parameters
4930
+    'urn:WSRegistration', // namespace
4931
+    'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple', // soapaction
4932
+    'rpc', // style
4933
+    'encoded', // use
4934 4934
     'This service unsubscribe a user from a course'                     // documentation
4935 4935
 );
4936 4936
 /**
@@ -5000,10 +5000,10 @@  discard block
 block discarded – undo
5000 5000
     'all',
5001 5001
     '',
5002 5002
     array(
5003
-        'original_user_id_values'   => array('name' => 'original_user_id_values',   'type' => 'tns:originalUsersList'),
5004
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
5005
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
5006
-        'original_course_id_name'   => array('name' => 'original_course_id_value',  'type' => 'xsd:string')
5003
+        'original_user_id_values'   => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'),
5004
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
5005
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
5006
+        'original_course_id_name'   => array('name' => 'original_course_id_value', 'type' => 'xsd:string')
5007 5007
     )
5008 5008
 );
5009 5009
 
@@ -5097,13 +5097,13 @@  discard block
 block discarded – undo
5097 5097
 
5098 5098
 
5099 5099
 // Register the method to expose
5100
-$server->register('WSSuscribeUsersToSession',                          // method name
5100
+$server->register('WSSuscribeUsersToSession', // method name
5101 5101
     array('subscribeUsersToSession' => 'tns:subscribeUsersToSession'), // input parameters
5102
-    array('return' => 'tns:results_subscribeUsersToSession'),          // output parameters
5103
-    'urn:WSRegistration',                                              // namespace
5104
-    'urn:WSRegistration#WSSuscribeUsersToSession',                     // soapaction
5105
-    'rpc',                                                             // style
5106
-    'encoded',                                                         // use
5102
+    array('return' => 'tns:results_subscribeUsersToSession'), // output parameters
5103
+    'urn:WSRegistration', // namespace
5104
+    'urn:WSRegistration#WSSuscribeUsersToSession', // soapaction
5105
+    'rpc', // style
5106
+    'encoded', // use
5107 5107
     'This service subscribes a user to a session'                      // documentation
5108 5108
 );
5109 5109
 
@@ -5180,7 +5180,7 @@  discard block
 block discarded – undo
5180 5180
 
5181 5181
     $count_results = count($results);
5182 5182
     $output = array();
5183
-    for($i = 0; $i < $count_results; $i++) {
5183
+    for ($i = 0; $i < $count_results; $i++) {
5184 5184
         $output[] = array(
5185 5185
             'original_user_id_values' => $orig_user_id_value[$i],
5186 5186
             'original_session_id_value' => $orig_session_id_value[$i],
@@ -5200,25 +5200,25 @@  discard block
 block discarded – undo
5200 5200
     'all',
5201 5201
     '',
5202 5202
     array(
5203
-        'session'    => array('name' => 'session',    'type' => 'xsd:string'), // Session ID
5204
-        'user_id'    => array('name' => 'user_id',    'type' => 'xsd:string'), // Chamilo user_id
5203
+        'session'    => array('name' => 'session', 'type' => 'xsd:string'), // Session ID
5204
+        'user_id'    => array('name' => 'user_id', 'type' => 'xsd:string'), // Chamilo user_id
5205 5205
         'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string')
5206 5206
     )
5207 5207
 );
5208
-$server->register('WSSubscribeUserToSessionSimple',                                   // method name
5209
-    array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'),  // input parameters
5210
-    array('return' => 'xsd:string'),                                                  // output parameters
5211
-    'urn:WSRegistration',                                                             // namespace
5212
-    'urn:WSRegistration#WSSubscribeUserToSessionSimple',                              // soapaction
5213
-    'rpc',                                                                            // style
5214
-    'encoded',                                                                        // use
5208
+$server->register('WSSubscribeUserToSessionSimple', // method name
5209
+    array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'), // input parameters
5210
+    array('return' => 'xsd:string'), // output parameters
5211
+    'urn:WSRegistration', // namespace
5212
+    'urn:WSRegistration#WSSubscribeUserToSessionSimple', // soapaction
5213
+    'rpc', // style
5214
+    'encoded', // use
5215 5215
     'This service subscribes a user to a session in a simple way'                     // documentation
5216 5216
 );
5217 5217
 function WSSubscribeUserToSessionSimple($params) {
5218 5218
     global $debug;
5219 5219
 
5220 5220
     if ($debug) {
5221
-        error_log('WSSubscribeUserToSessionSimple with params=[' . serialize($params). ']');
5221
+        error_log('WSSubscribeUserToSessionSimple with params=['.serialize($params).']');
5222 5222
     }
5223 5223
 
5224 5224
     // Check security key
@@ -5227,8 +5227,8 @@  discard block
 block discarded – undo
5227 5227
     }
5228 5228
 
5229 5229
     // Get input parameters
5230
-    $session_id = intval($params['session']);  // Session ID
5231
-    $user_id    = intval($params['user_id']);  // Chamilo user id
5230
+    $session_id = intval($params['session']); // Session ID
5231
+    $user_id    = intval($params['user_id']); // Chamilo user id
5232 5232
 
5233 5233
     // Get user id
5234 5234
     $user_data = api_get_user_info($user_id);
@@ -5329,13 +5329,13 @@  discard block
 block discarded – undo
5329 5329
 );
5330 5330
 
5331 5331
 // Register the method to expose
5332
-$server->register('WSUnsuscribeUsersFromSession',                              // method name
5332
+$server->register('WSUnsuscribeUsersFromSession', // method name
5333 5333
     array('unsubscribeUsersFromSession' => 'tns:unsubscribeUsersFromSession'), // input parameters
5334
-    array('return' => 'tns:results_unsubscribeUsersFromSession'),              // output parameters
5335
-    'urn:WSRegistration',                                                      // namespace
5336
-    'urn:WSRegistration#WSUnsuscribeUsersFromSession',                         // soapaction
5337
-    'rpc',                                                                     // style
5338
-    'encoded',                                                                 // use
5334
+    array('return' => 'tns:results_unsubscribeUsersFromSession'), // output parameters
5335
+    'urn:WSRegistration', // namespace
5336
+    'urn:WSRegistration#WSUnsuscribeUsersFromSession', // soapaction
5337
+    'rpc', // style
5338
+    'encoded', // use
5339 5339
     'This service unsubscribes a user to a session'                            // documentation
5340 5340
 );
5341 5341
 
@@ -5349,7 +5349,7 @@  discard block
 block discarded – undo
5349 5349
     global $debug;
5350 5350
 
5351 5351
     if ($debug) {
5352
-        error_log('WSUnsuscribeUsersFromSession with params=[' . serialize($params). ']');
5352
+        error_log('WSUnsuscribeUsersFromSession with params=['.serialize($params).']');
5353 5353
     }
5354 5354
 
5355 5355
     $user_table = Database::get_main_table(TABLE_MAIN_USER);
@@ -5441,7 +5441,7 @@  discard block
 block discarded – undo
5441 5441
     'all',
5442 5442
     '',
5443 5443
     array(
5444
-        'course_code'   => array('name' => 'course_code',   'type' => 'xsd:string'),
5444
+        'course_code'   => array('name' => 'course_code', 'type' => 'xsd:string'),
5445 5445
     )
5446 5446
 );
5447 5447
 
@@ -5477,9 +5477,9 @@  discard block
 block discarded – undo
5477 5477
     '',
5478 5478
     array(
5479 5479
         'original_course_id_values' => array('name' => 'original_course_id_values', 'type' => 'tns:originalCoursesList'),
5480
-        'original_course_id_name'   => array('name' => 'original_course_id_name',   'type' => 'xsd:string'),
5480
+        'original_course_id_name'   => array('name' => 'original_course_id_name', 'type' => 'xsd:string'),
5481 5481
         'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'),
5482
-        'original_session_id_name'  => array('name' => 'original_session_id_name',  'type' => 'xsd:string')
5482
+        'original_session_id_name'  => array('name' => 'original_session_id_name', 'type' => 'xsd:string')
5483 5483
     )
5484 5484
 );
5485 5485
 
@@ -5532,13 +5532,13 @@  discard block
 block discarded – undo
5532 5532
 );
5533 5533
 
5534 5534
 // Register the method to expose
5535
-$server->register('WSSuscribeCoursesToSession',                            // method name
5535
+$server->register('WSSuscribeCoursesToSession', // method name
5536 5536
     array('subscribeCoursesToSession' => 'tns:subscribeCoursesToSession'), // input parameters
5537
-    array('return' => 'tns:results_subscribeCoursesToSession'),            // output parameters
5538
-    'urn:WSRegistration',                                                  // namespace
5539
-    'urn:WSRegistration#WSSuscribeCoursesToSession',                       // soapaction
5540
-    'rpc',                                                                 // style
5541
-    'encoded',                                                             // use
5537
+    array('return' => 'tns:results_subscribeCoursesToSession'), // output parameters
5538
+    'urn:WSRegistration', // namespace
5539
+    'urn:WSRegistration#WSSuscribeCoursesToSession', // soapaction
5540
+    'rpc', // style
5541
+    'encoded', // use
5542 5542
     'This service subscribes a course to a session'                        // documentation
5543 5543
 );
5544 5544
 
@@ -5676,13 +5676,13 @@  discard block
 block discarded – undo
5676 5676
 
5677 5677
 
5678 5678
 // Register the method to expose
5679
-$server->register('WSUnsuscribeCoursesFromSession',                                // method name
5679
+$server->register('WSUnsuscribeCoursesFromSession', // method name
5680 5680
     array('unsubscribeCoursesFromSession' => 'tns:unsubscribeCoursesFromSession'), // input parameters
5681
-    array('return' => 'tns:results_unsubscribeCoursesFromSession'),                // output parameters
5682
-    'urn:WSRegistration',                                                          // namespace
5683
-    'urn:WSRegistration#WSUnsuscribeCoursesFromSession',                           // soapaction
5684
-    'rpc',                                                                         // style
5685
-    'encoded',                                                                     // use
5681
+    array('return' => 'tns:results_unsubscribeCoursesFromSession'), // output parameters
5682
+    'urn:WSRegistration', // namespace
5683
+    'urn:WSRegistration#WSUnsuscribeCoursesFromSession', // soapaction
5684
+    'rpc', // style
5685
+    'encoded', // use
5686 5686
     'This service subscribes a course to a session'                                // documentation
5687 5687
 );
5688 5688
 
@@ -5789,7 +5789,7 @@  discard block
 block discarded – undo
5789 5789
 
5790 5790
     $count_results = count($results);
5791 5791
     $output = array();
5792
-    for($i = 0; $i < $count_results; $i++) {
5792
+    for ($i = 0; $i < $count_results; $i++) {
5793 5793
         $output[] = array(
5794 5794
             'original_course_id_values' => $orig_course_id_value[$i],
5795 5795
             'original_session_id_value' => $orig_session_id_value[$i],
@@ -5847,13 +5847,13 @@  discard block
 block discarded – undo
5847 5847
 
5848 5848
 
5849 5849
 // Register the method to expose
5850
-$server->register('WSListCourses',                                                  // method name
5850
+$server->register('WSListCourses', // method name
5851 5851
     array('listCourseInput' => 'tns:listCourseInput'), // input parameters
5852
-    array('return' => 'tns:courses'),                                               // output parameters
5853
-    'urn:WSRegistration',                                                           // namespace
5854
-    'urn:WSRegistration#WSListCourses',                                             // soapaction
5855
-    'rpc',                                                                          // style
5856
-    'encoded',                                                                      // use
5852
+    array('return' => 'tns:courses'), // output parameters
5853
+    'urn:WSRegistration', // namespace
5854
+    'urn:WSRegistration#WSListCourses', // soapaction
5855
+    'rpc', // style
5856
+    'encoded', // use
5857 5857
     'This service list courses available on the system'                             // documentation
5858 5858
 );
5859 5859
 
@@ -5933,27 +5933,27 @@  discard block
 block discarded – undo
5933 5933
     'all',
5934 5934
     '',
5935 5935
     array(
5936
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
5937
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
5938
-        'chamilo_username'          => array('name' => 'chamilo_username',          'type' => 'xsd:string'),
5939
-        'secret_key'                => array('name' => 'secret_key',                'type' => 'xsd:string')
5936
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
5937
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
5938
+        'chamilo_username'          => array('name' => 'chamilo_username', 'type' => 'xsd:string'),
5939
+        'secret_key'                => array('name' => 'secret_key', 'type' => 'xsd:string')
5940 5940
     )
5941 5941
 );
5942 5942
 
5943 5943
 // Register the method to expose
5944
-$server->register('WSUpdateUserApiKey',      // method name
5944
+$server->register('WSUpdateUserApiKey', // method name
5945 5945
     array('userApiKey' => 'tns:userApiKey'), // input parameters
5946
-    array('return' => 'xsd:string'),         // output parameters
5947
-    'urn:WSRegistration',                    // namespace
5948
-    'urn:WSRegistration#WSListCourses',      // soapaction
5949
-    'rpc',                                   // style
5950
-    'encoded',                               // use
5946
+    array('return' => 'xsd:string'), // output parameters
5947
+    'urn:WSRegistration', // namespace
5948
+    'urn:WSRegistration#WSListCourses', // soapaction
5949
+    'rpc', // style
5950
+    'encoded', // use
5951 5951
     'This service return user api key'       // documentation
5952 5952
 );
5953 5953
 
5954 5954
 
5955 5955
 function WSUpdateUserApiKey($params) {
5956
-    if(!WSHelperVerifyKey($params)) {
5956
+    if (!WSHelperVerifyKey($params)) {
5957 5957
         return returnError(WS_ERROR_SECRET_KEY);
5958 5958
     }
5959 5959
 
@@ -5995,11 +5995,11 @@  discard block
 block discarded – undo
5995 5995
     'all',
5996 5996
     '',
5997 5997
     array(
5998
-        'from'  => array('name' => 'from',  'type' => 'xsd:int'),
5999
-        'to'    => array('name' => 'to',    'type' => 'xsd:int'),
6000
-        'date_start'  => array('name' => 'date_start',  'type' => 'xsd:string'),
6001
-        'date_end'    => array('name' => 'date_end',    'type' => 'xsd:string'),
6002
-        'secret_key'  => array('name' => 'secret_key',  'type' => 'xsd:string')
5998
+        'from'  => array('name' => 'from', 'type' => 'xsd:int'),
5999
+        'to'    => array('name' => 'to', 'type' => 'xsd:int'),
6000
+        'date_start'  => array('name' => 'date_start', 'type' => 'xsd:string'),
6001
+        'date_end'    => array('name' => 'date_end', 'type' => 'xsd:string'),
6002
+        'secret_key'  => array('name' => 'secret_key', 'type' => 'xsd:string')
6003 6003
     )
6004 6004
 );
6005 6005
 
@@ -6010,11 +6010,11 @@  discard block
 block discarded – undo
6010 6010
     'all',
6011 6011
     '',
6012 6012
     array(
6013
-        'id' => array ('name' => 'id'  , 'type' => 'xsd:int'),
6014
-        'title' => array ('name' => 'title', 'type' => 'xsd:string'),
6015
-        'url' => array ('name' => 'url', 'type' => 'xsd:string'),
6016
-        'date_start' => array ('name' => 'date_start', 'type' => 'xsd:string'),
6017
-        'date_end' => array ('name' => 'date_end', 'type' => 'xsd:string'),
6013
+        'id' => array('name' => 'id', 'type' => 'xsd:int'),
6014
+        'title' => array('name' => 'title', 'type' => 'xsd:string'),
6015
+        'url' => array('name' => 'url', 'type' => 'xsd:string'),
6016
+        'date_start' => array('name' => 'date_start', 'type' => 'xsd:string'),
6017
+        'date_end' => array('name' => 'date_end', 'type' => 'xsd:string'),
6018 6018
     )
6019 6019
 );
6020 6020
 
@@ -6033,13 +6033,13 @@  discard block
 block discarded – undo
6033 6033
 );
6034 6034
 
6035 6035
 // Register the method to expose
6036
-$server->register('WSListSessions',           // method name
6037
-    array('input'  => 'tns:session_arg'),     // input parameters
6038
-    array('return' => 'tns:sessions'),        // output parameters
6039
-    'urn:WSRegistration',                     // namespace
6040
-    'urn:WSRegistration#WSListSessions',      // soapaction
6041
-    'rpc',                                    // style
6042
-    'encoded',                                // use
6036
+$server->register('WSListSessions', // method name
6037
+    array('input'  => 'tns:session_arg'), // input parameters
6038
+    array('return' => 'tns:sessions'), // output parameters
6039
+    'urn:WSRegistration', // namespace
6040
+    'urn:WSRegistration#WSListSessions', // soapaction
6041
+    'rpc', // style
6042
+    'encoded', // use
6043 6043
     'This service returns a list of sessions' // documentation
6044 6044
 );
6045 6045
 
@@ -6097,20 +6097,20 @@  discard block
 block discarded – undo
6097 6097
     'all',
6098 6098
     '',
6099 6099
     array(
6100
-        'course'       => array('name' => 'course',     'type' => 'xsd:string'), //Course string code
6101
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'), //Chamilo user_id
6100
+        'course'       => array('name' => 'course', 'type' => 'xsd:string'), //Course string code
6101
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id
6102 6102
         'secret_key'   => array('name' => 'secret_key', 'type' => 'xsd:string')
6103 6103
     )
6104 6104
 );
6105 6105
 
6106 6106
 // Register the method to expose
6107
-$server->register('WSUserSubscribedInCourse',                            // method name
6108
-    array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'),    // input parameters
6109
-    array('return' => 'xsd:string'),                                        // output parameters
6110
-    'urn:WSRegistration',                                                    // namespace
6111
-    'urn:WSRegistration#WSUserSubscribedInCourse',                       // soapaction
6112
-    'rpc',                                                                    // style
6113
-    'encoded',                                                                // use
6107
+$server->register('WSUserSubscribedInCourse', // method name
6108
+    array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'), // input parameters
6109
+    array('return' => 'xsd:string'), // output parameters
6110
+    'urn:WSRegistration', // namespace
6111
+    'urn:WSRegistration#WSUserSubscribedInCourse', // soapaction
6112
+    'rpc', // style
6113
+    'encoded', // use
6114 6114
     'This service checks if user assigned to course'    // documentation
6115 6115
 );
6116 6116
 
@@ -6124,7 +6124,7 @@  discard block
 block discarded – undo
6124 6124
     global $debug;
6125 6125
 
6126 6126
     if ($debug) error_log('WSUserSubscribedInCourse');
6127
-    if ($debug) error_log('Params '. print_r($params, 1));
6127
+    if ($debug) error_log('Params '.print_r($params, 1));
6128 6128
     if (!WSHelperVerifyKey($params)) {
6129 6129
 
6130 6130
         return returnError(WS_ERROR_SECRET_KEY);
@@ -6132,7 +6132,7 @@  discard block
 block discarded – undo
6132 6132
     $courseCode  = $params['course']; //Course code
6133 6133
     $userId      = $params['user_id']; //chamilo user id
6134 6134
 
6135
-    return (CourseManager::is_user_subscribed_in_course($userId,$courseCode));
6135
+    return (CourseManager::is_user_subscribed_in_course($userId, $courseCode));
6136 6136
 }
6137 6137
 
6138 6138
 
@@ -6160,8 +6160,8 @@  discard block
 block discarded – undo
6160 6160
     'all',
6161 6161
     '',
6162 6162
     array(
6163
-        'variable' => array('name'=>'variable','type'=>'xsd:string'),
6164
-        'value' => array('name'=>'value','type'=>'xsd:string')
6163
+        'variable' => array('name'=>'variable', 'type'=>'xsd:string'),
6164
+        'value' => array('name'=>'value', 'type'=>'xsd:string')
6165 6165
     )
6166 6166
 );
6167 6167
 
@@ -6223,12 +6223,12 @@  discard block
 block discarded – undo
6223 6223
 //Reister WSSearchSession
6224 6224
 $server->register(
6225 6225
     'WSSearchSession',
6226
-    array('SearchSession' => 'tns:SearchSession'),      // input parameters
6227
-    array('return' => 'tns:searchedSessionList'),       // output parameters
6228
-    'urn:WSRegistration',                               // namespace
6229
-    'urn:WSRegistration#WSSearchSession',               // soapaction
6230
-    'rpc',                                              // style
6231
-    'encoded',                                          // use
6226
+    array('SearchSession' => 'tns:SearchSession'), // input parameters
6227
+    array('return' => 'tns:searchedSessionList'), // output parameters
6228
+    'urn:WSRegistration', // namespace
6229
+    'urn:WSRegistration#WSSearchSession', // soapaction
6230
+    'rpc', // style
6231
+    'encoded', // use
6232 6232
     'This service to get a session list filtered by name, description or short description extra field'    // documentation
6233 6233
 );
6234 6234
 
@@ -6283,12 +6283,12 @@  discard block
 block discarded – undo
6283 6283
 //Reister WSFetchSession
6284 6284
 $server->register(
6285 6285
     'WSFetchSession',
6286
-    array('SearchSession' => 'tns:FetchSession'),                    // input parameters
6287
-    array('return' => 'tns:searchedSessionList'),       // output parameters
6288
-    'urn:WSRegistration',                               // namespace
6289
-    'urn:WSRegistration#WSFetchSession',                // soapaction
6290
-    'rpc',                                              // style
6291
-    'encoded',                                          // use
6286
+    array('SearchSession' => 'tns:FetchSession'), // input parameters
6287
+    array('return' => 'tns:searchedSessionList'), // output parameters
6288
+    'urn:WSRegistration', // namespace
6289
+    'urn:WSRegistration#WSFetchSession', // soapaction
6290
+    'rpc', // style
6291
+    'encoded', // use
6292 6292
     'This service get a session by its id. Optionally can get its extra fields values'    // documentation
6293 6293
 );
6294 6294
 
@@ -6365,16 +6365,16 @@  discard block
 block discarded – undo
6365 6365
 );
6366 6366
 // Register the method to expose
6367 6367
 $server->register(
6368
-    'WSCertificatesList',                           // method name
6368
+    'WSCertificatesList', // method name
6369 6369
     array(
6370
-        'startingDate' => 'xsd:string',             // input parameters
6370
+        'startingDate' => 'xsd:string', // input parameters
6371 6371
         'endingDate' => 'xsd:string'
6372 6372
     ),
6373
-    array('return' => 'tns:certificatesList'),      // output parameters
6374
-    'urn:WSRegistration',                           // namespace
6375
-    'urn:WSRegistration#WSCertificatesList',        // soapaction
6376
-    'rpc',                                          // style
6377
-    'encoded',                                      // use
6373
+    array('return' => 'tns:certificatesList'), // output parameters
6374
+    'urn:WSRegistration', // namespace
6375
+    'urn:WSRegistration#WSCertificatesList', // soapaction
6376
+    'rpc', // style
6377
+    'encoded', // use
6378 6378
     'This service returns a list of certificates'   // documentation
6379 6379
 );
6380 6380
 
@@ -6440,13 +6440,13 @@  discard block
 block discarded – undo
6440 6440
 );
6441 6441
 
6442 6442
 // Register the method to expose
6443
-$server->register('WSCreateGroup',              // method name
6444
-    array('createGroup' => 'tns:createGroup'),  // input parameters
6445
-    array('return' => 'xsd:string'),            // output parameters
6446
-    'urn:WSRegistration',                       // namespace
6447
-    'urn:WSRegistration#WSCreateGroup',         // soapaction
6448
-    'rpc',                                      // style
6449
-    'encoded',                                  // use
6443
+$server->register('WSCreateGroup', // method name
6444
+    array('createGroup' => 'tns:createGroup'), // input parameters
6445
+    array('return' => 'xsd:string'), // output parameters
6446
+    'urn:WSRegistration', // namespace
6447
+    'urn:WSRegistration#WSCreateGroup', // soapaction
6448
+    'rpc', // style
6449
+    'encoded', // use
6450 6450
     'This service adds a group'                 // documentation
6451 6451
 );
6452 6452
 
@@ -6489,13 +6489,13 @@  discard block
 block discarded – undo
6489 6489
 );
6490 6490
 
6491 6491
 // Register the method to expose
6492
-$server->register('WSUpdateGroup',              // method name
6493
-    array('updateGroup' => 'tns:updateGroup'),  // input parameters
6494
-    array('return' => 'xsd:string'),            // output parameters
6495
-    'urn:WSRegistration',                       // namespace
6496
-    'urn:WSRegistration#WSUpdateGroup',         // soapaction
6497
-    'rpc',                                      // style
6498
-    'encoded',                                  // use
6492
+$server->register('WSUpdateGroup', // method name
6493
+    array('updateGroup' => 'tns:updateGroup'), // input parameters
6494
+    array('return' => 'xsd:string'), // output parameters
6495
+    'urn:WSRegistration', // namespace
6496
+    'urn:WSRegistration#WSUpdateGroup', // soapaction
6497
+    'rpc', // style
6498
+    'encoded', // use
6499 6499
     'This service updates a group'              // documentation
6500 6500
 );
6501 6501
 
@@ -6540,13 +6540,13 @@  discard block
 block discarded – undo
6540 6540
 );
6541 6541
 
6542 6542
 // Register the method to expose
6543
-$server->register('WSDeleteGroup',              // method name
6544
-    array('deleteGroup' => 'tns:deleteGroup'),  // input parameters
6545
-    array('return' => 'xsd:string'),            // output parameters
6546
-    'urn:WSRegistration',                       // namespace
6547
-    'urn:WSRegistration#WSDeleteGroup',         // soapaction
6548
-    'rpc',                                      // style
6549
-    'encoded',                                  // use
6543
+$server->register('WSDeleteGroup', // method name
6544
+    array('deleteGroup' => 'tns:deleteGroup'), // input parameters
6545
+    array('return' => 'xsd:string'), // output parameters
6546
+    'urn:WSRegistration', // namespace
6547
+    'urn:WSRegistration#WSDeleteGroup', // soapaction
6548
+    'rpc', // style
6549
+    'encoded', // use
6550 6550
     'This service deletes a group'              // documentation
6551 6551
 );
6552 6552
 
@@ -6583,13 +6583,13 @@  discard block
 block discarded – undo
6583 6583
 );
6584 6584
 
6585 6585
 // Register the method to expose
6586
-$server->register('GroupBindToParent',                      // method name
6587
-    array('groupBindToParent' => 'tns:groupBindToParent'),  // input parameters
6588
-    array('return' => 'xsd:string'),                        // output parameters
6589
-    'urn:WSRegistration',                                   // namespace
6590
-    'urn:WSRegistration#GroupBindToParent',                 // soapaction
6591
-    'rpc',                                                  // style
6592
-    'encoded',                                              // use
6586
+$server->register('GroupBindToParent', // method name
6587
+    array('groupBindToParent' => 'tns:groupBindToParent'), // input parameters
6588
+    array('return' => 'xsd:string'), // output parameters
6589
+    'urn:WSRegistration', // namespace
6590
+    'urn:WSRegistration#GroupBindToParent', // soapaction
6591
+    'rpc', // style
6592
+    'encoded', // use
6593 6593
     'This service binds a group to a parent'                // documentation
6594 6594
 );
6595 6595
 
@@ -6625,13 +6625,13 @@  discard block
 block discarded – undo
6625 6625
 );
6626 6626
 
6627 6627
 // Register the method to expose
6628
-$server->register('GroupUnbindFromParent',                          // method name
6629
-    array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'),  // input parameters
6630
-    array('return' => 'xsd:string'),                                // output parameters
6631
-    'urn:WSRegistration',                                           // namespace
6632
-    'urn:WSRegistration#GroupUnbindFromParent',                     // soapaction
6633
-    'rpc',                                                          // style
6634
-    'encoded',                                                      // use
6628
+$server->register('GroupUnbindFromParent', // method name
6629
+    array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'), // input parameters
6630
+    array('return' => 'xsd:string'), // output parameters
6631
+    'urn:WSRegistration', // namespace
6632
+    'urn:WSRegistration#GroupUnbindFromParent', // soapaction
6633
+    'rpc', // style
6634
+    'encoded', // use
6635 6635
     'This service unbinds a group from its parent'                  // documentation
6636 6636
 );
6637 6637
 
@@ -6665,13 +6665,13 @@  discard block
 block discarded – undo
6665 6665
 );
6666 6666
 
6667 6667
 // Register the method to expose
6668
-$server->register('WSAddUserToGroup',                   // method name
6669
-    array('addUserToGroup' => 'tns:addUserToGroup'),    // input parameters
6670
-    array('return' => 'xsd:string'),                    // output parameters
6671
-    'urn:WSRegistration',                               // namespace
6672
-    'urn:WSRegistration#WSAddUserToGroup',              // soapaction
6673
-    'rpc',                                              // style
6674
-    'encoded',                                          // use
6668
+$server->register('WSAddUserToGroup', // method name
6669
+    array('addUserToGroup' => 'tns:addUserToGroup'), // input parameters
6670
+    array('return' => 'xsd:string'), // output parameters
6671
+    'urn:WSRegistration', // namespace
6672
+    'urn:WSRegistration#WSAddUserToGroup', // soapaction
6673
+    'rpc', // style
6674
+    'encoded', // use
6675 6675
     'This service adds a user to a group'               // documentation
6676 6676
 );
6677 6677
 
@@ -6708,13 +6708,13 @@  discard block
 block discarded – undo
6708 6708
 );
6709 6709
 
6710 6710
 // Register the method to expose
6711
-$server->register('WSUpdateUserRoleInGroup',                        // method name
6712
-    array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'),  // input parameters
6713
-    array('return' => 'xsd:string'),                                // output parameters
6714
-    'urn:WSRegistration',                                           // namespace
6715
-    'urn:WSRegistration#WSUpdateUserRoleInGroup',                   // soapaction
6716
-    'rpc',                                                          // style
6717
-    'encoded',                                                      // use
6711
+$server->register('WSUpdateUserRoleInGroup', // method name
6712
+    array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'), // input parameters
6713
+    array('return' => 'xsd:string'), // output parameters
6714
+    'urn:WSRegistration', // namespace
6715
+    'urn:WSRegistration#WSUpdateUserRoleInGroup', // soapaction
6716
+    'rpc', // style
6717
+    'encoded', // use
6718 6718
     'This service updates a user role in group'                     // documentation
6719 6719
 );
6720 6720
 
@@ -6753,13 +6753,13 @@  discard block
 block discarded – undo
6753 6753
 );
6754 6754
 
6755 6755
 // Register the method to expose
6756
-$server->register('WSDeleteUserFromGroup',                      // method name
6757
-    array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'),  // input parameters
6758
-    array('return' => 'xsd:string'),                            // output parameters
6759
-    'urn:WSRegistration',                                       // namespace
6760
-    'urn:WSRegistration#WSDeleteUserFromGroup',                 // soapaction
6761
-    'rpc',                                                      // style
6762
-    'encoded',                                                  // use
6756
+$server->register('WSDeleteUserFromGroup', // method name
6757
+    array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'), // input parameters
6758
+    array('return' => 'xsd:string'), // output parameters
6759
+    'urn:WSRegistration', // namespace
6760
+    'urn:WSRegistration#WSDeleteUserFromGroup', // soapaction
6761
+    'rpc', // style
6762
+    'encoded', // use
6763 6763
     'This service deletes a user from a group'                  // documentation
6764 6764
 );
6765 6765
 
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   +426 added lines, -426 removed lines patch added patch discarded remove patch
@@ -11,458 +11,458 @@
 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
         global $api_failureList;
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) {
236
-			$failure = $api_failureList[0];
237
-			if($failure == 'login-pass already taken') {
238
-				return new WSError(102, 'This username is already taken');
239
-			} else if($failure == 'encrypt_method invalid') {
240
-				return new WSError(103, 'The encryption of the password is invalid');
241
-			} else {
242
-				return new WSError(104, 'There was an error creating the user');
243
-			}
244
-		} else {
245
-			return $result;
246
-		}
247
-	}
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
+            $failure = $api_failureList[0];
237
+            if($failure == 'login-pass already taken') {
238
+                return new WSError(102, 'This username is already taken');
239
+            } else if($failure == 'encrypt_method invalid') {
240
+                return new WSError(103, 'The encryption of the password is invalid');
241
+            } else {
242
+                return new WSError(104, 'There was an error creating the user');
243
+            }
244
+        } else {
245
+            return $result;
246
+        }
247
+    }
248 248
 
249
-	/**
250
-	 * Creates a user
251
-	 *
252
-	 * @param string API secret key
253
-	 * @param string User first name
254
-	 * @param string User last name
255
-	 * @param int User status
256
-	 * @param string Login name
257
-	 * @param string Password (encrypted or not)
258
-	 * @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
259
-	 * to include the salt in the extra fields if you are encrypting the password
260
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
261
-	 * @param string User id value. Leave blank if you are using the internal user_id
262
-	 * @param int Visibility. Set by default to 1
263
-	 * @param string User email. Set by default to an empty string
264
-	 * @param string Language. Set by default to english
265
-	 * @param string Phone. Set by default to an empty string
266
-	 * @param string Expiration date. Set to null by default
267
-	 * @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
268
-	 * @return int New user id generated by the system
269
-	 */
270
-	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()) {
271
-		// First, verify the secret key
272
-		$verifKey = $this->verifyKey($secret_key);
273
-		if($verifKey instanceof WSError) {
274
-			$this->handleError($verifKey);
275
-		} else {
276
-			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
-			if($result instanceof WSError) {
278
-				$this->handleError($result);
279
-			} else {
280
-				return $result;
281
-			}
282
-		}
283
-	}
249
+    /**
250
+     * Creates a user
251
+     *
252
+     * @param string API secret key
253
+     * @param string User first name
254
+     * @param string User last name
255
+     * @param int User status
256
+     * @param string Login name
257
+     * @param string Password (encrypted or not)
258
+     * @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
259
+     * to include the salt in the extra fields if you are encrypting the password
260
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
261
+     * @param string User id value. Leave blank if you are using the internal user_id
262
+     * @param int Visibility. Set by default to 1
263
+     * @param string User email. Set by default to an empty string
264
+     * @param string Language. Set by default to english
265
+     * @param string Phone. Set by default to an empty string
266
+     * @param string Expiration date. Set to null by default
267
+     * @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
268
+     * @return int New user id generated by the system
269
+     */
270
+    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()) {
271
+        // First, verify the secret key
272
+        $verifKey = $this->verifyKey($secret_key);
273
+        if($verifKey instanceof WSError) {
274
+            $this->handleError($verifKey);
275
+        } else {
276
+            $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
+            if($result instanceof WSError) {
278
+                $this->handleError($result);
279
+            } else {
280
+                return $result;
281
+            }
282
+        }
283
+    }
284 284
 
285
-	/**
286
-	 * Creates multiple users
287
-	 *
288
-	 * @param string API secret key
289
-	 * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
290
-	 * @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'))
291
-	 */
292
-	public function CreateUsers($secret_key, $users) {
293
-		$verifKey = $this->verifyKey($secret_key);
294
-		if($verifKey instanceof WSError) {
295
-			$this->handleError($verifKey);
296
-		} else {
297
-			$results = array();
298
-			foreach($users as $user) {
299
-				$result_tmp = array();
285
+    /**
286
+     * Creates multiple users
287
+     *
288
+     * @param string API secret key
289
+     * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
290
+     * @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'))
291
+     */
292
+    public function CreateUsers($secret_key, $users) {
293
+        $verifKey = $this->verifyKey($secret_key);
294
+        if($verifKey instanceof WSError) {
295
+            $this->handleError($verifKey);
296
+        } else {
297
+            $results = array();
298
+            foreach($users as $user) {
299
+                $result_tmp = array();
300 300
                 // re-initialize variables just in case
301 301
                 $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null;
302
-				extract($user);
303
-				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
-				if($result instanceof WSError) {
305
-					$result_tmp['result'] = $result->toArray();
306
-					$result_tmp['user_id_value'] = $user_id_value;
307
-					$result_tmp['user_id_generated'] = 0;
308
-				} else {
309
-					$result_tmp['result'] = $this->getSuccessfulResult();
310
-					$result_tmp['user_id_value'] = $user_id_value;
311
-					$result_tmp['user_id_generated'] = $result;
312
-				}
313
-				$results[] = $result_tmp;
314
-			}
315
-			return $results;
316
-		}
317
-	}
302
+                extract($user);
303
+                $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
+                if($result instanceof WSError) {
305
+                    $result_tmp['result'] = $result->toArray();
306
+                    $result_tmp['user_id_value'] = $user_id_value;
307
+                    $result_tmp['user_id_generated'] = 0;
308
+                } else {
309
+                    $result_tmp['result'] = $this->getSuccessfulResult();
310
+                    $result_tmp['user_id_value'] = $user_id_value;
311
+                    $result_tmp['user_id_generated'] = $result;
312
+                }
313
+                $results[] = $result_tmp;
314
+            }
315
+            return $results;
316
+        }
317
+    }
318 318
 
319
-	/**
320
-	 * Edits user info (helper method)
321
-	 *
322
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
323
-	 * @param string User id value
324
-	 * @param string First name
325
-	 * @param string Last name
326
-	 * @param int User status
327
-	 * @param string Login name
328
-	 * @param string Password. Leave blank if you don't want to update it
329
-	 * @param string Encrypt method
330
-	 * @param string User email
331
-	 * @param string Language. Set by default to english
332
-	 * @param string Phone. Set by default to an empty string
333
-	 * @param string Expiration date. Set to null by default
334
-	 * @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
335
-	 * @return mixed True if user was successfully updated, WSError otherwise
336
-	 */
337
-	protected function editUserHelper(
338
-		$user_id_field_name,
339
-		$user_id_value,
340
-		$firstname,
341
-		$lastname,
342
-		$status,
343
-		$loginname,
344
-		$password,
345
-		$encrypt_method,
346
-		$email,
347
-		$language,
348
-		$phone,
349
-		$expiration_date,
350
-		$extras
351
-	) {
319
+    /**
320
+     * Edits user info (helper method)
321
+     *
322
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
323
+     * @param string User id value
324
+     * @param string First name
325
+     * @param string Last name
326
+     * @param int User status
327
+     * @param string Login name
328
+     * @param string Password. Leave blank if you don't want to update it
329
+     * @param string Encrypt method
330
+     * @param string User email
331
+     * @param string Language. Set by default to english
332
+     * @param string Phone. Set by default to an empty string
333
+     * @param string Expiration date. Set to null by default
334
+     * @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
335
+     * @return mixed True if user was successfully updated, WSError otherwise
336
+     */
337
+    protected function editUserHelper(
338
+        $user_id_field_name,
339
+        $user_id_value,
340
+        $firstname,
341
+        $lastname,
342
+        $status,
343
+        $loginname,
344
+        $password,
345
+        $encrypt_method,
346
+        $email,
347
+        $language,
348
+        $phone,
349
+        $expiration_date,
350
+        $extras
351
+    ) {
352 352
         global $api_failureList;
353
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
-		if($user_id instanceof WSError) {
355
-			return $user_id;
356
-		} else {
357
-			if($password == '') {
358
-				$password = null;
359
-			}
360
-			$user_info = api_get_user_info($user_id);
361
-			if (count($extras) == 0) {
362
-				$extras = null;
363
-			}
353
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
+        if($user_id instanceof WSError) {
355
+            return $user_id;
356
+        } else {
357
+            if($password == '') {
358
+                $password = null;
359
+            }
360
+            $user_info = api_get_user_info($user_id);
361
+            if (count($extras) == 0) {
362
+                $extras = null;
363
+            }
364 364
 
365
-			$result = UserManager::update_user(
366
-				$user_id,
367
-				$firstname,
368
-				$lastname,
369
-				$loginname,
370
-				$password,
371
-				PLATFORM_AUTH_SOURCE,
372
-				$email,
373
-				$status,
374
-				'',
375
-				$phone,
376
-				$user_info['picture_uri'],
377
-				$expiration_date,
378
-				$user_info['active'],
379
-				null,
380
-				$user_info['hr_dept_id'],
381
-				$extras,
382
-				$encrypt_method
383
-			);
384
-			if (!$result) {
385
-				$failure = $api_failureList[0];
386
-				if($failure == 'encrypt_method invalid') {
387
-					return new WSError(103, 'The encryption of the password is invalid');
388
-				} else {
389
-					return new WSError(105, 'There was an error updating the user');
390
-				}
391
-			} else {
392
-				return $result;
393
-			}
394
-		}
395
-	}
365
+            $result = UserManager::update_user(
366
+                $user_id,
367
+                $firstname,
368
+                $lastname,
369
+                $loginname,
370
+                $password,
371
+                PLATFORM_AUTH_SOURCE,
372
+                $email,
373
+                $status,
374
+                '',
375
+                $phone,
376
+                $user_info['picture_uri'],
377
+                $expiration_date,
378
+                $user_info['active'],
379
+                null,
380
+                $user_info['hr_dept_id'],
381
+                $extras,
382
+                $encrypt_method
383
+            );
384
+            if (!$result) {
385
+                $failure = $api_failureList[0];
386
+                if($failure == 'encrypt_method invalid') {
387
+                    return new WSError(103, 'The encryption of the password is invalid');
388
+                } else {
389
+                    return new WSError(105, 'There was an error updating the user');
390
+                }
391
+            } else {
392
+                return $result;
393
+            }
394
+        }
395
+    }
396 396
 
397
-	/**
398
-	 * Edits user info
399
-	 *
400
-	 * @param string API secret key
401
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
402
-	 * @param string User id value
403
-	 * @param string First name
404
-	 * @param string Last name
405
-	 * @param int User status
406
-	 * @param string Login name
407
-	 * @param string Password. Leave blank if you don't want to update it
408
-	 * @param string Encrypt method
409
-	 * @param string User email
410
-	 * @param string Language. Set by default to english
411
-	 * @param string Phone. Set by default to an empty string
412
-	 * @param string Expiration date. Set to null by default
413
-	 * @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
414
-	 */
415
-	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) {
416
-		// First, verify the secret key
417
-		$verifKey = $this->verifyKey($secret_key);
418
-		if($verifKey instanceof WSError) {
419
-			$this->handleError($verifKey);
420
-		} else {
397
+    /**
398
+     * Edits user info
399
+     *
400
+     * @param string API secret key
401
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
402
+     * @param string User id value
403
+     * @param string First name
404
+     * @param string Last name
405
+     * @param int User status
406
+     * @param string Login name
407
+     * @param string Password. Leave blank if you don't want to update it
408
+     * @param string Encrypt method
409
+     * @param string User email
410
+     * @param string Language. Set by default to english
411
+     * @param string Phone. Set by default to an empty string
412
+     * @param string Expiration date. Set to null by default
413
+     * @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
414
+     */
415
+    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) {
416
+        // First, verify the secret key
417
+        $verifKey = $this->verifyKey($secret_key);
418
+        if($verifKey instanceof WSError) {
419
+            $this->handleError($verifKey);
420
+        } else {
421 421
 
422
-			$extras_associative = array();
423
-			if (!empty($extras)) {
424
-				foreach($extras as $extra) {
425
-					$extras_associative[$extra['field_name']] = $extra['field_value'];
426
-				}
427
-			}
422
+            $extras_associative = array();
423
+            if (!empty($extras)) {
424
+                foreach($extras as $extra) {
425
+                    $extras_associative[$extra['field_name']] = $extra['field_value'];
426
+                }
427
+            }
428 428
 
429
-			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
-			if($result instanceof WSError) {
431
-				$this->handleError($result);
432
-			}
433
-		}
434
-	}
429
+            $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
+            if($result instanceof WSError) {
431
+                $this->handleError($result);
432
+            }
433
+        }
434
+    }
435 435
 
436
-	/**
437
-	 * Edits multiple users
438
-	 *
439
-	 * @param string API secret key
440
-	 * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
441
-	 * @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
442
-	 * than 0, an error occured
443
-	 */
444
-	public function EditUsers($secret_key, $users) {
445
-		$verifKey = $this->verifyKey($secret_key);
446
-		if($verifKey instanceof WSError) {
447
-			$this->handleError($verifKey);
448
-		} else {
449
-			$results = array();
450
-			foreach($users as $user) {
451
-				$result_tmp = array();
436
+    /**
437
+     * Edits multiple users
438
+     *
439
+     * @param string API secret key
440
+     * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
441
+     * @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
442
+     * than 0, an error occured
443
+     */
444
+    public function EditUsers($secret_key, $users) {
445
+        $verifKey = $this->verifyKey($secret_key);
446
+        if($verifKey instanceof WSError) {
447
+            $this->handleError($verifKey);
448
+        } else {
449
+            $results = array();
450
+            foreach($users as $user) {
451
+                $result_tmp = array();
452 452
                 // re-initialize variables just in case
453 453
                 $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null;
454
-				extract($user);
455
-				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456
-				$result_tmp['user_id_value'] = $user['user_id_value'];
457
-				if($result_op instanceof WSError) {
458
-					// Return the error in the results
459
-					$result_tmp['result'] = $result_op->toArray();
460
-				} else {
461
-					$result_tmp['result'] = $this->getSuccessfulResult();
462
-				}
463
-				$results[] = $result_tmp;
464
-			}
465
-			return $results;
466
-		}
467
-	}
454
+                extract($user);
455
+                $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456
+                $result_tmp['user_id_value'] = $user['user_id_value'];
457
+                if($result_op instanceof WSError) {
458
+                    // Return the error in the results
459
+                    $result_tmp['result'] = $result_op->toArray();
460
+                } else {
461
+                    $result_tmp['result'] = $this->getSuccessfulResult();
462
+                }
463
+                $results[] = $result_tmp;
464
+            }
465
+            return $results;
466
+        }
467
+    }
468 468
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 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,20 +223,20 @@  discard block
 block discarded – undo
223 223
         global $api_failureList;
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
                 }
234 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 235
 		if (!$result) {
236 236
 			$failure = $api_failureList[0];
237
-			if($failure == 'login-pass already taken') {
237
+			if ($failure == 'login-pass already taken') {
238 238
 				return new WSError(102, 'This username is already taken');
239
-			} else if($failure == 'encrypt_method invalid') {
239
+			} else if ($failure == 'encrypt_method invalid') {
240 240
 				return new WSError(103, 'The encryption of the password is invalid');
241 241
 			} else {
242 242
 				return new WSError(104, 'There was an error creating the user');
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	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()) {
271 271
 		// First, verify the secret key
272 272
 		$verifKey = $this->verifyKey($secret_key);
273
-		if($verifKey instanceof WSError) {
273
+		if ($verifKey instanceof WSError) {
274 274
 			$this->handleError($verifKey);
275 275
 		} else {
276 276
 			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
-			if($result instanceof WSError) {
277
+			if ($result instanceof WSError) {
278 278
 				$this->handleError($result);
279 279
 			} else {
280 280
 				return $result;
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	public function CreateUsers($secret_key, $users) {
293 293
 		$verifKey = $this->verifyKey($secret_key);
294
-		if($verifKey instanceof WSError) {
294
+		if ($verifKey instanceof WSError) {
295 295
 			$this->handleError($verifKey);
296 296
 		} else {
297 297
 			$results = array();
298
-			foreach($users as $user) {
298
+			foreach ($users as $user) {
299 299
 				$result_tmp = array();
300 300
                 // re-initialize variables just in case
301 301
                 $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null;
302 302
 				extract($user);
303 303
 				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
-				if($result instanceof WSError) {
304
+				if ($result instanceof WSError) {
305 305
 					$result_tmp['result'] = $result->toArray();
306 306
 					$result_tmp['user_id_value'] = $user_id_value;
307 307
 					$result_tmp['user_id_generated'] = 0;
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 	) {
352 352
         global $api_failureList;
353 353
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
-		if($user_id instanceof WSError) {
354
+		if ($user_id instanceof WSError) {
355 355
 			return $user_id;
356 356
 		} else {
357
-			if($password == '') {
357
+			if ($password == '') {
358 358
 				$password = null;
359 359
 			}
360 360
 			$user_info = api_get_user_info($user_id);
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 			);
384 384
 			if (!$result) {
385 385
 				$failure = $api_failureList[0];
386
-				if($failure == 'encrypt_method invalid') {
386
+				if ($failure == 'encrypt_method invalid') {
387 387
 					return new WSError(103, 'The encryption of the password is invalid');
388 388
 				} else {
389 389
 					return new WSError(105, 'There was an error updating the user');
@@ -415,19 +415,19 @@  discard block
 block discarded – undo
415 415
 	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) {
416 416
 		// First, verify the secret key
417 417
 		$verifKey = $this->verifyKey($secret_key);
418
-		if($verifKey instanceof WSError) {
418
+		if ($verifKey instanceof WSError) {
419 419
 			$this->handleError($verifKey);
420 420
 		} else {
421 421
 
422 422
 			$extras_associative = array();
423 423
 			if (!empty($extras)) {
424
-				foreach($extras as $extra) {
424
+				foreach ($extras as $extra) {
425 425
 					$extras_associative[$extra['field_name']] = $extra['field_value'];
426 426
 				}
427 427
 			}
428 428
 
429 429
 			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
-			if($result instanceof WSError) {
430
+			if ($result instanceof WSError) {
431 431
 				$this->handleError($result);
432 432
 			}
433 433
 		}
@@ -443,18 +443,18 @@  discard block
 block discarded – undo
443 443
 	 */
444 444
 	public function EditUsers($secret_key, $users) {
445 445
 		$verifKey = $this->verifyKey($secret_key);
446
-		if($verifKey instanceof WSError) {
446
+		if ($verifKey instanceof WSError) {
447 447
 			$this->handleError($verifKey);
448 448
 		} else {
449 449
 			$results = array();
450
-			foreach($users as $user) {
450
+			foreach ($users as $user) {
451 451
 				$result_tmp = array();
452 452
                 // re-initialize variables just in case
453 453
                 $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null;
454 454
 				extract($user);
455 455
 				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456 456
 				$result_tmp['user_id_value'] = $user['user_id_value'];
457
-				if($result_op instanceof WSError) {
457
+				if ($result_op instanceof WSError) {
458 458
 					// Return the error in the results
459 459
 					$result_tmp['result'] = $result_op->toArray();
460 460
 				} else {
Please login to merge, or discard this patch.