@@ -192,7 +192,8 @@ discard block |
||
| 192 | 192 | $viewReceivedCategory, |
| 193 | 193 | $viewSentCategory, |
| 194 | 194 | $view |
| 195 | -) { |
|
| 195 | +) |
|
| 196 | +{ |
|
| 196 | 197 | $form = new FormValidator( |
| 197 | 198 | 'form1', |
| 198 | 199 | 'post', |
@@ -621,7 +622,8 @@ discard block |
||
| 621 | 622 | || $allowStudentToStudent == 'true' |
| 622 | 623 | || $current_user['status'] != 5 // Always allow teachers. |
| 623 | 624 | || $current_user['is_tutor'] == 1 // Always allow tutors. |
| 624 | - ) && $current_user['user_id'] != $_user['user_id']) { // Don't include yourself. |
|
| 625 | + ) && $current_user['user_id'] != $_user['user_id']) { |
|
| 626 | +// Don't include yourself. |
|
| 625 | 627 | if ($current_user['user_id'] == $current_user_id) { |
| 626 | 628 | continue; |
| 627 | 629 | } |
@@ -792,10 +794,15 @@ discard block |
||
| 792 | 794 | "; |
| 793 | 795 | $result = Database::query($sql); |
| 794 | 796 | |
| 795 | - if (!($res = Database::fetch_array($result))) |
|
| 796 | - die(get_lang('GeneralError').' (code 901)'); |
|
| 797 | - if ($owner == 0) return $res['uploader_id']; |
|
| 798 | - if ($res['uploader_id'] == $owner) return true; |
|
| 797 | + if (!($res = Database::fetch_array($result))) { |
|
| 798 | + die(get_lang('GeneralError').' (code 901)'); |
|
| 799 | + } |
|
| 800 | + if ($owner == 0) { |
|
| 801 | + return $res['uploader_id']; |
|
| 802 | + } |
|
| 803 | + if ($res['uploader_id'] == $owner) { |
|
| 804 | + return true; |
|
| 805 | + } |
|
| 799 | 806 | die(get_lang('GeneralError').' (code '.$or_die.')'); |
| 800 | 807 | } |
| 801 | 808 | |
@@ -936,7 +943,8 @@ discard block |
||
| 936 | 943 | } |
| 937 | 944 | |
| 938 | 945 | // check if the file is actually uploaded |
| 939 | - if (!is_uploaded_file($dropbox_filetmpname)) { // check user fraud : no clean error msg. |
|
| 946 | + if (!is_uploaded_file($dropbox_filetmpname)) { |
|
| 947 | +// check user fraud : no clean error msg. |
|
| 940 | 948 | Display::addFlash(Display::return_message(get_lang('TheFileIsNotUploaded'), 'warning')); |
| 941 | 949 | |
| 942 | 950 | return false; |
@@ -992,7 +1000,8 @@ discard block |
||
| 992 | 1000 | break; |
| 993 | 1001 | } |
| 994 | 1002 | } |
| 995 | - } else { // rename file to login_filename_uniqueId format |
|
| 1003 | + } else { |
|
| 1004 | +// rename file to login_filename_uniqueId format |
|
| 996 | 1005 | $dropbox_filename = $_user['username']."_".$dropbox_filename."_".uniqid(''); |
| 997 | 1006 | } |
| 998 | 1007 | |
@@ -208,7 +208,8 @@ |
||
| 208 | 208 | $sessionId = 0, |
| 209 | 209 | $downloadCertificateLink = '', |
| 210 | 210 | $badgeLink = '' |
| 211 | -) { |
|
| 211 | +) |
|
| 212 | +{ |
|
| 212 | 213 | $documentInfo = DocumentManager::get_document_data_by_id( |
| 213 | 214 | $lpItemId, |
| 214 | 215 | $courseCode, |
@@ -262,7 +262,8 @@ |
||
| 262 | 262 | return null; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool. |
|
| 265 | + if (api_is_allowed_to_edit()) { |
|
| 266 | +// Let students make access only through "Surveys" tool. |
|
| 266 | 267 | $tbl_name = $this->get_survey_table(); |
| 267 | 268 | $session_id = api_get_session_id(); |
| 268 | 269 | if ($tbl_name != '') { |
@@ -4691,7 +4691,8 @@ discard block |
||
| 4691 | 4691 | if ($debug) { |
| 4692 | 4692 | if ($session_id) { |
| 4693 | 4693 | foreach ($enreg as $key => $value) { |
| 4694 | - if (substr($key, 0, 6) == 'extra_') { //an extra field |
|
| 4694 | + if (substr($key, 0, 6) == 'extra_') { |
|
| 4695 | +//an extra field |
|
| 4695 | 4696 | self::update_session_extra_field_value($session_id, substr($key, 6), $value); |
| 4696 | 4697 | } |
| 4697 | 4698 | } |
@@ -4738,7 +4739,8 @@ discard block |
||
| 4738 | 4739 | |
| 4739 | 4740 | if ($session_id) { |
| 4740 | 4741 | foreach ($enreg as $key => $value) { |
| 4741 | - if (substr($key, 0, 6) == 'extra_') { //an extra field |
|
| 4742 | + if (substr($key, 0, 6) == 'extra_') { |
|
| 4743 | +//an extra field |
|
| 4742 | 4744 | self::update_session_extra_field_value($session_id, substr($key, 6), $value); |
| 4743 | 4745 | } |
| 4744 | 4746 | } |
@@ -4836,7 +4838,8 @@ discard block |
||
| 4836 | 4838 | Database::update($tbl_session, $params, array('id = ?' => $session_id)); |
| 4837 | 4839 | |
| 4838 | 4840 | foreach ($enreg as $key => $value) { |
| 4839 | - if (substr($key, 0, 6) == 'extra_') { //an extra field |
|
| 4841 | + if (substr($key, 0, 6) == 'extra_') { |
|
| 4842 | +//an extra field |
|
| 4840 | 4843 | self::update_session_extra_field_value($session_id, substr($key, 6), $value); |
| 4841 | 4844 | } |
| 4842 | 4845 | } |
@@ -15,7 +15,9 @@ discard block |
||
| 15 | 15 | $use_anonymous = true; |
| 16 | 16 | |
| 17 | 17 | $debug = 0; |
| 18 | -if ($debug > 0) error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0); |
|
| 18 | +if ($debug > 0) { |
|
| 19 | + error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0); |
|
| 20 | +} |
|
| 19 | 21 | |
| 20 | 22 | // Language files that needs to be included. |
| 21 | 23 | if (isset($_GET['action'])) { |
@@ -211,10 +213,14 @@ discard block |
||
| 211 | 213 | // If refresh is set, we regenerate the oLP object from the database (kind of flush). |
| 212 | 214 | Session::erase('refresh'); |
| 213 | 215 | $myrefresh = 1; |
| 214 | - if ($debug > 0) error_log('New LP - Refresh asked', 0); |
|
| 215 | -} |
|
| 216 | + if ($debug > 0) { |
|
| 217 | + error_log('New LP - Refresh asked', 0); |
|
| 218 | + } |
|
| 219 | + } |
|
| 216 | 220 | |
| 217 | -if ($debug > 0) error_log('New LP - Passed refresh check', 0); |
|
| 221 | +if ($debug > 0) { |
|
| 222 | + error_log('New LP - Passed refresh check', 0); |
|
| 223 | +} |
|
| 218 | 224 | |
| 219 | 225 | if (!empty($_REQUEST['dialog_box'])) { |
| 220 | 226 | $dialog_box = stripslashes(urldecode($_REQUEST['dialog_box'])); |
@@ -224,17 +230,23 @@ discard block |
||
| 224 | 230 | $lp_found = false; |
| 225 | 231 | $lpObject = Session::read('lpobject'); |
| 226 | 232 | if (!empty($lpObject)) { |
| 227 | - if ($debug > 0) error_log('New LP - SESSION[lpobject] is defined', 0); |
|
| 233 | + if ($debug > 0) { |
|
| 234 | + error_log('New LP - SESSION[lpobject] is defined', 0); |
|
| 235 | + } |
|
| 228 | 236 | $oLP = unserialize($lpObject); |
| 229 | 237 | if (isset($oLP) && is_object($oLP)) { |
| 230 | - if ($debug > 0) error_log('New LP - oLP is object', 0); |
|
| 238 | + if ($debug > 0) { |
|
| 239 | + error_log('New LP - oLP is object', 0); |
|
| 240 | + } |
|
| 231 | 241 | if ($myrefresh == 1 || |
| 232 | 242 | empty($oLP->cc) || |
| 233 | 243 | $oLP->cc != api_get_course_id() || |
| 234 | 244 | $oLP->lp_view_session_id != $session_id || |
| 235 | 245 | $oLP->scorm_debug == '1' |
| 236 | 246 | ) { |
| 237 | - if ($debug > 0) error_log('New LP - Course has changed, discard lp object', 0); |
|
| 247 | + if ($debug > 0) { |
|
| 248 | + error_log('New LP - Course has changed, discard lp object', 0); |
|
| 249 | + } |
|
| 238 | 250 | if ($myrefresh == 1) { |
| 239 | 251 | $myrefresh_id = $oLP->get_id(); |
| 240 | 252 | } |
@@ -250,13 +262,19 @@ discard block |
||
| 250 | 262 | |
| 251 | 263 | $course_id = api_get_course_int_id(); |
| 252 | 264 | |
| 253 | -if ($debug > 0) error_log('New LP - Passed data remains check', 0); |
|
| 265 | +if ($debug > 0) { |
|
| 266 | + error_log('New LP - Passed data remains check', 0); |
|
| 267 | +} |
|
| 254 | 268 | |
| 255 | 269 | if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) { |
| 256 | - if ($debug > 0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0); |
|
| 270 | + if ($debug > 0) { |
|
| 271 | + error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0); |
|
| 272 | + } |
|
| 257 | 273 | // Regenerate a new lp object? Not always as some pages don't need the object (like upload?) |
| 258 | 274 | if (!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)) { |
| 259 | - if ($debug > 0) error_log('New LP - lp_id is defined', 0); |
|
| 275 | + if ($debug > 0) { |
|
| 276 | + error_log('New LP - lp_id is defined', 0); |
|
| 277 | + } |
|
| 260 | 278 | // Select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the |
| 261 | 279 | // right object. |
| 262 | 280 | if (!empty($_REQUEST['lp_id'])) { |
@@ -268,16 +286,22 @@ discard block |
||
| 268 | 286 | $lp_table = Database::get_course_table(TABLE_LP_MAIN); |
| 269 | 287 | if (is_numeric($lp_id)) { |
| 270 | 288 | $sel = "SELECT lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id"; |
| 271 | - if ($debug > 0) error_log('New LP - querying '.$sel, 0); |
|
| 289 | + if ($debug > 0) { |
|
| 290 | + error_log('New LP - querying '.$sel, 0); |
|
| 291 | + } |
|
| 272 | 292 | $res = Database::query($sel); |
| 273 | 293 | |
| 274 | 294 | if (Database::num_rows($res)) { |
| 275 | 295 | $row = Database::fetch_array($res); |
| 276 | 296 | $type = $row['lp_type']; |
| 277 | - if ($debug > 0) error_log('New LP - found row - type '.$type.' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 297 | + if ($debug > 0) { |
|
| 298 | + error_log('New LP - found row - type '.$type.' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 299 | + } |
|
| 278 | 300 | switch ($type) { |
| 279 | 301 | case 1: |
| 280 | - if ($debug > 0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 302 | + if ($debug > 0) { |
|
| 303 | + error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 304 | + } |
|
| 281 | 305 | |
| 282 | 306 | $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id()); |
| 283 | 307 | if ($oLP !== false) { |
@@ -287,7 +311,9 @@ discard block |
||
| 287 | 311 | } |
| 288 | 312 | break; |
| 289 | 313 | case 2: |
| 290 | - if ($debug > 0) error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 314 | + if ($debug > 0) { |
|
| 315 | + error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 316 | + } |
|
| 291 | 317 | $oLP = new scorm(api_get_course_id(), $lp_id, api_get_user_id()); |
| 292 | 318 | if ($oLP !== false) { |
| 293 | 319 | $lp_found = true; |
@@ -296,7 +322,9 @@ discard block |
||
| 296 | 322 | } |
| 297 | 323 | break; |
| 298 | 324 | case 3: |
| 299 | - if ($debug > 0) error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 325 | + if ($debug > 0) { |
|
| 326 | + error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 327 | + } |
|
| 300 | 328 | $oLP = new aicc(api_get_course_id(), $lp_id, api_get_user_id()); |
| 301 | 329 | if ($oLP !== false) { |
| 302 | 330 | $lp_found = true; |
@@ -305,7 +333,9 @@ discard block |
||
| 305 | 333 | } |
| 306 | 334 | break; |
| 307 | 335 | default: |
| 308 | - if ($debug > 0) error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 336 | + if ($debug > 0) { |
|
| 337 | + error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0); |
|
| 338 | + } |
|
| 309 | 339 | $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id()); |
| 310 | 340 | if ($oLP !== false) { |
| 311 | 341 | $lp_found = true; |
@@ -316,17 +346,23 @@ discard block |
||
| 316 | 346 | } |
| 317 | 347 | } |
| 318 | 348 | } else { |
| 319 | - if ($debug > 0) error_log('New LP - Request[lp_id] is not numeric', 0); |
|
| 349 | + if ($debug > 0) { |
|
| 350 | + error_log('New LP - Request[lp_id] is not numeric', 0); |
|
| 351 | + } |
|
| 320 | 352 | } |
| 321 | 353 | } else { |
| 322 | - if ($debug > 0) error_log('New LP - Request[lp_id] and refresh_id were empty', 0); |
|
| 354 | + if ($debug > 0) { |
|
| 355 | + error_log('New LP - Request[lp_id] and refresh_id were empty', 0); |
|
| 356 | + } |
|
| 323 | 357 | } |
| 324 | 358 | if ($lp_found) { |
| 325 | 359 | Session::write('oLP', $oLP); |
| 326 | 360 | } |
| 327 | 361 | } |
| 328 | 362 | |
| 329 | -if ($debug > 0) error_log('New LP - Passed oLP creation check', 0); |
|
| 363 | +if ($debug > 0) { |
|
| 364 | + error_log('New LP - Passed oLP creation check', 0); |
|
| 365 | +} |
|
| 330 | 366 | |
| 331 | 367 | $is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false); |
| 332 | 368 | |
@@ -616,15 +652,15 @@ discard block |
||
| 616 | 652 | } |
| 617 | 653 | break; |
| 618 | 654 | case 'auto_launch': |
| 619 | - if (api_get_course_setting('enable_lp_auto_launch') == 1) { //Redirect to a specific LP |
|
| 655 | + if (api_get_course_setting('enable_lp_auto_launch') == 1) { |
|
| 656 | +//Redirect to a specific LP |
|
| 620 | 657 | if (!$is_allowed_to_edit) { |
| 621 | 658 | api_not_allowed(true); |
| 622 | 659 | } |
| 623 | 660 | if (!$lp_found) { |
| 624 | 661 | error_log('New LP - No learnpath given for set_autolaunch', 0); |
| 625 | 662 | require 'lp_list.php'; |
| 626 | - } |
|
| 627 | - else { |
|
| 663 | + } else { |
|
| 628 | 664 | $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']); |
| 629 | 665 | require 'lp_list.php'; |
| 630 | 666 | exit; |
@@ -1140,16 +1176,24 @@ discard block |
||
| 1140 | 1176 | } |
| 1141 | 1177 | break; |
| 1142 | 1178 | case 'content': |
| 1143 | - if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0); |
|
| 1179 | + if ($debug > 0) { |
|
| 1180 | + error_log('New LP - Item id is '.intval($_GET['item_id']), 0); |
|
| 1181 | + } |
|
| 1144 | 1182 | if (!$lp_found) { |
| 1145 | 1183 | error_log('New LP - No learnpath given for content', 0); |
| 1146 | 1184 | require 'lp_list.php'; |
| 1147 | 1185 | } else { |
| 1148 | - if ($debug > 0) error_log('New LP - save_last()', 0); |
|
| 1186 | + if ($debug > 0) { |
|
| 1187 | + error_log('New LP - save_last()', 0); |
|
| 1188 | + } |
|
| 1149 | 1189 | $_SESSION['oLP']->save_last(); |
| 1150 | - if ($debug > 0) error_log('New LP - set_current_item()', 0); |
|
| 1190 | + if ($debug > 0) { |
|
| 1191 | + error_log('New LP - set_current_item()', 0); |
|
| 1192 | + } |
|
| 1151 | 1193 | $_SESSION['oLP']->set_current_item($_GET['item_id']); |
| 1152 | - if ($debug > 0) error_log('New LP - start_current_item()', 0); |
|
| 1194 | + if ($debug > 0) { |
|
| 1195 | + error_log('New LP - start_current_item()', 0); |
|
| 1196 | + } |
|
| 1153 | 1197 | $_SESSION['oLP']->start_current_item(); |
| 1154 | 1198 | require 'lp_content.php'; |
| 1155 | 1199 | } |
@@ -1264,8 +1308,7 @@ discard block |
||
| 1264 | 1308 | require 'lp_message.php'; |
| 1265 | 1309 | break; |
| 1266 | 1310 | case 'return_to_course_homepage': |
| 1267 | - if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } |
|
| 1268 | - else { |
|
| 1311 | + if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else { |
|
| 1269 | 1312 | $_SESSION['oLP']->save_current(); |
| 1270 | 1313 | $_SESSION['oLP']->save_last(); |
| 1271 | 1314 | $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id(); |
@@ -1453,8 +1496,10 @@ discard block |
||
| 1453 | 1496 | |
| 1454 | 1497 | if (!empty($_SESSION['oLP'])) { |
| 1455 | 1498 | $_SESSION['lpobject'] = serialize($_SESSION['oLP']); |
| 1456 | - if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0); |
|
| 1457 | -} |
|
| 1499 | + if ($debug > 0) { |
|
| 1500 | + error_log('New LP - lpobject is serialized in session', 0); |
|
| 1501 | + } |
|
| 1502 | + } |
|
| 1458 | 1503 | |
| 1459 | 1504 | if (!empty($redirectTo)) { |
| 1460 | 1505 | header("Location: $redirectTo"); |
@@ -532,7 +532,9 @@ discard block |
||
| 532 | 532 | if ($file != '.' && $file != '..') { |
| 533 | 533 | $filetype = 'file'; |
| 534 | 534 | |
| 535 | - if (is_dir($course_sys_dir.$new_dir.$file)) $filetype = 'folder'; |
|
| 535 | + if (is_dir($course_sys_dir.$new_dir.$file)) { |
|
| 536 | + $filetype = 'folder'; |
|
| 537 | + } |
|
| 536 | 538 | |
| 537 | 539 | // TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible! |
| 538 | 540 | //$safe_file = api_replace_dangerous_char($file, 'strict'); |
@@ -844,7 +846,8 @@ discard block |
||
| 844 | 846 | $v = @substr($v, 1, @strlen($v) - 2); |
| 845 | 847 | } |
| 846 | 848 | if ($sec) { |
| 847 | - if (api_strtolower($sec) == 'course_description') { // A special case. |
|
| 849 | + if (api_strtolower($sec) == 'course_description') { |
|
| 850 | +// A special case. |
|
| 848 | 851 | $r[api_strtolower($sec)] = $k; |
| 849 | 852 | } else { |
| 850 | 853 | $r[api_strtolower($sec)][api_strtolower($k)] = $v; |
@@ -906,7 +909,8 @@ discard block |
||
| 906 | 909 | if ($pure_data) { |
| 907 | 910 | $r[api_strtolower($sec)] .= $f[$i]; |
| 908 | 911 | } else { |
| 909 | - if (api_strtolower($sec) == 'course_description') { // A special case. |
|
| 912 | + if (api_strtolower($sec) == 'course_description') { |
|
| 913 | +// A special case. |
|
| 910 | 914 | $r[api_strtolower($sec)] = $k; |
| 911 | 915 | } else { |
| 912 | 916 | $r[api_strtolower($sec)][api_strtolower($k)] = $v; |
@@ -1059,11 +1059,13 @@ discard block |
||
| 1059 | 1059 | ); |
| 1060 | 1060 | if ($last_login_date_tmp != false && |
| 1061 | 1061 | $last_login_date == false |
| 1062 | - ) { // TODO: To be cleaned |
|
| 1062 | + ) { |
|
| 1063 | +// TODO: To be cleaned |
|
| 1063 | 1064 | $last_login_date = $last_login_date_tmp; |
| 1064 | 1065 | } elseif ($last_login_date_tmp != false && |
| 1065 | 1066 | $last_login_date != false |
| 1066 | - ) { // TODO: Repeated previous condition. To be cleaned. |
|
| 1067 | + ) { |
|
| 1068 | +// TODO: Repeated previous condition. To be cleaned. |
|
| 1067 | 1069 | // Find the max and assign it to first_login_date |
| 1068 | 1070 | if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
| 1069 | 1071 | $last_login_date = $last_login_date_tmp; |
@@ -1246,9 +1248,11 @@ discard block |
||
| 1246 | 1248 | null, |
| 1247 | 1249 | false |
| 1248 | 1250 | ); |
| 1249 | - if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
| 1251 | + if ($last_login_date_tmp != false && $last_login_date == false) { |
|
| 1252 | +// TODO: To be cleaned. |
|
| 1250 | 1253 | $last_login_date = $last_login_date_tmp; |
| 1251 | - } elseif ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
| 1254 | + } elseif ($last_login_date_tmp != false && $last_login_date == false) { |
|
| 1255 | +// TODO: Repeated previous condition. To be cleaned. |
|
| 1252 | 1256 | // Find the max and assign it to first_login_date |
| 1253 | 1257 | if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
| 1254 | 1258 | $last_login_date = $last_login_date_tmp; |
@@ -1634,9 +1638,11 @@ discard block |
||
| 1634 | 1638 | $session_id, |
| 1635 | 1639 | false |
| 1636 | 1640 | ); |
| 1637 | - if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
| 1641 | + if ($last_login_date_tmp != false && $last_login_date == false) { |
|
| 1642 | +// TODO: To be cleaned. |
|
| 1638 | 1643 | $last_login_date = $last_login_date_tmp; |
| 1639 | - } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
| 1644 | + } else if ($last_login_date_tmp != false && $last_login_date == false) { |
|
| 1645 | +// TODO: Repeated previous condition. To be cleaned. |
|
| 1640 | 1646 | // Find the max and assign it to first_login_date |
| 1641 | 1647 | if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
| 1642 | 1648 | $last_login_date = $last_login_date_tmp; |
@@ -1906,7 +1912,9 @@ discard block |
||
| 1906 | 1912 | FROM $tbl_course course |
| 1907 | 1913 | WHERE course.code IN (".implode(',', $courses_code).")"; |
| 1908 | 1914 | |
| 1909 | - if (!in_array($direction, array('ASC', 'DESC'))) $direction = 'ASC'; |
|
| 1915 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
| 1916 | + $direction = 'ASC'; |
|
| 1917 | + } |
|
| 1910 | 1918 | |
| 1911 | 1919 | $column = intval($column); |
| 1912 | 1920 | $from = intval($from); |
@@ -81,11 +81,15 @@ discard block |
||
| 81 | 81 | for (; $i < sizeof($poly) && (!empty($poly[$i]['x']) && !empty($poly[$i]['y'])); $i++) { |
| 82 | 82 | /* special cases */ |
| 83 | 83 | if ($poly[$i - 1]['y'] == $poly[$i]['y']) { |
| 84 | - if ($poly[$i - 1]['x'] == $poly[$i]['x']) |
|
| 85 | - continue; // twice the same point |
|
| 86 | - else { // infinite elevation of the edge |
|
| 87 | - if (is_array($bords[$poly[$i]['y']])) |
|
| 88 | - array_push($bords[$poly[$i]['y']], $poly[$i]['x']); |
|
| 84 | + if ($poly[$i - 1]['x'] == $poly[$i]['x']) { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 87 | + // twice the same point |
|
| 88 | + else { |
|
| 89 | +// infinite elevation of the edge |
|
| 90 | + if (is_array($bords[$poly[$i]['y']])) { |
|
| 91 | + array_push($bords[$poly[$i]['y']], $poly[$i]['x']); |
|
| 92 | + } |
|
| 89 | 93 | $old_pente = 0; |
| 90 | 94 | continue; |
| 91 | 95 | } |
@@ -93,9 +97,13 @@ discard block |
||
| 93 | 97 | |
| 94 | 98 | //echo 'point:'.$poly[$i]['y']; bug here |
| 95 | 99 | // adding the point as a part of an edge |
| 96 | - if (is_array($bords[$poly[$i]['y']])) //avoid warning |
|
| 100 | + if (is_array($bords[$poly[$i]['y']])) { |
|
| 101 | + //avoid warning |
|
| 97 | 102 | array_push($bords[$poly[$i]['y']], $poly[$i]['x']); |
| 98 | - if (DEBUG) echo '('.$poly[$i]['x'].';'.$poly[$i]['y'].') '; |
|
| 103 | + } |
|
| 104 | + if (DEBUG) { |
|
| 105 | + echo '('.$poly[$i]['x'].';'.$poly[$i]['y'].') '; |
|
| 106 | + } |
|
| 99 | 107 | |
| 100 | 108 | /* computing the elevation of the edge going */ |
| 101 | 109 | // from $poly[$i-1] to $poly[$i] |
@@ -108,10 +116,12 @@ discard block |
||
| 108 | 116 | if ($i > 1) { |
| 109 | 117 | if (($old_pente < 0 && $pente > 0) |
| 110 | 118 | || ($old_pente > 0 && $pente < 0)) { |
| 111 | - if (is_array($bords[$poly[$i]['y']])) //avoid warning |
|
| 119 | + if (is_array($bords[$poly[$i]['y']])) { |
|
| 120 | + //avoid warning |
|
| 112 | 121 | { |
| 113 | 122 | array_push($bords[$poly[$i]['y']], $poly[$i]['x']); |
| 114 | 123 | } |
| 124 | + } |
|
| 115 | 125 | |
| 116 | 126 | if (DEBUG) { |
| 117 | 127 | echo '*('.$poly[$i]['x']. |
@@ -142,7 +152,8 @@ discard block |
||
| 142 | 152 | } |
| 143 | 153 | |
| 144 | 154 | // closing the polygone (the edge between $poly[$i-1] and $poly[0]) |
| 145 | - if ($poly[$i - 1]['y'] != $poly[0]['y']) {// droite--> rien à faire |
|
| 155 | + if ($poly[$i - 1]['y'] != $poly[0]['y']) { |
|
| 156 | +// droite--> rien à faire |
|
| 146 | 157 | |
| 147 | 158 | // elevation between $poly[0]['x'] and $poly[1]['x']) |
| 148 | 159 | $rest = $poly[0]['y'] - $poly[1]['y']; |
@@ -162,14 +173,17 @@ discard block |
||
| 162 | 173 | |
| 163 | 174 | // doubling the first point if needed (see above) |
| 164 | 175 | if (($pente1 < 0 && $pente > 0) || ($pente1 > 0 && $pente < 0)) { |
| 165 | - if (is_array($bords[$poly[$i - 1]['y']])) |
|
| 166 | - array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x'])); |
|
| 176 | + if (is_array($bords[$poly[$i - 1]['y']])) { |
|
| 177 | + array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x'])); |
|
| 178 | + } |
|
| 167 | 179 | //if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') '; |
| 168 | 180 | } |
| 169 | 181 | // doubling the last point if neededd |
| 170 | 182 | if (($old_pente < 0 && $pente > 0) || ($old_pente > 0 && $pente < 0)) { |
| 171 | - if (is_array($bords[$poly[$i - 1]['y']])) //avoid warning |
|
| 183 | + if (is_array($bords[$poly[$i - 1]['y']])) { |
|
| 184 | + //avoid warning |
|
| 172 | 185 | array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x'])); |
| 186 | + } |
|
| 173 | 187 | //if (DEBUG) echo '*('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') '; |
| 174 | 188 | } |
| 175 | 189 | |
@@ -189,13 +203,15 @@ discard block |
||
| 189 | 203 | /* basic idea: we sort a column of edges. |
| 190 | 204 | For each pair of point, we color the points in between */ |
| 191 | 205 | $n = count($bords); |
| 192 | - for ($i = 0; $i < $n; $i++) { // Y |
|
| 206 | + for ($i = 0; $i < $n; $i++) { |
|
| 207 | +// Y |
|
| 193 | 208 | //error_log(__FILE__.' - Border Num '.$i,0); |
| 194 | 209 | if (is_array($bords[$i])) { |
| 195 | 210 | sort($bords[$i]); |
| 196 | 211 | } |
| 197 | 212 | |
| 198 | - for ($j = 0; $j < sizeof($bords[$i]); $j += 2) { // bords |
|
| 213 | + for ($j = 0; $j < sizeof($bords[$i]); $j += 2) { |
|
| 214 | +// bords |
|
| 199 | 215 | if (!isset($bords[$i][$j + 1])) { |
| 200 | 216 | continue; |
| 201 | 217 | } |
@@ -576,7 +576,9 @@ discard block |
||
| 576 | 576 | |
| 577 | 577 | // First check wether the login already exists |
| 578 | 578 | if (!UserManager::is_username_available($loginName)) { |
| 579 | - if ($debug) error_log("Username $loginName is not available"); |
|
| 579 | + if ($debug) { |
|
| 580 | + error_log("Username $loginName is not available"); |
|
| 581 | + } |
|
| 580 | 582 | return 0; |
| 581 | 583 | } |
| 582 | 584 | |
@@ -1084,9 +1086,15 @@ discard block |
||
| 1084 | 1086 | ); |
| 1085 | 1087 | } |
| 1086 | 1088 | |
| 1087 | - if ($debug) error_log('$userId found: '.$userId); |
|
| 1088 | - if ($debug) error_log('$courseId found: '.$courseId); |
|
| 1089 | - if ($debug) error_log('$sessionId found: '.$sessionId); |
|
| 1089 | + if ($debug) { |
|
| 1090 | + error_log('$userId found: '.$userId); |
|
| 1091 | + } |
|
| 1092 | + if ($debug) { |
|
| 1093 | + error_log('$courseId found: '.$courseId); |
|
| 1094 | + } |
|
| 1095 | + if ($debug) { |
|
| 1096 | + error_log('$sessionId found: '.$sessionId); |
|
| 1097 | + } |
|
| 1090 | 1098 | |
| 1091 | 1099 | return [ |
| 1092 | 1100 | 'user_id' => $userId, |
@@ -1115,13 +1123,17 @@ discard block |
||
| 1115 | 1123 | function WSSubscribeTeacherToSessionCourse($params) |
| 1116 | 1124 | { |
| 1117 | 1125 | global $debug; |
| 1118 | - if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); |
|
| 1126 | + if ($debug) { |
|
| 1127 | + error_log('WSSubscribeTeacherToSessionCourse'); |
|
| 1128 | + } |
|
| 1119 | 1129 | |
| 1120 | 1130 | if (!WSHelperVerifyKey($params)) { |
| 1121 | 1131 | return returnError(WS_ERROR_SECRET_KEY); |
| 1122 | 1132 | } |
| 1123 | 1133 | |
| 1124 | - if ($debug) error_log('Params '.print_r($params, 1)); |
|
| 1134 | + if ($debug) { |
|
| 1135 | + error_log('Params '.print_r($params, 1)); |
|
| 1136 | + } |
|
| 1125 | 1137 | |
| 1126 | 1138 | $params = parseCourseSessionUserParams($params); |
| 1127 | 1139 | |
@@ -1134,13 +1146,17 @@ discard block |
||
| 1134 | 1146 | $result = 0; |
| 1135 | 1147 | |
| 1136 | 1148 | if (!empty($coaches)) { |
| 1137 | - if ($debug) error_log('Coaches: '.print_r($coaches, 1)); |
|
| 1149 | + if ($debug) { |
|
| 1150 | + error_log('Coaches: '.print_r($coaches, 1)); |
|
| 1151 | + } |
|
| 1138 | 1152 | if (in_array($userId, $coaches)) { |
| 1139 | 1153 | $result = 1; |
| 1140 | 1154 | } |
| 1141 | 1155 | } |
| 1142 | 1156 | |
| 1143 | - if ($debug) error_log('Result: '.$result); |
|
| 1157 | + if ($debug) { |
|
| 1158 | + error_log('Result: '.$result); |
|
| 1159 | + } |
|
| 1144 | 1160 | |
| 1145 | 1161 | return $result; |
| 1146 | 1162 | } |
@@ -1166,13 +1182,17 @@ discard block |
||
| 1166 | 1182 | { |
| 1167 | 1183 | global $debug; |
| 1168 | 1184 | |
| 1169 | - if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); |
|
| 1185 | + if ($debug) { |
|
| 1186 | + error_log('WSSubscribeTeacherToSessionCourse'); |
|
| 1187 | + } |
|
| 1170 | 1188 | |
| 1171 | 1189 | if (!WSHelperVerifyKey($params)) { |
| 1172 | 1190 | return returnError(WS_ERROR_SECRET_KEY); |
| 1173 | 1191 | } |
| 1174 | 1192 | |
| 1175 | - if ($debug) error_log('Params '.print_r($params, 1)); |
|
| 1193 | + if ($debug) { |
|
| 1194 | + error_log('Params '.print_r($params, 1)); |
|
| 1195 | + } |
|
| 1176 | 1196 | |
| 1177 | 1197 | $params = parseCourseSessionUserParams($params); |
| 1178 | 1198 | |
@@ -1186,7 +1206,9 @@ discard block |
||
| 1186 | 1206 | $result = 0; |
| 1187 | 1207 | |
| 1188 | 1208 | if (!empty($coaches)) { |
| 1189 | - if ($debug) error_log('Coaches: '.print_r($coaches, 1)); |
|
| 1209 | + if ($debug) { |
|
| 1210 | + error_log('Coaches: '.print_r($coaches, 1)); |
|
| 1211 | + } |
|
| 1190 | 1212 | if (!in_array($userId, $coaches)) { |
| 1191 | 1213 | $result = 1; |
| 1192 | 1214 | } |
@@ -1194,7 +1216,9 @@ discard block |
||
| 1194 | 1216 | $result = 1; |
| 1195 | 1217 | } |
| 1196 | 1218 | |
| 1197 | - if ($debug) error_log('Final Result: '.$result); |
|
| 1219 | + if ($debug) { |
|
| 1220 | + error_log('Final Result: '.$result); |
|
| 1221 | + } |
|
| 1198 | 1222 | |
| 1199 | 1223 | return $result; |
| 1200 | 1224 | } |
@@ -1247,8 +1271,12 @@ discard block |
||
| 1247 | 1271 | { |
| 1248 | 1272 | global $_user, $_configuration, $debug; |
| 1249 | 1273 | $debug = 1; |
| 1250 | - if ($debug) error_log('WSCreateUserPasswordCrypted'); |
|
| 1251 | - if ($debug) error_log(print_r($params, 1)); |
|
| 1274 | + if ($debug) { |
|
| 1275 | + error_log('WSCreateUserPasswordCrypted'); |
|
| 1276 | + } |
|
| 1277 | + if ($debug) { |
|
| 1278 | + error_log(print_r($params, 1)); |
|
| 1279 | + } |
|
| 1252 | 1280 | |
| 1253 | 1281 | if (!WSHelperVerifyKey($params)) { |
| 1254 | 1282 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -1280,22 +1308,30 @@ discard block |
||
| 1280 | 1308 | if ($_configuration['password_encryption'] === $encrypt_method) { |
| 1281 | 1309 | if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) { |
| 1282 | 1310 | $msg = "Encryption $encrypt_method is invalid"; |
| 1283 | - if ($debug) error_log($msg); |
|
| 1311 | + if ($debug) { |
|
| 1312 | + error_log($msg); |
|
| 1313 | + } |
|
| 1284 | 1314 | return $msg; |
| 1285 | 1315 | |
| 1286 | 1316 | } elseif ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) { |
| 1287 | 1317 | $msg = "Encryption $encrypt_method is invalid"; |
| 1288 | - if ($debug) error_log($msg); |
|
| 1318 | + if ($debug) { |
|
| 1319 | + error_log($msg); |
|
| 1320 | + } |
|
| 1289 | 1321 | return $msg; |
| 1290 | 1322 | } |
| 1291 | 1323 | } else { |
| 1292 | 1324 | $msg = "This encryption $encrypt_method is not configured"; |
| 1293 | - if ($debug) error_log($msg); |
|
| 1325 | + if ($debug) { |
|
| 1326 | + error_log($msg); |
|
| 1327 | + } |
|
| 1294 | 1328 | return $msg; |
| 1295 | 1329 | } |
| 1296 | 1330 | } else { |
| 1297 | 1331 | $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured'; |
| 1298 | - if ($debug) error_log($msg); |
|
| 1332 | + if ($debug) { |
|
| 1333 | + error_log($msg); |
|
| 1334 | + } |
|
| 1299 | 1335 | return $msg; |
| 1300 | 1336 | } |
| 1301 | 1337 | |
@@ -1315,10 +1351,14 @@ discard block |
||
| 1315 | 1351 | $original_user_id_name |
| 1316 | 1352 | ); |
| 1317 | 1353 | |
| 1318 | - if ($debug) error_log('Ready to create user'); |
|
| 1354 | + if ($debug) { |
|
| 1355 | + error_log('Ready to create user'); |
|
| 1356 | + } |
|
| 1319 | 1357 | |
| 1320 | 1358 | if ($user_id > 0) { |
| 1321 | - if ($debug) error_log('User found with id: '.$user_id); |
|
| 1359 | + if ($debug) { |
|
| 1360 | + error_log('User found with id: '.$user_id); |
|
| 1361 | + } |
|
| 1322 | 1362 | |
| 1323 | 1363 | // Check whether user is not active |
| 1324 | 1364 | //@todo why this condition exists?? |
@@ -1328,7 +1368,9 @@ discard block |
||
| 1328 | 1368 | $r_check_user = Database::fetch_row($resu); |
| 1329 | 1369 | $count_check_user = Database::num_rows($resu); |
| 1330 | 1370 | if ($count_check_user > 0) { |
| 1331 | - if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1'); |
|
| 1371 | + if ($debug) { |
|
| 1372 | + error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1'); |
|
| 1373 | + } |
|
| 1332 | 1374 | $sql = "UPDATE $table_user SET |
| 1333 | 1375 | lastname='".Database::escape_string($lastName)."', |
| 1334 | 1376 | firstname='".Database::escape_string($firstName)."', |
@@ -1364,11 +1406,15 @@ discard block |
||
| 1364 | 1406 | } |
| 1365 | 1407 | return $r_check_user[0]; |
| 1366 | 1408 | } else { |
| 1367 | - if ($debug) error_log('User exists but is active. Cant be updated'); |
|
| 1409 | + if ($debug) { |
|
| 1410 | + error_log('User exists but is active. Cant be updated'); |
|
| 1411 | + } |
|
| 1368 | 1412 | return 0; |
| 1369 | 1413 | } |
| 1370 | 1414 | } else { |
| 1371 | - if ($debug) error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name"); |
|
| 1415 | + if ($debug) { |
|
| 1416 | + error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name"); |
|
| 1417 | + } |
|
| 1372 | 1418 | } |
| 1373 | 1419 | |
| 1374 | 1420 | // Default language. |
@@ -1384,12 +1430,16 @@ discard block |
||
| 1384 | 1430 | |
| 1385 | 1431 | // First check wether the login already exists |
| 1386 | 1432 | if (!UserManager::is_username_available($loginName)) { |
| 1387 | - if ($debug) error_log("Username $loginName is not available"); |
|
| 1433 | + if ($debug) { |
|
| 1434 | + error_log("Username $loginName is not available"); |
|
| 1435 | + } |
|
| 1388 | 1436 | return 0; |
| 1389 | 1437 | } |
| 1390 | 1438 | |
| 1391 | 1439 | $queryExpirationDate = ''; |
| 1392 | - if (!empty($params['expiration_date'])) $queryExpirationDate = "expiration_date = '".Database::escape_string($expiration_date)."', "; |
|
| 1440 | + if (!empty($params['expiration_date'])) { |
|
| 1441 | + $queryExpirationDate = "expiration_date = '".Database::escape_string($expiration_date)."', "; |
|
| 1442 | + } |
|
| 1393 | 1443 | |
| 1394 | 1444 | $sql = "INSERT INTO $table_user SET |
| 1395 | 1445 | lastname = '".Database::escape_string(trim($lastName))."', |
@@ -1419,7 +1469,9 @@ discard block |
||
| 1419 | 1469 | |
| 1420 | 1470 | $url_id = api_get_current_access_url_id(); |
| 1421 | 1471 | UrlManager::add_user_to_url($return, $url_id); |
| 1422 | - if ($debug) error_log("Adding user_id = $return to URL id $url_id "); |
|
| 1472 | + if ($debug) { |
|
| 1473 | + error_log("Adding user_id = $return to URL id $url_id "); |
|
| 1474 | + } |
|
| 1423 | 1475 | |
| 1424 | 1476 | // Create extra field for the original_user_id_name |
| 1425 | 1477 | UserManager::create_extra_field( |
@@ -1456,7 +1508,9 @@ discard block |
||
| 1456 | 1508 | } |
| 1457 | 1509 | } |
| 1458 | 1510 | } else { |
| 1459 | - if ($debug) error_log('Error while inserting a user'); |
|
| 1511 | + if ($debug) { |
|
| 1512 | + error_log('Error while inserting a user'); |
|
| 1513 | + } |
|
| 1460 | 1514 | |
| 1461 | 1515 | return 0; |
| 1462 | 1516 | } |
@@ -2947,10 +3001,12 @@ discard block |
||
| 2947 | 3001 | $params['visibility'] = $visibility; |
| 2948 | 3002 | $params['disk_quota'] = $diskQuota; |
| 2949 | 3003 | |
| 2950 | - if (isset($subscribe) && $subscribe != '') { // Valid values: 0, 1 |
|
| 3004 | + if (isset($subscribe) && $subscribe != '') { |
|
| 3005 | +// Valid values: 0, 1 |
|
| 2951 | 3006 | $params['subscribe'] = $subscribe; |
| 2952 | 3007 | } |
| 2953 | - if (isset($unsubscribe) && $subscribe != '') { // Valid values: 0, 1 |
|
| 3008 | + if (isset($unsubscribe) && $subscribe != '') { |
|
| 3009 | +// Valid values: 0, 1 |
|
| 2954 | 3010 | $params['unsubscribe'] = $unsubscribe; |
| 2955 | 3011 | } |
| 2956 | 3012 | |
@@ -3327,7 +3383,8 @@ discard block |
||
| 3327 | 3383 | ); |
| 3328 | 3384 | |
| 3329 | 3385 | // Define the method WSEditCourse |
| 3330 | -function WSEditCourse($params) { |
|
| 3386 | +function WSEditCourse($params) |
|
| 3387 | +{ |
|
| 3331 | 3388 | |
| 3332 | 3389 | global $_configuration; |
| 3333 | 3390 | if (!WSHelperVerifyKey($params)) { |
@@ -4250,7 +4307,8 @@ discard block |
||
| 4250 | 4307 | if (empty($name)) { |
| 4251 | 4308 | $results[] = 0; //SessionNameIsRequired |
| 4252 | 4309 | continue; |
| 4253 | - } elseif (empty($id_coach)) { // Session must have coach |
|
| 4310 | + } elseif (empty($id_coach)) { |
|
| 4311 | +// Session must have coach |
|
| 4254 | 4312 | $results[] = 0; |
| 4255 | 4313 | continue; |
| 4256 | 4314 | } elseif (empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start, $day_start, $year_start))) { |
@@ -4545,12 +4603,15 @@ discard block |
||
| 4545 | 4603 | ); |
| 4546 | 4604 | |
| 4547 | 4605 | // define the method WSSubscribeUserToCourse |
| 4548 | -function WSSubscribeUserToCourse($params) { |
|
| 4606 | +function WSSubscribeUserToCourse($params) |
|
| 4607 | +{ |
|
| 4549 | 4608 | global $debug; |
| 4550 | 4609 | if (!WSHelperVerifyKey($params)) { |
| 4551 | 4610 | return returnError(WS_ERROR_SECRET_KEY); |
| 4552 | 4611 | } |
| 4553 | - if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params, 1)); |
|
| 4612 | + if ($debug) { |
|
| 4613 | + error_log('WSSubscribeUserToCourse params: '.print_r($params, 1)); |
|
| 4614 | + } |
|
| 4554 | 4615 | |
| 4555 | 4616 | $results = array(); |
| 4556 | 4617 | $userscourses = $params['userscourses']; |
@@ -4569,7 +4630,9 @@ discard block |
||
| 4569 | 4630 | $original_user_id['original_user_id_value'], |
| 4570 | 4631 | $original_user_id['original_user_id_name'] |
| 4571 | 4632 | ); |
| 4572 | - if ($debug) error_log('WSSubscribeUserToCourse user_id: '.$user_id); |
|
| 4633 | + if ($debug) { |
|
| 4634 | + error_log('WSSubscribeUserToCourse user_id: '.$user_id); |
|
| 4635 | + } |
|
| 4573 | 4636 | |
| 4574 | 4637 | if ($user_id == 0) { |
| 4575 | 4638 | // If user was not found, there was a problem |
@@ -4587,13 +4650,19 @@ discard block |
||
| 4587 | 4650 | // Course was not found |
| 4588 | 4651 | $resultValue = 0; |
| 4589 | 4652 | } else { |
| 4590 | - if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode); |
|
| 4653 | + if ($debug) { |
|
| 4654 | + error_log('WSSubscribeUserToCourse courseCode: '.$courseCode); |
|
| 4655 | + } |
|
| 4591 | 4656 | $result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false); |
| 4592 | 4657 | if ($result) { |
| 4593 | 4658 | $resultValue = 1; |
| 4594 | - if ($debug) error_log('WSSubscribeUserToCourse subscribed'); |
|
| 4659 | + if ($debug) { |
|
| 4660 | + error_log('WSSubscribeUserToCourse subscribed'); |
|
| 4661 | + } |
|
| 4595 | 4662 | } else { |
| 4596 | - if ($debug) error_log('WSSubscribeUserToCourse NOT subscribed: '); |
|
| 4663 | + if ($debug) { |
|
| 4664 | + error_log('WSSubscribeUserToCourse NOT subscribed: '); |
|
| 4665 | + } |
|
| 4597 | 4666 | } |
| 4598 | 4667 | } |
| 4599 | 4668 | } |
@@ -4649,11 +4718,16 @@ discard block |
||
| 4649 | 4718 | ); |
| 4650 | 4719 | |
| 4651 | 4720 | // define the method WSSubscribeUserToCourse |
| 4652 | -function WSSubscribeUserToCourseSimple($params) { |
|
| 4721 | +function WSSubscribeUserToCourseSimple($params) |
|
| 4722 | +{ |
|
| 4653 | 4723 | global $debug; |
| 4654 | 4724 | |
| 4655 | - if ($debug) error_log('WSSubscribeUserToCourseSimple'); |
|
| 4656 | - if ($debug) error_log('Params '.print_r($params, 1)); |
|
| 4725 | + if ($debug) { |
|
| 4726 | + error_log('WSSubscribeUserToCourseSimple'); |
|
| 4727 | + } |
|
| 4728 | + if ($debug) { |
|
| 4729 | + error_log('Params '.print_r($params, 1)); |
|
| 4730 | + } |
|
| 4657 | 4731 | if (!WSHelperVerifyKey($params)) { |
| 4658 | 4732 | return returnError(WS_ERROR_SECRET_KEY); |
| 4659 | 4733 | } |
@@ -4671,7 +4745,9 @@ discard block |
||
| 4671 | 4745 | if (empty($user_data)) { |
| 4672 | 4746 | // If user was not found, there was a problem |
| 4673 | 4747 | $result = "User $user_id does not exist"; |
| 4674 | - if ($debug) error_log($result); |
|
| 4748 | + if ($debug) { |
|
| 4749 | + error_log($result); |
|
| 4750 | + } |
|
| 4675 | 4751 | return $result; |
| 4676 | 4752 | } |
| 4677 | 4753 | if (!empty($course_code)) { |
@@ -4679,14 +4755,22 @@ discard block |
||
| 4679 | 4755 | if (empty($course_data)) { |
| 4680 | 4756 | // Course was not found |
| 4681 | 4757 | $result = "Course $course_code does not exist in the platform "; |
| 4682 | - if ($debug) error_log($result); |
|
| 4758 | + if ($debug) { |
|
| 4759 | + error_log($result); |
|
| 4760 | + } |
|
| 4683 | 4761 | } else { |
| 4684 | - if ($debug) error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']); |
|
| 4762 | + if ($debug) { |
|
| 4763 | + error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']); |
|
| 4764 | + } |
|
| 4685 | 4765 | if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status)) { |
| 4686 | 4766 | $result = 'User was not registered possible reasons: User already registered to the course, Course visibility doesnt allow user subscriptions '; |
| 4687 | - if ($debug) error_log($result); |
|
| 4767 | + if ($debug) { |
|
| 4768 | + error_log($result); |
|
| 4769 | + } |
|
| 4688 | 4770 | } else { |
| 4689 | - if ($debug) error_log('User registered to the course: '.$course_data['code']); |
|
| 4771 | + if ($debug) { |
|
| 4772 | + error_log('User registered to the course: '.$course_data['code']); |
|
| 4773 | + } |
|
| 4690 | 4774 | $result = 1; |
| 4691 | 4775 | } |
| 4692 | 4776 | } |
@@ -4737,8 +4821,12 @@ discard block |
||
| 4737 | 4821 | function WSGetUser($params) |
| 4738 | 4822 | { |
| 4739 | 4823 | global $debug; |
| 4740 | - if ($debug) error_log('WSGetUser'); |
|
| 4741 | - if ($debug) error_log('$params: '.print_r($params, 1)); |
|
| 4824 | + if ($debug) { |
|
| 4825 | + error_log('WSGetUser'); |
|
| 4826 | + } |
|
| 4827 | + if ($debug) { |
|
| 4828 | + error_log('$params: '.print_r($params, 1)); |
|
| 4829 | + } |
|
| 4742 | 4830 | |
| 4743 | 4831 | if (!WSHelperVerifyKey($params)) { |
| 4744 | 4832 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -4793,8 +4881,12 @@ discard block |
||
| 4793 | 4881 | function WSGetUserFromUsername($params) |
| 4794 | 4882 | { |
| 4795 | 4883 | global $debug; |
| 4796 | - if ($debug) error_log('WSGetUserFromUsername'); |
|
| 4797 | - if ($debug) error_log('$params: '.print_r($params, 1)); |
|
| 4884 | + if ($debug) { |
|
| 4885 | + error_log('WSGetUserFromUsername'); |
|
| 4886 | + } |
|
| 4887 | + if ($debug) { |
|
| 4888 | + error_log('$params: '.print_r($params, 1)); |
|
| 4889 | + } |
|
| 4798 | 4890 | |
| 4799 | 4891 | if (!WSHelperVerifyKey($params)) { |
| 4800 | 4892 | return returnError(WS_ERROR_SECRET_KEY); |
@@ -5271,7 +5363,9 @@ discard block |
||
| 5271 | 5363 | ); |
| 5272 | 5364 | $results[] = 1; |
| 5273 | 5365 | |
| 5274 | - if ($debug) error_log("subscribe user:$user_id to session $sessionId"); |
|
| 5366 | + if ($debug) { |
|
| 5367 | + error_log("subscribe user:$user_id to session $sessionId"); |
|
| 5368 | + } |
|
| 5275 | 5369 | } |
| 5276 | 5370 | } |
| 5277 | 5371 | } // end principal foreach |
@@ -5312,7 +5406,8 @@ discard block |
||
| 5312 | 5406 | 'encoded', // use |
| 5313 | 5407 | 'This service subscribes a user to a session in a simple way' // documentation |
| 5314 | 5408 | ); |
| 5315 | -function WSSubscribeUserToSessionSimple($params) { |
|
| 5409 | +function WSSubscribeUserToSessionSimple($params) |
|
| 5410 | +{ |
|
| 5316 | 5411 | global $debug; |
| 5317 | 5412 | |
| 5318 | 5413 | if ($debug) { |
@@ -5355,7 +5450,9 @@ discard block |
||
| 5355 | 5450 | SESSION_VISIBLE_READ_ONLY, |
| 5356 | 5451 | false |
| 5357 | 5452 | ); |
| 5358 | - if ($debug) error_log('User registered to the course: '.$session_id); |
|
| 5453 | + if ($debug) { |
|
| 5454 | + error_log('User registered to the course: '.$session_id); |
|
| 5455 | + } |
|
| 5359 | 5456 | $result = 1; |
| 5360 | 5457 | } |
| 5361 | 5458 | } |
@@ -5503,7 +5600,9 @@ discard block |
||
| 5503 | 5600 | |
| 5504 | 5601 | $results[] = 1; |
| 5505 | 5602 | |
| 5506 | - if ($debug) error_log("Unsubscribe user:$user_id to session:$id_session"); |
|
| 5603 | + if ($debug) { |
|
| 5604 | + error_log("Unsubscribe user:$user_id to session:$id_session"); |
|
| 5605 | + } |
|
| 5507 | 5606 | } |
| 5508 | 5607 | } |
| 5509 | 5608 | } // end principal foreach |
@@ -5650,7 +5749,9 @@ discard block |
||
| 5650 | 5749 | return returnError(WS_ERROR_SECRET_KEY); |
| 5651 | 5750 | } |
| 5652 | 5751 | |
| 5653 | - if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1)); |
|
| 5752 | + if ($debug) { |
|
| 5753 | + error_log('WSSuscribeCoursesToSession: '.print_r($params, 1)); |
|
| 5754 | + } |
|
| 5654 | 5755 | |
| 5655 | 5756 | $coursessessions_params = $params['coursessessions']; |
| 5656 | 5757 | $results = array(); |
@@ -5696,7 +5797,9 @@ discard block |
||
| 5696 | 5797 | array($courseInfo['real_id']), |
| 5697 | 5798 | false |
| 5698 | 5799 | ); |
| 5699 | - if ($debug) error_log("add_courses_to_session: course:$courseCode to session:$sessionId"); |
|
| 5800 | + if ($debug) { |
|
| 5801 | + error_log("add_courses_to_session: course:$courseCode to session:$sessionId"); |
|
| 5802 | + } |
|
| 5700 | 5803 | |
| 5701 | 5804 | $results[] = 1; |
| 5702 | 5805 | } |
@@ -6966,12 +7069,15 @@ discard block |
||
| 6966 | 7069 | ); |
| 6967 | 7070 | |
| 6968 | 7071 | // define the method WSRegisterUserVisibilityToCourseInCatalogue |
| 6969 | -function WSAddUserVisibilityToCourseInCatalogue($params) { |
|
| 7072 | +function WSAddUserVisibilityToCourseInCatalogue($params) |
|
| 7073 | +{ |
|
| 6970 | 7074 | global $debug; |
| 6971 | 7075 | if (!WSHelperVerifyKey($params)) { |
| 6972 | 7076 | return returnError(WS_ERROR_SECRET_KEY); |
| 6973 | 7077 | } |
| 6974 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue params: '.print_r($params, 1)); |
|
| 7078 | + if ($debug) { |
|
| 7079 | + error_log('WSAddUserVisibilityToCourseCatalogue params: '.print_r($params, 1)); |
|
| 7080 | + } |
|
| 6975 | 7081 | |
| 6976 | 7082 | $results = array(); |
| 6977 | 7083 | $userscourses = $params['userscourses']; |
@@ -6987,7 +7093,9 @@ discard block |
||
| 6987 | 7093 | $original_user_id['original_user_id_value'], |
| 6988 | 7094 | $original_user_id['original_user_id_name'] |
| 6989 | 7095 | ); |
| 6990 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue userId: '.$userId); |
|
| 7096 | + if ($debug) { |
|
| 7097 | + error_log('WSAddUserVisibilityToCourseCatalogue userId: '.$userId); |
|
| 7098 | + } |
|
| 6991 | 7099 | |
| 6992 | 7100 | if ($userId == 0) { |
| 6993 | 7101 | // If user was not found, there was a problem |
@@ -7004,13 +7112,19 @@ discard block |
||
| 7004 | 7112 | // Course was not found |
| 7005 | 7113 | $resultValue = 0; |
| 7006 | 7114 | } else { |
| 7007 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue courseCode: '.$courseCode); |
|
| 7115 | + if ($debug) { |
|
| 7116 | + error_log('WSAddUserVisibilityToCourseCatalogue courseCode: '.$courseCode); |
|
| 7117 | + } |
|
| 7008 | 7118 | $result = CourseManager::addUserVisibilityToCourseInCatalogue($userId, $courseCode, $visible); |
| 7009 | 7119 | if ($result) { |
| 7010 | 7120 | $resultValue = 1; |
| 7011 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue registered'); |
|
| 7121 | + if ($debug) { |
|
| 7122 | + error_log('WSAddUserVisibilityToCourseCatalogue registered'); |
|
| 7123 | + } |
|
| 7012 | 7124 | } else { |
| 7013 | - if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue NOT registered: '); |
|
| 7125 | + if ($debug) { |
|
| 7126 | + error_log('WSAddUserVisibilityToCourseCatalogue NOT registered: '); |
|
| 7127 | + } |
|
| 7014 | 7128 | } |
| 7015 | 7129 | } |
| 7016 | 7130 | } |
@@ -7038,12 +7152,15 @@ discard block |
||
| 7038 | 7152 | ); |
| 7039 | 7153 | |
| 7040 | 7154 | // define the method WSRemoveUserVisibilityToCourseInCatalogue |
| 7041 | -function WSRemoveUserVisibilityToCourseInCatalogue($params) { |
|
| 7155 | +function WSRemoveUserVisibilityToCourseInCatalogue($params) |
|
| 7156 | +{ |
|
| 7042 | 7157 | global $debug; |
| 7043 | 7158 | if (!WSHelperVerifyKey($params)) { |
| 7044 | 7159 | return returnError(WS_ERROR_SECRET_KEY); |
| 7045 | 7160 | } |
| 7046 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue params: '.print_r($params, 1)); |
|
| 7161 | + if ($debug) { |
|
| 7162 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue params: '.print_r($params, 1)); |
|
| 7163 | + } |
|
| 7047 | 7164 | |
| 7048 | 7165 | $results = array(); |
| 7049 | 7166 | $userscourses = $params['userscourses']; |
@@ -7059,7 +7176,9 @@ discard block |
||
| 7059 | 7176 | $original_user_id['original_user_id_value'], |
| 7060 | 7177 | $original_user_id['original_user_id_name'] |
| 7061 | 7178 | ); |
| 7062 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue user_id: '.$userId); |
|
| 7179 | + if ($debug) { |
|
| 7180 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue user_id: '.$userId); |
|
| 7181 | + } |
|
| 7063 | 7182 | |
| 7064 | 7183 | if ($userId == 0) { |
| 7065 | 7184 | // If user was not found, there was a problem |
@@ -7076,13 +7195,19 @@ discard block |
||
| 7076 | 7195 | // Course was not found |
| 7077 | 7196 | $resultValue = 0; |
| 7078 | 7197 | } else { |
| 7079 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue courseCode: '.$courseCode); |
|
| 7198 | + if ($debug) { |
|
| 7199 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue courseCode: '.$courseCode); |
|
| 7200 | + } |
|
| 7080 | 7201 | $result = CourseManager::removeUserVisibilityToCourseInCatalogue($userId, $courseCode, $visible); |
| 7081 | 7202 | if ($result) { |
| 7082 | 7203 | $resultValue = 1; |
| 7083 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue removed'); |
|
| 7204 | + if ($debug) { |
|
| 7205 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue removed'); |
|
| 7206 | + } |
|
| 7084 | 7207 | } else { |
| 7085 | - if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue NOT removed: '); |
|
| 7208 | + if ($debug) { |
|
| 7209 | + error_log('WSRemoveUserVisibilityToCourseInCatalogue NOT removed: '); |
|
| 7210 | + } |
|
| 7086 | 7211 | } |
| 7087 | 7212 | } |
| 7088 | 7213 | } |