Completed
Push — 1.10.x ( 60fa62...2aecf0 )
by Yannick
42:06
created
main/webservices/cm_soap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 	 * Singleton method
41 41
 	 */
42 42
 	public static function singleton() {
43
-		if(!isset(self::$_instance)) {
43
+		if (!isset(self::$_instance)) {
44 44
 			self::$_instance = new soap_server();
45 45
 			// Set the error handler
46 46
 			WSCMError::setErrorHandler(new WSCMSoapErrorHandler());
Please login to merge, or discard this patch.
main/webservices/webservice_user.php 1 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.
main/webservices/cm_webservice_courses.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 {
16 16
 
17 17
     public function get_courses_code($username, $password) {
18
-        if($this->verifyUserPass($username, $password) == "valid") {
18
+        if ($this->verifyUserPass($username, $password) == "valid") {
19 19
             $user_id = UserManager::get_user_id_from_username($username);
20 20
             $listOfCourses = UserManager::get_personal_session_course_list($user_id);
21 21
 
22 22
             $courses_id = "#";
23
-            foreach ($listOfCourses as $course){
23
+            foreach ($listOfCourses as $course) {
24 24
                 $courses_id .= $course['code']."#";
25 25
             }
26 26
             return $courses_id;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function get_course_title($username, $password, $course_code)
33 33
     {
34
-        if($this->verifyUserPass($username, $password) == "valid")
34
+        if ($this->verifyUserPass($username, $password) == "valid")
35 35
         {
36 36
             $course_info = CourseManager::get_course_information($course_code);
37 37
             return $course_info['title'];
Please login to merge, or discard this patch.
main/webservices/http-auth.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $digest = getDigest();
13 13
 
14 14
 // If there was no digest, show login
15
-if (is_null($digest)) requireLogin($realm,$nonce);
15
+if (is_null($digest)) requireLogin($realm, $nonce);
16 16
 
17 17
 $digestParts = digestParse($digest);
18 18
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 $validResponse = md5("{$A1}:{$digestParts['nonce']}:{$digestParts['nc']}:{$digestParts['cnonce']}:{$digestParts['qop']}:{$A2}");
27 27
 
28 28
 if ($digestParts['response'] != $validResponse)
29
-  requireLogin($realm,$nonce);
29
+  requireLogin($realm, $nonce);
30 30
 else {
31 31
   // We're in!
32 32
   echo 'a7532ae474e5e66a0c16eddab02e02a7';
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     // most other servers
43 43
     }
44 44
     elseif (isset($_SERVER['HTTP_AUTHENTICATION'])) {
45
-      if (strpos(strtolower($_SERVER['HTTP_AUTHENTICATION']),'digest')===0)
45
+      if (strpos(strtolower($_SERVER['HTTP_AUTHENTICATION']), 'digest') === 0)
46 46
         $digest = substr($_SERVER['HTTP_AUTHORIZATION'], 7);
47 47
     }
48 48
     elseif (isset($_SERVER['HTTP_WWW_AUTHENTICATE'])) {
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 }
54 54
 
55 55
 // This function forces a login prompt
56
-function requireLogin($realm,$nonce) {
57
-    header('WWW-Authenticate: Digest realm="' . $realm . '",qop="auth",nonce="' . $nonce . '",opaque="' . md5($realm) . '"');
56
+function requireLogin($realm, $nonce) {
57
+    header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$nonce.'",opaque="'.md5($realm).'"');
58 58
     header('HTTP/1.1 401');
59 59
     echo 'Authentication Canceled';
60 60
     die();
Please login to merge, or discard this patch.
main/webservices/cm_webservice.php 1 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.
main/webservices/cm_webservice_inbox.php 1 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.
main/webservices/example_fill_users_fields.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 $tuserfv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
22 22
 $sql = "SELECT user_id, username FROM $tuser ORDER BY user_id";
23 23
 $res = Database::query($sql);
24
-while($row = Database::fetch_array($res)) {
24
+while ($row = Database::fetch_array($res)) {
25 25
   $sql2 = "INSERT INTO $tuserfv (item_id, field_id, value)
26 26
            VALUES (".$row['user_id'].", 11,'".$row['username']."')";
27 27
   $res2 = Database::query($sql2);
Please login to merge, or discard this patch.
main/calendar/ical_export.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
 $event = $agenda->get_event($id);
44 44
 
45 45
 if (!empty($event)) {
46
-	define('ICAL_LANG',api_get_language_isocode());
46
+	define('ICAL_LANG', api_get_language_isocode());
47 47
 
48 48
     $ical = new vcalendar();
49
-    $ical->setConfig('unique_id',api_get_path(WEB_PATH));
50
-    $ical->setProperty( 'method', 'PUBLISH' );
51
-    $ical->setConfig('url',api_get_path(WEB_PATH));
49
+    $ical->setConfig('unique_id', api_get_path(WEB_PATH));
50
+    $ical->setProperty('method', 'PUBLISH');
51
+    $ical->setConfig('url', api_get_path(WEB_PATH));
52 52
     $vevent = new vevent();
53 53
 
54
-    switch($_GET['class']) {
54
+    switch ($_GET['class']) {
55 55
         case 'public':
56 56
             $vevent->setClass('PUBLIC');
57 57
             break;
@@ -69,44 +69,44 @@  discard block
 block discarded – undo
69 69
     $event['start_date'] = api_get_local_time($event['start_date']);
70 70
     $event['end_date'] = api_get_local_time($event['end_date']);
71 71
 
72
-    switch($type) {
72
+    switch ($type) {
73 73
         case 'personal':
74 74
         case 'platform':
75
-            $vevent->setProperty( 'summary', api_convert_encoding($event['title'],'UTF-8', $charset));
76
-            if(empty($event['start_date'])){header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER']));}
77
-            list($y,$m,$d,$h,$M,$s) = preg_split('/[\s:-]/',$event['start_date']);
78
-            $vevent->setProperty('dtstart',array('year'=>$y,'month'=>$m,'day'=>$d,'hour'=>$h,'min'=>$M,'sec'=>$s));
79
-            if(empty($event['end_date'])) {
80
-                $y2=$y;$m2=$m;$d2=$d;$h2=$h;$M2=$M+15;$s2=$s;
81
-                if($M2>60){$M2=$M2-60;$h2+=1;}
75
+            $vevent->setProperty('summary', api_convert_encoding($event['title'], 'UTF-8', $charset));
76
+            if (empty($event['start_date'])) {header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER'])); }
77
+            list($y, $m, $d, $h, $M, $s) = preg_split('/[\s:-]/', $event['start_date']);
78
+            $vevent->setProperty('dtstart', array('year'=>$y, 'month'=>$m, 'day'=>$d, 'hour'=>$h, 'min'=>$M, 'sec'=>$s));
79
+            if (empty($event['end_date'])) {
80
+                $y2 = $y; $m2 = $m; $d2 = $d; $h2 = $h; $M2 = $M + 15; $s2 = $s;
81
+                if ($M2 > 60) {$M2 = $M2 - 60; $h2 += 1; }
82 82
             } else {
83
-                list($y2,$m2,$d2,$h2,$M2,$s2) = preg_split('/[\s:-]/',$event['end_date']);
83
+                list($y2, $m2, $d2, $h2, $M2, $s2) = preg_split('/[\s:-]/', $event['end_date']);
84 84
             }
85
-            $vevent->setProperty('dtend',array('year'=>$y2,'month'=>$m2,'day'=>$d2,'hour'=>$h2,'min'=>$M2,'sec'=>$s2));
85
+            $vevent->setProperty('dtend', array('year'=>$y2, 'month'=>$m2, 'day'=>$d2, 'hour'=>$h2, 'min'=>$M2, 'sec'=>$s2));
86 86
             //$vevent->setProperty( 'LOCATION', get_lang('Unknown') ); // property name - case independent
87
-            $vevent->setProperty( 'description', api_convert_encoding($event['description'],'UTF-8',$charset));
87
+            $vevent->setProperty('description', api_convert_encoding($event['description'], 'UTF-8', $charset));
88 88
             //$vevent->setProperty( 'comment', 'This is a comment' );
89 89
             //$user = api_get_user_info($event['user']);
90 90
             //$vevent->setProperty('organizer',$user['mail']);
91 91
             //$vevent->setProperty('attendee',$user['mail']);
92 92
             //$vevent->setProperty( 'rrule', array( 'FREQ' => 'WEEKLY', 'count' => 4));// occurs also four next weeks
93
-            $ical->setConfig('filename',$y.$m.$d.$h.$M.$s.'-'.rand(1,1000).'.ics');
94
-            $ical->setComponent ($vevent); // add event to calendar
93
+            $ical->setConfig('filename', $y.$m.$d.$h.$M.$s.'-'.rand(1, 1000).'.ics');
94
+            $ical->setComponent($vevent); // add event to calendar
95 95
             $ical->returnCalendar();
96 96
             break;
97 97
         case 'course':
98
-            $vevent->setProperty( 'summary', api_convert_encoding($event['title'],'UTF-8',$charset));
99
-            if(empty($event['start_date'])){header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER']));}
100
-            list($y,$m,$d,$h,$M,$s) = preg_split('/[\s:-]/',$event['start_date']);
101
-            $vevent->setProperty('dtstart',array('year'=>$y,'month'=>$m,'day'=>$d,'hour'=>$h,'min'=>$M,'sec'=>$s));
98
+            $vevent->setProperty('summary', api_convert_encoding($event['title'], 'UTF-8', $charset));
99
+            if (empty($event['start_date'])) {header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER'])); }
100
+            list($y, $m, $d, $h, $M, $s) = preg_split('/[\s:-]/', $event['start_date']);
101
+            $vevent->setProperty('dtstart', array('year'=>$y, 'month'=>$m, 'day'=>$d, 'hour'=>$h, 'min'=>$M, 'sec'=>$s));
102 102
             if (empty($event['end_date'])) {
103
-                $y2=$y;$m2=$m;$d2=$d;$h2=$h;$M2=$M+15;$s2=$s;
104
-                if($M2>60){$M2=$M2-60;$h2+=1;}
103
+                $y2 = $y; $m2 = $m; $d2 = $d; $h2 = $h; $M2 = $M + 15; $s2 = $s;
104
+                if ($M2 > 60) {$M2 = $M2 - 60; $h2 += 1; }
105 105
             } else {
106
-                list($y2,$m2,$d2,$h2,$M2,$s2) = preg_split('/[\s:-]/',$event['end_date']);
106
+                list($y2, $m2, $d2, $h2, $M2, $s2) = preg_split('/[\s:-]/', $event['end_date']);
107 107
             }
108
-            $vevent->setProperty('dtend',array('year'=>$y2,'month'=>$m2,'day'=>$d2,'hour'=>$h2,'min'=>$M2,'sec'=>$s2));
109
-            $vevent->setProperty( 'description', api_convert_encoding($event['description'],'UTF-8',$charset));
108
+            $vevent->setProperty('dtend', array('year'=>$y2, 'month'=>$m2, 'day'=>$d2, 'hour'=>$h2, 'min'=>$M2, 'sec'=>$s2));
109
+            $vevent->setProperty('description', api_convert_encoding($event['description'], 'UTF-8', $charset));
110 110
             //$vevent->setProperty( 'comment', 'This is a comment' );
111 111
             //$user = api_get_user_info($event['user']);
112 112
             //$vevent->setProperty('organizer',$user['mail']);
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
                 $vevent->setProperty('rrule',array('FREQ'=>$freq,'UNTIL'=>array('year'=>$e_y,'month'=>$e_m,'day'=>$e_d),'INTERVAL'=>'1'));
121 121
             }*/
122 122
             //$vevent->setProperty( 'rrule', array( 'FREQ' => 'WEEKLY', 'count' => 4));// occurs also four next weeks
123
-            $ical->setConfig('filename',$y.$m.$d.$h.$M.$s.'-'.rand(1,1000).'.ics');
124
-            $ical->setComponent ($vevent); // add event to calendar
123
+            $ical->setConfig('filename', $y.$m.$d.$h.$M.$s.'-'.rand(1, 1000).'.ics');
124
+            $ical->setComponent($vevent); // add event to calendar
125 125
             $ical->returnCalendar();
126 126
             break;
127 127
         default:
Please login to merge, or discard this patch.
main/calendar/agenda_js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) {
37 37
     if ($_REQUEST['cidReq'] == -1) {
38 38
         // When is out of the course tool (e.g My agenda)
39
-        header('Location: ' . api_get_self());
39
+        header('Location: '.api_get_self());
40 40
         exit;
41 41
     } else {
42 42
         $type = 'course';
Please login to merge, or discard this patch.