Completed
Push — 1.10.x ( fe0e5a...3a6f9c )
by Yannick
134:15 queued 86:39
created
main/coursecopy/classes/CourseRestorer.class.php 1 patch
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -512,7 +512,9 @@  discard block
 block discarded – undo
512 512
 
513 513
                                     if (in_array($file_info['extension'], array('html', 'htm'))) {
514 514
                                         $content = file_get_contents($path.$document->path);
515
-                                        if (UTF8_CONVERT) $content = utf8_encode($content);
515
+                                        if (UTF8_CONVERT) {
516
+                                            $content = utf8_encode($content);
517
+                                        }
516 518
                                         $content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
517 519
                                             $content,
518 520
                                             $this->course->code,
@@ -2240,7 +2242,11 @@  discard block
 block discarded – undo
2240 2242
 		            c_id = ".$this->destination_course_id." AND
2241 2243
 		            code='".self::DBUTF8escapestring($survey_code)."'";
2242 2244
 		$result = Database::query($sql);
2243
-		if (Database::num_rows($result) > 0) return false; else return true;
2245
+		if (Database::num_rows($result) > 0) {
2246
+		    return false;
2247
+		} else {
2248
+		    return true;
2249
+		}
2244 2250
 	}
2245 2251
 
2246 2252
 	/**
@@ -2719,8 +2725,9 @@  discard block
 block discarded – undo
2719 2725
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2720 2726
                         }*/
2721 2727
                     } elseif(is_dir($path)) {
2722
-                        if (!is_dir($dest . '/' . $file))
2723
-                        mkdir($dest . '/' . $file);
2728
+                        if (!is_dir($dest . '/' . $file)) {
2729
+                                                mkdir($dest . '/' . $file);
2730
+                        }
2724 2731
                        self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2725 2732
                     }
2726 2733
                 }
Please login to merge, or discard this patch.
main/search/search_suggestions.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,6 +104,8 @@
 block discarded – undo
104 104
 }
105 105
 
106 106
 $q = strtolower($_GET["q"]);
107
-if (!$q) return;
107
+if (!$q) {
108
+    return;
109
+}
108 110
 //echo $q . "| value\n";
109 111
 get_suggestions_from_search_engine($q);
Please login to merge, or discard this patch.
main/permissions/group_permissions.inc.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,9 +97,11 @@
 block discarded – undo
97 97
 echo "\t</tr>\n";
98 98
 
99 99
 // the main area with the checkboxes or images
100
-foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
100
+foreach ($tool_rights as $tool=>$rights) {
101
+    // $tool_rights contains all the possible tools and their rights
101 102
 {
102 103
 	echo "\t<tr>\n";
104
+}
103 105
 	echo "\t\t<td>\n";
104 106
 	echo get_lang($tool);
105 107
 	echo "\t\t</td>\n";
Please login to merge, or discard this patch.
main/permissions/permissions_functions.inc.php 1 patch
Braces   +10 added lines, -16 removed lines patch added patch discarded remove patch
@@ -132,24 +132,20 @@  discard block
 block discarded – undo
132 132
 	{
133 133
 		$table=Database::get_course_table(TABLE_PERMISSION_USER);
134 134
 		$id_field = 'user_id';
135
-	}
136
-	elseif ($content == 'group')
135
+	} elseif ($content == 'group')
137 136
 	{
138 137
 		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
139 138
 		$id_field = 'group_id';
140
-	}
141
-	elseif ($content == 'role')
139
+	} elseif ($content == 'role')
142 140
 	{
143 141
 		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
144 142
 		$id_field = 'role_id';
145
-	}
146
-	elseif ($content == 'platform_role')
143
+	} elseif ($content == 'platform_role')
147 144
 	{
148 145
 		$table=Database::get_main_table(TABLE_ROLE_PERMISSION);
149 146
 		$id_field = 'role_id';
150 147
         $course_id_condition = '';
151
-	}
152
-	elseif ($content == 'task')
148
+	} elseif ($content == 'task')
153 149
 	{
154 150
 		$table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
155 151
 		$id_field = 'task_id';
@@ -162,8 +158,9 @@  discard block
 block discarded – undo
162 158
 		WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'";
163 159
 	$result = Database::query($sql);
164 160
 
165
-	while($row = Database::fetch_array($result))
166
-		$currentpermissions[$row['tool']][] = $row['action'];
161
+	while($row = Database::fetch_array($result)) {
162
+			$currentpermissions[$row['tool']][] = $row['action'];
163
+	}
167 164
 
168 165
 	return $currentpermissions;
169 166
 }
@@ -321,14 +318,12 @@  discard block
 block discarded – undo
321 318
 	if ($course_admin)
322 319
 	{
323 320
 		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
324
-	}
325
-	else
321
+	} else
326 322
 	{
327 323
 		if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool]))
