@@ -785,7 +785,6 @@ |
||
785 | 785 | * lock = the user can no longer use this account |
786 | 786 | * @author Patrick Cool <[email protected]>, Ghent University |
787 | 787 | * @param int $active the current state of the account |
788 | - * @param int $user_id The user id |
|
789 | 788 | * @param string $url_params |
790 | 789 | * @return string Some HTML-code with the lock/unlock button |
791 | 790 | */ |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | require_once '../inc/global.inc.php'; |
11 | -$current_course_tool = TOOL_USER; |
|
11 | +$current_course_tool = TOOL_USER; |
|
12 | 12 | |
13 | 13 | // the section (for the tabs) |
14 | 14 | $this_section = SECTION_COURSES; |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | $current_session_id = api_get_session_id(); |
54 | -$list_register_user=''; |
|
55 | -$list_not_register_user=''; |
|
54 | +$list_register_user = ''; |
|
55 | +$list_not_register_user = ''; |
|
56 | 56 | |
57 | 57 | if (isset($_REQUEST['register'])) { |
58 | 58 | if ($type == COURSEMANAGER) { |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | |
81 | 81 | if (is_array($user_id_temp)) { |
82 | 82 | $counter = count($user_id_temp); |
83 | - for ($j=0; $j<$counter;$j++) { |
|
84 | - if ($user_id_temp[$j]==$_GET['user_id']) { |
|
85 | - if ($result_simple_sub) { |
|
83 | + for ($j = 0; $j < $counter; $j++) { |
|
84 | + if ($user_id_temp[$j] == $_GET['user_id']) { |
|
85 | + if ($result_simple_sub) { |
|
86 | 86 | Display::addFlash(Display::return_message($_SESSION['session_user_name'][$j].' '.get_lang('AddedToCourse'))); |
87 | 87 | } else { |
88 | 88 | Display::addFlash(Display::return_message($_SESSION['session_user_name'][$j].' '.get_lang('NotAddedToCourse'), 'error')); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | if (isset($_POST['action'])) { |
102 | - switch($_POST['action']) { |
|
102 | + switch ($_POST['action']) { |
|
103 | 103 | case 'subscribe': |
104 | 104 | if (is_array($_POST['user'])) { |
105 | 105 | foreach ($_POST['user'] as $index => $user_id) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $counter = 0; |
137 | 137 | $is_suscribe_counter = count($is_suscribe_user_id); |
138 | 138 | |
139 | - $list_register_user=''; |
|
139 | + $list_register_user = ''; |
|
140 | 140 | |
141 | 141 | for ($i = 0; $i < $is_suscribe_counter; $i++) { |
142 | 142 | for ($j = 0; $j < count($user_id_temp); $j++) { |
@@ -195,25 +195,25 @@ discard block |
||
195 | 195 | $parameters['type'] = $type; |
196 | 196 | $table->set_additional_parameters($parameters); |
197 | 197 | $col = 0; |
198 | -$table->set_header($col ++, '', false); |
|
199 | -$table->set_header($col ++, get_lang('OfficialCode')); |
|
198 | +$table->set_header($col++, '', false); |
|
199 | +$table->set_header($col++, get_lang('OfficialCode')); |
|
200 | 200 | if (api_is_western_name_order()) { |
201 | - $table->set_header($col ++, get_lang('FirstName')); |
|
202 | - $table->set_header($col ++, get_lang('LastName')); |
|
201 | + $table->set_header($col++, get_lang('FirstName')); |
|
202 | + $table->set_header($col++, get_lang('LastName')); |
|
203 | 203 | } else { |
204 | - $table->set_header($col ++, get_lang('LastName')); |
|
205 | - $table->set_header($col ++, get_lang('FirstName')); |
|
204 | + $table->set_header($col++, get_lang('LastName')); |
|
205 | + $table->set_header($col++, get_lang('FirstName')); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | if (api_get_setting('show_email_addresses') == 'true') { |
209 | - $table->set_header($col ++, get_lang('Email')); |
|
210 | - $table->set_column_filter($col -1, 'email_filter'); |
|
209 | + $table->set_header($col++, get_lang('Email')); |
|
210 | + $table->set_column_filter($col - 1, 'email_filter'); |
|
211 | 211 | } |
212 | 212 | $table->set_header($col++, get_lang('Active'), false); |
213 | -$table->set_column_filter($col -1, 'active_filter'); |
|
214 | -$table->set_header($col ++, get_lang('Actions'), false); |
|
215 | -$table->set_column_filter($col -1, 'reg_filter'); |
|
216 | -$table->set_form_actions(array ('subscribe' => get_lang('reg')), 'user'); |
|
213 | +$table->set_column_filter($col - 1, 'active_filter'); |
|
214 | +$table->set_header($col++, get_lang('Actions'), false); |
|
215 | +$table->set_column_filter($col - 1, 'reg_filter'); |
|
216 | +$table->set_form_actions(array('subscribe' => get_lang('reg')), 'user'); |
|
217 | 217 | |
218 | 218 | if (!empty($_POST['keyword'])) { |
219 | 219 | $keyword_name = Security::remove_XSS($_POST['keyword']); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $courseCode = api_get_course_id(); |
282 | 282 | $sessionId = api_get_session_id(); |
283 | 283 | |
284 | - if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') { |
|
284 | + if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'teacher') { |
|
285 | 285 | |
286 | 286 | if (api_get_session_id() != 0) { |
287 | 287 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | |
300 | 300 | if (api_is_multiple_url_enabled()) { |
301 | 301 | $url_access_id = api_get_current_access_url_id(); |
302 | - if ($url_access_id !=-1) { |
|
302 | + if ($url_access_id != -1) { |
|
303 | 303 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
304 | 304 | $sql = "SELECT COUNT(u.user_id) |
305 | 305 | FROM $user_table u |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | if (api_is_multiple_url_enabled()) { |
328 | 328 | $url_access_id = api_get_current_access_url_id(); |
329 | - if ($url_access_id !=-1) { |
|
329 | + if ($url_access_id != -1) { |
|
330 | 330 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
331 | 331 | |
332 | 332 | $sql = "SELECT COUNT(u.user_id) |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | |
357 | 357 | if (api_is_multiple_url_enabled()) { |
358 | 358 | $url_access_id = api_get_current_access_url_id(); |
359 | - if ($url_access_id !=-1) { |
|
359 | + if ($url_access_id != -1) { |
|
360 | 360 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
361 | 361 | $sql = "SELECT COUNT(u.user_id) |
362 | 362 | FROM $user_table u |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | if (isset($_GET['subscribe_user_filter_value']) && |
385 | 385 | !empty($_GET['subscribe_user_filter_value']) && |
386 | 386 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
387 | - ){ |
|
388 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
389 | - $sql .= " |
|
387 | + ) { |
|
388 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
389 | + $sql .= " |
|
390 | 390 | LEFT JOIN $table_user_field_values field_values |
391 | 391 | ON field_values.item_id = u.user_id |
392 | 392 | WHERE |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | field_values.field_id = '".intval($field_identification[0])."' AND |
396 | 396 | field_values.value = '".Database::escape_string($field_identification[1])."' |
397 | 397 | "; |
398 | - } else { |
|
399 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
398 | + } else { |
|
399 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | if (api_is_multiple_url_enabled()) { |
403 | 403 | $url_access_id = api_get_current_access_url_id(); |
404 | 404 | |
405 | - if ($url_access_id !=-1) { |
|
405 | + if ($url_access_id != -1) { |
|
406 | 406 | |
407 | 407 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
408 | 408 | |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $users_of_course[] = $course_user['user_id']; |
450 | 450 | } |
451 | 451 | } |
452 | - $sql .=" AND u.status <> ".ANONYMOUS." "; |
|
452 | + $sql .= " AND u.status <> ".ANONYMOUS." "; |
|
453 | 453 | $res = Database::query($sql); |
454 | 454 | $count_user = 0; |
455 | 455 | |
@@ -521,8 +521,8 @@ discard block |
||
521 | 521 | !empty($_GET['subscribe_user_filter_value']) && |
522 | 522 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
523 | 523 | ) { |
524 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
525 | - $sql .= " |
|
524 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
525 | + $sql .= " |
|
526 | 526 | LEFT JOIN $table_user_field_values field_values |
527 | 527 | ON field_values.item_id = u.user_id |
528 | 528 | WHERE |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | field_values.field_id = '".intval($field_identification[0])."' AND |
533 | 533 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
534 | 534 | } else { |
535 | - $sql .= "WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
|
535 | + $sql .= "WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
|
536 | 536 | } |
537 | 537 | |
538 | - $sql .= " AND access_url_id= $url_access_id"; |
|
538 | + $sql .= " AND access_url_id= $url_access_id"; |
|
539 | 539 | |
540 | 540 | } else { |
541 | 541 | // adding a teacher NOT through a session |
@@ -549,21 +549,21 @@ discard block |
||
549 | 549 | !empty($_GET['subscribe_user_filter_value']) && |
550 | 550 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
551 | 551 | ) { |
552 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
553 | - $sql .= " |
|
552 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
553 | + $sql .= " |
|
554 | 554 | LEFT JOIN $table_user_field_values field_values |
555 | 555 | ON field_values.item_id = u.user_id |
556 | 556 | WHERE |
557 | 557 | cu.user_id IS NULL AND u.status<>".DRH." AND |
558 | 558 | field_values.field_id = '".intval($field_identification[0])."' AND |
559 | 559 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
560 | - } else { |
|
561 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
560 | + } else { |
|
561 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | // adding a teacher NOT trough a session on a portal with multiple URLs |
565 | 565 | if (api_is_multiple_url_enabled()) { |
566 | - if ($url_access_id !=-1) { |
|
566 | + if ($url_access_id != -1) { |
|
567 | 567 | $sql = "SELECT $select_fields |
568 | 568 | FROM $user_table u |
569 | 569 | LEFT JOIN $course_user_table cu |
@@ -575,9 +575,9 @@ discard block |
||
575 | 575 | if (isset($_GET['subscribe_user_filter_value']) && |
576 | 576 | !empty($_GET['subscribe_user_filter_value']) && |
577 | 577 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
578 | - ){ |
|
578 | + ) { |
|
579 | 579 | $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
580 | - $sql .= " |
|
580 | + $sql .= " |
|
581 | 581 | LEFT JOIN $table_user_field_values field_values |
582 | 582 | ON field_values.item_id = u.user_id |
583 | 583 | WHERE |
@@ -585,8 +585,8 @@ discard block |
||
585 | 585 | u.status<>".DRH." AND |
586 | 586 | field_values.field_id = '".intval($field_identification[0])."' AND |
587 | 587 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
588 | - } else { |
|
589 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
588 | + } else { |
|
589 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | } |
@@ -607,9 +607,9 @@ discard block |
||
607 | 607 | } |
608 | 608 | |
609 | 609 | // applying the filter of the additional user profile fields |
610 | - if (isset($_GET['subscribe_user_filter_value']) AND !empty($_GET['subscribe_user_filter_value'])){ |
|
611 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
612 | - $sql .= " |
|
610 | + if (isset($_GET['subscribe_user_filter_value']) AND !empty($_GET['subscribe_user_filter_value'])) { |
|
611 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
612 | + $sql .= " |
|
613 | 613 | LEFT JOIN $table_user_field_values field_values |
614 | 614 | ON field_values.item_id = u.user_id |
615 | 615 | WHERE |
@@ -618,15 +618,15 @@ discard block |
||
618 | 618 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) AND |
619 | 619 | field_values.field_id = '".intval($field_identification[0])."' AND |
620 | 620 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
621 | - } else { |
|
622 | - $sql .= "WHERE |
|
621 | + } else { |
|
622 | + $sql .= "WHERE |
|
623 | 623 | cu.user_id IS NULL AND |
624 | 624 | u.status<>".DRH." AND |
625 | 625 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
626 | 626 | } |
627 | 627 | |
628 | 628 | if (api_is_multiple_url_enabled()) { |
629 | - $sql .= "AND access_url_id = $url_access_id"; |
|
629 | + $sql .= "AND access_url_id = $url_access_id"; |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | } else { |
@@ -638,9 +638,9 @@ discard block |
||
638 | 638 | c_id ='".$courseId."'"; |
639 | 639 | |
640 | 640 | // applying the filter of the additional user profile fields |
641 | - if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])){ |
|
642 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
643 | - $sql .= " |
|
641 | + if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])) { |
|
642 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
643 | + $sql .= " |
|
644 | 644 | LEFT JOIN $table_user_field_values field_values |
645 | 645 | ON field_values.item_id = u.user_id |
646 | 646 | WHERE |
@@ -648,14 +648,14 @@ discard block |
||
648 | 648 | u.status<>".DRH." AND |
649 | 649 | field_values.field_id = '".intval($field_identification[0])."' AND |
650 | 650 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
651 | - } else { |
|
652 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
651 | + } else { |
|
652 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | //showing only the courses of the current Chamilo access_url_id |
656 | 656 | |
657 | 657 | if (api_is_multiple_url_enabled()) { |
658 | - if ($url_access_id !=-1) { |
|
658 | + if ($url_access_id != -1) { |
|
659 | 659 | $sql = "SELECT $select_fields |
660 | 660 | FROM $user_table u |
661 | 661 | LEFT JOIN $course_user_table cu |
@@ -667,9 +667,9 @@ discard block |
||
667 | 667 | if (isset($_GET['subscribe_user_filter_value']) && |
668 | 668 | !empty($_GET['subscribe_user_filter_value']) && |
669 | 669 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
670 | - ){ |
|
670 | + ) { |
|
671 | 671 | $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
672 | - $sql .= " |
|
672 | + $sql .= " |
|
673 | 673 | LEFT JOIN $table_user_field_values field_values |
674 | 674 | ON field_values.item_id = u.user_id |
675 | 675 | WHERE |
@@ -679,8 +679,8 @@ discard block |
||
679 | 679 | field_values.value = '".Database::escape_string($field_identification[1])."' AND |
680 | 680 | access_url_id = $url_access_id |
681 | 681 | "; |
682 | - } else { |
|
683 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
682 | + } else { |
|
683 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
684 | 684 | } |
685 | 685 | } |
686 | 686 | } |
@@ -718,14 +718,14 @@ discard block |
||
718 | 718 | } |
719 | 719 | } |
720 | 720 | |
721 | - $sql .=" AND u.status != ".ANONYMOUS." "; |
|
721 | + $sql .= " AND u.status != ".ANONYMOUS." "; |
|
722 | 722 | |
723 | 723 | // Sorting and pagination (used by the sortable table) |
724 | 724 | $sql .= " ORDER BY col$column $direction "; |
725 | 725 | $sql .= " LIMIT $from,$number_of_items"; |
726 | 726 | |
727 | 727 | $res = Database::query($sql); |
728 | - $users = array (); |
|
728 | + $users = array(); |
|
729 | 729 | while ($user = Database::fetch_row($res)) { |
730 | 730 | $users[] = $user; |
731 | 731 | $_SESSION['session_user_id'][] = $user[0]; |
@@ -736,12 +736,12 @@ discard block |
||
736 | 736 | } |
737 | 737 | } |
738 | 738 | // adding additional users based on the search on the additional profile fields |
739 | - if (isset($_REQUEST['keyword'])){ |
|
739 | + if (isset($_REQUEST['keyword'])) { |
|
740 | 740 | if (is_array($additional_users)) { |
741 | - foreach($additional_users as $additional_user_key=>$additional_user_value){ |
|
741 | + foreach ($additional_users as $additional_user_key=>$additional_user_value) { |
|
742 | 742 | if (!in_array($additional_user_key, $_SESSION['session_user_id']) && |
743 | - !in_array($additional_user_key,$users_of_course) |
|
744 | - ){ |
|
743 | + !in_array($additional_user_key, $users_of_course) |
|
744 | + ) { |
|
745 | 745 | $users[] = array( |
746 | 746 | $additional_user_value['col0'], |
747 | 747 | $additional_user_value['col1'], |
@@ -792,20 +792,20 @@ discard block |
||
792 | 792 | |
793 | 793 | function active_filter($active, $url_params, $row) { |
794 | 794 | $_user = api_get_user_info(); |
795 | - if ($active=='1') { |
|
796 | - $action='AccountActive'; |
|
797 | - $image='accept'; |
|
795 | + if ($active == '1') { |
|
796 | + $action = 'AccountActive'; |
|
797 | + $image = 'accept'; |
|
798 | 798 | } |
799 | 799 | |
800 | - if ($active=='0') { |
|
801 | - $action='AccountInactive'; |
|
802 | - $image='error'; |
|
800 | + if ($active == '0') { |
|
801 | + $action = 'AccountInactive'; |
|
802 | + $image = 'error'; |
|
803 | 803 | } |
804 | 804 | $result = null; |
805 | - if ($row['0']<>$_user['user_id']) { |
|
805 | + if ($row['0'] <> $_user['user_id']) { |
|
806 | 806 | // you cannot lock yourself out otherwise you could disable all the accounts |
807 | 807 | // including your own => everybody is locked out and nobody can change it anymore. |
808 | - $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array() , ICON_SIZE_TINY); |
|
808 | + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array(), ICON_SIZE_TINY); |
|
809 | 809 | } |
810 | 810 | return $result; |
811 | 811 | } |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | $profiling_field_options_exact_values[] = $profiling_field_options; |
840 | 840 | } |
841 | 841 | $profiling_field_options_exact_values_sql = ''; |
842 | - foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue){ |
|
842 | + foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue) { |
|
843 | 843 | $profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') "; |
844 | 844 | } |
845 | 845 | |
@@ -880,9 +880,9 @@ discard block |
||
880 | 880 | function display_extra_profile_fields_filter() |
881 | 881 | { |
882 | 882 | // getting all the additional user profile fields |
883 | - $extra = UserManager::get_extra_fields(0,50,5,'ASC'); |
|
883 | + $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC'); |
|
884 | 884 | |
885 | - $return='<option value="">'.get_lang('SelectFilter').'</option>'; |
|
885 | + $return = '<option value="">'.get_lang('SelectFilter').'</option>'; |
|
886 | 886 | |
887 | 887 | // looping through the additional user profile fields |
888 | 888 | foreach ($extra as $id => $field_details) { |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | case ExtraField::FIELD_TYPE_SELECT: |
899 | 899 | case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: |
900 | 900 | $return .= '<optgroup label="'.$field_details[3].'">'; |
901 | - foreach($field_details[9] as $option_id => $option_details) { |
|
901 | + foreach ($field_details[9] as $option_id => $option_details) { |
|
902 | 902 | if ($_GET['subscribe_user_filter_value'] == $field_details[0].'*'.$option_details[1]) { |
903 | 903 | $selected = 'selected="selected"'; |
904 | 904 | } else { |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | // Access restriction |
26 | 26 | if (!api_is_allowed_to_edit()) { |
27 | - api_not_allowed(true); |
|
27 | + api_not_allowed(true); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $tool_name = get_lang("SubscribeUserToCourse"); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $courseInfo = api_get_course_info(); |
35 | 35 | |
36 | 36 | if ($type == COURSEMANAGER) { |
37 | - $tool_name = get_lang("SubscribeUserToCourseAsTeacher"); |
|
37 | + $tool_name = get_lang("SubscribeUserToCourseAsTeacher"); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | //extra entries in breadcrumb |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | "url" => "subscribe_user.php?type=".$type.'&'.api_get_cidreq(), |
48 | 48 | "name" => $tool_name, |
49 | 49 | ); |
50 | - $tool_name = get_lang('SearchResults'); |
|
50 | + $tool_name = get_lang('SearchResults'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $current_session_id = api_get_session_id(); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ); |
77 | 77 | } |
78 | 78 | |
79 | - $user_id_temp = $_SESSION['session_user_id']; |
|
79 | + $user_id_temp = $_SESSION['session_user_id']; |
|
80 | 80 | |
81 | 81 | if (is_array($user_id_temp)) { |
82 | 82 | $counter = count($user_id_temp); |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | |
170 | 170 | header('Location:'.api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'&type='.$type); |
171 | 171 | exit; |
172 | - break; |
|
173 | - } |
|
172 | + break; |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if (!empty($_SESSION['session_user_id'])) { |
177 | - unset($_SESSION['session_user_id']); |
|
177 | + unset($_SESSION['session_user_id']); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | if (!empty($_SESSION['session_user_name'])) { |
181 | - unset($_SESSION['session_user_name']); |
|
181 | + unset($_SESSION['session_user_name']); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $is_western_name_order = api_is_western_name_order(); |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | |
187 | 187 | // Build table |
188 | 188 | $table = new SortableTable( |
189 | - 'subscribe_users', |
|
190 | - 'get_number_of_users', |
|
191 | - 'get_user_data', |
|
192 | - ($is_western_name_order xor $sort_by_first_name) ? 3 : 2 |
|
189 | + 'subscribe_users', |
|
190 | + 'get_number_of_users', |
|
191 | + 'get_user_data', |
|
192 | + ($is_western_name_order xor $sort_by_first_name) ? 3 : 2 |
|
193 | 193 | ); |
194 | 194 | $parameters['keyword'] = $keyword; |
195 | 195 | $parameters['type'] = $type; |
@@ -272,20 +272,20 @@ discard block |
||
272 | 272 | */ |
273 | 273 | function get_number_of_users() |
274 | 274 | { |
275 | - // Database table definition |
|
276 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
277 | - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
278 | - $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
279 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
275 | + // Database table definition |
|
276 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
277 | + $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
278 | + $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
279 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
280 | 280 | |
281 | 281 | $courseCode = api_get_course_id(); |
282 | 282 | $sessionId = api_get_session_id(); |
283 | 283 | |
284 | - if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') { |
|
284 | + if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') { |
|
285 | 285 | |
286 | - if (api_get_session_id() != 0) { |
|
286 | + if (api_get_session_id() != 0) { |
|
287 | 287 | |
288 | - $sql = "SELECT COUNT(u.user_id) |
|
288 | + $sql = "SELECT COUNT(u.user_id) |
|
289 | 289 | FROM $user_table u |
290 | 290 | LEFT JOIN $tbl_session_rel_course_user cu |
291 | 291 | ON |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | u.status = 1 AND |
298 | 298 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
299 | 299 | |
300 | - if (api_is_multiple_url_enabled()) { |
|
301 | - $url_access_id = api_get_current_access_url_id(); |
|
302 | - if ($url_access_id !=-1) { |
|
303 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
304 | - $sql = "SELECT COUNT(u.user_id) |
|
300 | + if (api_is_multiple_url_enabled()) { |
|
301 | + $url_access_id = api_get_current_access_url_id(); |
|
302 | + if ($url_access_id !=-1) { |
|
303 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
304 | + $sql = "SELECT COUNT(u.user_id) |
|
305 | 305 | FROM $user_table u |
306 | 306 | LEFT JOIN $tbl_session_rel_course_user cu |
307 | 307 | ON |
@@ -315,34 +315,34 @@ discard block |
||
315 | 315 | u.status = 1 AND |
316 | 316 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) |
317 | 317 | "; |
318 | - } |
|
319 | - } |
|
320 | - } else { |
|
321 | - $sql = "SELECT COUNT(u.user_id) |
|
318 | + } |
|
319 | + } |
|
320 | + } else { |
|
321 | + $sql = "SELECT COUNT(u.user_id) |
|
322 | 322 | FROM $user_table u |
323 | 323 | LEFT JOIN $course_user_table cu |
324 | 324 | ON u.user_id = cu.user_id and c_id='".api_get_course_int_id()."' |
325 | 325 | WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
326 | 326 | |
327 | - if (api_is_multiple_url_enabled()) { |
|
328 | - $url_access_id = api_get_current_access_url_id(); |
|
329 | - if ($url_access_id !=-1) { |
|
330 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
327 | + if (api_is_multiple_url_enabled()) { |
|
328 | + $url_access_id = api_get_current_access_url_id(); |
|
329 | + if ($url_access_id !=-1) { |
|
330 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
331 | 331 | |
332 | - $sql = "SELECT COUNT(u.user_id) |
|
332 | + $sql = "SELECT COUNT(u.user_id) |
|
333 | 333 | FROM $user_table u |
334 | 334 | LEFT JOIN $course_user_table cu |
335 | 335 | ON u.user_id = cu.user_id AND c_id='".api_get_course_int_id()."' |
336 | 336 | INNER JOIN $tbl_url_rel_user as url_rel_user |
337 | 337 | ON (url_rel_user.user_id = u.user_id) |
338 | 338 | WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
339 | - } |
|
340 | - } |
|
341 | - } |
|
342 | - } else { |
|
343 | - // students |
|
344 | - if (api_get_session_id() != 0) { |
|
345 | - $sql = "SELECT COUNT(u.user_id) |
|
339 | + } |
|
340 | + } |
|
341 | + } |
|
342 | + } else { |
|
343 | + // students |
|
344 | + if (api_get_session_id() != 0) { |
|
345 | + $sql = "SELECT COUNT(u.user_id) |
|
346 | 346 | FROM $user_table u |
347 | 347 | LEFT JOIN $tbl_session_rel_course_user cu |
348 | 348 | ON |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | u.status<>".DRH." AND |
355 | 355 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
356 | 356 | |
357 | - if (api_is_multiple_url_enabled()) { |
|
358 | - $url_access_id = api_get_current_access_url_id(); |
|
359 | - if ($url_access_id !=-1) { |
|
360 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
361 | - $sql = "SELECT COUNT(u.user_id) |
|
357 | + if (api_is_multiple_url_enabled()) { |
|
358 | + $url_access_id = api_get_current_access_url_id(); |
|
359 | + if ($url_access_id !=-1) { |
|
360 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
361 | + $sql = "SELECT COUNT(u.user_id) |
|
362 | 362 | FROM $user_table u |
363 | 363 | LEFT JOIN $tbl_session_rel_course_user cu |
364 | 364 | ON |
@@ -372,21 +372,21 @@ discard block |
||
372 | 372 | u.status<>".DRH." AND |
373 | 373 | access_url_id= $url_access_id AND |
374 | 374 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
375 | - } |
|
376 | - } |
|
377 | - } else { |
|
378 | - $sql = "SELECT COUNT(u.user_id) |
|
375 | + } |
|
376 | + } |
|
377 | + } else { |
|
378 | + $sql = "SELECT COUNT(u.user_id) |
|
379 | 379 | FROM $user_table u |
380 | 380 | LEFT JOIN $course_user_table cu |
381 | 381 | ON u.user_id = cu.user_id AND c_id='".api_get_course_int_id()."'"; |
382 | 382 | |
383 | - // we change the SQL when we have a filter |
|
384 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
383 | + // we change the SQL when we have a filter |
|
384 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
385 | 385 | !empty($_GET['subscribe_user_filter_value']) && |
386 | 386 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
387 | 387 | ){ |
388 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
389 | - $sql .= " |
|
388 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
389 | + $sql .= " |
|
390 | 390 | LEFT JOIN $table_user_field_values field_values |
391 | 391 | ON field_values.item_id = u.user_id |
392 | 392 | WHERE |
@@ -395,32 +395,32 @@ discard block |
||
395 | 395 | field_values.field_id = '".intval($field_identification[0])."' AND |
396 | 396 | field_values.value = '".Database::escape_string($field_identification[1])."' |
397 | 397 | "; |
398 | - } else { |
|
399 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
400 | - } |
|
398 | + } else { |
|
399 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
400 | + } |
|
401 | 401 | |
402 | - if (api_is_multiple_url_enabled()) { |
|
403 | - $url_access_id = api_get_current_access_url_id(); |
|
402 | + if (api_is_multiple_url_enabled()) { |
|
403 | + $url_access_id = api_get_current_access_url_id(); |
|
404 | 404 | |
405 | - if ($url_access_id !=-1) { |
|
405 | + if ($url_access_id !=-1) { |
|
406 | 406 | |
407 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
407 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
408 | 408 | |
409 | - $sql = "SELECT COUNT(u.user_id) |
|
409 | + $sql = "SELECT COUNT(u.user_id) |
|
410 | 410 | FROM $user_table u |
411 | 411 | LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and c_id='".api_get_course_int_id()."' |
412 | 412 | INNER JOIN $tbl_url_rel_user as url_rel_user |
413 | 413 | ON (url_rel_user.user_id = u.user_id) |
414 | 414 | WHERE cu.user_id IS NULL AND access_url_id= $url_access_id AND u.status<>".DRH." "; |
415 | - } |
|
416 | - } |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - // when there is a keyword then we are searching and we have to change the SQL statement |
|
421 | - if (isset($_GET['keyword']) AND !empty($_GET['keyword'])) { |
|
422 | - $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
423 | - $sql .= " AND ( |
|
415 | + } |
|
416 | + } |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + // when there is a keyword then we are searching and we have to change the SQL statement |
|
421 | + if (isset($_GET['keyword']) AND !empty($_GET['keyword'])) { |
|
422 | + $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
423 | + $sql .= " AND ( |
|
424 | 424 | firstname LIKE '%".$keyword."%' OR |
425 | 425 | lastname LIKE '%".$keyword."%' OR |
426 | 426 | email LIKE '%".$keyword."%' OR |
@@ -428,37 +428,37 @@ discard block |
||
428 | 428 | official_code LIKE '%".$keyword."%' |
429 | 429 | )"; |
430 | 430 | |
431 | - // we also want to search for users who have something in their profile fields that matches the keyword |
|
432 | - if (api_get_setting('ProfilingFilterAddingUsers') == 'true') { |
|
433 | - $additional_users = search_additional_profile_fields($keyword); |
|
434 | - } |
|
431 | + // we also want to search for users who have something in their profile fields that matches the keyword |
|
432 | + if (api_get_setting('ProfilingFilterAddingUsers') == 'true') { |
|
433 | + $additional_users = search_additional_profile_fields($keyword); |
|
434 | + } |
|
435 | 435 | |
436 | - // getting all the users of the course (to make sure that we do not display users that are already in the course) |
|
437 | - if (!empty($_SESSION["id_session"])) { |
|
436 | + // getting all the users of the course (to make sure that we do not display users that are already in the course) |
|
437 | + if (!empty($_SESSION["id_session"])) { |
|
438 | 438 | $a_course_users = CourseManager:: get_user_list_from_course_code( |
439 | 439 | $courseCode, |
440 | 440 | $sessionId |
441 | 441 | ); |
442 | - } else { |
|
442 | + } else { |
|
443 | 443 | $a_course_users = CourseManager:: get_user_list_from_course_code( |
444 | 444 | $courseCode, |
445 | 445 | 0 |
446 | 446 | ); |
447 | - } |
|
448 | - foreach ($a_course_users as $user_id=>$course_user) { |
|
449 | - $users_of_course[] = $course_user['user_id']; |
|
450 | - } |
|
451 | - } |
|
447 | + } |
|
448 | + foreach ($a_course_users as $user_id=>$course_user) { |
|
449 | + $users_of_course[] = $course_user['user_id']; |
|
450 | + } |
|
451 | + } |
|
452 | 452 | $sql .=" AND u.status <> ".ANONYMOUS." "; |
453 | - $res = Database::query($sql); |
|
453 | + $res = Database::query($sql); |
|
454 | 454 | $count_user = 0; |
455 | 455 | |
456 | 456 | if ($res) { |
457 | - $row = Database::fetch_row($res); |
|
458 | - $count_user = $row[0]; |
|
459 | - } |
|
457 | + $row = Database::fetch_row($res); |
|
458 | + $count_user = $row[0]; |
|
459 | + } |
|
460 | 460 | |
461 | - return $count_user; |
|
461 | + return $count_user; |
|
462 | 462 | } |
463 | 463 | /** |
464 | 464 | * Get the users to display on the current page. |
@@ -468,17 +468,17 @@ discard block |
||
468 | 468 | $url_access_id = api_get_current_access_url_id(); |
469 | 469 | $course_code = api_get_course_id(); |
470 | 470 | $session_id = api_get_session_id(); |
471 | - $courseId = api_get_course_int_id(); |
|
471 | + $courseId = api_get_course_int_id(); |
|
472 | 472 | |
473 | - // Database table definitions |
|
474 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
475 | - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
476 | - $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
477 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
473 | + // Database table definitions |
|
474 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
475 | + $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
476 | + $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
477 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
478 | 478 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
479 | 479 | |
480 | 480 | // adding teachers |
481 | - $is_western_name_order = api_is_western_name_order(); |
|
481 | + $is_western_name_order = api_is_western_name_order(); |
|
482 | 482 | |
483 | 483 | if (api_get_setting('show_email_addresses') == 'true') { |
484 | 484 | |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | u.active AS col4, |
504 | 504 | u.user_id AS col5"; |
505 | 505 | } |
506 | - if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) { |
|
507 | - // adding a teacher through a session |
|
508 | - if (!empty($session_id)) { |
|
509 | - $sql = "SELECT $select_fields |
|
506 | + if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) { |
|
507 | + // adding a teacher through a session |
|
508 | + if (!empty($session_id)) { |
|
509 | + $sql = "SELECT $select_fields |
|
510 | 510 | FROM $user_table u |
511 | 511 | LEFT JOIN $tbl_session_rel_course_user cu |
512 | 512 | ON |
@@ -516,13 +516,13 @@ discard block |
||
516 | 516 | INNER JOIN $tbl_url_rel_user as url_rel_user |
517 | 517 | ON (url_rel_user.user_id = u.user_id) "; |
518 | 518 | |
519 | - // applying the filter of the additional user profile fields |
|
520 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
521 | - !empty($_GET['subscribe_user_filter_value']) && |
|
522 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
523 | - ) { |
|
524 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
525 | - $sql .= " |
|
519 | + // applying the filter of the additional user profile fields |
|
520 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
521 | + !empty($_GET['subscribe_user_filter_value']) && |
|
522 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
523 | + ) { |
|
524 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
525 | + $sql .= " |
|
526 | 526 | LEFT JOIN $table_user_field_values field_values |
527 | 527 | ON field_values.item_id = u.user_id |
528 | 528 | WHERE |
@@ -531,53 +531,53 @@ discard block |
||
531 | 531 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) AND |
532 | 532 | field_values.field_id = '".intval($field_identification[0])."' AND |
533 | 533 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
534 | - } else { |
|
535 | - $sql .= "WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
|
536 | - } |
|
534 | + } else { |
|
535 | + $sql .= "WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
|
536 | + } |
|
537 | 537 | |
538 | 538 | $sql .= " AND access_url_id= $url_access_id"; |
539 | 539 | |
540 | - } else { |
|
541 | - // adding a teacher NOT through a session |
|
542 | - $sql = "SELECT $select_fields |
|
540 | + } else { |
|
541 | + // adding a teacher NOT through a session |
|
542 | + $sql = "SELECT $select_fields |
|
543 | 543 | FROM $user_table u |
544 | 544 | LEFT JOIN $course_user_table cu |
545 | 545 | ON u.user_id = cu.user_id AND c_id = '".$courseId."'"; |
546 | 546 | |
547 | - // applying the filter of the additional user profile fields |
|
548 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
549 | - !empty($_GET['subscribe_user_filter_value']) && |
|
550 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
551 | - ) { |
|
552 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
553 | - $sql .= " |
|
547 | + // applying the filter of the additional user profile fields |
|
548 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
549 | + !empty($_GET['subscribe_user_filter_value']) && |
|
550 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
551 | + ) { |
|
552 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
553 | + $sql .= " |
|
554 | 554 | LEFT JOIN $table_user_field_values field_values |
555 | 555 | ON field_values.item_id = u.user_id |
556 | 556 | WHERE |
557 | 557 | cu.user_id IS NULL AND u.status<>".DRH." AND |
558 | 558 | field_values.field_id = '".intval($field_identification[0])."' AND |
559 | 559 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
560 | - } else { |
|
561 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
562 | - } |
|
563 | - |
|
564 | - // adding a teacher NOT trough a session on a portal with multiple URLs |
|
565 | - if (api_is_multiple_url_enabled()) { |
|
566 | - if ($url_access_id !=-1) { |
|
567 | - $sql = "SELECT $select_fields |
|
560 | + } else { |
|
561 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
562 | + } |
|
563 | + |
|
564 | + // adding a teacher NOT trough a session on a portal with multiple URLs |
|
565 | + if (api_is_multiple_url_enabled()) { |
|
566 | + if ($url_access_id !=-1) { |
|
567 | + $sql = "SELECT $select_fields |
|
568 | 568 | FROM $user_table u |
569 | 569 | LEFT JOIN $course_user_table cu |
570 | 570 | ON u.user_id = cu.user_id and c_id='".$courseId."' |
571 | 571 | INNER JOIN $tbl_url_rel_user as url_rel_user |
572 | 572 | ON (url_rel_user.user_id = u.user_id) "; |
573 | 573 | |
574 | - // applying the filter of the additional user profile fields |
|
575 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
576 | - !empty($_GET['subscribe_user_filter_value']) && |
|
577 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
578 | - ){ |
|
579 | - $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
580 | - $sql .= " |
|
574 | + // applying the filter of the additional user profile fields |
|
575 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
576 | + !empty($_GET['subscribe_user_filter_value']) && |
|
577 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
578 | + ){ |
|
579 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
580 | + $sql .= " |
|
581 | 581 | LEFT JOIN $table_user_field_values field_values |
582 | 582 | ON field_values.item_id = u.user_id |
583 | 583 | WHERE |
@@ -585,16 +585,16 @@ discard block |
||
585 | 585 | u.status<>".DRH." AND |
586 | 586 | field_values.field_id = '".intval($field_identification[0])."' AND |
587 | 587 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
588 | - } else { |
|
589 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
590 | - } |
|
591 | - } |
|
592 | - } |
|
593 | - } |
|
594 | - } else { |
|
595 | - // adding a student |
|
596 | - if (!empty($session_id)) { |
|
597 | - $sql = "SELECT $select_fields |
|
588 | + } else { |
|
589 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + } else { |
|
595 | + // adding a student |
|
596 | + if (!empty($session_id)) { |
|
597 | + $sql = "SELECT $select_fields |
|
598 | 598 | FROM $user_table u |
599 | 599 | LEFT JOIN $tbl_session_rel_course_user cu |
600 | 600 | ON |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | $sql .= "AND access_url_id = $url_access_id"; |
630 | 630 | } |
631 | 631 | |
632 | - } else { |
|
632 | + } else { |
|
633 | 633 | $sql = "SELECT $select_fields |
634 | 634 | FROM $user_table u |
635 | 635 | LEFT JOIN $course_user_table cu |
@@ -637,10 +637,10 @@ discard block |
||
637 | 637 | u.user_id = cu.user_id AND |
638 | 638 | c_id ='".$courseId."'"; |
639 | 639 | |
640 | - // applying the filter of the additional user profile fields |
|
641 | - if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])){ |
|
642 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
643 | - $sql .= " |
|
640 | + // applying the filter of the additional user profile fields |
|
641 | + if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])){ |
|
642 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
643 | + $sql .= " |
|
644 | 644 | LEFT JOIN $table_user_field_values field_values |
645 | 645 | ON field_values.item_id = u.user_id |
646 | 646 | WHERE |
@@ -648,28 +648,28 @@ discard block |
||
648 | 648 | u.status<>".DRH." AND |
649 | 649 | field_values.field_id = '".intval($field_identification[0])."' AND |
650 | 650 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
651 | - } else { |
|
652 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
653 | - } |
|
651 | + } else { |
|
652 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
653 | + } |
|
654 | 654 | |
655 | - //showing only the courses of the current Chamilo access_url_id |
|
655 | + //showing only the courses of the current Chamilo access_url_id |
|
656 | 656 | |
657 | - if (api_is_multiple_url_enabled()) { |
|
658 | - if ($url_access_id !=-1) { |
|
659 | - $sql = "SELECT $select_fields |
|
657 | + if (api_is_multiple_url_enabled()) { |
|
658 | + if ($url_access_id !=-1) { |
|
659 | + $sql = "SELECT $select_fields |
|
660 | 660 | FROM $user_table u |
661 | 661 | LEFT JOIN $course_user_table cu |
662 | 662 | ON u.user_id = cu.user_id AND c_id='".$courseId."' |
663 | 663 | INNER JOIN $tbl_url_rel_user as url_rel_user |
664 | 664 | ON (url_rel_user.user_id = u.user_id) "; |
665 | 665 | |
666 | - // applying the filter of the additional user profile fields |
|
667 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
668 | - !empty($_GET['subscribe_user_filter_value']) && |
|
669 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
670 | - ){ |
|
671 | - $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
672 | - $sql .= " |
|
666 | + // applying the filter of the additional user profile fields |
|
667 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
668 | + !empty($_GET['subscribe_user_filter_value']) && |
|
669 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
670 | + ){ |
|
671 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
672 | + $sql .= " |
|
673 | 673 | LEFT JOIN $table_user_field_values field_values |
674 | 674 | ON field_values.item_id = u.user_id |
675 | 675 | WHERE |
@@ -679,19 +679,19 @@ discard block |
||
679 | 679 | field_values.value = '".Database::escape_string($field_identification[1])."' AND |
680 | 680 | access_url_id = $url_access_id |
681 | 681 | "; |
682 | - } else { |
|
683 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
684 | - } |
|
685 | - } |
|
686 | - } |
|
687 | - } |
|
688 | - } |
|
689 | - |
|
690 | - // adding additional WHERE statements to the SQL for the search functionality |
|
682 | + } else { |
|
683 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
684 | + } |
|
685 | + } |
|
686 | + } |
|
687 | + } |
|
688 | + } |
|
689 | + |
|
690 | + // adding additional WHERE statements to the SQL for the search functionality |
|
691 | 691 | $additional_users = null; |
692 | - if (isset($_REQUEST['keyword'])) { |
|
693 | - $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
694 | - $sql .= " AND ( |
|
692 | + if (isset($_REQUEST['keyword'])) { |
|
693 | + $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
694 | + $sql .= " AND ( |
|
695 | 695 | firstname LIKE '%".$keyword."%' OR |
696 | 696 | lastname LIKE '%".$keyword."%' OR |
697 | 697 | email LIKE '%".$keyword."%' OR |
@@ -700,46 +700,46 @@ discard block |
||
700 | 700 | ) |
701 | 701 | "; |
702 | 702 | |
703 | - if (api_get_setting('ProfilingFilterAddingUsers') == 'true') { |
|
704 | - // we also want to search for users who have something in |
|
705 | - // their profile fields that matches the keyword |
|
706 | - $additional_users = search_additional_profile_fields($keyword); |
|
707 | - } |
|
708 | - |
|
709 | - // getting all the users of the course (to make sure that we do not |
|
710 | - // display users that are already in the course) |
|
711 | - if (!empty($session_id)) { |
|
712 | - $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $session_id); |
|
713 | - } else { |
|
714 | - $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0); |
|
715 | - } |
|
716 | - foreach ($a_course_users as $user_id=>$course_user) { |
|
717 | - $users_of_course[] = $course_user['user_id']; |
|
718 | - } |
|
719 | - } |
|
720 | - |
|
721 | - $sql .=" AND u.status != ".ANONYMOUS." "; |
|
722 | - |
|
723 | - // Sorting and pagination (used by the sortable table) |
|
724 | - $sql .= " ORDER BY col$column $direction "; |
|
725 | - $sql .= " LIMIT $from,$number_of_items"; |
|
726 | - |
|
727 | - $res = Database::query($sql); |
|
728 | - $users = array (); |
|
729 | - while ($user = Database::fetch_row($res)) { |
|
730 | - $users[] = $user; |
|
731 | - $_SESSION['session_user_id'][] = $user[0]; |
|
732 | - if ($is_western_name_order) { |
|
733 | - $_SESSION['session_user_name'][] = api_get_person_name($user[2], $user[3]); |
|
734 | - } else { |
|
735 | - $_SESSION['session_user_name'][] = api_get_person_name($user[3], $user[2]); |
|
736 | - } |
|
737 | - } |
|
738 | - // adding additional users based on the search on the additional profile fields |
|
739 | - if (isset($_REQUEST['keyword'])){ |
|
740 | - if (is_array($additional_users)) { |
|
741 | - foreach($additional_users as $additional_user_key=>$additional_user_value){ |
|
742 | - if (!in_array($additional_user_key, $_SESSION['session_user_id']) && |
|
703 | + if (api_get_setting('ProfilingFilterAddingUsers') == 'true') { |
|
704 | + // we also want to search for users who have something in |
|
705 | + // their profile fields that matches the keyword |
|
706 | + $additional_users = search_additional_profile_fields($keyword); |
|
707 | + } |
|
708 | + |
|
709 | + // getting all the users of the course (to make sure that we do not |
|
710 | + // display users that are already in the course) |
|
711 | + if (!empty($session_id)) { |
|
712 | + $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $session_id); |
|
713 | + } else { |
|
714 | + $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0); |
|
715 | + } |
|
716 | + foreach ($a_course_users as $user_id=>$course_user) { |
|
717 | + $users_of_course[] = $course_user['user_id']; |
|
718 | + } |
|
719 | + } |
|
720 | + |
|
721 | + $sql .=" AND u.status != ".ANONYMOUS." "; |
|
722 | + |
|
723 | + // Sorting and pagination (used by the sortable table) |
|
724 | + $sql .= " ORDER BY col$column $direction "; |
|
725 | + $sql .= " LIMIT $from,$number_of_items"; |
|
726 | + |
|
727 | + $res = Database::query($sql); |
|
728 | + $users = array (); |
|
729 | + while ($user = Database::fetch_row($res)) { |
|
730 | + $users[] = $user; |
|
731 | + $_SESSION['session_user_id'][] = $user[0]; |
|
732 | + if ($is_western_name_order) { |
|
733 | + $_SESSION['session_user_name'][] = api_get_person_name($user[2], $user[3]); |
|
734 | + } else { |
|
735 | + $_SESSION['session_user_name'][] = api_get_person_name($user[3], $user[2]); |
|
736 | + } |
|
737 | + } |
|
738 | + // adding additional users based on the search on the additional profile fields |
|
739 | + if (isset($_REQUEST['keyword'])){ |
|
740 | + if (is_array($additional_users)) { |
|
741 | + foreach($additional_users as $additional_user_key=>$additional_user_value){ |
|
742 | + if (!in_array($additional_user_key, $_SESSION['session_user_id']) && |
|
743 | 743 | !in_array($additional_user_key,$users_of_course) |
744 | 744 | ){ |
745 | 745 | $users[] = array( |
@@ -751,11 +751,11 @@ discard block |
||
751 | 751 | $additional_user_value['col5'], |
752 | 752 | $additional_user_value['col6'], |
753 | 753 | ); |
754 | - } |
|
755 | - } |
|
756 | - } |
|
757 | - } |
|
758 | - return $users; |
|
754 | + } |
|
755 | + } |
|
756 | + } |
|
757 | + } |
|
758 | + return $users; |
|
759 | 759 | } |
760 | 760 | /** |
761 | 761 | * Returns a mailto-link |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | * @return string HTML-code with a mailto-link |
764 | 764 | */ |
765 | 765 | function email_filter($email) { |
766 | - return Display :: encrypted_mailto_link($email, $email); |
|
766 | + return Display :: encrypted_mailto_link($email, $email); |
|
767 | 767 | } |
768 | 768 | /** |
769 | 769 | * Build the reg-column of the table |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | } else { |
777 | 777 | $type = STUDENT; |
778 | 778 | } |
779 | - $result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?register=yes&type='.$type.'&user_id='.$user_id.'">'.get_lang("reg").'</a>'; |
|
780 | - return $result; |
|
779 | + $result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?register=yes&type='.$type.'&user_id='.$user_id.'">'.get_lang("reg").'</a>'; |
|
780 | + return $result; |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | /** |
@@ -791,23 +791,23 @@ discard block |
||
791 | 791 | */ |
792 | 792 | |
793 | 793 | function active_filter($active, $url_params, $row) { |
794 | - $_user = api_get_user_info(); |
|
795 | - if ($active=='1') { |
|
796 | - $action='AccountActive'; |
|
797 | - $image='accept'; |
|
798 | - } |
|
799 | - |
|
800 | - if ($active=='0') { |
|
801 | - $action='AccountInactive'; |
|
802 | - $image='error'; |
|
803 | - } |
|
794 | + $_user = api_get_user_info(); |
|
795 | + if ($active=='1') { |
|
796 | + $action='AccountActive'; |
|
797 | + $image='accept'; |
|
798 | + } |
|
799 | + |
|
800 | + if ($active=='0') { |
|
801 | + $action='AccountInactive'; |
|
802 | + $image='error'; |
|
803 | + } |
|
804 | 804 | $result = null; |
805 | - if ($row['0']<>$_user['user_id']) { |
|
806 | - // you cannot lock yourself out otherwise you could disable all the accounts |
|
807 | - // including your own => everybody is locked out and nobody can change it anymore. |
|
808 | - $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array() , ICON_SIZE_TINY); |
|
809 | - } |
|
810 | - return $result; |
|
805 | + if ($row['0']<>$_user['user_id']) { |
|
806 | + // you cannot lock yourself out otherwise you could disable all the accounts |
|
807 | + // including your own => everybody is locked out and nobody can change it anymore. |
|
808 | + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array() , ICON_SIZE_TINY); |
|
809 | + } |
|
810 | + return $result; |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | /** |
@@ -825,29 +825,29 @@ discard block |
||
825 | 825 | */ |
826 | 826 | function search_additional_profile_fields($keyword) |
827 | 827 | { |
828 | - // database table definitions |
|
829 | - $table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS); |
|
830 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
828 | + // database table definitions |
|
829 | + $table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS); |
|
830 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
831 | 831 | $tableExtraField = Database::get_main_table(TABLE_EXTRA_FIELD); |
832 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
832 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
833 | 833 | |
834 | - // getting the field option text that match this keyword (for radio buttons and checkboxes) |
|
835 | - $sql = "SELECT * FROM $table_user_field_options |
|
834 | + // getting the field option text that match this keyword (for radio buttons and checkboxes) |
|
835 | + $sql = "SELECT * FROM $table_user_field_options |
|
836 | 836 | WHERE display_text LIKE '%".$keyword."%'"; |
837 | - $result_profiling = Database::query($sql); |
|
838 | - while ($profiling_field_options = Database::fetch_array($result_profiling)) { |
|
839 | - $profiling_field_options_exact_values[] = $profiling_field_options; |
|
840 | - } |
|
837 | + $result_profiling = Database::query($sql); |
|
838 | + while ($profiling_field_options = Database::fetch_array($result_profiling)) { |
|
839 | + $profiling_field_options_exact_values[] = $profiling_field_options; |
|
840 | + } |
|
841 | 841 | $profiling_field_options_exact_values_sql = ''; |
842 | - foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue){ |
|
843 | - $profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') "; |
|
844 | - } |
|
842 | + foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue){ |
|
843 | + $profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') "; |
|
844 | + } |
|
845 | 845 | |
846 | 846 | $extraFieldType = \Chamilo\CoreBundle\Entity\ExtraField::USER_FIELD_TYPE; |
847 | 847 | |
848 | - // getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword |
|
849 | - // or all the users who have entered the keyword in a free-form field |
|
850 | - $sql = "SELECT |
|
848 | + // getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword |
|
849 | + // or all the users who have entered the keyword in a free-form field |
|
850 | + $sql = "SELECT |
|
851 | 851 | user.user_id as col0, |
852 | 852 | user.official_code as col1, |
853 | 853 | user.lastname as col2, |
@@ -861,13 +861,13 @@ discard block |
||
861 | 861 | user_values.field_id = e.id AND |
862 | 862 | e.extra_field_type = $extraFieldType AND |
863 | 863 | (value LIKE '%".$keyword."%'".$profiling_field_options_exact_values_sql.")"; |
864 | - $result = Database::query($sql); |
|
864 | + $result = Database::query($sql); |
|
865 | 865 | $additional_users = array(); |
866 | - while ($profiled_users = Database::fetch_array($result)) { |
|
867 | - $additional_users[$profiled_users['col0']] = $profiled_users; |
|
868 | - } |
|
866 | + while ($profiled_users = Database::fetch_array($result)) { |
|
867 | + $additional_users[$profiled_users['col0']] = $profiled_users; |
|
868 | + } |
|
869 | 869 | |
870 | - return $additional_users; |
|
870 | + return $additional_users; |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | /** |
@@ -879,41 +879,41 @@ discard block |
||
879 | 879 | */ |
880 | 880 | function display_extra_profile_fields_filter() |
881 | 881 | { |
882 | - // getting all the additional user profile fields |
|
883 | - $extra = UserManager::get_extra_fields(0,50,5,'ASC'); |
|
884 | - |
|
885 | - $return='<option value="">'.get_lang('SelectFilter').'</option>'; |
|
886 | - |
|
887 | - // looping through the additional user profile fields |
|
888 | - foreach ($extra as $id => $field_details) { |
|
889 | - // $field_details[2] contains the type of the additional user profile field |
|
890 | - switch ($field_details[2]) { |
|
891 | - // text fields cannot be used as a filter |
|
892 | - case ExtraField::FIELD_TYPE_TEXT: |
|
893 | - break; |
|
894 | - // text area fields cannot be used as a filter |
|
895 | - case ExtraField::FIELD_TYPE_TEXTAREA: |
|
896 | - break; |
|
897 | - case ExtraField::FIELD_TYPE_RADIO: |
|
898 | - case ExtraField::FIELD_TYPE_SELECT: |
|
899 | - case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: |
|
900 | - $return .= '<optgroup label="'.$field_details[3].'">'; |
|
901 | - foreach($field_details[9] as $option_id => $option_details) { |
|
902 | - if ($_GET['subscribe_user_filter_value'] == $field_details[0].'*'.$option_details[1]) { |
|
903 | - $selected = 'selected="selected"'; |
|
904 | - } else { |
|
905 | - $selected = false; |
|
906 | - } |
|
907 | - $return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>'; |
|
908 | - } |
|
909 | - $return .= '</optgroup>'; |
|
910 | - break; |
|
911 | - } |
|
912 | - } |
|
913 | - |
|
914 | - echo '<form id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?api_get_cidreq" style="float:left;">'; |
|
915 | - echo ' <input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />'; |
|
916 | - echo '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>'; |
|
917 | - echo '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>'; |
|
918 | - echo '</form>'; |
|
882 | + // getting all the additional user profile fields |
|
883 | + $extra = UserManager::get_extra_fields(0,50,5,'ASC'); |
|
884 | + |
|
885 | + $return='<option value="">'.get_lang('SelectFilter').'</option>'; |
|
886 | + |
|
887 | + // looping through the additional user profile fields |
|
888 | + foreach ($extra as $id => $field_details) { |
|
889 | + // $field_details[2] contains the type of the additional user profile field |
|
890 | + switch ($field_details[2]) { |
|
891 | + // text fields cannot be used as a filter |
|
892 | + case ExtraField::FIELD_TYPE_TEXT: |
|
893 | + break; |
|
894 | + // text area fields cannot be used as a filter |
|
895 | + case ExtraField::FIELD_TYPE_TEXTAREA: |
|
896 | + break; |
|
897 | + case ExtraField::FIELD_TYPE_RADIO: |
|
898 | + case ExtraField::FIELD_TYPE_SELECT: |
|
899 | + case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: |
|
900 | + $return .= '<optgroup label="'.$field_details[3].'">'; |
|
901 | + foreach($field_details[9] as $option_id => $option_details) { |
|
902 | + if ($_GET['subscribe_user_filter_value'] == $field_details[0].'*'.$option_details[1]) { |
|
903 | + $selected = 'selected="selected"'; |
|
904 | + } else { |
|
905 | + $selected = false; |
|
906 | + } |
|
907 | + $return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>'; |
|
908 | + } |
|
909 | + $return .= '</optgroup>'; |
|
910 | + break; |
|
911 | + } |
|
912 | + } |
|
913 | + |
|
914 | + echo '<form id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?api_get_cidreq" style="float:left;">'; |
|
915 | + echo ' <input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />'; |
|
916 | + echo '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>'; |
|
917 | + echo '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>'; |
|
918 | + echo '</form>'; |
|
919 | 919 | } |
@@ -735,7 +735,6 @@ |
||
735 | 735 | * lock = the user can no longer use this account |
736 | 736 | * @author Patrick Cool <[email protected]>, Ghent University |
737 | 737 | * @param int $active the current state of the account |
738 | - * @param int $user_id The user id |
|
739 | 738 | * @param string $urlParams |
740 | 739 | * |
741 | 740 | * @return string Some HTML-code with the lock/unlock button |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | $use_anonymous = true; |
15 | 15 | require_once '../inc/global.inc.php'; |
16 | -$current_course_tool = TOOL_USER; |
|
16 | +$current_course_tool = TOOL_USER; |
|
17 | 17 | $this_section = SECTION_COURSES; |
18 | 18 | |
19 | 19 | // notice for unauthorized people. |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | //Can't auto unregister from a session |
43 | 43 | if (!empty($sessionId)) { |
44 | - $course_info['unsubscribe'] = 0; |
|
44 | + $course_info['unsubscribe'] = 0; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /* Unregistering a user section */ |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | '#', |
173 | 173 | get_lang('UserPicture'), |
174 | 174 | get_lang('OfficialCode'), |
175 | - get_lang('FirstName') . ', ' . get_lang('LastName'), |
|
175 | + get_lang('FirstName').', '.get_lang('LastName'), |
|
176 | 176 | get_lang('Email'), |
177 | 177 | get_lang('Phone') |
178 | 178 | ); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | '#', |
182 | 182 | get_lang('UserPicture'), |
183 | 183 | get_lang('OfficialCode'), |
184 | - get_lang('LastName') . ', ' . get_lang('FirstName'), |
|
184 | + get_lang('LastName').', '.get_lang('FirstName'), |
|
185 | 185 | get_lang('Email'), |
186 | 186 | get_lang('Phone') |
187 | 187 | ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | if (api_is_multiple_url_enabled()) { |
207 | 207 | $sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au '; |
208 | 208 | } |
209 | - $sql .=" WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id "; |
|
209 | + $sql .= " WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id "; |
|
210 | 210 | $sql .= ' AND session_id = '.$sessionId; |
211 | 211 | |
212 | 212 | if (api_is_multiple_url_enabled()) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | true |
241 | 241 | ); |
242 | 242 | if (!empty($extra_fields)) { |
243 | - foreach($extra_fields as $key => $extra_value) { |
|
243 | + foreach ($extra_fields as $key => $extra_value) { |
|
244 | 244 | $user[$key] = $extra_value; |
245 | 245 | } |
246 | 246 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $counter, |
255 | 255 | $user_image, |
256 | 256 | $user['official_code'], |
257 | - $user['firstname'] . ', ' . $user['lastname'], |
|
257 | + $user['firstname'].', '.$user['lastname'], |
|
258 | 258 | $user['email'], |
259 | 259 | $user['phone'] |
260 | 260 | ); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $counter, |
264 | 264 | $user_image, |
265 | 265 | $user['official_code'], |
266 | - $user['lastname'] . ', ' . $user['firstname'], |
|
266 | + $user['lastname'].', '.$user['firstname'], |
|
267 | 267 | $user['email'], |
268 | 268 | $user['phone'] |
269 | 269 | ); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $counter, |
343 | 343 | $user_image, |
344 | 344 | $user['official_code'], |
345 | - $user['firstname'] . ', ' . $user['lastname'], |
|
345 | + $user['firstname'].', '.$user['lastname'], |
|
346 | 346 | $user['email'], |
347 | 347 | $user['phone'] |
348 | 348 | ); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $counter, |
352 | 352 | $user_image, |
353 | 353 | $user['official_code'], |
354 | - $user['lastname'] . ', ' . $user['firstname'], |
|
354 | + $user['lastname'].', '.$user['firstname'], |
|
355 | 355 | $user['email'], |
356 | 356 | $user['phone'] |
357 | 357 | ); |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | $userInfo = api_get_user_info($user_id); |
702 | 702 | $userPicture = $userInfo['avatar']; |
703 | 703 | |
704 | - $photo= '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />'; |
|
704 | + $photo = '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />'; |
|
705 | 705 | |
706 | 706 | $temp[] = $user_id; |
707 | 707 | $temp[] = $photo; |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | if (api_get_setting('allow_user_course_subscription_by_course_admin') === 'true' or api_is_platform_admin()) { |
827 | 827 | // unregister |
828 | 828 | if ($user_id != $current_user_id || api_is_platform_admin()) { |
829 | - $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'. |
|
829 | + $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;">'. |
|
830 | 830 | get_lang('Unreg').'</a> '; |
831 | 831 | } else { |
832 | 832 | //$result .= Display::return_icon('unsubscribe_course_na.png', get_lang('Unreg'),'',ICON_SIZE_SMALL).'</a> '; |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | // Show buttons for unsubscribe |
837 | 837 | if ($course_info['unsubscribe'] == 1) { |
838 | 838 | if ($user_id == $current_user_id) { |
839 | - $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'. |
|
839 | + $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;">'. |
|
840 | 840 | get_lang('Unreg').'</a> '; |
841 | 841 | } |
842 | 842 | } |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | |
918 | 918 | // Actions column |
919 | 919 | $table->set_header($header_nr++, get_lang('Action'), false); |
920 | - $table->set_column_filter($header_nr-1, 'modify_filter'); |
|
920 | + $table->set_column_filter($header_nr - 1, 'modify_filter'); |
|
921 | 921 | |
922 | 922 | if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') { |
923 | 923 | $table->set_form_actions(array('unsubscribe' => get_lang('Unreg')), 'user'); |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | } else { |
926 | 926 | if ($course_info['unsubscribe'] == 1) { |
927 | 927 | $table->set_header($header_nr++, get_lang('Action'), false); |
928 | - $table->set_column_filter($header_nr-1, 'modify_filter'); |
|
928 | + $table->set_column_filter($header_nr - 1, 'modify_filter'); |
|
929 | 929 | } |
930 | 930 | } |
931 | 931 | |
@@ -981,19 +981,19 @@ discard block |
||
981 | 981 | echo '<div class="col-md-6">'; |
982 | 982 | echo $icon; |
983 | 983 | $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=csv&type='.$type.'">'. |
984 | - Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
984 | + Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
985 | 985 | $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=xls&type='.$type.'">'. |
986 | - Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
986 | + Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
987 | 987 | |
988 | 988 | if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' || |
989 | 989 | api_is_platform_admin() |
990 | 990 | ) { |
991 | 991 | $actions .= '<a href="user_import.php?'.api_get_cidreq().'&action=import">'. |
992 | - Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
992 | + Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=pdf&type='.$type.'">'. |
996 | - Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
996 | + Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
997 | 997 | echo $actions; |
998 | 998 | |
999 | 999 | echo '</div>'; |
@@ -17,6 +17,9 @@ |
||
17 | 17 | define('WS_ERROR_INVALID_INPUT', 3); |
18 | 18 | define('WS_ERROR_SETTING', 4); |
19 | 19 | |
20 | +/** |
|
21 | + * @param integer $code |
|
22 | + */ |
|
20 | 23 | function return_error($code) { |
21 | 24 | $fault = null; |
22 | 25 | switch ($code) { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | if ($debug) { |
78 | - error_log("checkip " . intval($check_ip)); |
|
78 | + error_log("checkip ".intval($check_ip)); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | if ($check_ip) { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | '', |
132 | 132 | 'SOAP-ENC:Array', |
133 | 133 | array(), |
134 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:portalItem[]')),'tns:portalItem' |
|
134 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:portalItem[]')), 'tns:portalItem' |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | $server->wsdl->addComplexType( |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | ); |
147 | 147 | |
148 | 148 | // Register the method to expose |
149 | -$server->register('WSGetPortals', // method name |
|
150 | - array('getPortals' => 'tns:getPortals'), // input parameters |
|
151 | - array('return' => 'tns:portalList'), // output parameters |
|
152 | - 'urn:WSAccessUrl', // namespace |
|
153 | - 'urn:WSAccessUrl#WSGetPortals', // soapaction |
|
154 | - 'rpc', // style |
|
155 | - 'encoded', // use |
|
149 | +$server->register('WSGetPortals', // method name |
|
150 | + array('getPortals' => 'tns:getPortals'), // input parameters |
|
151 | + array('return' => 'tns:portalList'), // output parameters |
|
152 | + 'urn:WSAccessUrl', // namespace |
|
153 | + 'urn:WSAccessUrl#WSGetPortals', // soapaction |
|
154 | + 'rpc', // style |
|
155 | + 'encoded', // use |
|
156 | 156 | 'This service adds a user to portal' // documentation |
157 | 157 | ); |
158 | 158 | |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | ); |
194 | 194 | |
195 | 195 | // Register the method to expose |
196 | -$server->register('WSAddUserToPortal', // method name |
|
197 | - array('addUserToPortal' => 'tns:AddUserToPortal'), // input parameters |
|
198 | - array('return' => 'xsd:string'), // output parameters |
|
199 | - 'urn:WSAccessUrl', // namespace |
|
200 | - 'urn:WSAccessUrl#WSAddUserToPortal', // soapaction |
|
201 | - 'rpc', // style |
|
202 | - 'encoded', // use |
|
196 | +$server->register('WSAddUserToPortal', // method name |
|
197 | + array('addUserToPortal' => 'tns:AddUserToPortal'), // input parameters |
|
198 | + array('return' => 'xsd:string'), // output parameters |
|
199 | + 'urn:WSAccessUrl', // namespace |
|
200 | + 'urn:WSAccessUrl#WSAddUserToPortal', // soapaction |
|
201 | + 'rpc', // style |
|
202 | + 'encoded', // use |
|
203 | 203 | 'This service adds a user to portal' // documentation |
204 | 204 | ); |
205 | 205 | |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | } |
225 | 225 | |
226 | 226 | // Register the method to expose |
227 | -$server->register('WSRemoveUserFromPortal', // method name |
|
228 | - array('removeUserFromPortal' => 'tns:AddUserToPortal'), // input parameters |
|
229 | - array('return' => 'xsd:string'), // output parameters |
|
230 | - 'urn:WSAccessUrl', // namespace |
|
231 | - 'urn:WSAccessUrl#WSRemoveUserFromPortal', // soapaction |
|
232 | - 'rpc', // style |
|
233 | - 'encoded', // use |
|
227 | +$server->register('WSRemoveUserFromPortal', // method name |
|
228 | + array('removeUserFromPortal' => 'tns:AddUserToPortal'), // input parameters |
|
229 | + array('return' => 'xsd:string'), // output parameters |
|
230 | + 'urn:WSAccessUrl', // namespace |
|
231 | + 'urn:WSAccessUrl#WSRemoveUserFromPortal', // soapaction |
|
232 | + 'rpc', // style |
|
233 | + 'encoded', // use |
|
234 | 234 | 'This service remove a user from a portal' // documentation |
235 | 235 | ); |
236 | 236 | |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | ); |
268 | 268 | |
269 | 269 | // Register the method to expose |
270 | -$server->register('WSGetPortalListFromUser', // method name |
|
271 | - array('getPortalListFromUser' => 'tns:getPortalListFromUser'), // input parameters |
|
272 | - array('return' => 'tns:portalList'), // output parameters |
|
273 | - 'urn:WSAccessUrl', // namespace |
|
274 | - 'urn:WSAccessUrl#WSGetPortalListFromUser', // soapaction |
|
275 | - 'rpc', // style |
|
276 | - 'encoded', // use |
|
270 | +$server->register('WSGetPortalListFromUser', // method name |
|
271 | + array('getPortalListFromUser' => 'tns:getPortalListFromUser'), // input parameters |
|
272 | + array('return' => 'tns:portalList'), // output parameters |
|
273 | + 'urn:WSAccessUrl', // namespace |
|
274 | + 'urn:WSAccessUrl#WSGetPortalListFromUser', // soapaction |
|
275 | + 'rpc', // style |
|
276 | + 'encoded', // use |
|
277 | 277 | 'This service remove a user from a portal' // documentation |
278 | 278 | ); |
279 | 279 | |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | ); |
312 | 312 | |
313 | 313 | // Register the method to expose |
314 | -$server->register('WSGetPortalListFromCourse', // method name |
|
315 | - array('getPortalListFromCourse' => 'tns:getPortalListFromCourse'), // input parameters |
|
316 | - array('return' => 'tns:portalList'), // output parameters |
|
317 | - 'urn:WSAccessUrl', // namespace |
|
318 | - 'urn:WSAccessUrl#getPortalListFromCourse', // soapaction |
|
319 | - 'rpc', // style |
|
320 | - 'encoded', // use |
|
314 | +$server->register('WSGetPortalListFromCourse', // method name |
|
315 | + array('getPortalListFromCourse' => 'tns:getPortalListFromCourse'), // input parameters |
|
316 | + array('return' => 'tns:portalList'), // output parameters |
|
317 | + 'urn:WSAccessUrl', // namespace |
|
318 | + 'urn:WSAccessUrl#getPortalListFromCourse', // soapaction |
|
319 | + 'rpc', // style |
|
320 | + 'encoded', // use |
|
321 | 321 | 'This service remove a user from a portal' // documentation |
322 | 322 | ); |
323 | 323 | |
@@ -361,13 +361,13 @@ discard block |
||
361 | 361 | ); |
362 | 362 | |
363 | 363 | // Register the method to expose |
364 | -$server->register('WSAddCourseToPortal', // method name |
|
365 | - array('addCourseToPortal' => 'tns:addCourseToPortal'), // input parameters |
|
366 | - array('return' => 'xsd:string'), // output parameters |
|
367 | - 'urn:WSAccessUrl', // namespace |
|
368 | - 'urn:WSAccessUrl#WSAddCourseToPortal', // soapaction |
|
369 | - 'rpc', // style |
|
370 | - 'encoded', // use |
|
364 | +$server->register('WSAddCourseToPortal', // method name |
|
365 | + array('addCourseToPortal' => 'tns:addCourseToPortal'), // input parameters |
|
366 | + array('return' => 'xsd:string'), // output parameters |
|
367 | + 'urn:WSAccessUrl', // namespace |
|
368 | + 'urn:WSAccessUrl#WSAddCourseToPortal', // soapaction |
|
369 | + 'rpc', // style |
|
370 | + 'encoded', // use |
|
371 | 371 | 'This service adds a course to portal' // documentation |
372 | 372 | ); |
373 | 373 | |
@@ -394,13 +394,13 @@ discard block |
||
394 | 394 | } |
395 | 395 | |
396 | 396 | // Register the method to expose |
397 | -$server->register('WSRemoveCourseFromPortal', // method name |
|
398 | - array('removeCourseFromPortal' => 'tns:addCourseToPortal'), // input parameters |
|
399 | - array('return' => 'xsd:string'), // output parameters |
|
400 | - 'urn:WSAccessUrl', // namespace |
|
401 | - 'urn:WSAccessUrl#WSRemoveCourseFromPortal', // soapaction |
|
402 | - 'rpc', // style |
|
403 | - 'encoded', // use |
|
397 | +$server->register('WSRemoveCourseFromPortal', // method name |
|
398 | + array('removeCourseFromPortal' => 'tns:addCourseToPortal'), // input parameters |
|
399 | + array('return' => 'xsd:string'), // output parameters |
|
400 | + 'urn:WSAccessUrl', // namespace |
|
401 | + 'urn:WSAccessUrl#WSRemoveCourseFromPortal', // soapaction |
|
402 | + 'rpc', // style |
|
403 | + 'encoded', // use |
|
404 | 404 | 'This service remove a course from a portal' // documentation |
405 | 405 | ); |
406 | 406 |
@@ -58,19 +58,22 @@ discard block |
||
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 |
||
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 |
@@ -84,7 +84,7 @@ |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | - * @param $directoryPath |
|
87 | + * @param string $directoryPath |
|
88 | 88 | * @return bool |
89 | 89 | */ |
90 | 90 | function deleteDirectory($directoryPath) |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | { |
20 | 20 | $fileData = $pptData['file_data']; |
21 | 21 | $dataInfo = pathinfo($pptData['file_name']); |
22 | - $fileName = basename($pptData['file_name'], '.' . $dataInfo['extension']); |
|
22 | + $fileName = basename($pptData['file_name'], '.'.$dataInfo['extension']); |
|
23 | 23 | $fullFileName = $pptData['file_name']; |
24 | 24 | |
25 | 25 | $tempArchivePath = api_get_path(SYS_ARCHIVE_PATH); |
26 | - $tempPath = $tempArchivePath . 'wsConvert/' . $fileName . '/'; |
|
27 | - $tempPathNewFiles = $tempArchivePath . 'wsConvert/' . $fileName . '-n/'; |
|
26 | + $tempPath = $tempArchivePath.'wsConvert/'.$fileName.'/'; |
|
27 | + $tempPathNewFiles = $tempArchivePath.'wsConvert/'.$fileName.'-n/'; |
|
28 | 28 | |
29 | 29 | $perms = api_get_permissions_for_new_directories(); |
30 | 30 | if (!is_dir($tempPath)) { |
@@ -33,28 +33,28 @@ discard block |
||
33 | 33 | if (!is_dir($tempPathNewFiles)) { |
34 | 34 | mkdir($tempPathNewFiles, $perms, true); |
35 | 35 | } |
36 | - if (!is_dir($tempPathNewFiles . $fileName)) { |
|
37 | - mkdir($tempPathNewFiles . $fileName, $perms, true); |
|
36 | + if (!is_dir($tempPathNewFiles.$fileName)) { |
|
37 | + mkdir($tempPathNewFiles.$fileName, $perms, true); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $file = base64_decode($fileData); |
41 | - file_put_contents($tempPath . $fullFileName, $file); |
|
41 | + file_put_contents($tempPath.$fullFileName, $file); |
|
42 | 42 | |
43 | 43 | if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php |
44 | - $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'); |
|
45 | - $classPath = $converterPath . ';' . $converterPath . '/jodconverter-2.2.2.jar;' . $converterPath . '/jodconverter-cli-2.2.2.jar'; |
|
46 | - $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $classPath . '" DokeosConverter'; |
|
44 | + $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png'); |
|
45 | + $classPath = $converterPath.';'.$converterPath.'/jodconverter-2.2.2.jar;'.$converterPath.'/jodconverter-cli-2.2.2.jar'; |
|
46 | + $cmd = 'java -Dfile.encoding=UTF-8 -cp "'.$classPath.'" DokeosConverter'; |
|
47 | 47 | } else { |
48 | - $converterPath = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'; |
|
48 | + $converterPath = api_get_path(SYS_PATH).'main/inc/lib/ppt2png'; |
|
49 | 49 | $classPath = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar'; |
50 | - $cmd = 'cd ' . $converterPath . ' && java ' . $classPath . ' DokeosConverter'; |
|
50 | + $cmd = 'cd '.$converterPath.' && java '.$classPath.' DokeosConverter'; |
|
51 | 51 | } |
52 | 52 | |
53 | - $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port'); |
|
54 | - $cmd .= ' -w 720 -h 540 -d oogie "' . $tempPath . $fullFileName.'" "' . $tempPathNewFiles . $fileName . '.html"'; |
|
53 | + $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port'); |
|
54 | + $cmd .= ' -w 720 -h 540 -d oogie "'.$tempPath.$fullFileName.'" "'.$tempPathNewFiles.$fileName.'.html"'; |
|
55 | 55 | |
56 | 56 | $perms = api_get_permissions_for_new_files(); |
57 | - chmod($tempPathNewFiles . $fileName, $perms); |
|
57 | + chmod($tempPathNewFiles.$fileName, $perms); |
|
58 | 58 | |
59 | 59 | $files = array(); |
60 | 60 | $return = 0; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $images = array(); |
65 | 65 | foreach ($files as $file) { |
66 | 66 | $imageData = explode('||', $file); |
67 | - $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles . $fileName . '/' . $imageData[1])); |
|
67 | + $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles.$fileName.'/'.$imageData[1])); |
|
68 | 68 | } |
69 | 69 | $data = array( |
70 | 70 | 'files' => $files, |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | function deleteDirectory($directoryPath) |
91 | 91 | { |
92 | - $files = array_diff(scandir($directoryPath), array('.','..')); |
|
92 | + $files = array_diff(scandir($directoryPath), array('.', '..')); |
|
93 | 93 | foreach ($files as $file) { |
94 | 94 | if (is_dir("$directoryPath/$file")) { |
95 | 95 | deleteDirectory("$directoryPath/$file"); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $webCodePath = api_get_path(WEB_CODE_PATH); |
107 | 107 | $options = array( |
108 | 108 | 'uri' => $webPath, |
109 | - 'location' => $webCodePath . 'webservices/additional_webservices.php' |
|
109 | + 'location' => $webCodePath.'webservices/additional_webservices.php' |
|
110 | 110 | ); |
111 | 111 | |
112 | 112 | $soapServer = new SoapServer(NULL, $options); |
@@ -32,6 +32,8 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @param int Error code |
34 | 34 | * @param string Error message |
35 | + * @param integer $code |
|
36 | + * @param string $message |
|
35 | 37 | */ |
36 | 38 | public function __construct($code, $message) { |
37 | 39 | $this->code = $code; |
@@ -42,6 +44,7 @@ discard block |
||
42 | 44 | * Sets the error handler |
43 | 45 | * |
44 | 46 | * @param WSErrorHandler Error handler |
47 | + * @param WSCMSoapErrorHandler $handler |
|
45 | 48 | */ |
46 | 49 | public static function setErrorHandler($handler) { |
47 | 50 | if($handler instanceof WSErrorHandler) { |
@@ -76,6 +79,7 @@ discard block |
||
76 | 79 | * Handle method |
77 | 80 | * |
78 | 81 | * @param WSError Error |
82 | + * @return void |
|
79 | 83 | */ |
80 | 84 | public function handle($error); |
81 | 85 | } |
@@ -102,7 +106,7 @@ discard block |
||
102 | 106 | * Verifies the API key |
103 | 107 | * |
104 | 108 | * @param string Secret key |
105 | - * @return mixed WSError in case of failure, null in case of success |
|
109 | + * @return WSCMError|null WSError in case of failure, null in case of success |
|
106 | 110 | */ |
107 | 111 | protected function verifyKey($secret_key) { |
108 | 112 | $ip = trim($_SERVER['REMOTE_ADDR']); |
@@ -6,120 +6,120 @@ discard block |
||
6 | 6 | * Error returned by one of the methods of the web service. Contains an error code and an error message |
7 | 7 | */ |
8 | 8 | class WSCMError { |
9 | - /** |
|
10 | - * Error handler. This needs to be a class that implements the interface WSErrorHandler |
|
11 | - * |
|
12 | - * @var WSErrorHandler |
|
13 | - */ |
|
14 | - protected static $_handler; |
|
9 | + /** |
|
10 | + * Error handler. This needs to be a class that implements the interface WSErrorHandler |
|
11 | + * |
|
12 | + * @var WSErrorHandler |
|
13 | + */ |
|
14 | + protected static $_handler; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Error code |
|
18 | - * |
|
19 | - * @var int |
|
20 | - */ |
|
21 | - public $code; |
|
16 | + /** |
|
17 | + * Error code |
|
18 | + * |
|
19 | + * @var int |
|
20 | + */ |
|
21 | + public $code; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Error message |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - public $message; |
|
23 | + /** |
|
24 | + * Error message |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + public $message; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Constructor |
|
32 | - * |
|
33 | - * @param int Error code |
|
34 | - * @param string Error message |
|
35 | - */ |
|
36 | - public function __construct($code, $message) { |
|
37 | - $this->code = $code; |
|
38 | - $this->message = $message; |
|
39 | - } |
|
30 | + /** |
|
31 | + * Constructor |
|
32 | + * |
|
33 | + * @param int Error code |
|
34 | + * @param string Error message |
|
35 | + */ |
|
36 | + public function __construct($code, $message) { |
|
37 | + $this->code = $code; |
|
38 | + $this->message = $message; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Sets the error handler |
|
43 | - * |
|
44 | - * @param WSErrorHandler Error handler |
|
45 | - */ |
|
46 | - public static function setErrorHandler($handler) { |
|
47 | - if($handler instanceof WSErrorHandler) { |
|
48 | - self::$_handler = $handler; |
|
49 | - } |
|
50 | - } |
|
41 | + /** |
|
42 | + * Sets the error handler |
|
43 | + * |
|
44 | + * @param WSErrorHandler Error handler |
|
45 | + */ |
|
46 | + public static function setErrorHandler($handler) { |
|
47 | + if($handler instanceof WSErrorHandler) { |
|
48 | + self::$_handler = $handler; |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Returns the error handler |
|
54 | - * |
|
55 | - * @return WSErrorHandler Error handler |
|
56 | - */ |
|
57 | - public static function getErrorHandler() { |
|
58 | - return self::$_handler; |
|
59 | - } |
|
52 | + /** |
|
53 | + * Returns the error handler |
|
54 | + * |
|
55 | + * @return WSErrorHandler Error handler |
|
56 | + */ |
|
57 | + public static function getErrorHandler() { |
|
58 | + return self::$_handler; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Transforms the error into an array |
|
63 | - * |
|
64 | - * @return array Associative array with code and message |
|
65 | - */ |
|
66 | - public function toArray() { |
|
67 | - return array('code' => $this->code, 'message' => $this->message); |
|
68 | - } |
|
61 | + /** |
|
62 | + * Transforms the error into an array |
|
63 | + * |
|
64 | + * @return array Associative array with code and message |
|
65 | + */ |
|
66 | + public function toArray() { |
|
67 | + return array('code' => $this->code, 'message' => $this->message); |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Interface that must be implemented by any error handler |
73 | 73 | */ |
74 | 74 | interface WSCMErrorHandler { |
75 | - /** |
|
76 | - * Handle method |
|
77 | - * |
|
78 | - * @param WSError Error |
|
79 | - */ |
|
80 | - public function handle($error); |
|
75 | + /** |
|
76 | + * Handle method |
|
77 | + * |
|
78 | + * @param WSError Error |
|
79 | + */ |
|
80 | + public function handle($error); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Main class of the webservice. Webservice classes extend this class |
85 | 85 | */ |
86 | 86 | class WSCM { |
87 | - /** |
|
88 | - * Chamilo configuration |
|
89 | - * |
|
90 | - * @var array |
|
91 | - */ |
|
92 | - protected $_configuration; |
|
87 | + /** |
|
88 | + * Chamilo configuration |
|
89 | + * |
|
90 | + * @var array |
|
91 | + */ |
|
92 | + protected $_configuration; |
|
93 | 93 | |
94 | - /** |
|
95 | - * Constructor |
|
96 | - */ |
|
97 | - public function __construct() { |
|
98 | - $this->_configuration = $GLOBALS['_configuration']; |
|
99 | - } |
|
94 | + /** |
|
95 | + * Constructor |
|
96 | + */ |
|
97 | + public function __construct() { |
|
98 | + $this->_configuration = $GLOBALS['_configuration']; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Verifies the API key |
|
103 | - * |
|
104 | - * @param string Secret key |
|
105 | - * @return mixed WSError in case of failure, null in case of success |
|
106 | - */ |
|
107 | - protected function verifyKey($secret_key) { |
|
108 | - $ip = trim($_SERVER['REMOTE_ADDR']); |
|
109 | - // if we are behind a reverse proxy, assume it will send the |
|
110 | - // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
111 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
112 | - list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
113 | - $ip = trim($ip1); |
|
114 | - } |
|
115 | - $security_key = $ip.$this->_configuration['security_key']; |
|
101 | + /** |
|
102 | + * Verifies the API key |
|
103 | + * |
|
104 | + * @param string Secret key |
|
105 | + * @return mixed WSError in case of failure, null in case of success |
|
106 | + */ |
|
107 | + protected function verifyKey($secret_key) { |
|
108 | + $ip = trim($_SERVER['REMOTE_ADDR']); |
|
109 | + // if we are behind a reverse proxy, assume it will send the |
|
110 | + // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
111 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
112 | + list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
113 | + $ip = trim($ip1); |
|
114 | + } |
|
115 | + $security_key = $ip.$this->_configuration['security_key']; |
|
116 | 116 | |
117 | - if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
118 | - return new WSCMError(1, "API key is invalid"); |
|
119 | - } else { |
|
120 | - return null; |
|
121 | - } |
|
122 | - } |
|
117 | + if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
118 | + return new WSCMError(1, "API key is invalid"); |
|
119 | + } else { |
|
120 | + return null; |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Verifies if the user is valid |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | $login = $username; |
135 | 135 | $password = $pass; |
136 | 136 | |
137 | - //lookup the user in the main database |
|
137 | + //lookup the user in the main database |
|
138 | 138 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
139 | - $sql = "SELECT user_id, username, password, auth_source, active, expiration_date |
|
139 | + $sql = "SELECT user_id, username, password, auth_source, active, expiration_date |
|
140 | 140 | FROM $user_table |
141 | 141 | WHERE username = '".trim(addslashes($login))."'"; |
142 | - $result = Database::query($sql); |
|
142 | + $result = Database::query($sql); |
|
143 | 143 | |
144 | 144 | if (Database::num_rows($result) > 0) { |
145 | 145 | $uData = Database::fetch_array($result); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Return the encrypted pass |
174 | - * @deprecated |
|
174 | + * @deprecated |
|
175 | 175 | * @param <String> $pass |
176 | 176 | * @return <String> $pass encrypted |
177 | 177 | */ |
@@ -180,112 +180,112 @@ discard block |
||
180 | 180 | }*/ |
181 | 181 | |
182 | 182 | /** |
183 | - * Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
184 | - * in the system database |
|
185 | - * |
|
186 | - * @param string User id field name |
|
187 | - * @param string User id value |
|
188 | - * @return mixed System user id if the user was found, WSError otherwise |
|
189 | - */ |
|
190 | - protected function getUserId($user_id_field_name, $user_id_value) { |
|
191 | - if($user_id_field_name == "chamilo_user_id") { |
|
192 | - if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
193 | - return intval($user_id_value); |
|
194 | - } else { |
|
195 | - return new WSCMError(100, "User not found"); |
|
196 | - } |
|
197 | - } else { |
|
198 | - $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
|
199 | - if($user_id == 0) { |
|
200 | - return new WSCMError(100, "User not found"); |
|
201 | - } else { |
|
202 | - return $user_id; |
|
203 | - } |
|
204 | - } |
|
205 | - } |
|
183 | + * Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
184 | + * in the system database |
|
185 | + * |
|
186 | + * @param string User id field name |
|
187 | + * @param string User id value |
|
188 | + * @return mixed System user id if the user was found, WSError otherwise |
|
189 | + */ |
|
190 | + protected function getUserId($user_id_field_name, $user_id_value) { |
|
191 | + if($user_id_field_name == "chamilo_user_id") { |
|
192 | + if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
193 | + return intval($user_id_value); |
|
194 | + } else { |
|
195 | + return new WSCMError(100, "User not found"); |
|
196 | + } |
|
197 | + } else { |
|
198 | + $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
|
199 | + if($user_id == 0) { |
|
200 | + return new WSCMError(100, "User not found"); |
|
201 | + } else { |
|
202 | + return $user_id; |
|
203 | + } |
|
204 | + } |
|
205 | + } |
|
206 | 206 | |
207 | - /** |
|
208 | - * Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
209 | - * in the system database |
|
210 | - * |
|
211 | - * @param string Course id field name |
|
212 | - * @param string Course id value |
|
213 | - * @return mixed System course id if the course was found, WSError otherwise |
|
214 | - */ |
|
215 | - protected function getCourseId($course_id_field_name, $course_id_value) { |
|
216 | - if($course_id_field_name == "chamilo_course_id") { |
|
217 | - if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
218 | - return intval($course_id_value); |
|
219 | - } else { |
|
220 | - return new WSCMError(200, "Course not found"); |
|
221 | - } |
|
222 | - } else { |
|
223 | - $courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name); |
|
224 | - if (empty($courseId)) { |
|
225 | - return new WSCMError(200, "Course not found"); |
|
226 | - } else { |
|
227 | - return $courseId; |
|
228 | - } |
|
229 | - } |
|
230 | - } |
|
207 | + /** |
|
208 | + * Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
209 | + * in the system database |
|
210 | + * |
|
211 | + * @param string Course id field name |
|
212 | + * @param string Course id value |
|
213 | + * @return mixed System course id if the course was found, WSError otherwise |
|
214 | + */ |
|
215 | + protected function getCourseId($course_id_field_name, $course_id_value) { |
|
216 | + if($course_id_field_name == "chamilo_course_id") { |
|
217 | + if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
218 | + return intval($course_id_value); |
|
219 | + } else { |
|
220 | + return new WSCMError(200, "Course not found"); |
|
221 | + } |
|
222 | + } else { |
|
223 | + $courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name); |
|
224 | + if (empty($courseId)) { |
|
225 | + return new WSCMError(200, "Course not found"); |
|
226 | + } else { |
|
227 | + return $courseId; |
|
228 | + } |
|
229 | + } |
|
230 | + } |
|
231 | 231 | |
232 | - /** |
|
233 | - * Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
234 | - * in the system database |
|
235 | - * |
|
236 | - * @param string Session id field name |
|
237 | - * @param string Session id value |
|
238 | - * @return mixed System session id if the session was found, WSError otherwise |
|
239 | - */ |
|
240 | - protected function getSessionId($session_id_field_name, $session_id_value) |
|
241 | - { |
|
242 | - if ($session_id_field_name == "chamilo_session_id") { |
|
243 | - $session = SessionManager::fetch((int)$session_id_value); |
|
244 | - if(!empty($session)) { |
|
245 | - return intval($session_id_value); |
|
246 | - } else { |
|
247 | - return new WSCMError(300, "Session not found"); |
|
248 | - } |
|
249 | - } else { |
|
250 | - $session_id = SessionManager::getSessionIdFromOriginalId( |
|
251 | - $session_id_value, |
|
252 | - $session_id_field_name |
|
253 | - ); |
|
254 | - if($session_id == 0) { |
|
255 | - return new WSCMError(300, "Session not found"); |
|
256 | - } else { |
|
257 | - return $session_id; |
|
258 | - } |
|
259 | - } |
|
260 | - } |
|
232 | + /** |
|
233 | + * Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
234 | + * in the system database |
|
235 | + * |
|
236 | + * @param string Session id field name |
|
237 | + * @param string Session id value |
|
238 | + * @return mixed System session id if the session was found, WSError otherwise |
|
239 | + */ |
|
240 | + protected function getSessionId($session_id_field_name, $session_id_value) |
|
241 | + { |
|
242 | + if ($session_id_field_name == "chamilo_session_id") { |
|
243 | + $session = SessionManager::fetch((int)$session_id_value); |
|
244 | + if(!empty($session)) { |
|
245 | + return intval($session_id_value); |
|
246 | + } else { |
|
247 | + return new WSCMError(300, "Session not found"); |
|
248 | + } |
|
249 | + } else { |
|
250 | + $session_id = SessionManager::getSessionIdFromOriginalId( |
|
251 | + $session_id_value, |
|
252 | + $session_id_field_name |
|
253 | + ); |
|
254 | + if($session_id == 0) { |
|
255 | + return new WSCMError(300, "Session not found"); |
|
256 | + } else { |
|
257 | + return $session_id; |
|
258 | + } |
|
259 | + } |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * Handles an error by calling the WSError error handler |
|
264 | - * |
|
265 | - * @param WSError Error |
|
266 | - */ |
|
267 | - protected function handleError($error) { |
|
268 | - $handler = WSCMError::getErrorHandler(); |
|
269 | - $handler->handle($error); |
|
270 | - } |
|
262 | + /** |
|
263 | + * Handles an error by calling the WSError error handler |
|
264 | + * |
|
265 | + * @param WSError Error |
|
266 | + */ |
|
267 | + protected function handleError($error) { |
|
268 | + $handler = WSCMError::getErrorHandler(); |
|
269 | + $handler->handle($error); |
|
270 | + } |
|
271 | 271 | |
272 | - /** |
|
273 | - * Gets a successful result |
|
274 | - * |
|
275 | - * @return array Array with a code of 0 and a message 'Operation was successful' |
|
276 | - */ |
|
277 | - protected function getSuccessfulResult() { |
|
278 | - return array('code' => 0, 'message' => 'Operation was successful'); |
|
279 | - } |
|
272 | + /** |
|
273 | + * Gets a successful result |
|
274 | + * |
|
275 | + * @return array Array with a code of 0 and a message 'Operation was successful' |
|
276 | + */ |
|
277 | + protected function getSuccessfulResult() { |
|
278 | + return array('code' => 0, 'message' => 'Operation was successful'); |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Test function. Returns the string success |
|
283 | - * |
|
284 | - * @return string Success |
|
285 | - */ |
|
286 | - public function test() { |
|
287 | - return "success"; |
|
288 | - } |
|
281 | + /** |
|
282 | + * Test function. Returns the string success |
|
283 | + * |
|
284 | + * @return string Success |
|
285 | + */ |
|
286 | + public function test() { |
|
287 | + return "success"; |
|
288 | + } |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not) |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param WSErrorHandler Error handler |
45 | 45 | */ |
46 | 46 | public static function setErrorHandler($handler) { |
47 | - if($handler instanceof WSErrorHandler) { |
|
47 | + if ($handler instanceof WSErrorHandler) { |
|
48 | 48 | self::$_handler = $handler; |
49 | 49 | } |
50 | 50 | } |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | // if we are behind a reverse proxy, assume it will send the |
110 | 110 | // HTTP_X_FORWARDED_FOR header and use this IP instead |
111 | 111 | if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
112 | - list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
112 | + list($ip1, $ip2) = split(',', $_SERVER['HTTP_X_FORWARDED_FOR']); |
|
113 | 113 | $ip = trim($ip1); |
114 | 114 | } |
115 | 115 | $security_key = $ip.$this->_configuration['security_key']; |
116 | 116 | |
117 | - if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
117 | + if (!api_is_valid_secret_key($secret_key, $security_key)) { |
|
118 | 118 | return new WSCMError(1, "API key is invalid"); |
119 | 119 | } else { |
120 | 120 | return null; |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | // Check the user's password |
150 | 150 | if ($password == $uData['password'] AND (trim($login) == $uData['username'])) { |
151 | 151 | // Check if the account is active (not locked) |
152 | - if ($uData['active']=='1') { |
|
152 | + if ($uData['active'] == '1') { |
|
153 | 153 | // Check if the expiration date has not been reached |
154 | - if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') { |
|
154 | + if ($uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date'] == '0000-00-00 00:00:00') { |
|
155 | 155 | return "valid"; |
156 | 156 | } |
157 | 157 | else |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | * @return mixed System user id if the user was found, WSError otherwise |
189 | 189 | */ |
190 | 190 | protected function getUserId($user_id_field_name, $user_id_value) { |
191 | - if($user_id_field_name == "chamilo_user_id") { |
|
192 | - if(UserManager::is_user_id_valid(intval($user_id_value))) { |
|
191 | + if ($user_id_field_name == "chamilo_user_id") { |
|
192 | + if (UserManager::is_user_id_valid(intval($user_id_value))) { |
|
193 | 193 | return intval($user_id_value); |
194 | 194 | } else { |
195 | 195 | return new WSCMError(100, "User not found"); |
196 | 196 | } |
197 | 197 | } else { |
198 | 198 | $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name); |
199 | - if($user_id == 0) { |
|
199 | + if ($user_id == 0) { |
|
200 | 200 | return new WSCMError(100, "User not found"); |
201 | 201 | } else { |
202 | 202 | return $user_id; |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | * @return mixed System course id if the course was found, WSError otherwise |
214 | 214 | */ |
215 | 215 | protected function getCourseId($course_id_field_name, $course_id_value) { |
216 | - if($course_id_field_name == "chamilo_course_id") { |
|
217 | - if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
216 | + if ($course_id_field_name == "chamilo_course_id") { |
|
217 | + if (CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) { |
|
218 | 218 | return intval($course_id_value); |
219 | 219 | } else { |
220 | 220 | return new WSCMError(200, "Course not found"); |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | protected function getSessionId($session_id_field_name, $session_id_value) |
241 | 241 | { |
242 | 242 | if ($session_id_field_name == "chamilo_session_id") { |
243 | - $session = SessionManager::fetch((int)$session_id_value); |
|
244 | - if(!empty($session)) { |
|
243 | + $session = SessionManager::fetch((int) $session_id_value); |
|
244 | + if (!empty($session)) { |
|
245 | 245 | return intval($session_id_value); |
246 | 246 | } else { |
247 | 247 | return new WSCMError(300, "Session not found"); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $session_id_value, |
252 | 252 | $session_id_field_name |
253 | 253 | ); |
254 | - if($session_id == 0) { |
|
254 | + if ($session_id == 0) { |
|
255 | 255 | return new WSCMError(300, "Session not found"); |
256 | 256 | } else { |
257 | 257 | return $session_id; |
@@ -153,18 +153,18 @@ |
||
153 | 153 | // Check if the expiration date has not been reached |
154 | 154 | if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') { |
155 | 155 | return "valid"; |
156 | + } else { |
|
157 | + return get_lang('AccountExpired'); |
|
156 | 158 | } |
157 | - else |
|
158 | - return get_lang('AccountExpired'); |
|
159 | + } else { |
|
160 | + return get_lang('AccountInactive'); |
|
159 | 161 | } |
160 | - else |
|
161 | - return get_lang('AccountInactive'); |
|
162 | + } else { |
|
163 | + return get_lang('InvalidId'); |
|
162 | 164 | } |
163 | - else |
|
164 | - return get_lang('InvalidId'); |
|
165 | + } else { |
|
166 | + return get_lang('AccountURLInactive'); |
|
165 | 167 | } |
166 | - else |
|
167 | - return get_lang('AccountURLInactive'); |
|
168 | 168 | } |
169 | 169 | return get_lang('InvalidId'); |
170 | 170 | } |
@@ -342,6 +342,7 @@ |
||
342 | 342 | * @param string User id value |
343 | 343 | * @param int Set to 1 to subscribe, 0 to unsubscribe |
344 | 344 | * @param int Status (STUDENT or TEACHER) Used for subscription only |
345 | + * @param integer $state |
|
345 | 346 | * @return mixed True if subscription or unsubscription was successful, false otherwise |
346 | 347 | */ |
347 | 348 | protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |
@@ -10,521 +10,521 @@ |
||
10 | 10 | */ |
11 | 11 | class WSCMCourse extends WSCM |
12 | 12 | { |
13 | - /** |
|
14 | - * Deletes a course (helper method) |
|
15 | - * |
|
16 | - * @param string Course id field name |
|
17 | - * @param string Course id value |
|
18 | - * @return mixed True if the course was successfully deleted, WSError otherwise |
|
19 | - */ |
|
20 | - protected function deleteCourseHelper($course_id_field_name, $course_id_value) { |
|
21 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
22 | - if($course_id instanceof WSCMError) { |
|
23 | - return $course_id; |
|
24 | - } else { |
|
25 | - $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
26 | - CourseManager::delete_course($course_code); |
|
27 | - return true; |
|
28 | - } |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Deletes a course |
|
33 | - * |
|
34 | - * @param string API secret key |
|
35 | - * @param string Course id field name |
|
36 | - * @param string Course id value |
|
37 | - */ |
|
38 | - public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) { |
|
39 | - $verifKey = $this->verifyKey($secret_key); |
|
40 | - if($verifKey instanceof WSError) { |
|
41 | - $this->handleError($verifKey); |
|
42 | - } else { |
|
43 | - $result = $this->deleteCourseHelper($course_id_field_name, $course_id_value); |
|
44 | - if($result instanceof WSError) { |
|
45 | - $this->handleError($result); |
|
46 | - } |
|
47 | - } |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Deletes multiple courses |
|
52 | - * |
|
53 | - * @param string API secret key |
|
54 | - * @param array Array of courses with elements of the form array('course_id_field_name' => 'name_of_field', 'course_id_value' => 'value') |
|
55 | - * @return array Array with elements like array('course_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
56 | - * than 0, an error occured |
|
57 | - */ |
|
58 | - public function DeleteCourses($secret_key, $courses) { |
|
59 | - $verifKey = $this->verifyKey($secret_key); |
|
60 | - if($verifKey instanceof WSError) { |
|
61 | - $this->handleError($verifKey); |
|
62 | - } else { |
|
63 | - $results = array(); |
|
64 | - foreach($courses as $course) { |
|
65 | - $result_tmp = array(); |
|
66 | - $result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']); |
|
67 | - $result_tmp['course_id_value'] = $course['course_id_value']; |
|
68 | - if($result_op instanceof WSCMError) { |
|
69 | - // Return the error in the results |
|
70 | - $result_tmp['result'] = $result_op->toArray(); |
|
71 | - } else { |
|
72 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
73 | - } |
|
74 | - $results[] = $result_tmp; |
|
75 | - } |
|
76 | - return $results; |
|
77 | - } |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Creates a course (helper method) |
|
82 | - * |
|
83 | - * @param string Title |
|
84 | - * @param string Category code |
|
85 | - * @param string Wanted code. If it's not defined, it will be generated automatically |
|
86 | - * @param string Tutor name |
|
87 | - * @param string Course admin user id field name |
|
88 | - * @param string Course admin user id value |
|
89 | - * @param string Course language |
|
90 | - * @param string Course id field name |
|
91 | - * @param string Course id value |
|
92 | - * @param array Course extra fields |
|
93 | - * @return mixed Generated id if creation was successful, WSError otherwise |
|
94 | - */ |
|
95 | - protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
|
96 | - // Add the original course id field name and value to the extra fields if needed |
|
97 | - $extras_associative = array(); |
|
98 | - if($course_id_field_name != "chamilo_course_id") { |
|
99 | - $extras_associative[$course_id_field_name] = $course_id_value; |
|
100 | - } |
|
101 | - foreach($extras as $extra) { |
|
102 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
103 | - } |
|
104 | - $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value); |
|
105 | - if($course_admin_id instanceof WSError) { |
|
106 | - return $course_admin_id; |
|
107 | - } |
|
108 | - if($wanted_code == '') { |
|
109 | - $wanted_code = CourseManager::generate_course_code($title); |
|
110 | - } |
|
111 | - $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0); |
|
112 | - if (!$result) { |
|
113 | - return new WSError(202, 'There was an error creating the course'); |
|
114 | - } else { |
|
115 | - // Update extra fields |
|
116 | - foreach($extras_associative as $fname => $fvalue) { |
|
117 | - CourseManager::update_course_extra_field_value($result, $fname, $fvalue); |
|
118 | - } |
|
119 | - // Get course id |
|
120 | - $course_info = CourseManager::get_course_information($result); |
|
121 | - return $course_info['real_id']; |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Creates a course |
|
127 | - * |
|
128 | - * @param string API secret key |
|
129 | - * @param string Title |
|
130 | - * @param string Category code |
|
131 | - * @param string Wanted code. If it's not defined, it will be generated automatically |
|
132 | - * @param string Tutor name |
|
133 | - * @param string Course admin user id field name |
|
134 | - * @param string Course admin user id value |
|
135 | - * @param string Course language |
|
136 | - * @param string Course id field name |
|
137 | - * @param string Course id value |
|
138 | - * @param array Course extra fields |
|
139 | - * @return int Course id generated |
|
140 | - */ |
|
141 | - public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
|
142 | - // First, verify the secret key |
|
143 | - $verifKey = $this->verifyKey($secret_key); |
|
144 | - if($verifKey instanceof WSError) { |
|
145 | - $this->handleError($verifKey); |
|
146 | - } else { |
|
147 | - $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
|
148 | - if($result instanceof WSError) { |
|
149 | - $this->handleError($result); |
|
150 | - } else { |
|
151 | - return $result; |
|
152 | - } |
|
153 | - } |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Create multiple courses |
|
158 | - * |
|
159 | - * @param string API secret key |
|
160 | - * @param array Courses to be created, with elements following the structure presented in CreateCourse |
|
161 | - * @return array Array with elements of the form array('course_id_value' => 'original value sent', 'course_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
162 | - */ |
|
163 | - public function CreateCourses($secret_key, $courses) { |
|
164 | - // First, verify the secret key |
|
165 | - $verifKey = $this->verifyKey($secret_key); |
|
166 | - if($verifKey instanceof WSCMError) { |
|
167 | - $this->handleError($verifKey); |
|
168 | - } else { |
|
169 | - $results = array(); |
|
170 | - foreach($courses as $course) { |
|
171 | - $result_tmp = array(); |
|
172 | - //reinitialize variables just in case |
|
173 | - $title = $category_code = $wanted_code = $tutor_name = $course_admin_user_id_field_name = $course_admin_user_id_value = $language = $course_id_field_name = $course_id_value = $extras = null; |
|
174 | - extract($course); |
|
175 | - $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
|
176 | - if($result instanceof WSCMError) { |
|
177 | - $result_tmp['result'] = $result->toArray(); |
|
178 | - $result_tmp['course_id_value'] = $course_id_value; |
|
179 | - $result_tmp['course_id_generated'] = 0; |
|
180 | - } else { |
|
181 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
182 | - $result_tmp['course_id_value'] = $course_id_value; |
|
183 | - $result_tmp['course_id_generated'] = $result; |
|
184 | - } |
|
185 | - $results[] = $result_tmp; |
|
186 | - } |
|
187 | - return $results; |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Edits a course (helper method) |
|
193 | - * |
|
194 | - * @param string Course id field name |
|
195 | - * @param string Course id value |
|
196 | - * @param string Title |
|
197 | - * @param string Category code |
|
198 | - * @param string Department name |
|
199 | - * @param string Department url |
|
200 | - * @param string Course language |
|
201 | - * @param int Visibility |
|
202 | - * @param int Subscribe (0 = denied, 1 = allowed) |
|
203 | - * @param int Unsubscribe (0 = denied, 1 = allowed) |
|
204 | - * @param string Visual code |
|
205 | - * @param array Course extra fields |
|
206 | - * @return mixed True in case of success, WSError otherwise |
|
207 | - */ |
|
208 | - protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
|
209 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
210 | - if($course_id instanceof WSCMError) { |
|
211 | - return $course_id; |
|
212 | - } else { |
|
213 | - $attributes = array(); |
|
214 | - if(!is_empty($title)) { |
|
215 | - $attributes['title'] = $title; |
|
216 | - } |
|
217 | - if(!is_empty($category_code)) { |
|
218 | - $attributes['category_code'] = $category_code; |
|
219 | - } |
|
220 | - if(!is_empty($department_name)) { |
|
221 | - $attributes['department_name'] = $department_name; |
|
222 | - } |
|
223 | - if(!is_empty($department_url)) { |
|
224 | - $attributes['department_url'] = $department_url; |
|
225 | - } |
|
226 | - if(!is_empty($language)) { |
|
227 | - $attributes['course_language'] = $language; |
|
228 | - } |
|
229 | - if($visibility != '') { |
|
230 | - $attributes['visibility'] = (int)$visibility; |
|
231 | - } |
|
232 | - if($subscribe != '') { |
|
233 | - $attributes['subscribe'] = (int)$subscribe; |
|
234 | - } |
|
235 | - if($unsubscribe != '') { |
|
236 | - $attributes['unsubscribe'] = (int)$unsubscribe; |
|
237 | - } |
|
238 | - if(!is_empty($visual_code)) { |
|
239 | - $attributes['visual_code'] = $visual_code; |
|
240 | - } |
|
241 | - if(!is_empty($attributes)) { |
|
242 | - CourseManager::update_attributes($course_id, $attributes); |
|
243 | - } |
|
244 | - if(!empty($extras)) { |
|
245 | - $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
246 | - $extras_associative = array(); |
|
247 | - foreach($extras as $extra) { |
|
248 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
249 | - } |
|
250 | - foreach($extras_associative as $fname => $fvalue) { |
|
251 | - CourseManager::update_extra_field_value($course_code, $fname, $fvalue); |
|
252 | - } |
|
253 | - } |
|
254 | - return true; |
|
255 | - } |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Edits a course |
|
260 | - * |
|
261 | - * @param string API secret key |
|
262 | - * @param string Course id field name |
|
263 | - * @param string Course id value |
|
264 | - * @param string Title |
|
265 | - * @param string Category code |
|
266 | - * @param string Department name |
|
267 | - * @param string Department url |
|
268 | - * @param string Course language |
|
269 | - * @param int Visibility |
|
270 | - * @param int Subscribe (0 = denied, 1 = allowed) |
|
271 | - * @param int Unsubscribe (0 = denied, 1 = allowed) |
|
272 | - * @param string Visual code |
|
273 | - * @param array Course extra fields |
|
274 | - */ |
|
275 | - public function EditCourse($secret_key, $course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
|
276 | - $verifKey = $this->verifyKey($secret_key); |
|
277 | - if($verifKey instanceof WSCMError) { |
|
278 | - $this->handleError($verifKey); |
|
279 | - } else { |
|
280 | - $result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras); |
|
281 | - if($result instanceof WSCMError) { |
|
282 | - $this->handleError($result); |
|
283 | - } |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * List courses |
|
289 | - * |
|
290 | - * @param string API secret key |
|
291 | - * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
292 | - * @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility', |
|
293 | - * 'category_name' => 'Name of the category of the course', 'number_students' => 'Number of students in the course', 'external_course_id' => 'External course id') |
|
294 | - */ |
|
295 | - public function ListCourses($secret_key, $course_id_field_name) { |
|
296 | - $verifKey = $this->verifyKey($secret_key); |
|
297 | - if($verifKey instanceof WSError) { |
|
298 | - $this->handleError($verifKey); |
|
299 | - } else { |
|
300 | - $courses_result = array(); |
|
301 | - $category_names = array(); |
|
302 | - |
|
303 | - $courses = CourseManager::get_courses_list(); |
|
304 | - foreach($courses as $course) { |
|
305 | - $course_tmp = array(); |
|
306 | - $course_tmp['id'] = $course['id']; |
|
307 | - $course_tmp['code'] = $course['code']; |
|
308 | - $course_tmp['title'] = $course['title']; |
|
309 | - $course_tmp['language'] = $course['course_language']; |
|
310 | - $course_tmp['visibility'] = $course['visibility']; |
|
311 | - |
|
312 | - // Determining category name |
|
313 | - if($category_names[$course['category_code']]) { |
|
314 | - $course_tmp['category_name'] = $category_names[$course['category_code']]; |
|
315 | - } else { |
|
316 | - $category = CourseManager::get_course_category($course['category_code']); |
|
317 | - $category_names[$course['category_code']] = $category['name']; |
|
318 | - $course_tmp['category_name'] = $category['name']; |
|
319 | - } |
|
320 | - |
|
321 | - // Determining number of students registered in course |
|
322 | - $user_list = CourseManager::get_user_list_from_course_code($course['code']); |
|
323 | - $course_tmp['number_students'] = count($user_list); |
|
324 | - |
|
325 | - // Determining external course id |
|
326 | - $course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_id_field_name, $course['code']); |
|
327 | - |
|
328 | - |
|
329 | - $courses_result[] = $course_tmp; |
|
330 | - } |
|
331 | - |
|
332 | - return $courses_result; |
|
333 | - } |
|
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Subscribe or unsubscribe user to a course (helper method) |
|
338 | - * |
|
339 | - * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
340 | - * @param string Course id value. |
|
341 | - * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
342 | - * @param string User id value |
|
343 | - * @param int Set to 1 to subscribe, 0 to unsubscribe |
|
344 | - * @param int Status (STUDENT or TEACHER) Used for subscription only |
|
345 | - * @return mixed True if subscription or unsubscription was successful, false otherwise |
|
346 | - */ |
|
347 | - protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |
|
348 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
349 | - if($course_id instanceof WSError) { |
|
350 | - return $course_id; |
|
351 | - } else { |
|
352 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
353 | - if($user_id instanceof WSError) { |
|
354 | - return $user_id; |
|
355 | - } else { |
|
356 | - $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
357 | - if($state == 0) { |
|
358 | - // Unsubscribe user |
|
359 | - CourseManager::unsubscribe_user($user_id, $course_code); |
|
360 | - return true; |
|
361 | - } else { |
|
362 | - // Subscribe user |
|
363 | - if(CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
364 | - return true; |
|
365 | - } else { |
|
366 | - return new WSError(203, 'An error occured subscribing to this course'); |
|
367 | - } |
|
368 | - } |
|
369 | - } |
|
370 | - } |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * Subscribe user to a course |
|
375 | - * |
|
376 | - * @param string API secret key |
|
377 | - * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
378 | - * @param string Course id value. |
|
379 | - * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
380 | - * @param string User id value |
|
381 | - * @param int Status (1 = Teacher, 5 = Student) |
|
382 | - */ |
|
383 | - public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) { |
|
384 | - $verifKey = $this->verifyKey($secret_key); |
|
385 | - if($verifKey instanceof WSError) { |
|
386 | - $this->handleError($verifKey); |
|
387 | - } else { |
|
388 | - $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status); |
|
389 | - if($result instanceof WSError) { |
|
390 | - $this->handleError($result); |
|
391 | - } |
|
392 | - } |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Unsusbscribe user from course |
|
397 | - * |
|
398 | - * @param string API secret key |
|
399 | - * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
400 | - * @param string Course id value. |
|
401 | - * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
402 | - * @param string User id value |
|
403 | - */ |
|
404 | - public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) { |
|
405 | - $verifKey = $this->verifyKey($secret_key); |
|
406 | - if($verifKey instanceof WSError) { |
|
407 | - $this->handleError($verifKey); |
|
408 | - } else { |
|
409 | - $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0); |
|
410 | - if($result instanceof WSError) { |
|
411 | - $this->handleError($result); |
|
412 | - } |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - /** |
|
417 | - * Returns the descriptions of a course, along with their id |
|
418 | - * |
|
419 | - * @param string API secret key |
|
420 | - * @param string Course id field name |
|
421 | - * @param string Course id value |
|
422 | - * @return array Returns an array with elements of the form ('course_desc_id' => 1, 'course_desc_title' => 'Title', 'course_desc_content' => 'Content') |
|
423 | - */ |
|
424 | - public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) { |
|
425 | - $verifKey = $this->verifyKey($secret_key); |
|
426 | - if($verifKey instanceof WSError) { |
|
427 | - $this->handleError($verifKey); |
|
428 | - } else { |
|
429 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
430 | - if($course_id instanceof WSError) { |
|
431 | - return $course_id; |
|
432 | - } else { |
|
433 | - // Course exists, get its descriptions |
|
434 | - $descriptions = CourseDescription::get_descriptions($course_id); |
|
435 | - $results = array(); |
|
436 | - foreach($descriptions as $description) { |
|
437 | - $results[] = array('course_desc_id' => $description->get_description_type(), |
|
438 | - 'course_desc_title' => $description->get_title(), |
|
439 | - 'course_desc_content' => $description->get_content()); |
|
440 | - } |
|
441 | - return $results; |
|
442 | - } |
|
443 | - } |
|
444 | - } |
|
445 | - |
|
446 | - |
|
447 | - /** |
|
448 | - * Edit course description |
|
449 | - * |
|
450 | - * @param string API secret key |
|
451 | - * @param string Course id field name |
|
452 | - * @param string Course id value |
|
453 | - * @param int Category id from course description |
|
454 | - * @param string Description title |
|
455 | - * @param string Course description content |
|
456 | - */ |
|
457 | - public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) { |
|
458 | - $verifKey = $this->verifyKey($secret_key); |
|
459 | - if($verifKey instanceof WSError) { |
|
460 | - $this->handleError($verifKey); |
|
461 | - } else { |
|
462 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
463 | - if($course_id instanceof WSError) { |
|
464 | - return $course_id; |
|
465 | - } else { |
|
466 | - // Create the new course description |
|
467 | - $cd = new CourseDescription(); |
|
468 | - $cd->set_description_type($course_desc_id); |
|
469 | - $cd->set_title($course_desc_title); |
|
470 | - $cd->set_content($course_desc_content); |
|
471 | - $cd->set_session_id(0); |
|
472 | - |
|
473 | - // Get course info |
|
13 | + /** |
|
14 | + * Deletes a course (helper method) |
|
15 | + * |
|
16 | + * @param string Course id field name |
|
17 | + * @param string Course id value |
|
18 | + * @return mixed True if the course was successfully deleted, WSError otherwise |
|
19 | + */ |
|
20 | + protected function deleteCourseHelper($course_id_field_name, $course_id_value) { |
|
21 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
22 | + if($course_id instanceof WSCMError) { |
|
23 | + return $course_id; |
|
24 | + } else { |
|
25 | + $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
26 | + CourseManager::delete_course($course_code); |
|
27 | + return true; |
|
28 | + } |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Deletes a course |
|
33 | + * |
|
34 | + * @param string API secret key |
|
35 | + * @param string Course id field name |
|
36 | + * @param string Course id value |
|
37 | + */ |
|
38 | + public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) { |
|
39 | + $verifKey = $this->verifyKey($secret_key); |
|
40 | + if($verifKey instanceof WSError) { |
|
41 | + $this->handleError($verifKey); |
|
42 | + } else { |
|
43 | + $result = $this->deleteCourseHelper($course_id_field_name, $course_id_value); |
|
44 | + if($result instanceof WSError) { |
|
45 | + $this->handleError($result); |
|
46 | + } |
|
47 | + } |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Deletes multiple courses |
|
52 | + * |
|
53 | + * @param string API secret key |
|
54 | + * @param array Array of courses with elements of the form array('course_id_field_name' => 'name_of_field', 'course_id_value' => 'value') |
|
55 | + * @return array Array with elements like array('course_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
56 | + * than 0, an error occured |
|
57 | + */ |
|
58 | + public function DeleteCourses($secret_key, $courses) { |
|
59 | + $verifKey = $this->verifyKey($secret_key); |
|
60 | + if($verifKey instanceof WSError) { |
|
61 | + $this->handleError($verifKey); |
|
62 | + } else { |
|
63 | + $results = array(); |
|
64 | + foreach($courses as $course) { |
|
65 | + $result_tmp = array(); |
|
66 | + $result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']); |
|
67 | + $result_tmp['course_id_value'] = $course['course_id_value']; |
|
68 | + if($result_op instanceof WSCMError) { |
|
69 | + // Return the error in the results |
|
70 | + $result_tmp['result'] = $result_op->toArray(); |
|
71 | + } else { |
|
72 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
73 | + } |
|
74 | + $results[] = $result_tmp; |
|
75 | + } |
|
76 | + return $results; |
|
77 | + } |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Creates a course (helper method) |
|
82 | + * |
|
83 | + * @param string Title |
|
84 | + * @param string Category code |
|
85 | + * @param string Wanted code. If it's not defined, it will be generated automatically |
|
86 | + * @param string Tutor name |
|
87 | + * @param string Course admin user id field name |
|
88 | + * @param string Course admin user id value |
|
89 | + * @param string Course language |
|
90 | + * @param string Course id field name |
|
91 | + * @param string Course id value |
|
92 | + * @param array Course extra fields |
|
93 | + * @return mixed Generated id if creation was successful, WSError otherwise |
|
94 | + */ |
|
95 | + protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
|
96 | + // Add the original course id field name and value to the extra fields if needed |
|
97 | + $extras_associative = array(); |
|
98 | + if($course_id_field_name != "chamilo_course_id") { |
|
99 | + $extras_associative[$course_id_field_name] = $course_id_value; |
|
100 | + } |
|
101 | + foreach($extras as $extra) { |
|
102 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
103 | + } |
|
104 | + $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value); |
|
105 | + if($course_admin_id instanceof WSError) { |
|
106 | + return $course_admin_id; |
|
107 | + } |
|
108 | + if($wanted_code == '') { |
|
109 | + $wanted_code = CourseManager::generate_course_code($title); |
|
110 | + } |
|
111 | + $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0); |
|
112 | + if (!$result) { |
|
113 | + return new WSError(202, 'There was an error creating the course'); |
|
114 | + } else { |
|
115 | + // Update extra fields |
|
116 | + foreach($extras_associative as $fname => $fvalue) { |
|
117 | + CourseManager::update_course_extra_field_value($result, $fname, $fvalue); |
|
118 | + } |
|
119 | + // Get course id |
|
120 | + $course_info = CourseManager::get_course_information($result); |
|
121 | + return $course_info['real_id']; |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Creates a course |
|
127 | + * |
|
128 | + * @param string API secret key |
|
129 | + * @param string Title |
|
130 | + * @param string Category code |
|
131 | + * @param string Wanted code. If it's not defined, it will be generated automatically |
|
132 | + * @param string Tutor name |
|
133 | + * @param string Course admin user id field name |
|
134 | + * @param string Course admin user id value |
|
135 | + * @param string Course language |
|
136 | + * @param string Course id field name |
|
137 | + * @param string Course id value |
|
138 | + * @param array Course extra fields |
|
139 | + * @return int Course id generated |
|
140 | + */ |
|
141 | + public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
|
142 | + // First, verify the secret key |
|
143 | + $verifKey = $this->verifyKey($secret_key); |
|
144 | + if($verifKey instanceof WSError) { |
|
145 | + $this->handleError($verifKey); |
|
146 | + } else { |
|
147 | + $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
|
148 | + if($result instanceof WSError) { |
|
149 | + $this->handleError($result); |
|
150 | + } else { |
|
151 | + return $result; |
|
152 | + } |
|
153 | + } |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Create multiple courses |
|
158 | + * |
|
159 | + * @param string API secret key |
|
160 | + * @param array Courses to be created, with elements following the structure presented in CreateCourse |
|
161 | + * @return array Array with elements of the form array('course_id_value' => 'original value sent', 'course_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
162 | + */ |
|
163 | + public function CreateCourses($secret_key, $courses) { |
|
164 | + // First, verify the secret key |
|
165 | + $verifKey = $this->verifyKey($secret_key); |
|
166 | + if($verifKey instanceof WSCMError) { |
|
167 | + $this->handleError($verifKey); |
|
168 | + } else { |
|
169 | + $results = array(); |
|
170 | + foreach($courses as $course) { |
|
171 | + $result_tmp = array(); |
|
172 | + //reinitialize variables just in case |
|
173 | + $title = $category_code = $wanted_code = $tutor_name = $course_admin_user_id_field_name = $course_admin_user_id_value = $language = $course_id_field_name = $course_id_value = $extras = null; |
|
174 | + extract($course); |
|
175 | + $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
|
176 | + if($result instanceof WSCMError) { |
|
177 | + $result_tmp['result'] = $result->toArray(); |
|
178 | + $result_tmp['course_id_value'] = $course_id_value; |
|
179 | + $result_tmp['course_id_generated'] = 0; |
|
180 | + } else { |
|
181 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
182 | + $result_tmp['course_id_value'] = $course_id_value; |
|
183 | + $result_tmp['course_id_generated'] = $result; |
|
184 | + } |
|
185 | + $results[] = $result_tmp; |
|
186 | + } |
|
187 | + return $results; |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Edits a course (helper method) |
|
193 | + * |
|
194 | + * @param string Course id field name |
|
195 | + * @param string Course id value |
|
196 | + * @param string Title |
|
197 | + * @param string Category code |
|
198 | + * @param string Department name |
|
199 | + * @param string Department url |
|
200 | + * @param string Course language |
|
201 | + * @param int Visibility |
|
202 | + * @param int Subscribe (0 = denied, 1 = allowed) |
|
203 | + * @param int Unsubscribe (0 = denied, 1 = allowed) |
|
204 | + * @param string Visual code |
|
205 | + * @param array Course extra fields |
|
206 | + * @return mixed True in case of success, WSError otherwise |
|
207 | + */ |
|
208 | + protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
|
209 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
210 | + if($course_id instanceof WSCMError) { |
|
211 | + return $course_id; |
|
212 | + } else { |
|
213 | + $attributes = array(); |
|
214 | + if(!is_empty($title)) { |
|
215 | + $attributes['title'] = $title; |
|
216 | + } |
|
217 | + if(!is_empty($category_code)) { |
|
218 | + $attributes['category_code'] = $category_code; |
|
219 | + } |
|
220 | + if(!is_empty($department_name)) { |
|
221 | + $attributes['department_name'] = $department_name; |
|
222 | + } |
|
223 | + if(!is_empty($department_url)) { |
|
224 | + $attributes['department_url'] = $department_url; |
|
225 | + } |
|
226 | + if(!is_empty($language)) { |
|
227 | + $attributes['course_language'] = $language; |
|
228 | + } |
|
229 | + if($visibility != '') { |
|
230 | + $attributes['visibility'] = (int)$visibility; |
|
231 | + } |
|
232 | + if($subscribe != '') { |
|
233 | + $attributes['subscribe'] = (int)$subscribe; |
|
234 | + } |
|
235 | + if($unsubscribe != '') { |
|
236 | + $attributes['unsubscribe'] = (int)$unsubscribe; |
|
237 | + } |
|
238 | + if(!is_empty($visual_code)) { |
|
239 | + $attributes['visual_code'] = $visual_code; |
|
240 | + } |
|
241 | + if(!is_empty($attributes)) { |
|
242 | + CourseManager::update_attributes($course_id, $attributes); |
|
243 | + } |
|
244 | + if(!empty($extras)) { |
|
245 | + $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
246 | + $extras_associative = array(); |
|
247 | + foreach($extras as $extra) { |
|
248 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
249 | + } |
|
250 | + foreach($extras_associative as $fname => $fvalue) { |
|
251 | + CourseManager::update_extra_field_value($course_code, $fname, $fvalue); |
|
252 | + } |
|
253 | + } |
|
254 | + return true; |
|
255 | + } |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Edits a course |
|
260 | + * |
|
261 | + * @param string API secret key |
|
262 | + * @param string Course id field name |
|
263 | + * @param string Course id value |
|
264 | + * @param string Title |
|
265 | + * @param string Category code |
|
266 | + * @param string Department name |
|
267 | + * @param string Department url |
|
268 | + * @param string Course language |
|
269 | + * @param int Visibility |
|
270 | + * @param int Subscribe (0 = denied, 1 = allowed) |
|
271 | + * @param int Unsubscribe (0 = denied, 1 = allowed) |
|
272 | + * @param string Visual code |
|
273 | + * @param array Course extra fields |
|
274 | + */ |
|
275 | + public function EditCourse($secret_key, $course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
|
276 | + $verifKey = $this->verifyKey($secret_key); |
|
277 | + if($verifKey instanceof WSCMError) { |
|
278 | + $this->handleError($verifKey); |
|
279 | + } else { |
|
280 | + $result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras); |
|
281 | + if($result instanceof WSCMError) { |
|
282 | + $this->handleError($result); |
|
283 | + } |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * List courses |
|
289 | + * |
|
290 | + * @param string API secret key |
|
291 | + * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
292 | + * @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility', |
|
293 | + * 'category_name' => 'Name of the category of the course', 'number_students' => 'Number of students in the course', 'external_course_id' => 'External course id') |
|
294 | + */ |
|
295 | + public function ListCourses($secret_key, $course_id_field_name) { |
|
296 | + $verifKey = $this->verifyKey($secret_key); |
|
297 | + if($verifKey instanceof WSError) { |
|
298 | + $this->handleError($verifKey); |
|
299 | + } else { |
|
300 | + $courses_result = array(); |
|
301 | + $category_names = array(); |
|
302 | + |
|
303 | + $courses = CourseManager::get_courses_list(); |
|
304 | + foreach($courses as $course) { |
|
305 | + $course_tmp = array(); |
|
306 | + $course_tmp['id'] = $course['id']; |
|
307 | + $course_tmp['code'] = $course['code']; |
|
308 | + $course_tmp['title'] = $course['title']; |
|
309 | + $course_tmp['language'] = $course['course_language']; |
|
310 | + $course_tmp['visibility'] = $course['visibility']; |
|
311 | + |
|
312 | + // Determining category name |
|
313 | + if($category_names[$course['category_code']]) { |
|
314 | + $course_tmp['category_name'] = $category_names[$course['category_code']]; |
|
315 | + } else { |
|
316 | + $category = CourseManager::get_course_category($course['category_code']); |
|
317 | + $category_names[$course['category_code']] = $category['name']; |
|
318 | + $course_tmp['category_name'] = $category['name']; |
|
319 | + } |
|
320 | + |
|
321 | + // Determining number of students registered in course |
|
322 | + $user_list = CourseManager::get_user_list_from_course_code($course['code']); |
|
323 | + $course_tmp['number_students'] = count($user_list); |
|
324 | + |
|
325 | + // Determining external course id |
|
326 | + $course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_id_field_name, $course['code']); |
|
327 | + |
|
328 | + |
|
329 | + $courses_result[] = $course_tmp; |
|
330 | + } |
|
331 | + |
|
332 | + return $courses_result; |
|
333 | + } |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Subscribe or unsubscribe user to a course (helper method) |
|
338 | + * |
|
339 | + * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
340 | + * @param string Course id value. |
|
341 | + * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
342 | + * @param string User id value |
|
343 | + * @param int Set to 1 to subscribe, 0 to unsubscribe |
|
344 | + * @param int Status (STUDENT or TEACHER) Used for subscription only |
|
345 | + * @return mixed True if subscription or unsubscription was successful, false otherwise |
|
346 | + */ |
|
347 | + protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |
|
348 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
349 | + if($course_id instanceof WSError) { |
|
350 | + return $course_id; |
|
351 | + } else { |
|
352 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
353 | + if($user_id instanceof WSError) { |
|
354 | + return $user_id; |
|
355 | + } else { |
|
356 | + $course_code = CourseManager::get_course_code_from_course_id($course_id); |
|
357 | + if($state == 0) { |
|
358 | + // Unsubscribe user |
|
359 | + CourseManager::unsubscribe_user($user_id, $course_code); |
|
360 | + return true; |
|
361 | + } else { |
|
362 | + // Subscribe user |
|
363 | + if(CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
364 | + return true; |
|
365 | + } else { |
|
366 | + return new WSError(203, 'An error occured subscribing to this course'); |
|
367 | + } |
|
368 | + } |
|
369 | + } |
|
370 | + } |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Subscribe user to a course |
|
375 | + * |
|
376 | + * @param string API secret key |
|
377 | + * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
378 | + * @param string Course id value. |
|
379 | + * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
380 | + * @param string User id value |
|
381 | + * @param int Status (1 = Teacher, 5 = Student) |
|
382 | + */ |
|
383 | + public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) { |
|
384 | + $verifKey = $this->verifyKey($secret_key); |
|
385 | + if($verifKey instanceof WSError) { |
|
386 | + $this->handleError($verifKey); |
|
387 | + } else { |
|
388 | + $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status); |
|
389 | + if($result instanceof WSError) { |
|
390 | + $this->handleError($result); |
|
391 | + } |
|
392 | + } |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Unsusbscribe user from course |
|
397 | + * |
|
398 | + * @param string API secret key |
|
399 | + * @param string Course id field name. Use "chamilo_course_id" to use internal id |
|
400 | + * @param string Course id value. |
|
401 | + * @param string User id field name. Use "chamilo_user_id" to use internal id |
|
402 | + * @param string User id value |
|
403 | + */ |
|
404 | + public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) { |
|
405 | + $verifKey = $this->verifyKey($secret_key); |
|
406 | + if($verifKey instanceof WSError) { |
|
407 | + $this->handleError($verifKey); |
|
408 | + } else { |
|
409 | + $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0); |
|
410 | + if($result instanceof WSError) { |
|
411 | + $this->handleError($result); |
|
412 | + } |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + /** |
|
417 | + * Returns the descriptions of a course, along with their id |
|
418 | + * |
|
419 | + * @param string API secret key |
|
420 | + * @param string Course id field name |
|
421 | + * @param string Course id value |
|
422 | + * @return array Returns an array with elements of the form ('course_desc_id' => 1, 'course_desc_title' => 'Title', 'course_desc_content' => 'Content') |
|
423 | + */ |
|
424 | + public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) { |
|
425 | + $verifKey = $this->verifyKey($secret_key); |
|
426 | + if($verifKey instanceof WSError) { |
|
427 | + $this->handleError($verifKey); |
|
428 | + } else { |
|
429 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
430 | + if($course_id instanceof WSError) { |
|
431 | + return $course_id; |
|
432 | + } else { |
|
433 | + // Course exists, get its descriptions |
|
434 | + $descriptions = CourseDescription::get_descriptions($course_id); |
|
435 | + $results = array(); |
|
436 | + foreach($descriptions as $description) { |
|
437 | + $results[] = array('course_desc_id' => $description->get_description_type(), |
|
438 | + 'course_desc_title' => $description->get_title(), |
|
439 | + 'course_desc_content' => $description->get_content()); |
|
440 | + } |
|
441 | + return $results; |
|
442 | + } |
|
443 | + } |
|
444 | + } |
|
445 | + |
|
446 | + |
|
447 | + /** |
|
448 | + * Edit course description |
|
449 | + * |
|
450 | + * @param string API secret key |
|
451 | + * @param string Course id field name |
|
452 | + * @param string Course id value |
|
453 | + * @param int Category id from course description |
|
454 | + * @param string Description title |
|
455 | + * @param string Course description content |
|
456 | + */ |
|
457 | + public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) { |
|
458 | + $verifKey = $this->verifyKey($secret_key); |
|
459 | + if($verifKey instanceof WSError) { |
|
460 | + $this->handleError($verifKey); |
|
461 | + } else { |
|
462 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
463 | + if($course_id instanceof WSError) { |
|
464 | + return $course_id; |
|
465 | + } else { |
|
466 | + // Create the new course description |
|
467 | + $cd = new CourseDescription(); |
|
468 | + $cd->set_description_type($course_desc_id); |
|
469 | + $cd->set_title($course_desc_title); |
|
470 | + $cd->set_content($course_desc_content); |
|
471 | + $cd->set_session_id(0); |
|
472 | + |
|
473 | + // Get course info |
|
474 | 474 | $course_info = CourseManager::get_course_information( |
475 | 475 | CourseManager::get_course_code_from_course_id($course_id) |
476 | 476 | ); |
477 | - // Check if this course description exists |
|
478 | - $descriptions = CourseDescription::get_descriptions($course_id); |
|
479 | - $exists = false; |
|
480 | - foreach($descriptions as $description) { |
|
481 | - if($description->get_description_type() == $course_desc_id) { |
|
482 | - $exists = true; |
|
483 | - } |
|
484 | - } |
|
477 | + // Check if this course description exists |
|
478 | + $descriptions = CourseDescription::get_descriptions($course_id); |
|
479 | + $exists = false; |
|
480 | + foreach($descriptions as $description) { |
|
481 | + if($description->get_description_type() == $course_desc_id) { |
|
482 | + $exists = true; |
|
483 | + } |
|
484 | + } |
|
485 | 485 | $cd->set_course_id($course_info['real_id']); |
486 | - if (!$exists) { |
|
487 | - $cd->set_progress(0); |
|
488 | - $cd->insert(); |
|
489 | - } else { |
|
490 | - $cd->update(); |
|
491 | - } |
|
492 | - } |
|
493 | - } |
|
494 | - } |
|
495 | - public function unreadMessage($username, $password) |
|
496 | - { |
|
497 | - if($this->verifyUserPass($username, $password) == "valid") |
|
498 | - { |
|
499 | - $table_message = Database::get_main_table(TABLE_MESSAGE); |
|
500 | - $user_id = UserManager::get_user_id_from_username($username); |
|
501 | - $condition_msg_status = ' msg_status = 1 '; // define('MESSAGE_STATUS_UNREAD', '1'); |
|
502 | - |
|
503 | - $sql_query = "SELECT COUNT(*) as number_messages FROM $table_message WHERE $condition_msg_status AND user_receiver_id=".$user_id; |
|
504 | - |
|
505 | - $sql_result = Database::query($sql_query); |
|
506 | - $result = Database::fetch_array($sql_result); |
|
507 | - return $result['number_messages']; |
|
508 | - } |
|
509 | - return "0"; |
|
510 | - } |
|
511 | - |
|
512 | - public function get_message_data($username, $password) |
|
513 | - { |
|
514 | - if($this->verifyUserPass($username, $password) == "valid") |
|
515 | - { |
|
516 | - $user_id = get_user_id_from_username($username); |
|
517 | - |
|
518 | - } |
|
519 | - |
|
520 | - } |
|
521 | - |
|
522 | - public function nada($username, $password) |
|
523 | - { |
|
524 | - if($this->verifyUserPass($username, $password) == "valid") |
|
525 | - return $username.$password; |
|
526 | - return $username; |
|
527 | - } |
|
486 | + if (!$exists) { |
|
487 | + $cd->set_progress(0); |
|
488 | + $cd->insert(); |
|
489 | + } else { |
|
490 | + $cd->update(); |
|
491 | + } |
|
492 | + } |
|
493 | + } |
|
494 | + } |
|
495 | + public function unreadMessage($username, $password) |
|
496 | + { |
|
497 | + if($this->verifyUserPass($username, $password) == "valid") |
|
498 | + { |
|
499 | + $table_message = Database::get_main_table(TABLE_MESSAGE); |
|
500 | + $user_id = UserManager::get_user_id_from_username($username); |
|
501 | + $condition_msg_status = ' msg_status = 1 '; // define('MESSAGE_STATUS_UNREAD', '1'); |
|
502 | + |
|
503 | + $sql_query = "SELECT COUNT(*) as number_messages FROM $table_message WHERE $condition_msg_status AND user_receiver_id=".$user_id; |
|
504 | + |
|
505 | + $sql_result = Database::query($sql_query); |
|
506 | + $result = Database::fetch_array($sql_result); |
|
507 | + return $result['number_messages']; |
|
508 | + } |
|
509 | + return "0"; |
|
510 | + } |
|
511 | + |
|
512 | + public function get_message_data($username, $password) |
|
513 | + { |
|
514 | + if($this->verifyUserPass($username, $password) == "valid") |
|
515 | + { |
|
516 | + $user_id = get_user_id_from_username($username); |
|
517 | + |
|
518 | + } |
|
519 | + |
|
520 | + } |
|
521 | + |
|
522 | + public function nada($username, $password) |
|
523 | + { |
|
524 | + if($this->verifyUserPass($username, $password) == "valid") |
|
525 | + return $username.$password; |
|
526 | + return $username; |
|
527 | + } |
|
528 | 528 | |
529 | 529 | |
530 | 530 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | protected function deleteCourseHelper($course_id_field_name, $course_id_value) { |
21 | 21 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
22 | - if($course_id instanceof WSCMError) { |
|
22 | + if ($course_id instanceof WSCMError) { |
|
23 | 23 | return $course_id; |
24 | 24 | } else { |
25 | 25 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) { |
39 | 39 | $verifKey = $this->verifyKey($secret_key); |
40 | - if($verifKey instanceof WSError) { |
|
40 | + if ($verifKey instanceof WSError) { |
|
41 | 41 | $this->handleError($verifKey); |
42 | 42 | } else { |
43 | 43 | $result = $this->deleteCourseHelper($course_id_field_name, $course_id_value); |
44 | - if($result instanceof WSError) { |
|
44 | + if ($result instanceof WSError) { |
|
45 | 45 | $this->handleError($result); |
46 | 46 | } |
47 | 47 | } |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function DeleteCourses($secret_key, $courses) { |
59 | 59 | $verifKey = $this->verifyKey($secret_key); |
60 | - if($verifKey instanceof WSError) { |
|
60 | + if ($verifKey instanceof WSError) { |
|
61 | 61 | $this->handleError($verifKey); |
62 | 62 | } else { |
63 | 63 | $results = array(); |
64 | - foreach($courses as $course) { |
|
64 | + foreach ($courses as $course) { |
|
65 | 65 | $result_tmp = array(); |
66 | 66 | $result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']); |
67 | 67 | $result_tmp['course_id_value'] = $course['course_id_value']; |
68 | - if($result_op instanceof WSCMError) { |
|
68 | + if ($result_op instanceof WSCMError) { |
|
69 | 69 | // Return the error in the results |
70 | 70 | $result_tmp['result'] = $result_op->toArray(); |
71 | 71 | } else { |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
96 | 96 | // Add the original course id field name and value to the extra fields if needed |
97 | 97 | $extras_associative = array(); |
98 | - if($course_id_field_name != "chamilo_course_id") { |
|
98 | + if ($course_id_field_name != "chamilo_course_id") { |
|
99 | 99 | $extras_associative[$course_id_field_name] = $course_id_value; |
100 | 100 | } |
101 | - foreach($extras as $extra) { |
|
101 | + foreach ($extras as $extra) { |
|
102 | 102 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
103 | 103 | } |
104 | 104 | $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value); |
105 | - if($course_admin_id instanceof WSError) { |
|
105 | + if ($course_admin_id instanceof WSError) { |
|
106 | 106 | return $course_admin_id; |
107 | 107 | } |
108 | - if($wanted_code == '') { |
|
108 | + if ($wanted_code == '') { |
|
109 | 109 | $wanted_code = CourseManager::generate_course_code($title); |
110 | 110 | } |
111 | 111 | $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | return new WSError(202, 'There was an error creating the course'); |
114 | 114 | } else { |
115 | 115 | // Update extra fields |
116 | - foreach($extras_associative as $fname => $fvalue) { |
|
116 | + foreach ($extras_associative as $fname => $fvalue) { |
|
117 | 117 | CourseManager::update_course_extra_field_value($result, $fname, $fvalue); |
118 | 118 | } |
119 | 119 | // Get course id |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
142 | 142 | // First, verify the secret key |
143 | 143 | $verifKey = $this->verifyKey($secret_key); |
144 | - if($verifKey instanceof WSError) { |
|
144 | + if ($verifKey instanceof WSError) { |
|
145 | 145 | $this->handleError($verifKey); |
146 | 146 | } else { |
147 | 147 | $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
148 | - if($result instanceof WSError) { |
|
148 | + if ($result instanceof WSError) { |
|
149 | 149 | $this->handleError($result); |
150 | 150 | } else { |
151 | 151 | return $result; |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | public function CreateCourses($secret_key, $courses) { |
164 | 164 | // First, verify the secret key |
165 | 165 | $verifKey = $this->verifyKey($secret_key); |
166 | - if($verifKey instanceof WSCMError) { |
|
166 | + if ($verifKey instanceof WSCMError) { |
|
167 | 167 | $this->handleError($verifKey); |
168 | 168 | } else { |
169 | 169 | $results = array(); |
170 | - foreach($courses as $course) { |
|
170 | + foreach ($courses as $course) { |
|
171 | 171 | $result_tmp = array(); |
172 | 172 | //reinitialize variables just in case |
173 | 173 | $title = $category_code = $wanted_code = $tutor_name = $course_admin_user_id_field_name = $course_admin_user_id_value = $language = $course_id_field_name = $course_id_value = $extras = null; |
174 | 174 | extract($course); |
175 | 175 | $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
176 | - if($result instanceof WSCMError) { |
|
176 | + if ($result instanceof WSCMError) { |
|
177 | 177 | $result_tmp['result'] = $result->toArray(); |
178 | 178 | $result_tmp['course_id_value'] = $course_id_value; |
179 | 179 | $result_tmp['course_id_generated'] = 0; |
@@ -207,47 +207,47 @@ discard block |
||
207 | 207 | */ |
208 | 208 | protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
209 | 209 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
210 | - if($course_id instanceof WSCMError) { |
|
210 | + if ($course_id instanceof WSCMError) { |
|
211 | 211 | return $course_id; |
212 | 212 | } else { |
213 | 213 | $attributes = array(); |
214 | - if(!is_empty($title)) { |
|
214 | + if (!is_empty($title)) { |
|
215 | 215 | $attributes['title'] = $title; |
216 | 216 | } |
217 | - if(!is_empty($category_code)) { |
|
217 | + if (!is_empty($category_code)) { |
|
218 | 218 | $attributes['category_code'] = $category_code; |
219 | 219 | } |
220 | - if(!is_empty($department_name)) { |
|
220 | + if (!is_empty($department_name)) { |
|
221 | 221 | $attributes['department_name'] = $department_name; |
222 | 222 | } |
223 | - if(!is_empty($department_url)) { |
|
223 | + if (!is_empty($department_url)) { |
|
224 | 224 | $attributes['department_url'] = $department_url; |
225 | 225 | } |
226 | - if(!is_empty($language)) { |
|
226 | + if (!is_empty($language)) { |
|
227 | 227 | $attributes['course_language'] = $language; |
228 | 228 | } |
229 | - if($visibility != '') { |
|
230 | - $attributes['visibility'] = (int)$visibility; |
|
229 | + if ($visibility != '') { |
|
230 | + $attributes['visibility'] = (int) $visibility; |
|
231 | 231 | } |
232 | - if($subscribe != '') { |
|
233 | - $attributes['subscribe'] = (int)$subscribe; |
|
232 | + if ($subscribe != '') { |
|
233 | + $attributes['subscribe'] = (int) $subscribe; |
|
234 | 234 | } |
235 | - if($unsubscribe != '') { |
|
236 | - $attributes['unsubscribe'] = (int)$unsubscribe; |
|
235 | + if ($unsubscribe != '') { |
|
236 | + $attributes['unsubscribe'] = (int) $unsubscribe; |
|
237 | 237 | } |
238 | - if(!is_empty($visual_code)) { |
|
238 | + if (!is_empty($visual_code)) { |
|
239 | 239 | $attributes['visual_code'] = $visual_code; |
240 | 240 | } |
241 | - if(!is_empty($attributes)) { |
|
241 | + if (!is_empty($attributes)) { |
|
242 | 242 | CourseManager::update_attributes($course_id, $attributes); |
243 | 243 | } |
244 | - if(!empty($extras)) { |
|
244 | + if (!empty($extras)) { |
|
245 | 245 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
246 | 246 | $extras_associative = array(); |
247 | - foreach($extras as $extra) { |
|
247 | + foreach ($extras as $extra) { |
|
248 | 248 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
249 | 249 | } |
250 | - foreach($extras_associative as $fname => $fvalue) { |
|
250 | + foreach ($extras_associative as $fname => $fvalue) { |
|
251 | 251 | CourseManager::update_extra_field_value($course_code, $fname, $fvalue); |
252 | 252 | } |
253 | 253 | } |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | */ |
275 | 275 | public function EditCourse($secret_key, $course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
276 | 276 | $verifKey = $this->verifyKey($secret_key); |
277 | - if($verifKey instanceof WSCMError) { |
|
277 | + if ($verifKey instanceof WSCMError) { |
|
278 | 278 | $this->handleError($verifKey); |
279 | 279 | } else { |
280 | 280 | $result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras); |
281 | - if($result instanceof WSCMError) { |
|
281 | + if ($result instanceof WSCMError) { |
|
282 | 282 | $this->handleError($result); |
283 | 283 | } |
284 | 284 | } |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function ListCourses($secret_key, $course_id_field_name) { |
296 | 296 | $verifKey = $this->verifyKey($secret_key); |
297 | - if($verifKey instanceof WSError) { |
|
297 | + if ($verifKey instanceof WSError) { |
|
298 | 298 | $this->handleError($verifKey); |
299 | 299 | } else { |
300 | 300 | $courses_result = array(); |
301 | 301 | $category_names = array(); |
302 | 302 | |
303 | 303 | $courses = CourseManager::get_courses_list(); |
304 | - foreach($courses as $course) { |
|
304 | + foreach ($courses as $course) { |
|
305 | 305 | $course_tmp = array(); |
306 | 306 | $course_tmp['id'] = $course['id']; |
307 | 307 | $course_tmp['code'] = $course['code']; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $course_tmp['visibility'] = $course['visibility']; |
311 | 311 | |
312 | 312 | // Determining category name |
313 | - if($category_names[$course['category_code']]) { |
|
313 | + if ($category_names[$course['category_code']]) { |
|
314 | 314 | $course_tmp['category_name'] = $category_names[$course['category_code']]; |
315 | 315 | } else { |
316 | 316 | $category = CourseManager::get_course_category($course['category_code']); |
@@ -346,21 +346,21 @@ discard block |
||
346 | 346 | */ |
347 | 347 | protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |
348 | 348 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
349 | - if($course_id instanceof WSError) { |
|
349 | + if ($course_id instanceof WSError) { |
|
350 | 350 | return $course_id; |
351 | 351 | } else { |
352 | 352 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
353 | - if($user_id instanceof WSError) { |
|
353 | + if ($user_id instanceof WSError) { |
|
354 | 354 | return $user_id; |
355 | 355 | } else { |
356 | 356 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
357 | - if($state == 0) { |
|
357 | + if ($state == 0) { |
|
358 | 358 | // Unsubscribe user |
359 | 359 | CourseManager::unsubscribe_user($user_id, $course_code); |
360 | 360 | return true; |
361 | 361 | } else { |
362 | 362 | // Subscribe user |
363 | - if(CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
363 | + if (CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
364 | 364 | return true; |
365 | 365 | } else { |
366 | 366 | return new WSError(203, 'An error occured subscribing to this course'); |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) { |
384 | 384 | $verifKey = $this->verifyKey($secret_key); |
385 | - if($verifKey instanceof WSError) { |
|
385 | + if ($verifKey instanceof WSError) { |
|
386 | 386 | $this->handleError($verifKey); |
387 | 387 | } else { |
388 | 388 | $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status); |
389 | - if($result instanceof WSError) { |
|
389 | + if ($result instanceof WSError) { |
|
390 | 390 | $this->handleError($result); |
391 | 391 | } |
392 | 392 | } |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | */ |
404 | 404 | public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) { |
405 | 405 | $verifKey = $this->verifyKey($secret_key); |
406 | - if($verifKey instanceof WSError) { |
|
406 | + if ($verifKey instanceof WSError) { |
|
407 | 407 | $this->handleError($verifKey); |
408 | 408 | } else { |
409 | 409 | $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0); |
410 | - if($result instanceof WSError) { |
|
410 | + if ($result instanceof WSError) { |
|
411 | 411 | $this->handleError($result); |
412 | 412 | } |
413 | 413 | } |
@@ -423,17 +423,17 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) { |
425 | 425 | $verifKey = $this->verifyKey($secret_key); |
426 | - if($verifKey instanceof WSError) { |
|
426 | + if ($verifKey instanceof WSError) { |
|
427 | 427 | $this->handleError($verifKey); |
428 | 428 | } else { |
429 | 429 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
430 | - if($course_id instanceof WSError) { |
|
430 | + if ($course_id instanceof WSError) { |
|
431 | 431 | return $course_id; |
432 | 432 | } else { |
433 | 433 | // Course exists, get its descriptions |
434 | 434 | $descriptions = CourseDescription::get_descriptions($course_id); |
435 | 435 | $results = array(); |
436 | - foreach($descriptions as $description) { |
|
436 | + foreach ($descriptions as $description) { |
|
437 | 437 | $results[] = array('course_desc_id' => $description->get_description_type(), |
438 | 438 | 'course_desc_title' => $description->get_title(), |
439 | 439 | 'course_desc_content' => $description->get_content()); |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | */ |
457 | 457 | public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) { |
458 | 458 | $verifKey = $this->verifyKey($secret_key); |
459 | - if($verifKey instanceof WSError) { |
|
459 | + if ($verifKey instanceof WSError) { |
|
460 | 460 | $this->handleError($verifKey); |
461 | 461 | } else { |
462 | 462 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
463 | - if($course_id instanceof WSError) { |
|
463 | + if ($course_id instanceof WSError) { |
|
464 | 464 | return $course_id; |
465 | 465 | } else { |
466 | 466 | // Create the new course description |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | // Check if this course description exists |
478 | 478 | $descriptions = CourseDescription::get_descriptions($course_id); |
479 | 479 | $exists = false; |
480 | - foreach($descriptions as $description) { |
|
481 | - if($description->get_description_type() == $course_desc_id) { |
|
480 | + foreach ($descriptions as $description) { |
|
481 | + if ($description->get_description_type() == $course_desc_id) { |
|
482 | 482 | $exists = true; |
483 | 483 | } |
484 | 484 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | } |
495 | 495 | public function unreadMessage($username, $password) |
496 | 496 | { |
497 | - if($this->verifyUserPass($username, $password) == "valid") |
|
497 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
498 | 498 | { |
499 | 499 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
500 | 500 | $user_id = UserManager::get_user_id_from_username($username); |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | |
512 | 512 | public function get_message_data($username, $password) |
513 | 513 | { |
514 | - if($this->verifyUserPass($username, $password) == "valid") |
|
514 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
515 | 515 | { |
516 | 516 | $user_id = get_user_id_from_username($username); |
517 | 517 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | |
522 | 522 | public function nada($username, $password) |
523 | 523 | { |
524 | - if($this->verifyUserPass($username, $password) == "valid") |
|
524 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
525 | 525 | return $username.$password; |
526 | 526 | return $username; |
527 | 527 | } |
@@ -521,8 +521,9 @@ |
||
521 | 521 | |
522 | 522 | public function nada($username, $password) |
523 | 523 | { |
524 | - if($this->verifyUserPass($username, $password) == "valid") |
|
525 | - return $username.$password; |
|
524 | + if($this->verifyUserPass($username, $password) == "valid") { |
|
525 | + return $username.$password; |
|
526 | + } |
|
526 | 527 | return $username; |
527 | 528 | } |
528 | 529 |
@@ -204,6 +204,9 @@ |
||
204 | 204 | |
205 | 205 | } |
206 | 206 | |
207 | + /** |
|
208 | + * @param integer $user_id |
|
209 | + */ |
|
207 | 210 | protected function set_message_as_read($user_id, $message_id){ |
208 | 211 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
209 | 212 | $query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".$user_id." AND id='".$message_id."';"; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
38 | 38 | |
39 | 39 | $sql_query = "SELECT id FROM $table_message " . |
40 | - " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" . |
|
41 | - " ORDER BY send_date LIMIT $from,$number_of_items"; |
|
40 | + " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" . |
|
41 | + " ORDER BY send_date LIMIT $from,$number_of_items"; |
|
42 | 42 | |
43 | 43 | $sql_result = Database::query($sql_query); |
44 | 44 | $message = "#"; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
87 | 87 | |
88 | 88 | $sql_query = "SELECT ".$field_table." FROM $table_message " . |
89 | - " WHERE user_receiver_id=".$user_id." AND id=".$message_id; |
|
89 | + " WHERE user_receiver_id=".$user_id." AND id=".$message_id; |
|
90 | 90 | |
91 | 91 | $sql_result = Database::query($sql_query); |
92 | 92 | $result = Database::fetch_row($sql_result); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
108 | 108 | |
109 | 109 | $sql_query = "SELECT id FROM $table_message " . |
110 | - "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " . |
|
111 | - "ORDER BY send_date LIMIT $from,$number_of_items"; |
|
110 | + "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " . |
|
111 | + "ORDER BY send_date LIMIT $from,$number_of_items"; |
|
112 | 112 | |
113 | 113 | $sql_result = Database::query($sql_query); |
114 | 114 | $message = "#"; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
158 | 158 | |
159 | 159 | $sql_query = "SELECT ".$field_table." FROM $table_message " . |
160 | - " WHERE user_sender_id=".$user_id." AND id=".$id; |
|
160 | + " WHERE user_sender_id=".$user_id." AND id=".$id; |
|
161 | 161 | |
162 | 162 | $sql_result = Database::query($sql_query); |
163 | 163 | $result = Database::fetch_row($sql_result); |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
189 | 189 | |
190 | 190 | $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ". |
191 | - " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; |
|
191 | + " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; |
|
192 | 192 | $result = Database::query($query); |
193 | 193 | |
194 | 194 | $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ". |
195 | - " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; |
|
195 | + " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')"; |
|
196 | 196 | $result = Database::query($query); |
197 | 197 | |
198 | 198 | $inbox_last_id = Database::insert_id(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | { |
13 | 13 | public function unreadMessage($username, $password) |
14 | 14 | { |
15 | - if($this->verifyUserPass($username, $password) == "valid") |
|
15 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
16 | 16 | { |
17 | 17 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
18 | 18 | $user_id = UserManager::get_user_id_from_username($username); |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | |
31 | 31 | public function get_message_id($username, $password, $from, $number_of_items) |
32 | 32 | { |
33 | - if($this->verifyUserPass($username, $password) == "valid") |
|
33 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
34 | 34 | { |
35 | 35 | $user_id = UserManager::get_user_id_from_username($username); |
36 | 36 | |
37 | 37 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
38 | 38 | |
39 | - $sql_query = "SELECT id FROM $table_message " . |
|
40 | - " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" . |
|
39 | + $sql_query = "SELECT id FROM $table_message ". |
|
40 | + " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)". |
|
41 | 41 | " ORDER BY send_date LIMIT $from,$number_of_items"; |
42 | 42 | |
43 | 43 | $sql_result = Database::query($sql_query); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | public function get_message_data($username, $password, $message_id, $field) |
57 | 57 | { |
58 | - if($this->verifyUserPass($username, $password) == "valid") |
|
58 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
59 | 59 | { |
60 | 60 | $htmlcode = false; |
61 | 61 | $user_id = UserManager::get_user_id_from_username($username); |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | |
86 | 86 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
87 | 87 | |
88 | - $sql_query = "SELECT ".$field_table." FROM $table_message " . |
|
88 | + $sql_query = "SELECT ".$field_table." FROM $table_message ". |
|
89 | 89 | " WHERE user_receiver_id=".$user_id." AND id=".$message_id; |
90 | 90 | |
91 | 91 | $sql_result = Database::query($sql_query); |
92 | 92 | $result = Database::fetch_row($sql_result); |
93 | 93 | return (htmlcode) ? html_entity_decode($result[0]) : $result[0]; |
94 | 94 | |
95 | - }else |
|
95 | + } else |
|
96 | 96 | return get_lang('InvalidId'); |
97 | 97 | |
98 | 98 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | |
101 | 101 | public function get_message_id_sent($username, $password, $from, $number_of_items) |
102 | 102 | { |
103 | - if($this->verifyUserPass($username, $password) == "valid") |
|
103 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
104 | 104 | { |
105 | 105 | $user_id = UserManager::get_user_id_from_username($username); |
106 | 106 | |
107 | 107 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
108 | 108 | |
109 | - $sql_query = "SELECT id FROM $table_message " . |
|
110 | - "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " . |
|
109 | + $sql_query = "SELECT id FROM $table_message ". |
|
110 | + "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." ". |
|
111 | 111 | "ORDER BY send_date LIMIT $from,$number_of_items"; |
112 | 112 | |
113 | 113 | $sql_result = Database::query($sql_query); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | public function get_message_data_sent($username, $password, $id, $field) |
128 | 128 | { |
129 | - if($this->verifyUserPass($username, $password) == "valid") |
|
129 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
130 | 130 | { |
131 | 131 | $htmlcode = false; |
132 | 132 | switch ($field) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
158 | 158 | |
159 | - $sql_query = "SELECT ".$field_table." FROM $table_message " . |
|
159 | + $sql_query = "SELECT ".$field_table." FROM $table_message ". |
|
160 | 160 | " WHERE user_sender_id=".$user_id." AND id=".$id; |
161 | 161 | |
162 | 162 | $sql_result = Database::query($sql_query); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | return (htmlcode) ? html_entity_decode($result[0]) : $result[0]; |
166 | 166 | |
167 | - }else |
|
167 | + } else |
|
168 | 168 | return get_lang('InvalidId'); |
169 | 169 | |
170 | 170 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function message_send($username, $password, $receiver_user_id, $subject, $content) |
174 | 174 | { |
175 | 175 | //TODO: verificar data de envio. Esta divergindo de data! |
176 | - if($this->verifyUserPass($username, $password) == "valid") |
|
176 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
177 | 177 | { |
178 | 178 | $group_id = intval(0); |
179 | 179 | $parent_id = intval(0); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | } |
206 | 206 | |
207 | - protected function set_message_as_read($user_id, $message_id){ |
|
207 | + protected function set_message_as_read($user_id, $message_id) { |
|
208 | 208 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
209 | 209 | $query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".$user_id." AND id='".$message_id."';"; |
210 | 210 | $result = Database::query($query); |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | return $message; |
50 | 50 | |
51 | - } else |
|
52 | - return get_lang('InvalidId'); |
|
51 | + } else { |
|
52 | + return get_lang('InvalidId'); |
|
53 | + } |
|
53 | 54 | |
54 | 55 | } |
55 | 56 | |
@@ -92,8 +93,9 @@ discard block |
||
92 | 93 | $result = Database::fetch_row($sql_result); |
93 | 94 | return (htmlcode) ? html_entity_decode($result[0]) : $result[0]; |
94 | 95 | |
95 | - }else |
|
96 | - return get_lang('InvalidId'); |
|
96 | + } else { |
|
97 | + return get_lang('InvalidId'); |
|
98 | + } |
|
97 | 99 | |
98 | 100 | |
99 | 101 | } |
@@ -118,8 +120,9 @@ discard block |
||
118 | 120 | |
119 | 121 | return $message; |
120 | 122 | |
121 | - } else |
|
122 | - return get_lang('InvalidId'); |
|
123 | + } else { |
|
124 | + return get_lang('InvalidId'); |
|
125 | + } |
|
123 | 126 | |
124 | 127 | } |
125 | 128 | |
@@ -164,8 +167,9 @@ discard block |
||
164 | 167 | |
165 | 168 | return (htmlcode) ? html_entity_decode($result[0]) : $result[0]; |
166 | 169 | |
167 | - }else |
|
168 | - return get_lang('InvalidId'); |
|
170 | + } else { |
|
171 | + return get_lang('InvalidId'); |
|
172 | + } |
|
169 | 173 | |
170 | 174 | |
171 | 175 | } |
@@ -199,8 +203,9 @@ discard block |
||
199 | 203 | |
200 | 204 | return $inbox_last_id; |
201 | 205 | |
202 | - } else |
|
203 | - return get_lang('InvalidId'); |
|
206 | + } else { |
|
207 | + return get_lang('InvalidId'); |
|
208 | + } |
|
204 | 209 | |
205 | 210 | } |
206 | 211 |
@@ -137,7 +137,7 @@ |
||
137 | 137 | /** |
138 | 138 | * Get a list of users of which the given conditions match with a LIKE '%cond%' |
139 | 139 | * @param array $conditions a list of condition (exemple : status=>STUDENT) |
140 | - * @param array $order_by a list of fields on which sort |
|
140 | + * @param string[] $order_by a list of fields on which sort |
|
141 | 141 | * @return array An array with all users of the platform. |
142 | 142 | * @todo optional course code parameter, optional sorting parameters... |
143 | 143 | *@todo Use the UserManager class |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | { |
96 | 96 | global $charset; |
97 | 97 | if ($this->verifyUserPass($username, $password) == "valid") { |
98 | - $user_id = UserManager::get_user_id_from_username($username); |
|
98 | + $user_id = UserManager::get_user_id_from_username($username); |
|
99 | 99 | $message_title = get_lang('Invitation'); |
100 | 100 | $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message); |
101 | 101 | |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | |
136 | 136 | |
137 | 137 | /** |
138 | - * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
139 | - * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
140 | - * @param array $order_by a list of fields on which sort |
|
141 | - * @return array An array with all users of the platform. |
|
142 | - * @todo optional course code parameter, optional sorting parameters... |
|
138 | + * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
139 | + * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
140 | + * @param array $order_by a list of fields on which sort |
|
141 | + * @return array An array with all users of the platform. |
|
142 | + * @todo optional course code parameter, optional sorting parameters... |
|
143 | 143 | *@todo Use the UserManager class |
144 | 144 | * @todo security filter order by |
145 | - */ |
|
145 | + */ |
|
146 | 146 | private static function get_user_list_like_start($conditions = array(), $order_by = array()) |
147 | 147 | { |
148 | 148 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | public function find_id_user($username, $password, $name) |
15 | 15 | { |
16 | - if($this->verifyUserPass($username, $password) == "valid") |
|
16 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
17 | 17 | { |
18 | 18 | |
19 | 19 | $listResult = "#"; |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | $listArrayResult = array_unique($listArray); |
43 | - foreach($listArrayResult as $result) |
|
43 | + foreach ($listArrayResult as $result) |
|
44 | 44 | { |
45 | - $listResult .= $result . "#"; |
|
45 | + $listResult .= $result."#"; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return $listResult; |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | if ($this->verifyUserPass($username, $password) == "valid") { |
98 | 98 | $user_id = UserManager::get_user_id_from_username($username); |
99 | 99 | $message_title = get_lang('Invitation'); |
100 | - $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message); |
|
100 | + $count_is_true = SocialManager::send_invitation_friend($user_id, $userfriend_id, $message_title, $content_message); |
|
101 | 101 | |
102 | 102 | if ($count_is_true) { |
103 | - return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false); |
|
103 | + return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES, $charset), false); |
|
104 | 104 | } else { |
105 | - return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false); |
|
105 | + return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES, $charset), false); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | return get_lang('InvalidId'); |
@@ -20,6 +20,9 @@ |
||
20 | 20 | |
21 | 21 | define('WS_ERROR_SECRET_KEY', 1); |
22 | 22 | |
23 | +/** |
|
24 | + * @param integer $code |
|
25 | + */ |
|
23 | 26 | function return_error($code) { |
24 | 27 | $fault = null; |
25 | 28 | switch ($code) { |
@@ -581,7 +581,7 @@ |
||
581 | 581 | /*$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null; |
582 | 582 | $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;*/ |
583 | 583 | |
584 | - $courseInfo = CourseManager::getCourseInfoFromOriginalId( |
|
584 | + $courseInfo = CourseManager::getCourseInfoFromOriginalId( |
|
585 | 585 | $courseIdValue, |
586 | 586 | $courseIdName |
587 | 587 | ); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($debug) { |
68 | - error_log("checkip " . intval($check_ip)); |
|
68 | + error_log("checkip ".intval($check_ip)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | if ($check_ip) { |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | ); |
121 | 121 | |
122 | 122 | // Register the method to expose |
123 | -$server->register('WSImportLP', // method name |
|
124 | - array('params' => 'tns:params'), // input parameters |
|
125 | - array('return' => 'xsd:string'), // output parameters |
|
126 | - 'urn:WSLP', // namespace |
|
127 | - 'urn:WSLP#WSImportLP', // soapaction |
|
128 | - 'rpc', // style |
|
129 | - 'encoded', // use |
|
123 | +$server->register('WSImportLP', // method name |
|
124 | + array('params' => 'tns:params'), // input parameters |
|
125 | + array('return' => 'xsd:string'), // output parameters |
|
126 | + 'urn:WSLP', // namespace |
|
127 | + 'urn:WSLP#WSImportLP', // soapaction |
|
128 | + 'rpc', // style |
|
129 | + 'encoded', // use |
|
130 | 130 | 'This service adds users' // documentation |
131 | 131 | ); |
132 | 132 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | $uniqueFile = uniqid(); |
185 | 185 | $userId = 1; // admin |
186 | - $filePath = api_get_path(SYS_ARCHIVE_PATH) . $uniqueFile; |
|
186 | + $filePath = api_get_path(SYS_ARCHIVE_PATH).$uniqueFile; |
|
187 | 187 | file_put_contents($filePath, $fileData); |
188 | 188 | |
189 | 189 | $fileName = $params['filename']; |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | 'all', |
258 | 258 | '', |
259 | 259 | array( |
260 | - 'id' => array('name' => 'id', 'type' => 'xsd:string'), |
|
261 | - 'name' => array('name' => 'name', 'type' => 'xsd:string'), |
|
260 | + 'id' => array('name' => 'id', 'type' => 'xsd:string'), |
|
261 | + 'name' => array('name' => 'name', 'type' => 'xsd:string'), |
|
262 | 262 | ) |
263 | 263 | ); |
264 | 264 | |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | ); |
275 | 275 | |
276 | 276 | // Register the method to expose |
277 | -$server->register('WSGetLpList', // method name |
|
278 | - array('params' => 'tns:paramsGetLpList'), // input parameters |
|
279 | - array('return' => 'tns:lpList'), // output parameters |
|
280 | - 'urn:WSLP', // namespace |
|
281 | - 'urn:WSLP#WSGetLpList', // soapaction |
|
282 | - 'rpc', // style |
|
283 | - 'encoded', // use |
|
277 | +$server->register('WSGetLpList', // method name |
|
278 | + array('params' => 'tns:paramsGetLpList'), // input parameters |
|
279 | + array('return' => 'tns:lpList'), // output parameters |
|
280 | + 'urn:WSLP', // namespace |
|
281 | + 'urn:WSLP#WSGetLpList', // soapaction |
|
282 | + 'rpc', // style |
|
283 | + 'encoded', // use |
|
284 | 284 | 'This service adds users' // documentation |
285 | 285 | ); |
286 | 286 | |
@@ -369,13 +369,13 @@ discard block |
||
369 | 369 | ); |
370 | 370 | |
371 | 371 | // Register the method to expose |
372 | -$server->register('WSDeleteLp', // method name |
|
373 | - array('params' => 'tns:paramsDeleteLp'), // input parameters |
|
374 | - array('return' => 'xsd:string'), // output parameters |
|
375 | - 'urn:WSLP', // namespace |
|
376 | - 'urn:WSLP#WSDeleteLp', // soapaction |
|
377 | - 'rpc', // style |
|
378 | - 'encoded', // use |
|
372 | +$server->register('WSDeleteLp', // method name |
|
373 | + array('params' => 'tns:paramsDeleteLp'), // input parameters |
|
374 | + array('return' => 'xsd:string'), // output parameters |
|
375 | + 'urn:WSLP', // namespace |
|
376 | + 'urn:WSLP#WSDeleteLp', // soapaction |
|
377 | + 'rpc', // style |
|
378 | + 'encoded', // use |
|
379 | 379 | 'This service deletes a LP' // documentation |
380 | 380 | ); |
381 | 381 | |
@@ -434,9 +434,9 @@ discard block |
||
434 | 434 | if ($lp) { |
435 | 435 | if ($debug) error_log("LP deleted $lpId"); |
436 | 436 | |
437 | - $course_dir = $courseInfo['directory'] . '/document'; |
|
437 | + $course_dir = $courseInfo['directory'].'/document'; |
|
438 | 438 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
439 | - $base_work_dir = $sys_course_path . $course_dir; |
|
439 | + $base_work_dir = $sys_course_path.$course_dir; |
|
440 | 440 | |
441 | 441 | $items = $lp->get_flat_ordered_items_list($lpId, 0, $courseId); |
442 | 442 | |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | 'all', |
496 | 496 | '', |
497 | 497 | array( |
498 | - 'data' => array('name' => 'data', 'type' => 'xsd:string'), |
|
499 | - 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
500 | - 'filename' => array('name' => 'filename', 'type' => 'xsd:string'), |
|
498 | + 'data' => array('name' => 'data', 'type' => 'xsd:string'), |
|
499 | + 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
500 | + 'filename' => array('name' => 'filename', 'type' => 'xsd:string'), |
|
501 | 501 | ) |
502 | 502 | ); |
503 | 503 | |
@@ -548,13 +548,13 @@ discard block |
||
548 | 548 | ); |
549 | 549 | |
550 | 550 | // Register the method to expose |
551 | -$server->register('WSCreateLp', // method name |
|
552 | - array('params' => 'tns:paramsCreateLp'), // input parameters |
|
553 | - array('return' => 'xsd:string'), // output parameters |
|
554 | - 'urn:WSLP', // namespace |
|
555 | - 'urn:WSLP#WSCreateLp', // soapaction |
|
556 | - 'rpc', // style |
|
557 | - 'encoded', // use |
|
551 | +$server->register('WSCreateLp', // method name |
|
552 | + array('params' => 'tns:paramsCreateLp'), // input parameters |
|
553 | + array('return' => 'xsd:string'), // output parameters |
|
554 | + 'urn:WSLP', // namespace |
|
555 | + 'urn:WSLP#WSCreateLp', // soapaction |
|
556 | + 'rpc', // style |
|
557 | + 'encoded', // use |
|
558 | 558 | 'This service creates a LP' // documentation |
559 | 559 | ); |
560 | 560 |
@@ -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 | //if api_set_failure |
201 | 213 | return 'manifest.xml file not found'; |
202 | 214 | } |
@@ -215,10 +227,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |