@@ -48,19 +48,22 @@ discard block |
||
48 | 48 | list($ip1) = 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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | return 'manifest.xml file not found'; |
201 | 213 | } |
202 | 214 | |
@@ -214,10 +226,14 @@ discard block |
||
214 | 226 | $oScorm->set_maker($maker, $courseId); |
215 | 227 | //$oScorm->set_jslib('scorm_api.php'); |
216 | 228 | |
217 | - if ($debug) error_log('scorm was added'); |
|
229 | + if ($debug) { |
|
230 | + error_log('scorm was added'); |
|
231 | + } |
|
218 | 232 | return 1; |
219 | 233 | } else { |
220 | - if ($debug) error_log('manifest data empty'); |
|
234 | + if ($debug) { |
|
235 | + error_log('manifest data empty'); |
|
236 | + } |
|
221 | 237 | return 'manifest data empty'; |
222 | 238 | } |
223 | 239 | } |
@@ -310,7 +326,9 @@ discard block |
||
310 | 326 | ); |
311 | 327 | |
312 | 328 | if (empty($courseInfo)) { |
313 | - if ($debug) error_log("Course not found: $courseIdName : $courseIdValue"); |
|
329 | + if ($debug) { |
|
330 | + error_log("Course not found: $courseIdName : $courseIdValue"); |
|
331 | + } |
|
314 | 332 | return 'Course not found'; |
315 | 333 | } |
316 | 334 | |
@@ -325,7 +343,9 @@ discard block |
||
325 | 343 | |
326 | 344 | if (empty($sessionId)) { |
327 | 345 | |
328 | - if ($debug) error_log('Session not found'); |
|
346 | + if ($debug) { |
|
347 | + error_log('Session not found'); |
|
348 | + } |
|
329 | 349 | return 'Session not found'; |
330 | 350 | } |
331 | 351 | } |
@@ -406,7 +426,9 @@ discard block |
||
406 | 426 | ); |
407 | 427 | |
408 | 428 | if (empty($courseInfo)) { |
409 | - if ($debug) error_log("Course not found: $courseIdName : $courseIdValue"); |
|
429 | + if ($debug) { |
|
430 | + error_log("Course not found: $courseIdName : $courseIdValue"); |
|
431 | + } |
|
410 | 432 | return 'Course not found'; |
411 | 433 | } |
412 | 434 | $courseId = $courseInfo['real_id']; |
@@ -431,7 +453,9 @@ discard block |
||
431 | 453 | |
432 | 454 | $lp = new learnpath($courseCode, $lpId, null); |
433 | 455 | if ($lp) { |
434 | - if ($debug) error_log("LP deleted $lpId"); |
|
456 | + if ($debug) { |
|
457 | + error_log("LP deleted $lpId"); |
|
458 | + } |
|
435 | 459 | |
436 | 460 | $course_dir = $courseInfo['directory'] . '/document'; |
437 | 461 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
@@ -447,7 +471,9 @@ discard block |
||
447 | 471 | if ($item) { |
448 | 472 | $documentId = $item->get_path(); |
449 | 473 | |
450 | - if ($debug) error_log("lp item id found #$itemId"); |
|
474 | + if ($debug) { |
|
475 | + error_log("lp item id found #$itemId"); |
|
476 | + } |
|
451 | 477 | |
452 | 478 | $documentInfo = DocumentManager::get_document_data_by_id( |
453 | 479 | $documentId, |
@@ -473,7 +499,9 @@ discard block |
||
473 | 499 | } |
474 | 500 | } |
475 | 501 | } else { |
476 | - if ($debug) error_log("Document not found #$itemId"); |
|
502 | + if ($debug) { |
|
503 | + error_log("Document not found #$itemId"); |
|
504 | + } |
|
477 | 505 | } |
478 | 506 | } |
479 | 507 | } |
@@ -63,14 +63,16 @@ discard block |
||
63 | 63 | list($ip1) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); |
64 | 64 | $ip = trim($ip1); |
65 | 65 | } |
66 | - if ($debug) |
|
67 | - error_log("ip: $ip"); |
|
66 | + if ($debug) { |
|
67 | + error_log("ip: $ip"); |
|
68 | + } |
|
68 | 69 | // Check if a file that limits access from webservices exists and contains |
69 | 70 | // the restraining check |
70 | 71 | if (is_file('webservice-auth-ip.conf.php')) { |
71 | 72 | include 'webservice-auth-ip.conf.php'; |
72 | - if ($debug) |
|
73 | - error_log("webservice-auth-ip.conf.php file included"); |
|
73 | + if ($debug) { |
|
74 | + error_log("webservice-auth-ip.conf.php file included"); |
|
75 | + } |
|
74 | 76 | if (!empty($ws_auth_ip)) { |
75 | 77 | $check_ip = true; |
76 | 78 | $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip); |
@@ -554,7 +556,9 @@ discard block |
||
554 | 556 | |
555 | 557 | // First check wether the login already exists |
556 | 558 | if (!UserManager::is_username_available($loginName)) { |
557 | - if ($debug) error_log("Username $loginName is not available"); |
|
559 | + if ($debug) { |
|
560 | + error_log("Username $loginName is not available"); |
|
561 | + } |
|
558 | 562 | return 0; |
559 | 563 | } |
560 | 564 | |
@@ -1045,9 +1049,15 @@ discard block |
||
1045 | 1049 | ); |
1046 | 1050 | } |
1047 | 1051 | |
1048 | - if ($debug) error_log('$userId found: '. $userId); |
|
1049 | - if ($debug) error_log('$courseId found: '. $courseId); |
|
1050 | - if ($debug) error_log('$sessionId found: '. $sessionId); |
|
1052 | + if ($debug) { |
|
1053 | + error_log('$userId found: '. $userId); |
|
1054 | + } |
|
1055 | + if ($debug) { |
|
1056 | + error_log('$courseId found: '. $courseId); |
|
1057 | + } |
|
1058 | + if ($debug) { |
|
1059 | + error_log('$sessionId found: '. $sessionId); |
|
1060 | + } |
|
1051 | 1061 | |
1052 | 1062 | return [ |
1053 | 1063 | 'user_id' => $userId, |
@@ -1077,13 +1087,17 @@ discard block |
||
1077 | 1087 | { |
1078 | 1088 | global $debug; |
1079 | 1089 | |
1080 | - if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); |
|
1090 | + if ($debug) { |
|
1091 | + error_log('WSSubscribeTeacherToSessionCourse'); |
|
1092 | + } |
|
1081 | 1093 | |
1082 | 1094 | if (!WSHelperVerifyKey($params)) { |
1083 | 1095 | return returnError(WS_ERROR_SECRET_KEY); |
1084 | 1096 | } |
1085 | 1097 | |
1086 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
1098 | + if ($debug) { |
|
1099 | + error_log('Params '. print_r($params, 1)); |
|
1100 | + } |
|
1087 | 1101 | |
1088 | 1102 | $params = parseCourseSessionUserParams($params); |
1089 | 1103 | |
@@ -1096,13 +1110,17 @@ discard block |
||
1096 | 1110 | $result = 0; |
1097 | 1111 | |
1098 | 1112 | if (!empty($coaches)) { |
1099 | - if ($debug) error_log('Coaches: '. print_r($coaches, 1)); |
|
1113 | + if ($debug) { |
|
1114 | + error_log('Coaches: '. print_r($coaches, 1)); |
|
1115 | + } |
|
1100 | 1116 | if (in_array($userId, $coaches)) { |
1101 | 1117 | $result = 1; |
1102 | 1118 | } |
1103 | 1119 | } |
1104 | 1120 | |
1105 | - if ($debug) error_log('Result: '. $result); |
|
1121 | + if ($debug) { |
|
1122 | + error_log('Result: '. $result); |
|
1123 | + } |
|
1106 | 1124 | |
1107 | 1125 | return $result; |
1108 | 1126 | } |
@@ -1128,13 +1146,17 @@ discard block |
||
1128 | 1146 | { |
1129 | 1147 | global $debug; |
1130 | 1148 | |
1131 | - if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); |
|
1149 | + if ($debug) { |
|
1150 | + error_log('WSSubscribeTeacherToSessionCourse'); |
|
1151 | + } |
|
1132 | 1152 | |
1133 | 1153 | if (!WSHelperVerifyKey($params)) { |
1134 | 1154 | return returnError(WS_ERROR_SECRET_KEY); |
1135 | 1155 | } |
1136 | 1156 | |
1137 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
1157 | + if ($debug) { |
|
1158 | + error_log('Params '. print_r($params, 1)); |
|
1159 | + } |
|
1138 | 1160 | |
1139 | 1161 | $params = parseCourseSessionUserParams($params); |
1140 | 1162 | |
@@ -1148,7 +1170,9 @@ discard block |
||
1148 | 1170 | $result = 0; |
1149 | 1171 | |
1150 | 1172 | if (!empty($coaches)) { |
1151 | - if ($debug) error_log('Coaches: ' . print_r($coaches, 1)); |
|
1173 | + if ($debug) { |
|
1174 | + error_log('Coaches: ' . print_r($coaches, 1)); |
|
1175 | + } |
|
1152 | 1176 | if (!in_array($userId, $coaches)) { |
1153 | 1177 | $result = 1; |
1154 | 1178 | } |
@@ -1156,7 +1180,9 @@ discard block |
||
1156 | 1180 | $result = 1; |
1157 | 1181 | } |
1158 | 1182 | |
1159 | - if ($debug) error_log('Final Result: '. $result); |
|
1183 | + if ($debug) { |
|
1184 | + error_log('Final Result: '. $result); |
|
1185 | + } |
|
1160 | 1186 | |
1161 | 1187 | return $result; |
1162 | 1188 | } |
@@ -1208,8 +1234,12 @@ discard block |
||
1208 | 1234 | { |
1209 | 1235 | global $_user, $_configuration, $debug; |
1210 | 1236 | $debug = 1; |
1211 | - if ($debug) error_log('WSCreateUserPasswordCrypted'); |
|
1212 | - if ($debug) error_log(print_r($params,1)); |
|
1237 | + if ($debug) { |
|
1238 | + error_log('WSCreateUserPasswordCrypted'); |
|
1239 | + } |
|
1240 | + if ($debug) { |
|
1241 | + error_log(print_r($params,1)); |
|
1242 | + } |
|
1213 | 1243 | |
1214 | 1244 | if (!WSHelperVerifyKey($params)) { |
1215 | 1245 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -1241,22 +1271,30 @@ discard block |
||
1241 | 1271 | if ($_configuration['password_encryption'] === $encrypt_method ) { |
1242 | 1272 | if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) { |
1243 | 1273 | $msg = "Encryption $encrypt_method is invalid"; |
1244 | - if ($debug) error_log($msg); |
|
1274 | + if ($debug) { |
|
1275 | + error_log($msg); |
|
1276 | + } |
|
1245 | 1277 | return $msg; |
1246 | 1278 | |
1247 | 1279 | } else if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) { |
1248 | 1280 | $msg = "Encryption $encrypt_method is invalid"; |
1249 | - if ($debug) error_log($msg); |
|
1281 | + if ($debug) { |
|
1282 | + error_log($msg); |
|
1283 | + } |
|
1250 | 1284 | return $msg; |
1251 | 1285 | } |
1252 | 1286 | } else { |
1253 | 1287 | $msg = "This encryption $encrypt_method is not configured"; |
1254 | - if ($debug) error_log($msg); |
|
1288 | + if ($debug) { |
|
1289 | + error_log($msg); |
|
1290 | + } |
|
1255 | 1291 | return $msg; |
1256 | 1292 | } |
1257 | 1293 | } else { |
1258 | 1294 | $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured'; |
1259 | - if ($debug) error_log($msg); |
|
1295 | + if ($debug) { |
|
1296 | + error_log($msg); |
|
1297 | + } |
|
1260 | 1298 | return $msg; |
1261 | 1299 | } |
1262 | 1300 | |
@@ -1276,10 +1314,14 @@ discard block |
||
1276 | 1314 | $original_user_id_name |
1277 | 1315 | ); |
1278 | 1316 | |
1279 | - if ($debug) error_log('Ready to create user'); |
|
1317 | + if ($debug) { |
|
1318 | + error_log('Ready to create user'); |
|
1319 | + } |
|
1280 | 1320 | |
1281 | 1321 | if ($user_id > 0) { |
1282 | - if ($debug) error_log('User found with id: '.$user_id); |
|
1322 | + if ($debug) { |
|
1323 | + error_log('User found with id: '.$user_id); |
|
1324 | + } |
|
1283 | 1325 | |
1284 | 1326 | // Check whether user is not active |
1285 | 1327 | //@todo why this condition exists?? |
@@ -1290,7 +1332,9 @@ discard block |
||
1290 | 1332 | $count_check_user = Database::num_rows($resu); |
1291 | 1333 | if ($count_check_user > 0) { |
1292 | 1334 | |
1293 | - if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1'); |
|
1335 | + if ($debug) { |
|
1336 | + error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1'); |
|
1337 | + } |
|
1294 | 1338 | |
1295 | 1339 | $sql = "UPDATE $table_user SET |
1296 | 1340 | lastname='".Database::escape_string($lastName)."', |
@@ -1311,7 +1355,9 @@ discard block |
||
1311 | 1355 | hr_dept_id=".intval($hr_dept_id)." |
1312 | 1356 | WHERE user_id='".$r_check_user[0]."'"; |
1313 | 1357 | |
1314 | - if ($debug) error_log($sql); |
|
1358 | + if ($debug) { |
|
1359 | + error_log($sql); |
|
1360 | + } |
|
1315 | 1361 | Database::query($sql); |
1316 | 1362 | |
1317 | 1363 | if (is_array($extra_list) && count($extra_list) > 0) { |
@@ -1328,11 +1374,15 @@ discard block |
||
1328 | 1374 | } |
1329 | 1375 | return $r_check_user[0]; |
1330 | 1376 | } else { |
1331 | - if ($debug) error_log('User exists but is active. Cant be updated'); |
|
1377 | + if ($debug) { |
|
1378 | + error_log('User exists but is active. Cant be updated'); |
|
1379 | + } |
|
1332 | 1380 | return 0; |
1333 | 1381 | } |
1334 | 1382 | } else { |
1335 | - if ($debug) error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name"); |
|
1383 | + if ($debug) { |
|
1384 | + error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name"); |
|
1385 | + } |
|
1336 | 1386 | } |
1337 | 1387 | |
1338 | 1388 | // Default language. |
@@ -1348,12 +1398,16 @@ discard block |
||
1348 | 1398 | |
1349 | 1399 | // First check wether the login already exists |
1350 | 1400 | if (!UserManager::is_username_available($loginName)) { |
1351 | - if ($debug) error_log("Username $loginName is not available"); |
|
1401 | + if ($debug) { |
|
1402 | + error_log("Username $loginName is not available"); |
|
1403 | + } |
|
1352 | 1404 | return 0; |
1353 | 1405 | } |
1354 | 1406 | |
1355 | 1407 | $queryExpirationDate = ''; |
1356 | - if (!empty($params['expiration_date'])) $queryExpirationDate = "expiration_date = '".Database::escape_string($expiration_date)."', "; |
|
1408 | + if (!empty($params['expiration_date'])) { |
|
1409 | + $queryExpirationDate = "expiration_date = '".Database::escape_string($expiration_date)."', "; |
|
1410 | + } |
|
1357 | 1411 | |
1358 | 1412 | $sql = "INSERT INTO $table_user SET |
1359 | 1413 | lastname = '".Database::escape_string(trim($lastName))."', |
@@ -1373,7 +1427,9 @@ discard block |
||
1373 | 1427 | ".$queryExpirationDate." |
1374 | 1428 | hr_dept_id = '".Database::escape_string($hr_dept_id)."', |
1375 | 1429 | active = '".Database::escape_string($active)."'"; |
1376 | - if ($debug) error_log($sql); |
|
1430 | + if ($debug) { |
|
1431 | + error_log($sql); |
|
1432 | + } |
|
1377 | 1433 | |
1378 | 1434 | Database::query($sql); |
1379 | 1435 | $return = Database::insert_id(); |
@@ -1385,7 +1441,9 @@ discard block |
||
1385 | 1441 | |
1386 | 1442 | $url_id = api_get_current_access_url_id(); |
1387 | 1443 | UrlManager::add_user_to_url($return, $url_id); |
1388 | - if ($debug) error_log("Adding user_id = $return to URL id $url_id "); |
|
1444 | + if ($debug) { |
|
1445 | + error_log("Adding user_id = $return to URL id $url_id "); |
|
1446 | + } |
|
1389 | 1447 | |
1390 | 1448 | // Create extra field for the original_user_id_name |
1391 | 1449 | UserManager::create_extra_field( |
@@ -1422,7 +1480,9 @@ discard block |
||
1422 | 1480 | } |
1423 | 1481 | } |
1424 | 1482 | } else { |
1425 | - if ($debug) error_log('Error while inserting a user'); |
|
1483 | + if ($debug) { |
|
1484 | + error_log('Error while inserting a user'); |
|
1485 | + } |
|
1426 | 1486 | |
1427 | 1487 | return 0; |
1428 | 1488 | } |
@@ -4504,7 +4564,9 @@ discard block |
||
4504 | 4564 | if (!WSHelperVerifyKey($params)) { |
4505 | 4565 | return returnError(WS_ERROR_SECRET_KEY); |
4506 | 4566 | } |
4507 | - if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1)); |
|
4567 | + if ($debug) { |
|
4568 | + error_log('WSSubscribeUserToCourse params: '.print_r($params,1)); |
|
4569 | + } |
|
4508 | 4570 | |
4509 | 4571 | $results = array(); |
4510 | 4572 | $userscourses = $params['userscourses']; |
@@ -4523,7 +4585,9 @@ discard block |
||
4523 | 4585 | $original_user_id['original_user_id_value'], |
4524 | 4586 | $original_user_id['original_user_id_name'] |
4525 | 4587 | ); |
4526 | - if ($debug) error_log('WSSubscribeUserToCourse user_id: '.$user_id); |
|
4588 | + if ($debug) { |
|
4589 | + error_log('WSSubscribeUserToCourse user_id: '.$user_id); |
|
4590 | + } |
|
4527 | 4591 | |
4528 | 4592 | if ($user_id == 0) { |
4529 | 4593 | // If user was not found, there was a problem |
@@ -4541,13 +4605,19 @@ discard block |
||
4541 | 4605 | // Course was not found |
4542 | 4606 | $resultValue = 0; |
4543 | 4607 | } else { |
4544 | - if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode); |
|
4608 | + if ($debug) { |
|
4609 | + error_log('WSSubscribeUserToCourse courseCode: '.$courseCode); |
|
4610 | + } |
|
4545 | 4611 | $result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false); |
4546 | 4612 | if ($result) { |
4547 | 4613 | $resultValue = 1; |
4548 | - if ($debug) error_log('WSSubscribeUserToCourse subscribed'); |
|
4614 | + if ($debug) { |
|
4615 | + error_log('WSSubscribeUserToCourse subscribed'); |
|
4616 | + } |
|
4549 | 4617 | } else { |
4550 | - if ($debug) error_log('WSSubscribeUserToCourse NOT subscribed: '); |
|
4618 | + if ($debug) { |
|
4619 | + error_log('WSSubscribeUserToCourse NOT subscribed: '); |
|
4620 | + } |
|
4551 | 4621 | } |
4552 | 4622 | } |
4553 | 4623 | } |
@@ -4606,8 +4676,12 @@ discard block |
||
4606 | 4676 | function WSSubscribeUserToCourseSimple($params) { |
4607 | 4677 | global $debug; |
4608 | 4678 | |
4609 | - if ($debug) error_log('WSSubscribeUserToCourseSimple'); |
|
4610 | - if ($debug) error_log('Params '. print_r($params, 1)); |
|
4679 | + if ($debug) { |
|
4680 | + error_log('WSSubscribeUserToCourseSimple'); |
|
4681 | + } |
|
4682 | + if ($debug) { |
|
4683 | + error_log('Params '. print_r($params, 1)); |
|
4684 | + } |
|
4611 | 4685 | if (!WSHelperVerifyKey($params)) { |
4612 | 4686 | return returnError(WS_ERROR_SECRET_KEY); |
4613 | 4687 | } |
@@ -4625,7 +4699,9 @@ discard block |
||
4625 | 4699 | if (empty($user_data)) { |
4626 | 4700 | // If user was not found, there was a problem |
4627 | 4701 | $result = "User $user_id does not exist"; |
4628 | - if ($debug) error_log($result); |
|
4702 | + if ($debug) { |
|
4703 | + error_log($result); |
|
4704 | + } |
|
4629 | 4705 | return $result; |
4630 | 4706 | } |
4631 | 4707 | if (!empty($course_code)) { |
@@ -4633,14 +4709,22 @@ discard block |
||
4633 | 4709 | if (empty($course_data)) { |
4634 | 4710 | // Course was not found |
4635 | 4711 | $result = "Course $course_code does not exist in the platform "; |
4636 | - if ($debug) error_log($result); |
|
4712 | + if ($debug) { |
|
4713 | + error_log($result); |
|
4714 | + } |
|
4637 | 4715 | } else { |
4638 | - if ($debug) error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']); |
|
4716 | + if ($debug) { |
|
4717 | + error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']); |
|
4718 | + } |
|
4639 | 4719 | if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status)) { |
4640 | 4720 | $result = 'User was not registered possible reasons: User already registered to the course, Course visibility doesnt allow user subscriptions '; |
4641 | - if ($debug) error_log($result); |
|
4721 | + if ($debug) { |
|
4722 | + error_log($result); |
|
4723 | + } |
|
4642 | 4724 | } else { |
4643 | - if ($debug) error_log('User registered to the course: '.$course_data['code']); |
|
4725 | + if ($debug) { |
|
4726 | + error_log('User registered to the course: '.$course_data['code']); |
|
4727 | + } |
|
4644 | 4728 | $result = 1; |
4645 | 4729 | } |
4646 | 4730 | } |
@@ -4693,8 +4777,12 @@ discard block |
||
4693 | 4777 | function WSGetUser($params) |
4694 | 4778 | { |
4695 | 4779 | global $debug; |
4696 | - if ($debug) error_log('WSGetUser'); |
|
4697 | - if ($debug) error_log('$params: '.print_r($params, 1)); |
|
4780 | + if ($debug) { |
|
4781 | + error_log('WSGetUser'); |
|
4782 | + } |
|
4783 | + if ($debug) { |
|
4784 | + error_log('$params: '.print_r($params, 1)); |
|
4785 | + } |
|
4698 | 4786 | |
4699 | 4787 | if (!WSHelperVerifyKey($params)) { |
4700 | 4788 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -4748,8 +4836,12 @@ discard block |
||
4748 | 4836 | function WSGetUserFromUsername($params) |
4749 | 4837 | { |
4750 | 4838 | global $debug; |
4751 | - if ($debug) error_log('WSGetUserFromUsername'); |
|
4752 | - if ($debug) error_log('$params: '.print_r($params, 1)); |
|
4839 | + if ($debug) { |
|
4840 | + error_log('WSGetUserFromUsername'); |
|
4841 | + } |
|
4842 | + if ($debug) { |
|
4843 | + error_log('$params: '.print_r($params, 1)); |
|
4844 | + } |
|
4753 | 4845 | |
4754 | 4846 | if (!WSHelperVerifyKey($params)) { |
4755 | 4847 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -5216,7 +5308,9 @@ discard block |
||
5216 | 5308 | SessionManager::subscribe_users_to_session($sessionId, array($user_id), SESSION_VISIBLE_READ_ONLY, false); |
5217 | 5309 | $results[] = 1; |
5218 | 5310 | |
5219 | - if ($debug) error_log("subscribe user:$user_id to session $sessionId"); |
|
5311 | + if ($debug) { |
|
5312 | + error_log("subscribe user:$user_id to session $sessionId"); |
|
5313 | + } |
|
5220 | 5314 | } |
5221 | 5315 | } |
5222 | 5316 | } // end principal foreach |
@@ -5300,7 +5394,9 @@ discard block |
||
5300 | 5394 | SESSION_VISIBLE_READ_ONLY, |
5301 | 5395 | false |
5302 | 5396 | ); |
5303 | - if ($debug) error_log('User registered to the course: '.$session_id); |
|
5397 | + if ($debug) { |
|
5398 | + error_log('User registered to the course: '.$session_id); |
|
5399 | + } |
|
5304 | 5400 | $result = 1; |
5305 | 5401 | } |
5306 | 5402 | } |
@@ -5448,7 +5544,9 @@ discard block |
||
5448 | 5544 | |
5449 | 5545 | $results[] = 1; |
5450 | 5546 | |
5451 | - if ($debug) error_log("Unsubscribe user:$user_id to session:$id_session"); |
|
5547 | + if ($debug) { |
|
5548 | + error_log("Unsubscribe user:$user_id to session:$id_session"); |
|
5549 | + } |
|
5452 | 5550 | } |
5453 | 5551 | } |
5454 | 5552 | } // end principal foreach |
@@ -5595,7 +5693,9 @@ discard block |
||
5595 | 5693 | return returnError(WS_ERROR_SECRET_KEY); |
5596 | 5694 | } |
5597 | 5695 | |
5598 | - if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1)); |
|
5696 | + if ($debug) { |
|
5697 | + error_log('WSSuscribeCoursesToSession: '.print_r($params, 1)); |
|
5698 | + } |
|
5599 | 5699 | |
5600 | 5700 | $coursessessions_params = $params['coursessessions']; |
5601 | 5701 | $results = array(); |
@@ -5641,7 +5741,9 @@ discard block |
||
5641 | 5741 | array($courseInfo['real_id']), |
5642 | 5742 | false |
5643 | 5743 | ); |
5644 | - if ($debug) error_log("add_courses_to_session: course:$courseCode to session:$sessionId"); |
|
5744 | + if ($debug) { |
|
5745 | + error_log("add_courses_to_session: course:$courseCode to session:$sessionId"); |
|
5746 | + } |
|
5645 | 5747 | |
5646 | 5748 | $results[] = 1; |
5647 | 5749 | } |
@@ -6914,7 +7016,9 @@ discard block |
||
6914 | 7016 | if (!WSHelperVerifyKey($params)) { |
6915 | 7017 | return returnError(WS_ERROR_SECRET_KEY); |
6916 | 7018 | } |
6917 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue params: '.print_r($params, 1)); |
|
7019 | + if ($debug) { |
|
7020 | + error_log('WSAddUserVisibilityToCourseCatalogue params: '.print_r($params, 1)); |
|
7021 | + } |
|
6918 | 7022 | |
6919 | 7023 | $results = array(); |
6920 | 7024 | $userscourses = $params['userscourses']; |
@@ -6930,7 +7034,9 @@ discard block |
||
6930 | 7034 | $original_user_id['original_user_id_value'], |
6931 | 7035 | $original_user_id['original_user_id_name'] |
6932 | 7036 | ); |
6933 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue userId: '.$userId); |
|
7037 | + if ($debug) { |
|
7038 | + error_log('WSAddUserVisibilityToCourseCatalogue userId: '.$userId); |
|
7039 | + } |
|
6934 | 7040 | |
6935 | 7041 | if ($userId == 0) { |
6936 | 7042 | // If user was not found, there was a problem |
@@ -6947,13 +7053,19 @@ discard block |
||
6947 | 7053 | // Course was not found |
6948 | 7054 | $resultValue = 0; |
6949 | 7055 | } else { |
6950 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue courseCode: '.$courseCode); |
|
7056 | + if ($debug) { |
|
7057 | + error_log('WSAddUserVisibilityToCourseCatalogue courseCode: '.$courseCode); |
|
7058 | + } |
|
6951 | 7059 | $result = CourseManager::addUserVisibilityToCourseInCatalogue($userId, $courseCode, $visible); |
6952 | 7060 | if ($result) { |
6953 | 7061 | $resultValue = 1; |
6954 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue registered'); |
|
7062 | + if ($debug) { |
|
7063 | + error_log('WSAddUserVisibilityToCourseCatalogue registered'); |
|
7064 | + } |
|
6955 | 7065 | } else { |
6956 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue NOT registered: '); |
|
7066 | + if ($debug) { |
|
7067 | + error_log('WSAddUserVisibilityToCourseCatalogue NOT registered: '); |
|
7068 | + } |
|
6957 | 7069 | } |
6958 | 7070 | } |
6959 | 7071 | } |
@@ -6986,7 +7098,9 @@ discard block |
||
6986 | 7098 | if (!WSHelperVerifyKey($params)) { |
6987 | 7099 | return returnError(WS_ERROR_SECRET_KEY); |
6988 | 7100 | } |
6989 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue params: '.print_r($params, 1)); |
|
7101 | + if ($debug) { |
|
7102 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue params: '.print_r($params, 1)); |
|
7103 | + } |
|
6990 | 7104 | |
6991 | 7105 | $results = array(); |
6992 | 7106 | $userscourses = $params['userscourses']; |
@@ -7002,7 +7116,9 @@ discard block |
||
7002 | 7116 | $original_user_id['original_user_id_value'], |
7003 | 7117 | $original_user_id['original_user_id_name'] |
7004 | 7118 | ); |
7005 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue user_id: '.$userId); |
|
7119 | + if ($debug) { |
|
7120 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue user_id: '.$userId); |
|
7121 | + } |
|
7006 | 7122 | |
7007 | 7123 | if ($userId == 0) { |
7008 | 7124 | // If user was not found, there was a problem |
@@ -7020,13 +7136,19 @@ discard block |
||
7020 | 7136 | // Course was not found |
7021 | 7137 | $resultValue = 0; |
7022 | 7138 | } else { |
7023 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue courseCode: '.$courseCode); |
|
7139 | + if ($debug) { |
|
7140 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue courseCode: '.$courseCode); |
|
7141 | + } |
|
7024 | 7142 | $result = CourseManager::removeUserVisibilityToCourseInCatalogue($userId, $courseCode, $visible); |
7025 | 7143 | if ($result) { |
7026 | 7144 | $resultValue = 1; |
7027 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue removed'); |
|
7145 | + if ($debug) { |
|
7146 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue removed'); |
|
7147 | + } |
|
7028 | 7148 | } else { |
7029 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue NOT removed: '); |
|
7149 | + if ($debug) { |
|
7150 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue NOT removed: '); |
|
7151 | + } |
|
7030 | 7152 | } |
7031 | 7153 | } |
7032 | 7154 | } |
@@ -3267,7 +3267,9 @@ discard block |
||
3267 | 3267 | ); |
3268 | 3268 | } |
3269 | 3269 | |
3270 | - if ($debug) error_log('Start answer loop '); |
|
3270 | + if ($debug) { |
|
3271 | + error_log('Start answer loop '); |
|
3272 | + } |
|
3271 | 3273 | |
3272 | 3274 | for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { |
3273 | 3275 | $answer = $objAnswerTmp->selectAnswer($answerId); |
@@ -3381,7 +3383,9 @@ discard block |
||
3381 | 3383 | } |
3382 | 3384 | $totalScore += $answerWeighting; |
3383 | 3385 | |
3384 | - if ($debug) error_log("studentChoice: $studentChoice"); |
|
3386 | + if ($debug) { |
|
3387 | + error_log("studentChoice: $studentChoice"); |
|
3388 | + } |
|
3385 | 3389 | break; |
3386 | 3390 | case GLOBAL_MULTIPLE_ANSWER: |
3387 | 3391 | if ($from_database) { |
@@ -3406,7 +3410,9 @@ discard block |
||
3406 | 3410 | $real_answers[$answerId] = (bool)$studentChoice; |
3407 | 3411 | } |
3408 | 3412 | $totalScore += $answerWeighting; |
3409 | - if ($debug) error_log("studentChoice: $studentChoice"); |
|
3413 | + if ($debug) { |
|
3414 | + error_log("studentChoice: $studentChoice"); |
|
3415 | + } |
|
3410 | 3416 | break; |
3411 | 3417 | case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: |
3412 | 3418 | if ($from_database) { |
@@ -4201,7 +4207,9 @@ discard block |
||
4201 | 4207 | } // end switch Answertype |
4202 | 4208 | |
4203 | 4209 | if ($show_result) { |
4204 | - if ($debug) error_log('Showing questions $from '.$from); |
|
4210 | + if ($debug) { |
|
4211 | + error_log('Showing questions $from '.$from); |
|
4212 | + } |
|
4205 | 4213 | if ($from == 'exercise_result') { |
4206 | 4214 | //display answers (if not matching type, or if the answer is correct) |
4207 | 4215 | if ( |
@@ -4499,7 +4507,9 @@ discard block |
||
4499 | 4507 | } |
4500 | 4508 | } |
4501 | 4509 | } else { |
4502 | - if ($debug) error_log('Showing questions $from '.$from); |
|
4510 | + if ($debug) { |
|
4511 | + error_log('Showing questions $from '.$from); |
|
4512 | + } |
|
4503 | 4513 | |
4504 | 4514 | switch ($answerType) { |
4505 | 4515 | case UNIQUE_ANSWER: |
@@ -4846,10 +4856,14 @@ discard block |
||
4846 | 4856 | } |
4847 | 4857 | } |
4848 | 4858 | } |
4849 | - if ($debug) error_log(' ------ '); |
|
4859 | + if ($debug) { |
|
4860 | + error_log(' ------ '); |
|
4861 | + } |
|
4850 | 4862 | } // end for that loops over all answers of the current question |
4851 | 4863 | |
4852 | - if ($debug) error_log('-- end answer loop --'); |
|
4864 | + if ($debug) { |
|
4865 | + error_log('-- end answer loop --'); |
|
4866 | + } |
|
4853 | 4867 | |
4854 | 4868 | $final_answer = true; |
4855 | 4869 | |
@@ -4922,7 +4936,9 @@ discard block |
||
4922 | 4936 | // some results that haven't been stored in the database yet |
4923 | 4937 | if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) { |
4924 | 4938 | |
4925 | - if ($debug) error_log('$from AND this is a hotspot kind of question '); |
|
4939 | + if ($debug) { |
|
4940 | + error_log('$from AND this is a hotspot kind of question '); |
|
4941 | + } |
|
4926 | 4942 | |
4927 | 4943 | $my_exe_id = 0; |
4928 | 4944 | $from_database = 0; |
@@ -5109,8 +5125,12 @@ discard block |
||
5109 | 5125 | // stored by exercise_results.php (using the session) |
5110 | 5126 | |
5111 | 5127 | if ($saved_results) { |
5112 | - if ($debug) error_log("Save question results $saved_results"); |
|
5113 | - if ($debug) error_log(print_r($choice ,1 )); |
|
5128 | + if ($debug) { |
|
5129 | + error_log("Save question results $saved_results"); |
|
5130 | + } |
|
5131 | + if ($debug) { |
|
5132 | + error_log(print_r($choice ,1 )); |
|
5133 | + } |
|
5114 | 5134 | |
5115 | 5135 | if (empty($choice)) { |
5116 | 5136 | $choice = 0; |
@@ -7,7 +7,9 @@ |
||
7 | 7 | * @package chamilo.exercise |
8 | 8 | */ |
9 | 9 | |
10 | -if ( count( get_included_files() ) == 1 ) die( '---' ); |
|
10 | +if ( count( get_included_files() ) == 1 ) { |
|
11 | + die( '---' ); |
|
12 | +} |
|
11 | 13 | |
12 | 14 | if (!function_exists('mime_content_type')) { |
13 | 15 |
@@ -48,8 +48,7 @@ |
||
48 | 48 | foreach($items as $item) { /** @var $item MenuItemModel */ |
49 | 49 | if($item->hasChildren()) { |
50 | 50 | $this->activateByRoute($route, $item->getChildren()); |
51 | - } |
|
52 | - else { |
|
51 | + } else { |
|
53 | 52 | if($item->getRoute() == $route) { |
54 | 53 | $item->setIsActive(true); |
55 | 54 | } |
@@ -535,8 +535,8 @@ discard block |
||
535 | 535 | // Mark folders to import which are not selected by the user to import, |
536 | 536 | // but in which a document was selected. |
537 | 537 | $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
538 | - if (!empty($resources) && is_array($resources)) |
|
539 | - foreach ($resources as $id => $obj) { |
|
538 | + if (!empty($resources) && is_array($resources)) { |
|
539 | + foreach ($resources as $id => $obj) { |
|
540 | 540 | if (isset($obj->file_type) && $obj->file_type == 'folder' && |
541 | 541 | !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && |
542 | 542 | is_array($documents) |
@@ -544,6 +544,7 @@ discard block |
||
544 | 544 | foreach ($documents as $id_to_check => $post_value) { |
545 | 545 | if (isset($resources[$id_to_check])) { |
546 | 546 | $obj_to_check = $resources[$id_to_check]; |
547 | + } |
|
547 | 548 | $shared_path_part = substr( |
548 | 549 | $obj_to_check->path, |
549 | 550 | 0, |