328 324
 		{
329 325
 			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
330
-		}
331
-		else
326
+		} else
332 327
 		{
333 328
 			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
334 329
 			{
@@ -439,8 +434,7 @@  discard block
 block discarded – undo
439 434
 			$checked='checked';
440 435
 			$image='checkbox_on2.gif';
441 436
 			$action='revoke';
442
-		}
443
-		else
437
+		} else
444 438
 		{
445 439
 			$checked='';
446 440
 			$image='wrong.gif';
Please login to merge, or discard this patch.
main/permissions/user_permissions.inc.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -140,9 +140,11 @@  discard block
 block discarded – undo
140 140
 echo "\t</tr>\n";
141 141
 
142 142
 // the main area with the checkboxes or images
143
-foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
143
+foreach ($tool_rights as $tool=>$rights) {
144
+    // $tool_rights contains all the possible tools and their rights
144 145
 {
145 146
 	echo "\t<tr>\n";
147
+}
146 148
 	echo "\t\t<td>\n";
147 149
 	if (strstr($tool,'BLOG'))
148 150
 	{
@@ -152,8 +154,7 @@  discard block
 block discarded – undo
152 154
 		$blog_id = substr($tool,$tmp,strlen($tool));
153 155
 		// Get title
154 156
 		echo get_lang('Blog').": ".Blog::get_blog_title($blog_id);
155
-	}
156
-	else
157
+	} else
157 158
 	{
158 159
 		echo get_lang($tool);
159 160
 	}
Please login to merge, or discard this patch.
main/permissions/roles.php 1 patch
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
 		$result=Database::query($sql);
27 27
 		$role_id=Database::insert_id();
28 28
 		$result_message=store_permissions('role', $role_id);
29
-	}
30
-	else
29
+	} else
31 30
 	{
32 31
 		$result_message=get_lang('ErrorPleaseGiveRoleName');
33 32
 	}
@@ -122,9 +121,11 @@  discard block
 block discarded – undo
122 121
 	echo "\t</tr>\n";
123 122
 
124 123
 	// the main area with the checkboxes or images
125
-	foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
124
+	foreach ($tool_rights as $tool=>$rights) {
125
+	    // $tool_rights contains all the possible tools and their rights
126 126
 	{
127 127
 		echo "\t<tr>\n";
128
+	}
128 129
 		echo "\t\t<td>\n";
129 130
 		echo get_lang($tool);
130 131
 		echo "\t\t</td>\n";
@@ -216,9 +217,11 @@  discard block
 block discarded – undo
216 217
 	echo "\t</tr>\n";
217 218
 
218 219
 	// the main area with the checkboxes or images
219
-	foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
220
+	foreach ($tool_rights as $tool=>$rights) {
221
+	    // $tool_rights contains all the possible tools and their rights
220 222
 	{
221 223
 		echo "\t<tr>\n";
224
+	}
222 225
 		echo "\t\t<td>\n";
223 226
 		echo get_lang($tool);
224 227
 		echo "\t\t</td>\n";
@@ -237,8 +240,7 @@  discard block
 block discarded – undo
237 240
 					if ($_GET['scope']=='platform')
238 241
 					{
239 242
 						$roles_editable=false;
240
-					}
241
-					else
243
+					} else
242 244
 					{
243 245
 						$roles_editable=true;
244 246
 					}
Please login to merge, or discard this patch.
main/webservices/registration.soap.php 1 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.
main/webservices/access_url.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,19 +58,22 @@  discard block
 block discarded – undo
58 58
         list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
59 59
         $ip = trim($ip1);
60 60
     }
61
-    if ($debug)
62
-        error_log("ip: $ip");
61
+    if ($debug) {
62
+            error_log("ip: $ip");
63
+    }
63 64
     // Check if a file that limits access from webservices exists and contains
64 65
     // the restraining check
65 66
     if (is_file('webservice-auth-ip.conf.php')) {
66 67
         include 'webservice-auth-ip.conf.php';
67
-        if ($debug)
68
-            error_log("webservice-auth-ip.conf.php file included");
68
+        if ($debug) {
69
+                    error_log("webservice-auth-ip.conf.php file included");
70
+        }
69 71
         if (!empty($ws_auth_ip)) {
70 72
             $check_ip = true;
71 73
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
72
-            if ($debug)
73
-                error_log("ip_matches: $ip_matches");
74
+            if ($debug) {
75
+                            error_log("ip_matches: $ip_matches");
76
+            }
74 77
         }
75 78
     }
76 79
 
@@ -87,8 +90,9 @@  discard block
 block discarded – undo
87 90
 
88 91
     $result = api_is_valid_secret_key($secret_key, $security_key);
89 92
     //error_log($secret_key.'-'.$security_key);
90
-    if ($debug)
91
-        error_log('WSHelperVerifyKey result: '.intval($result));
93
+    if ($debug) {
94
+            error_log('WSHelperVerifyKey result: '.intval($result));
95
+    }
92 96
     return $result;
93 97
 }
94 98
 
Please login to merge, or discard this patch.
main/webservices/lp.php 1 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.