@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $from = intval($from); |
75 | 75 | $number_of_items = intval($number_of_items); |
76 | 76 | |
77 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
77 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
78 | 78 | $direction = 'ASC'; |
79 | 79 | } |
80 | 80 | |
@@ -97,24 +97,24 @@ discard block |
||
97 | 97 | $thematic[1] = '<a href="index.php?'.api_get_cidreq().'&action=thematic_details&thematic_id='.$thematic[0].'">'. |
98 | 98 | Security::remove_XSS($thematic[1], STUDENT).$session_star.'</a>'; |
99 | 99 | if (api_is_allowed_to_edit(null, true)) { |
100 | - $actions = ''; |
|
100 | + $actions = ''; |
|
101 | 101 | |
102 | 102 | if (api_get_session_id()) { |
103 | 103 | if (api_get_session_id() == $thematic[3]) { |
104 | 104 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic[0].'">'. |
105 | - Display::return_icon('lesson_plan.png',get_lang('ThematicPlan'),'',ICON_SIZE_SMALL).'</a> '; |
|
105 | + Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), '', ICON_SIZE_SMALL).'</a> '; |
|
106 | 106 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].'">'. |
107 | - Display::return_icon('lesson_plan_calendar.png',get_lang('ThematicAdvance'),'',ICON_SIZE_SMALL).'</a> '; |
|
107 | + Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), '', ICON_SIZE_SMALL).'</a> '; |
|
108 | 108 | |
109 | 109 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$thematic[0].'">'. |
110 | - Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
110 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; |
|
111 | 111 | $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$thematic[0].'">'. |
112 | - Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
112 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
113 | 113 | } else { |
114 | - $actions .= Display::return_icon('lesson_plan_na.png',get_lang('ThematicPlan'),'',ICON_SIZE_SMALL).' '; |
|
115 | - $actions .= Display::return_icon('lesson_plan_calendar_na.png',get_lang('ThematicAdvance'),'',ICON_SIZE_SMALL).' '; |
|
116 | - $actions .= Display::return_icon('edit_na.png',get_lang('Edit'),'',ICON_SIZE_SMALL); |
|
117 | - $actions .= Display::return_icon('delete_na.png',get_lang('Delete'),'',ICON_SIZE_SMALL).' '; |
|
114 | + $actions .= Display::return_icon('lesson_plan_na.png', get_lang('ThematicPlan'), '', ICON_SIZE_SMALL).' '; |
|
115 | + $actions .= Display::return_icon('lesson_plan_calendar_na.png', get_lang('ThematicAdvance'), '', ICON_SIZE_SMALL).' '; |
|
116 | + $actions .= Display::return_icon('edit_na.png', get_lang('Edit'), '', ICON_SIZE_SMALL); |
|
117 | + $actions .= Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL).' '; |
|
118 | 118 | $actions .= Display::url( |
119 | 119 | Display::return_icon('cd.gif', get_lang('Copy')), |
120 | 120 | 'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$thematic[0] |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | } |
123 | 123 | } else { |
124 | 124 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic[0].'">'. |
125 | - Display::return_icon('lesson_plan.png',get_lang('ThematicPlan'),'',ICON_SIZE_SMALL).'</a> '; |
|
125 | + Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), '', ICON_SIZE_SMALL).'</a> '; |
|
126 | 126 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].'">'. |
127 | - Display::return_icon('lesson_plan_calendar.png',get_lang('ThematicAdvance'),'',ICON_SIZE_SMALL).'</a> '; |
|
127 | + Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), '', ICON_SIZE_SMALL).'</a> '; |
|
128 | 128 | |
129 | 129 | if ($thematic[2] > 1) { |
130 | 130 | $actions .= '<a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$thematic[0].'">'. |
131 | - Display::return_icon('up.png', get_lang('Up'),'',ICON_SIZE_SMALL).'</a>'; |
|
131 | + Display::return_icon('up.png', get_lang('Up'), '', ICON_SIZE_SMALL).'</a>'; |
|
132 | 132 | } else { |
133 | - $actions .= Display::return_icon('up_na.png',' ','',ICON_SIZE_SMALL); |
|
133 | + $actions .= Display::return_icon('up_na.png', ' ', '', ICON_SIZE_SMALL); |
|
134 | 134 | } |
135 | 135 | if ($thematic[2] < self::get_max_thematic_item()) { |
136 | 136 | $actions .= '<a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$thematic[0].'">'. |
137 | - Display::return_icon('down.png',get_lang('Down'),'',ICON_SIZE_SMALL).'</a>'; |
|
137 | + Display::return_icon('down.png', get_lang('Down'), '', ICON_SIZE_SMALL).'</a>'; |
|
138 | 138 | } else { |
139 | - $actions .= Display::return_icon('down_na.png',' ','',ICON_SIZE_SMALL); |
|
139 | + $actions .= Display::return_icon('down_na.png', ' ', '', ICON_SIZE_SMALL); |
|
140 | 140 | } |
141 | 141 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$thematic[0].'">'. |
142 | - Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
142 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; |
|
143 | 143 | $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$thematic[0].'">'. |
144 | - Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
144 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
145 | 145 | } |
146 | 146 | $thematics[] = array($thematic[0], $thematic[1], $actions); |
147 | 147 | } |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | $res = Database::query($sql); |
279 | 279 | if (Database::num_rows($res) > 0) { |
280 | 280 | if (!empty($thematic_id)) { |
281 | - $data = Database::fetch_array($res,'ASSOC'); |
|
281 | + $data = Database::fetch_array($res, 'ASSOC'); |
|
282 | 282 | } else { |
283 | - while ($row = Database::fetch_array($res,'ASSOC')) { |
|
283 | + while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
284 | 284 | $data[$row['id']] = $row; |
285 | 285 | } |
286 | 286 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | |
376 | 376 | if (is_array($thematic_id)) { |
377 | 377 | foreach ($thematic_id as $id) { |
378 | - $id = intval($id); |
|
378 | + $id = intval($id); |
|
379 | 379 | $sql = "UPDATE $tbl_thematic SET active = 0 |
380 | 380 | WHERE c_id = $course_id AND id = $id"; |
381 | 381 | $result = Database::query($sql); |
@@ -391,8 +391,8 @@ discard block |
||
391 | 391 | ); |
392 | 392 | } |
393 | 393 | } |
394 | - } else { |
|
395 | - $thematic_id = intval($thematic_id); |
|
394 | + } else { |
|
395 | + $thematic_id = intval($thematic_id); |
|
396 | 396 | $sql = "UPDATE $tbl_thematic SET active = 0 |
397 | 397 | WHERE c_id = $course_id AND id = $thematic_id"; |
398 | 398 | $result = Database::query($sql); |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | $new_thematic_id = $thematic_copy->thematic_save(); |
429 | 429 | if (!empty($new_thematic_id)) { |
430 | 430 | $thematic_advanced = self::get_thematic_advance_by_thematic_id($thematic_id); |
431 | - if(!empty($thematic_advanced)) { |
|
432 | - foreach($thematic_advanced as $item) { |
|
431 | + if (!empty($thematic_advanced)) { |
|
432 | + foreach ($thematic_advanced as $item) { |
|
433 | 433 | $thematic = new Thematic(); |
434 | 434 | $thematic->set_thematic_advance_attributes( |
435 | 435 | 0, |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | $column = intval($column); |
493 | 493 | $from = intval($from); |
494 | 494 | $number_of_items = intval($number_of_items); |
495 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
495 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
496 | 496 | $direction = 'ASC'; |
497 | 497 | } |
498 | 498 | $data = array(); |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | $thematic_advance[1] = api_get_local_time($thematic_advance[1]); |
526 | 526 | $thematic_advance[1] = api_format_date($thematic_advance[1], DATE_TIME_FORMAT_LONG); |
527 | 527 | $actions = ''; |
528 | - $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>'; |
|
529 | - $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('delete.png',get_lang('Delete'),'',22).'</a></center>'; |
|
528 | + $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>'; |
|
529 | + $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a></center>'; |
|
530 | 530 | $data[] = array($i, $thematic_advance[1], $thematic_advance[2], $thematic_advance[3], $actions); |
531 | 531 | $i++; |
532 | 532 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | |
591 | 591 | $session_star = ''; |
592 | 592 | if (api_is_allowed_to_edit(null, true)) { |
593 | - if ($thematic_advance['session_id'] !=0) { |
|
593 | + if ($thematic_advance['session_id'] != 0) { |
|
594 | 594 | $session_star = api_get_session_image(api_get_session_id(), $uinfo['status']); |
595 | 595 | } |
596 | 596 | } |
@@ -616,13 +616,13 @@ discard block |
||
616 | 616 | |
617 | 617 | foreach ($data as $thematic_id => $thematic_plan_data) { |
618 | 618 | $new_thematic_plan_data = array(); |
619 | - foreach($thematic_plan_data as $thematic_item) { |
|
619 | + foreach ($thematic_plan_data as $thematic_item) { |
|
620 | 620 | $thematic_simple_list[] = $thematic_item['description_type']; |
621 | 621 | $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item; |
622 | 622 | } |
623 | 623 | |
624 | 624 | if (!empty($thematic_simple_list)) { |
625 | - foreach($thematic_simple_list as $item) { |
|
625 | + foreach ($thematic_simple_list as $item) { |
|
626 | 626 | $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title']; |
627 | 627 | } |
628 | 628 | } |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | } |
639 | 639 | if (!empty($data[$thematic_id][$id]['title']) && !empty($data[$thematic_id][$id]['description'])) { |
640 | 640 | if (api_is_allowed_to_edit(null, true)) { |
641 | - if ($data[$thematic_id][$id]['session_id'] !=0) { |
|
641 | + if ($data[$thematic_id][$id]['session_id'] != 0) { |
|
642 | 642 | $session_star = api_get_session_image(api_get_session_id(), $uinfo['status']); |
643 | 643 | } |
644 | 644 | } |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | if ($no_data) { |
652 | 652 | $return .= '<div><em>'.get_lang('StillDoNotHaveAThematicPlan').'</em></div>'; |
653 | 653 | } |
654 | - $return .= '</div>'; |
|
654 | + $return .= '</div>'; |
|
655 | 655 | $final_return[$thematic_id] = $return; |
656 | 656 | } |
657 | 657 | return $final_return; |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | api_get_session_id() |
692 | 692 | ); |
693 | 693 | foreach ($list as $value) { |
694 | - $elements[$value['ref']]= $value; |
|
694 | + $elements[$value['ref']] = $value; |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
@@ -865,18 +865,18 @@ discard block |
||
865 | 865 | api_get_session_id() |
866 | 866 | ); |
867 | 867 | |
868 | - $thematic_plan_complete_list = array(); |
|
868 | + $thematic_plan_complete_list = array(); |
|
869 | 869 | $thematic_plan_id_list = array(); |
870 | 870 | |
871 | 871 | if (!empty($items_from_course)) { |
872 | - foreach($items_from_course as $item) { |
|
872 | + foreach ($items_from_course as $item) { |
|
873 | 873 | $thematic_plan_id_list[] = $item['ref']; |
874 | 874 | $thematic_plan_complete_list[$item['ref']] = $item; |
875 | 875 | } |
876 | 876 | } |
877 | 877 | |
878 | 878 | if (!empty($items_from_session)) { |
879 | - foreach($items_from_session as $item) { |
|
879 | + foreach ($items_from_session as $item) { |
|
880 | 880 | $thematic_plan_id_list[] = $item['ref']; |
881 | 881 | $thematic_plan_complete_list[$item['ref']] = $item; |
882 | 882 | } |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | if (!isset($thematic_id) && !isset($description_type)) { |
899 | 899 | // group all data group by thematic id |
900 | 900 | $tmp = array(); |
901 | - while ($row = Database::fetch_array($rs,'ASSOC')) { |
|
901 | + while ($row = Database::fetch_array($rs, 'ASSOC')) { |
|
902 | 902 | $tmp[] = $row['thematic_id']; |
903 | 903 | if (in_array($row['thematic_id'], $tmp)) { |
904 | 904 | $row['session_id'] = $thematic_plan_complete_list[$row['id']]; |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | } |
907 | 907 | } |
908 | 908 | } else { |
909 | - while ($row = Database::fetch_array($rs,'ASSOC')) { |
|
909 | + while ($row = Database::fetch_array($rs, 'ASSOC')) { |
|
910 | 910 | $row['session_id'] = $thematic_plan_complete_list[$row['id']]; |
911 | 911 | $data[] = $row; |
912 | 912 | } |
@@ -941,8 +941,8 @@ discard block |
||
941 | 941 | ); |
942 | 942 | |
943 | 943 | $elements_to_show = array(); |
944 | - foreach($list as $value) { |
|
945 | - $elements_to_show[]= $value['ref']; |
|
944 | + foreach ($list as $value) { |
|
945 | + $elements_to_show[] = $value['ref']; |
|
946 | 946 | } |
947 | 947 | $condition = ''; |
948 | 948 | if (!empty($elements_to_show)) { |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | c_id = $course_id AND |
955 | 955 | thematic_id = $thematic_id AND |
956 | 956 | description_type = '$description_type'"; |
957 | - $rs = Database::query($sql); |
|
957 | + $rs = Database::query($sql); |
|
958 | 958 | |
959 | 959 | $affected_rows = 0; |
960 | 960 | if (Database::num_rows($rs) > 0) { |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | $diff = array_diff($all, $a_thematic_advance_ids); |
1191 | 1191 | if (!empty($diff)) { |
1192 | 1192 | $upd = "UPDATE $tbl_thematic_advance SET done_advance = 0 |
1193 | - WHERE c_id = $course_id AND id IN(".implode(',',$diff).") "; |
|
1193 | + WHERE c_id = $course_id AND id IN(".implode(',', $diff).") "; |
|
1194 | 1194 | Database::query($upd); |
1195 | 1195 | } |
1196 | 1196 | |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | $course_code = api_get_course_id(); |
1305 | 1305 | } |
1306 | 1306 | if (api_get_session_id()) { |
1307 | - $thematic_data = $this->get_thematic_list(null, $course_code ); |
|
1307 | + $thematic_data = $this->get_thematic_list(null, $course_code); |
|
1308 | 1308 | } else { |
1309 | 1309 | $thematic_data = $this->get_thematic_list(null, $course_code, 0); |
1310 | 1310 | } |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | } |
1357 | 1357 | // calculate average by thematic |
1358 | 1358 | $count_total_advances = count($advances); |
1359 | - $average = round(($count_done_advances*100)/$count_total_advances); |
|
1359 | + $average = round(($count_done_advances * 100) / $count_total_advances); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | return $average; |
@@ -1447,12 +1447,12 @@ discard block |
||
1447 | 1447 | public function get_default_thematic_plan_title() |
1448 | 1448 | { |
1449 | 1449 | $default_thematic_plan_titles = array(); |
1450 | - $default_thematic_plan_titles[1]= get_lang('Objectives'); |
|
1451 | - $default_thematic_plan_titles[2]= get_lang('SkillToAcquire'); |
|
1452 | - $default_thematic_plan_titles[3]= get_lang('Methodology'); |
|
1453 | - $default_thematic_plan_titles[4]= get_lang('Infrastructure'); |
|
1454 | - $default_thematic_plan_titles[5]= get_lang('Assessment'); |
|
1455 | - $default_thematic_plan_titles[6]= get_lang('Others'); |
|
1450 | + $default_thematic_plan_titles[1] = get_lang('Objectives'); |
|
1451 | + $default_thematic_plan_titles[2] = get_lang('SkillToAcquire'); |
|
1452 | + $default_thematic_plan_titles[3] = get_lang('Methodology'); |
|
1453 | + $default_thematic_plan_titles[4] = get_lang('Infrastructure'); |
|
1454 | + $default_thematic_plan_titles[5] = get_lang('Assessment'); |
|
1455 | + $default_thematic_plan_titles[6] = get_lang('Others'); |
|
1456 | 1456 | |
1457 | 1457 | return $default_thematic_plan_titles; |
1458 | 1458 | } |
@@ -1464,12 +1464,12 @@ discard block |
||
1464 | 1464 | public function get_default_thematic_plan_icon() |
1465 | 1465 | { |
1466 | 1466 | $default_thematic_plan_icon = array(); |
1467 | - $default_thematic_plan_icon[1]= 'icons/32/objective.png'; |
|
1468 | - $default_thematic_plan_icon[2]= 'icons/32/skills.png'; |
|
1469 | - $default_thematic_plan_icon[3]= 'icons/32/strategy.png'; |
|
1470 | - $default_thematic_plan_icon[4]= 'icons/32/laptop.png'; |
|
1471 | - $default_thematic_plan_icon[5]= 'icons/32/assessment.png'; |
|
1472 | - $default_thematic_plan_icon[6]= 'icons/32/wizard.png'; |
|
1467 | + $default_thematic_plan_icon[1] = 'icons/32/objective.png'; |
|
1468 | + $default_thematic_plan_icon[2] = 'icons/32/skills.png'; |
|
1469 | + $default_thematic_plan_icon[3] = 'icons/32/strategy.png'; |
|
1470 | + $default_thematic_plan_icon[4] = 'icons/32/laptop.png'; |
|
1471 | + $default_thematic_plan_icon[5] = 'icons/32/assessment.png'; |
|
1472 | + $default_thematic_plan_icon[6] = 'icons/32/wizard.png'; |
|
1473 | 1473 | |
1474 | 1474 | return $default_thematic_plan_icon; |
1475 | 1475 | } |
@@ -1481,11 +1481,11 @@ discard block |
||
1481 | 1481 | public function get_default_question() |
1482 | 1482 | { |
1483 | 1483 | $question = array(); |
1484 | - $question[1]= get_lang('ObjectivesQuestions'); |
|
1485 | - $question[2]= get_lang('SkillToAcquireQuestions'); |
|
1486 | - $question[3]= get_lang('MethodologyQuestions'); |
|
1487 | - $question[4]= get_lang('InfrastructureQuestions'); |
|
1488 | - $question[5]= get_lang('AssessmentQuestions'); |
|
1484 | + $question[1] = get_lang('ObjectivesQuestions'); |
|
1485 | + $question[2] = get_lang('SkillToAcquireQuestions'); |
|
1486 | + $question[3] = get_lang('MethodologyQuestions'); |
|
1487 | + $question[4] = get_lang('InfrastructureQuestions'); |
|
1488 | + $question[5] = get_lang('AssessmentQuestions'); |
|
1489 | 1489 | |
1490 | 1490 | return $question; |
1491 | 1491 | } |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | if (isset($_configuration['language_measure_frequency']) && |
104 | 104 | $_configuration['language_measure_frequency'] == 1 |
105 | 105 | ) { |
106 | - require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; |
|
107 | - global $langstats; |
|
108 | - $langstats->add_use($variable,''); |
|
106 | + require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; |
|
107 | + global $langstats; |
|
108 | + $langstats->add_use($variable,''); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | if (!isset($used_lang_vars)) { |
112 | - $used_lang_vars = array(); |
|
112 | + $used_lang_vars = array(); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | // Caching results from some API functions, for speed. |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | static $text_direction = array(); |
306 | 306 | |
307 | 307 | if (empty($language)) { |
308 | - $language = api_get_interface_language(); |
|
308 | + $language = api_get_interface_language(); |
|
309 | 309 | } |
310 | 310 | if (!isset($text_direction[$language])) { |
311 | 311 | $text_direction[$language] = in_array(api_purify_language_id($language), |
@@ -536,24 +536,24 @@ discard block |
||
536 | 536 | case DATE_FORMAT_ONLY_DAYNAME: |
537 | 537 | $date_format = get_lang('dateFormatOnlyDayName', '', $language); |
538 | 538 | if (INTL_INSTALLED) { |
539 | - $datetype = IntlDateFormatter::SHORT; |
|
540 | - $timetype = IntlDateFormatter::NONE; |
|
541 | - } |
|
539 | + $datetype = IntlDateFormatter::SHORT; |
|
540 | + $timetype = IntlDateFormatter::NONE; |
|
541 | + } |
|
542 | 542 | break; |
543 | 543 | case DATE_FORMAT_NUMBER_NO_YEAR: |
544 | 544 | $date_format = get_lang('dateFormatShortNumberNoYear', '', $language); |
545 | - if (INTL_INSTALLED) { |
|
546 | - $datetype = IntlDateFormatter::SHORT; |
|
547 | - $timetype = IntlDateFormatter::NONE; |
|
548 | - } |
|
545 | + if (INTL_INSTALLED) { |
|
546 | + $datetype = IntlDateFormatter::SHORT; |
|
547 | + $timetype = IntlDateFormatter::NONE; |
|
548 | + } |
|
549 | + break; |
|
550 | + case DATE_FORMAT_NUMBER: |
|
551 | + $date_format = get_lang('dateFormatShortNumber', '', $language); |
|
552 | + if (INTL_INSTALLED) { |
|
553 | + $datetype = IntlDateFormatter::SHORT; |
|
554 | + $timetype = IntlDateFormatter::NONE; |
|
555 | + } |
|
549 | 556 | break; |
550 | - case DATE_FORMAT_NUMBER: |
|
551 | - $date_format = get_lang('dateFormatShortNumber', '', $language); |
|
552 | - if (INTL_INSTALLED) { |
|
553 | - $datetype = IntlDateFormatter::SHORT; |
|
554 | - $timetype = IntlDateFormatter::NONE; |
|
555 | - } |
|
556 | - break; |
|
557 | 557 | case TIME_NO_SEC_FORMAT: |
558 | 558 | $date_format = get_lang('timeNoSecFormat', '', $language); |
559 | 559 | if (INTL_INSTALLED) { |
@@ -589,14 +589,14 @@ discard block |
||
589 | 589 | $timetype = IntlDateFormatter::SHORT; |
590 | 590 | } |
591 | 591 | break; |
592 | - case DATE_TIME_FORMAT_SHORT: |
|
592 | + case DATE_TIME_FORMAT_SHORT: |
|
593 | 593 | $date_format = get_lang('dateTimeFormatShort', '', $language); |
594 | 594 | if (INTL_INSTALLED) { |
595 | 595 | $datetype = IntlDateFormatter::FULL; |
596 | 596 | $timetype = IntlDateFormatter::SHORT; |
597 | 597 | } |
598 | 598 | break; |
599 | - case DATE_TIME_FORMAT_SHORT_TIME_FIRST: |
|
599 | + case DATE_TIME_FORMAT_SHORT_TIME_FIRST: |
|
600 | 600 | $date_format = get_lang('dateTimeFormatShortTimeFirst', '', $language); |
601 | 601 | if (INTL_INSTALLED) { |
602 | 602 | $datetype = IntlDateFormatter::FULL; |
@@ -1817,7 +1817,6 @@ discard block |
||
1817 | 1817 | |
1818 | 1818 | /** |
1819 | 1819 | * Return true a date is valid |
1820 | - |
|
1821 | 1820 | * @param string $date example: 2014-06-30 13:05:05 |
1822 | 1821 | * @param string $format example: "Y-m-d H:i:s" |
1823 | 1822 | * |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | ) { |
106 | 106 | require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; |
107 | 107 | global $langstats; |
108 | - $langstats->add_use($variable,''); |
|
108 | + $langstats->add_use($variable, ''); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | if (!isset($used_lang_vars)) { |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | if ($use_users_timezone == 'true') { |
372 | 372 | $userId = api_get_user_id(); |
373 | 373 | // Get the timezone based on user preference, if it exists |
374 | - $timezone_user = UserManager::get_extra_user_data_by_field($userId,'timezone'); |
|
374 | + $timezone_user = UserManager::get_extra_user_data_by_field($userId, 'timezone'); |
|
375 | 375 | if (isset($timezone_user['timezone']) && $timezone_user['timezone'] != null) { |
376 | 376 | $to_timezone = $timezone_user['timezone']; |
377 | 377 | } |
@@ -636,10 +636,10 @@ discard block |
||
636 | 636 | // We replace %a %A %b %B masks of date format with translated strings |
637 | 637 | $translated = &_api_get_day_month_names($language); |
638 | 638 | $date_format = str_replace(array('%A', '%a', '%B', '%b'), |
639 | - array($translated['days_long'][(int)strftime('%w', $time )], |
|
640 | - $translated['days_short'][(int)strftime('%w', $time)], |
|
641 | - $translated['months_long'][(int)strftime('%m', $time) - 1], |
|
642 | - $translated['months_short'][(int)strftime('%m', $time) - 1]), |
|
639 | + array($translated['days_long'][(int) strftime('%w', $time)], |
|
640 | + $translated['days_short'][(int) strftime('%w', $time)], |
|
641 | + $translated['months_long'][(int) strftime('%m', $time) - 1], |
|
642 | + $translated['months_short'][(int) strftime('%m', $time) - 1]), |
|
643 | 643 | $date_format); |
644 | 644 | $formatted_date = api_to_system_encoding(strftime($date_format, $time), 'UTF-8'); |
645 | 645 | } |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | if ($seconds > $time) { |
738 | 738 | continue; |
739 | 739 | } |
740 | - $current_value = intval($time/$seconds); |
|
740 | + $current_value = intval($time / $seconds); |
|
741 | 741 | |
742 | 742 | if ($current_value != 1) { |
743 | 743 | $date_str = $sec_time_plu[$i]; |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | } |
755 | 755 | |
756 | 756 | if (!empty($key_result)) { |
757 | - if ($key_result[0] == $min_day && $key_result[1]== $min_minute) { |
|
757 | + if ($key_result[0] == $min_day && $key_result[1] == $min_minute) { |
|
758 | 758 | $key_result[1] = ' 0 '.$min_hours; |
759 | 759 | $str_result[0] = $time_result[0].' '.$key_result[0]; |
760 | 760 | $str_result[1] = $key_result[1]; |
@@ -1687,7 +1687,7 @@ discard block |
||
1687 | 1687 | * @return string Returns the encoding identificator modified in suitable for comparison way. |
1688 | 1688 | */ |
1689 | 1689 | function api_refine_encoding_id($encoding) { |
1690 | - if (is_array($encoding)){ |
|
1690 | + if (is_array($encoding)) { |
|
1691 | 1691 | return array_map('api_refine_encoding_id', $encoding); |
1692 | 1692 | } |
1693 | 1693 | return strtoupper(str_replace('_', '-', $encoding)); |
@@ -1710,8 +1710,7 @@ |
||
1710 | 1710 | } |
1711 | 1711 | } |
1712 | 1712 | return false; |
1713 | - } |
|
1714 | - elseif (is_array($encoding2)) { |
|
1713 | + } elseif (is_array($encoding2)) { |
|
1715 | 1714 | foreach ($encoding2 as $encoding) { |
1716 | 1715 | if (api_equal_encodings($encoding1, $encoding, $strict)) { |
1717 | 1716 | return true; |
@@ -437,6 +437,7 @@ discard block |
||
437 | 437 | * If null, the timezone will be determined based on user preference, |
438 | 438 | * or timezone chosen by the admin for the platform. |
439 | 439 | * @param string The timezone to be converted from. If null, UTC will be assumed. |
440 | + * @param string $to_timezone |
|
440 | 441 | * @return string The converted time formatted as Y-m-d H:i:s |
441 | 442 | * |
442 | 443 | * @author Guillaume Viguier <[email protected]> |
@@ -793,6 +794,7 @@ discard block |
||
793 | 794 | * @param mixed The time to be converted |
794 | 795 | * @param mixed Format to be used (TIME_NO_SEC_FORMAT, DATE_FORMAT_SHORT, DATE_FORMAT_LONG, DATE_TIME_FORMAT_LONG) |
795 | 796 | * @param string Timezone to be converted from. If null, UTC will be assumed. |
797 | + * @param string $from_timezone |
|
796 | 798 | * @return string Converted and localized date |
797 | 799 | * |
798 | 800 | * @author Guillaume Viguier <[email protected]> |
@@ -862,7 +864,7 @@ discard block |
||
862 | 864 | * @param int/string $format (optional) The person name format. It may be a pattern-string (for example '%t %l, %f' or '%T %F %L', ...) or some of the constants PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER. |
863 | 865 | * @param string $language (optional) The language id. If it is omitted, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only. |
864 | 866 | * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. |
865 | - * @return bool The result is sort of full name of the person. |
|
867 | + * @return string The result is sort of full name of the person. |
|
866 | 868 | * Sample results: |
867 | 869 | * Peter Ustinoff or Dr. Peter Ustinoff - the Western order |
868 | 870 | * Ustinoff Peter or Dr. Ustinoff Peter - the Eastern order |
@@ -956,7 +958,7 @@ discard block |
||
956 | 958 | |
957 | 959 | /** |
958 | 960 | * Checks whether a given format represents person name in Western order (for which first name is first). |
959 | - * @param int/string $format (optional) The person name format. It may be a pattern-string (for example '%t. %l, %f') or some of the constants PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER. |
|
961 | + * @param integer $format (optional) The person name format. It may be a pattern-string (for example '%t. %l, %f') or some of the constants PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER. |
|
960 | 962 | * @param string $language (optional) The language id. If it is omitted, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only. |
961 | 963 | * @return bool The result TRUE means that the order is first_name last_name, FALSE means last_name first_name. |
962 | 964 | * Note: You may use this function for determing the order of the fields or columns "First name" and "Last name" in forms, tables and reports. |
@@ -1184,8 +1186,8 @@ discard block |
||
1184 | 1186 | |
1185 | 1187 | /** |
1186 | 1188 | * This function returns a string or an array with all occurrences of search in subject (ignoring case) replaced with the given replace value. |
1187 | - * @param mixed $search String or array of strings to be found. |
|
1188 | - * @param mixed $replace String or array of strings used for replacement. |
|
1189 | + * @param string $search String or array of strings to be found. |
|
1190 | + * @param string $replace String or array of strings used for replacement. |
|
1189 | 1191 | * @param mixed $subject String or array of strings being searched. |
1190 | 1192 | * @param int $count (optional) The number of matched and replaced needles will be returned in count, which is passed by reference. |
1191 | 1193 | * @param string $encoding (optional) The used internally by this function character encoding. |
@@ -1248,10 +1250,10 @@ discard block |
||
1248 | 1250 | /** |
1249 | 1251 | * Finds first occurrence of a string within another, case insensitive. |
1250 | 1252 | * @param string $haystack The string from which to get the first occurrence. |
1251 | - * @param mixed $needle The string to be found. |
|
1253 | + * @param string $needle The string to be found. |
|
1252 | 1254 | * @param bool $before_needle (optional) Determines which portion of $haystack this function returns. The default value is FALSE. |
1253 | 1255 | * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. |
1254 | - * @return mixed Returns the portion of $haystack, or FALSE if $needle is not found. |
|
1256 | + * @return false|string Returns the portion of $haystack, or FALSE if $needle is not found. |
|
1255 | 1257 | * Notes: |
1256 | 1258 | * If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character. |
1257 | 1259 | * If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence of $needle. |
@@ -1307,7 +1309,7 @@ discard block |
||
1307 | 1309 | * @param mixed $needle The string which first character is to be found. |
1308 | 1310 | * @param bool $before_needle (optional) Determines which portion of $haystack this function returns. The default value is FALSE. |
1309 | 1311 | * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. |
1310 | - * @return mixed Returns the portion of $haystack, or FALSE if the first character from $needle is not found. |
|
1312 | + * @return false|string Returns the portion of $haystack, or FALSE if the first character from $needle is not found. |
|
1311 | 1313 | * Notes: |
1312 | 1314 | * If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character. |
1313 | 1315 | * If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence. |
@@ -1357,7 +1359,7 @@ discard block |
||
1357 | 1359 | * @param string $needle The string to be found. |
1358 | 1360 | * @param int $offset (optional) $offset may be specified to begin searching an arbitrary position. Negative values will stop searching at an arbitrary point prior to the end of the string. |
1359 | 1361 | * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. |
1360 | - * @return mixed Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not found. |
|
1362 | + * @return integer|null Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not found. |
|
1361 | 1363 | * Note: The first character's position is 0, the second character position is 1, and so on. |
1362 | 1364 | * This function is aimed at replacing the functions strrpos() and mb_strrpos() for human-language strings. |
1363 | 1365 | * @link http://php.net/manual/en/function.strrpos |
@@ -1374,7 +1376,7 @@ discard block |
||
1374 | 1376 | * @param mixed $needle The string to be found. |
1375 | 1377 | * @param bool $before_needle (optional) Determines which portion of $haystack this function returns. The default value is FALSE. |
1376 | 1378 | * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. |
1377 | - * @return mixed Returns the portion of $haystack, or FALSE if $needle is not found. |
|
1379 | + * @return false|string Returns the portion of $haystack, or FALSE if $needle is not found. |
|
1378 | 1380 | * Notes: |
1379 | 1381 | * If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character. |
1380 | 1382 | * If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence of $needle. |
@@ -1517,7 +1519,7 @@ discard block |
||
1517 | 1519 | * Note that this changes the return value in an array where every element is an array consisting of the matched string at index 0 and its string offset into subject at index 1. |
1518 | 1520 | * @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The optional parameter offset can be used to specify the alternate place from which to start the search. |
1519 | 1521 | * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. |
1520 | - * @return int|boolean Returns the number of times pattern matches or FALSE if an error occurred. |
|
1522 | + * @return integer Returns the number of times pattern matches or FALSE if an error occurred. |
|
1521 | 1523 | * @link http://php.net/preg_match |
1522 | 1524 | */ |
1523 | 1525 | function api_preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0, $encoding = null) { |
@@ -1540,7 +1542,7 @@ discard block |
||
1540 | 1542 | * If no order flag is given, PREG_PATTERN_ORDER is assumed. |
1541 | 1543 | * @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The optional parameter offset can be used to specify the alternate place from which to start the search. |
1542 | 1544 | * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. |
1543 | - * @return int|boolean Returns the number of full pattern matches (which might be zero), or FALSE if an error occurred. |
|
1545 | + * @return integer Returns the number of full pattern matches (which might be zero), or FALSE if an error occurred. |
|
1544 | 1546 | * @link http://php.net/preg_match_all |
1545 | 1547 | */ |
1546 | 1548 | function api_preg_match_all($pattern, $subject, &$matches, $flags = PREG_PATTERN_ORDER, $offset = 0, $encoding = null) { |
@@ -1555,8 +1557,8 @@ discard block |
||
1555 | 1557 | |
1556 | 1558 | /** |
1557 | 1559 | * Performs a regular expression search and replace, UTF-8 aware when it is applicable. |
1558 | - * @param string|array $pattern The pattern to search for. It can be either a string or an array with strings. |
|
1559 | - * @param string|array $replacement The string or an array with strings to replace. |
|
1560 | + * @param string $pattern The pattern to search for. It can be either a string or an array with strings. |
|
1561 | + * @param string $replacement The string or an array with strings to replace. |
|
1560 | 1562 | * @param string|array $subject The string or an array with strings to search and replace. |
1561 | 1563 | * @param int $limit The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit). |
1562 | 1564 | * @param int &$count If specified, this variable will be filled with the number of replacements done. |
@@ -1808,6 +1810,7 @@ discard block |
||
1808 | 1810 | /** |
1809 | 1811 | * Checks a string for UTF-8 validity. |
1810 | 1812 | * |
1813 | + * @param string $string |
|
1811 | 1814 | */ |
1812 | 1815 | function api_is_valid_utf8(&$string) |
1813 | 1816 | { |
@@ -1950,7 +1953,7 @@ discard block |
||
1950 | 1953 | /** |
1951 | 1954 | * Replaces non-valid formats for person names with the default (English) format. |
1952 | 1955 | * @param string $format The input format to be verified. |
1953 | - * @return bool Returns the same format if is is valid, otherwise returns a valid English format. |
|
1956 | + * @return string Returns the same format if is is valid, otherwise returns a valid English format. |
|
1954 | 1957 | */ |
1955 | 1958 | function _api_validate_person_name_format($format) { |
1956 | 1959 | if (empty($format) || stripos($format, '%f') === false || stripos($format, '%l') === false) { |
@@ -2077,6 +2080,9 @@ discard block |
||
2077 | 2080 | |
2078 | 2081 | // This function checks whether the function _api_convert_encoding() (the php- |
2079 | 2082 | // implementation) is able to convert from/to a given encoding. |
2083 | +/** |
|
2084 | + * @param string $encoding |
|
2085 | + */ |
|
2080 | 2086 | function _api_convert_encoding_supports($encoding) { |
2081 | 2087 | static $supports = array(); |
2082 | 2088 | if (!isset($supports[$encoding])) { |
@@ -167,9 +167,9 @@ |
||
167 | 167 | ini_set('session.use_cookies', $old_use_cookies); |
168 | 168 | session_cache_limiter($old_session_cache_limiter); |
169 | 169 | } else { |
170 | - if (isset($_OLD_SESSION)) { |
|
171 | - $_SESSION = $_OLD_SESSION; |
|
172 | - unset($_OLD_SESSION); |
|
170 | + if (isset($_OLD_SESSION)) { |
|
171 | + $_SESSION = $_OLD_SESSION; |
|
172 | + unset($_OLD_SESSION); |
|
173 | 173 | } else { |
174 | 174 | unset($_SESSION); |
175 | 175 | } |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | session_start(); |
146 | 146 | |
147 | 147 | $v = $seed = $_SESSION['seed'] = pack('H*', sha1( |
148 | - serialize($_SERVER) . |
|
149 | - serialize($_POST) . |
|
150 | - serialize($_GET) . |
|
151 | - serialize($_COOKIE) . |
|
152 | - serialize($GLOBALS) . |
|
153 | - serialize($_SESSION) . |
|
148 | + serialize($_SERVER). |
|
149 | + serialize($_POST). |
|
150 | + serialize($_GET). |
|
151 | + serialize($_COOKIE). |
|
152 | + serialize($GLOBALS). |
|
153 | + serialize($_SESSION). |
|
154 | 154 | serialize($_OLD_SESSION) |
155 | 155 | )); |
156 | 156 | if (!isset($_SESSION['count'])) { |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | // http://tools.ietf.org/html/rfc4253#section-7.2 |
184 | 184 | // |
185 | 185 | // see the is_string($crypto) part for an example of how to expand the keys |
186 | - $key = pack('H*', sha1($seed . 'A')); |
|
187 | - $iv = pack('H*', sha1($seed . 'C')); |
|
186 | + $key = pack('H*', sha1($seed.'A')); |
|
187 | + $iv = pack('H*', sha1($seed.'C')); |
|
188 | 188 | |
189 | 189 | // ciphers are used as per the nist.gov link below. also, see this link: |
190 | 190 | // |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $i = pack('H*', sha1(microtime())); |
232 | 232 | $r = pack('H*', sha1($i ^ $v)); |
233 | 233 | $v = pack('H*', sha1($r ^ $i)); |
234 | - $result.= $r; |
|
234 | + $result .= $r; |
|
235 | 235 | } |
236 | 236 | return substr($result, 0, $length); |
237 | 237 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $i = $crypto->encrypt(microtime()); |
244 | 244 | $r = $crypto->encrypt($i ^ $v); |
245 | 245 | $v = $crypto->encrypt($r ^ $i); |
246 | - $result.= $r; |
|
246 | + $result .= $r; |
|
247 | 247 | } |
248 | 248 | return substr($result, 0, $length); |
249 | 249 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | function Crypt_AES($mode = CRYPT_AES_MODE_CBC) |
179 | 179 | { |
180 | - if ( !defined('CRYPT_AES_MODE') ) { |
|
180 | + if (!defined('CRYPT_AES_MODE')) { |
|
181 | 181 | switch (true) { |
182 | 182 | case extension_loaded('mcrypt') && in_array('rijndael-128', mcrypt_list_algorithms()): |
183 | 183 | define('CRYPT_AES_MODE', CRYPT_AES_MODE_MCRYPT); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - switch ( CRYPT_AES_MODE ) { |
|
190 | + switch (CRYPT_AES_MODE) { |
|
191 | 191 | case CRYPT_AES_MODE_MCRYPT: |
192 | 192 | switch ($mode) { |
193 | 193 | case CRYPT_AES_MODE_ECB: |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | function setIV($iv) |
268 | 268 | { |
269 | 269 | parent::setIV($iv); |
270 | - if ( CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT ) { |
|
270 | + if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) { |
|
271 | 271 | $this->changed = true; |
272 | 272 | } |
273 | 273 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | function encrypt($plaintext) |
293 | 293 | { |
294 | - if ( CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT ) { |
|
294 | + if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) { |
|
295 | 295 | $this->_mcryptSetup(); |
296 | 296 | |
297 | 297 | // re: http://phpseclib.sourceforge.net/cfb-demo.phps |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | $max = 16 - $pos; |
309 | 309 | if ($len >= $max) { |
310 | 310 | $i = $max; |
311 | - $len-= $max; |
|
311 | + $len -= $max; |
|
312 | 312 | $pos = 0; |
313 | 313 | } else { |
314 | 314 | $i = $len; |
315 | - $pos+= $len; |
|
315 | + $pos += $len; |
|
316 | 316 | $len = 0; |
317 | 317 | } |
318 | 318 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -325,15 +325,15 @@ discard block |
||
325 | 325 | mcrypt_generic_init($this->enmcrypt, $this->key, $iv); |
326 | 326 | $this->enbuffer['enmcrypt_init'] = false; |
327 | 327 | } |
328 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 16)); |
|
328 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 16)); |
|
329 | 329 | $iv = substr($ciphertext, -16); |
330 | - $len%= 16; |
|
330 | + $len %= 16; |
|
331 | 331 | } else { |
332 | 332 | while ($len >= 16) { |
333 | 333 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, 16); |
334 | - $ciphertext.= $iv; |
|
335 | - $len-= 16; |
|
336 | - $i+= 16; |
|
334 | + $ciphertext .= $iv; |
|
335 | + $len -= 16; |
|
336 | + $i += 16; |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $iv = mcrypt_generic($this->ecb, $iv); |
343 | 343 | $block = $iv ^ substr($plaintext, -$len); |
344 | 344 | $iv = substr_replace($iv, $block, 0, $len); |
345 | - $ciphertext.= $block; |
|
345 | + $ciphertext .= $block; |
|
346 | 346 | $pos = $len; |
347 | 347 | } |
348 | 348 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | function decrypt($ciphertext) |
378 | 378 | { |
379 | - if ( CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT ) { |
|
379 | + if (CRYPT_AES_MODE == CRYPT_AES_MODE_MCRYPT) { |
|
380 | 380 | $this->_mcryptSetup(); |
381 | 381 | |
382 | 382 | if ($this->mode == 'ncfb' && $this->continuousBuffer) { |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | $max = 16 - $pos; |
391 | 391 | if ($len >= $max) { |
392 | 392 | $i = $max; |
393 | - $len-= $max; |
|
393 | + $len -= $max; |
|
394 | 394 | $pos = 0; |
395 | 395 | } else { |
396 | 396 | $i = $len; |
397 | - $pos+= $len; |
|
397 | + $pos += $len; |
|
398 | 398 | $len = 0; |
399 | 399 | } |
400 | 400 | // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize |
@@ -403,13 +403,13 @@ discard block |
||
403 | 403 | } |
404 | 404 | if ($len >= 16) { |
405 | 405 | $cb = substr($ciphertext, $i, $len - $len % 16); |
406 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
406 | + $plaintext .= mcrypt_generic($this->ecb, $iv.$cb) ^ $cb; |
|
407 | 407 | $iv = substr($cb, -16); |
408 | - $len%= 16; |
|
408 | + $len %= 16; |
|
409 | 409 | } |
410 | 410 | if ($len) { |
411 | 411 | $iv = mcrypt_generic($this->ecb, $iv); |
412 | - $plaintext.= $iv ^ substr($ciphertext, -$len); |
|
412 | + $plaintext .= $iv ^ substr($ciphertext, -$len); |
|
413 | 413 | $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); |
414 | 414 | $pos = $len; |
415 | 415 | } |
@@ -98,6 +98,7 @@ discard block |
||
98 | 98 | * CRYPT_DES_MODE_ECB or CRYPT_DES_MODE_CBC. If not explictly set, CRYPT_DES_MODE_CBC will be used. |
99 | 99 | * |
100 | 100 | * @param optional Integer $mode |
101 | + * @param integer $mode |
|
101 | 102 | * @return Crypt_TripleDES |
102 | 103 | * @access public |
103 | 104 | */ |
@@ -318,6 +319,7 @@ discard block |
||
318 | 319 | * |
319 | 320 | * @access public |
320 | 321 | * @param String $plaintext |
322 | + * @return string |
|
321 | 323 | */ |
322 | 324 | function encrypt($plaintext) |
323 | 325 | { |
@@ -625,13 +625,13 @@ |
||
625 | 625 | $l^= $p[++$i]; |
626 | 626 | $r^= ($sb_0[$l >> 24 & 0xff] + |
627 | 627 | $sb_1[$l >> 16 & 0xff] ^ |
628 | - $sb_2[$l >> 8 & 0xff]) + |
|
628 | + $sb_2[$l >> 8 & 0xff]) + |
|
629 | 629 | $sb_3[$l & 0xff]; |
630 | 630 | |
631 | 631 | $r^= $p[++$i]; |
632 | 632 | $l^= ($sb_0[$r >> 24 & 0xff] + |
633 | 633 | $sb_1[$r >> 16 & 0xff] ^ |
634 | - $sb_2[$r >> 8 & 0xff]) + |
|
634 | + $sb_2[$r >> 8 & 0xff]) + |
|
635 | 635 | $sb_3[$r & 0xff]; |
636 | 636 | |
637 | 637 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @access private |
279 | 279 | * @var array |
280 | 280 | */ |
281 | - var $sbox0 = array ( |
|
281 | + var $sbox0 = array( |
|
282 | 282 | 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, |
283 | 283 | 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, |
284 | 284 | 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | */ |
470 | 470 | function Crypt_Blowfish($mode = CRYPT_BLOWFISH_MODE_CBC) |
471 | 471 | { |
472 | - if ( !defined('CRYPT_BLOWFISH_MODE') ) { |
|
472 | + if (!defined('CRYPT_BLOWFISH_MODE')) { |
|
473 | 473 | switch (true) { |
474 | 474 | case extension_loaded('mcrypt') && in_array('blowfish', mcrypt_list_algorithms()): |
475 | 475 | define('CRYPT_BLOWFISH_MODE', CRYPT_BLOWFISH_MODE_MCRYPT); |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
482 | - switch ( CRYPT_BLOWFISH_MODE ) { |
|
482 | + switch (CRYPT_BLOWFISH_MODE) { |
|
483 | 483 | case CRYPT_BLOWFISH_MODE_MCRYPT: |
484 | 484 | switch ($mode) { |
485 | 485 | case CRYPT_BLOWFISH_MODE_ECB: |
@@ -590,13 +590,13 @@ discard block |
||
590 | 590 | $datar = 0; |
591 | 591 | for ($i = 0; $i < 18; $i += 2) { |
592 | 592 | $this->_encryptBlock($datal, $datar); |
593 | - $this->bctx['p'][$i ] = $datal; |
|
593 | + $this->bctx['p'][$i] = $datal; |
|
594 | 594 | $this->bctx['p'][$i + 1] = $datar; |
595 | 595 | } |
596 | 596 | for ($i = 0; $i < 4; ++$i) { |
597 | 597 | for ($j = 0; $j < 256; $j += 2) { |
598 | 598 | $this->_encryptBlock($datal, $datar); |
599 | - $this->bctx['sb'][$i][$j ] = $datal; |
|
599 | + $this->bctx['sb'][$i][$j] = $datal; |
|
600 | 600 | $this->bctx['sb'][$i][$j + 1] = $datar; |
601 | 601 | } |
602 | 602 | } |
@@ -622,17 +622,17 @@ discard block |
||
622 | 622 | |
623 | 623 | $i = -1; |
624 | 624 | while ($i < 15) { |
625 | - $l^= $p[++$i]; |
|
626 | - $r^= ($sb_0[$l >> 24 & 0xff] + |
|
627 | - $sb_1[$l >> 16 & 0xff] ^ |
|
628 | - $sb_2[$l >> 8 & 0xff]) + |
|
629 | - $sb_3[$l & 0xff]; |
|
630 | - |
|
631 | - $r^= $p[++$i]; |
|
632 | - $l^= ($sb_0[$r >> 24 & 0xff] + |
|
633 | - $sb_1[$r >> 16 & 0xff] ^ |
|
634 | - $sb_2[$r >> 8 & 0xff]) + |
|
635 | - $sb_3[$r & 0xff]; |
|
625 | + $l ^= $p[++$i]; |
|
626 | + $r ^= ($sb_0[$l >> 24 & 0xff] + |
|
627 | + $sb_1[$l >> 16 & 0xff] ^ |
|
628 | + $sb_2[$l >> 8 & 0xff]) + |
|
629 | + $sb_3[$l & 0xff]; |
|
630 | + |
|
631 | + $r ^= $p[++$i]; |
|
632 | + $l ^= ($sb_0[$r >> 24 & 0xff] + |
|
633 | + $sb_1[$r >> 16 & 0xff] ^ |
|
634 | + $sb_2[$r >> 8 & 0xff]) + |
|
635 | + $sb_3[$r & 0xff]; |
|
636 | 636 | |
637 | 637 | } |
638 | 638 | $Xr = $l ^ $p[16]; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | |
657 | 657 | switch ($method) { |
658 | 658 | default: // 'pbkdf2' |
659 | - list(, , $hash, $salt, $count) = func_get_args(); |
|
659 | + list(,, $hash, $salt, $count) = func_get_args(); |
|
660 | 660 | if (!isset($hash)) { |
661 | 661 | $hash = 'sha1'; |
662 | 662 | } |
@@ -680,12 +680,12 @@ discard block |
||
680 | 680 | $hmac = new Crypt_Hash(); |
681 | 681 | $hmac->setHash($hash); |
682 | 682 | $hmac->setKey($password); |
683 | - $f = $u = $hmac->hash($salt . pack('N', $i++)); |
|
683 | + $f = $u = $hmac->hash($salt.pack('N', $i++)); |
|
684 | 684 | for ($j = 2; $j <= $count; $j++) { |
685 | 685 | $u = $hmac->hash($u); |
686 | - $f^= $u; |
|
686 | + $f ^= $u; |
|
687 | 687 | } |
688 | - $key.= $f; |
|
688 | + $key .= $f; |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | */ |
728 | 728 | function encrypt($plaintext) |
729 | 729 | { |
730 | - if ( CRYPT_BLOWFISH_MODE == CRYPT_BLOWFISH_MODE_MCRYPT ) { |
|
730 | + if (CRYPT_BLOWFISH_MODE == CRYPT_BLOWFISH_MODE_MCRYPT) { |
|
731 | 731 | if ($this->paddable) { |
732 | 732 | $plaintext = $this->_pad($plaintext); |
733 | 733 | } |
@@ -753,11 +753,11 @@ discard block |
||
753 | 753 | $max = 8 - $pos; |
754 | 754 | if ($len >= $max) { |
755 | 755 | $i = $max; |
756 | - $len-= $max; |
|
756 | + $len -= $max; |
|
757 | 757 | $pos = 0; |
758 | 758 | } else { |
759 | 759 | $i = $len; |
760 | - $pos+= $len; |
|
760 | + $pos += $len; |
|
761 | 761 | $len = 0; |
762 | 762 | } |
763 | 763 | $ciphertext = substr($iv, $orig_pos) ^ $plaintext; |
@@ -770,15 +770,15 @@ discard block |
||
770 | 770 | mcrypt_generic_init($this->enmcrypt, $this->key, $iv); |
771 | 771 | $this->enbuffer['enmcrypt_init'] = false; |
772 | 772 | } |
773 | - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
773 | + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8)); |
|
774 | 774 | $iv = substr($ciphertext, -8); |
775 | - $len%= 8; |
|
775 | + $len %= 8; |
|
776 | 776 | } else { |
777 | 777 | while ($len >= 8) { |
778 | 778 | $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, 8); |
779 | - $ciphertext.= $iv; |
|
780 | - $len-= 8; |
|
781 | - $i+= 8; |
|
779 | + $ciphertext .= $iv; |
|
780 | + $len -= 8; |
|
781 | + $i += 8; |
|
782 | 782 | } |
783 | 783 | } |
784 | 784 | } |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | $iv = mcrypt_generic($this->ecb, $iv); |
787 | 787 | $block = $iv ^ substr($plaintext, -$len); |
788 | 788 | $iv = substr_replace($iv, $block, 0, $len); |
789 | - $ciphertext.= $block; |
|
789 | + $ciphertext .= $block; |
|
790 | 790 | $pos = $len; |
791 | 791 | } |
792 | 792 | return $ciphertext; |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | */ |
819 | 819 | function decrypt($ciphertext) |
820 | 820 | { |
821 | - if ( CRYPT_BLOWFISH_MODE == CRYPT_BLOWFISH_MODE_MCRYPT ) { |
|
821 | + if (CRYPT_BLOWFISH_MODE == CRYPT_BLOWFISH_MODE_MCRYPT) { |
|
822 | 822 | if ($this->paddable) { |
823 | 823 | // we pad with chr(0) since that's what mcrypt_generic does. to quote from http://php.net/function.mcrypt-generic : |
824 | 824 | // "The data is padded with "\0" to make sure the length of the data is n * blocksize." |
@@ -846,11 +846,11 @@ discard block |
||
846 | 846 | $max = 8 - $pos; |
847 | 847 | if ($len >= $max) { |
848 | 848 | $i = $max; |
849 | - $len-= $max; |
|
849 | + $len -= $max; |
|
850 | 850 | $pos = 0; |
851 | 851 | } else { |
852 | 852 | $i = $len; |
853 | - $pos+= $len; |
|
853 | + $pos += $len; |
|
854 | 854 | $len = 0; |
855 | 855 | } |
856 | 856 | $plaintext = substr($iv, $orig_pos) ^ $ciphertext; |
@@ -858,13 +858,13 @@ discard block |
||
858 | 858 | } |
859 | 859 | if ($len >= 8) { |
860 | 860 | $cb = substr($ciphertext, $i, $len - $len % 8); |
861 | - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; |
|
861 | + $plaintext .= mcrypt_generic($this->ecb, $iv.$cb) ^ $cb; |
|
862 | 862 | $iv = substr($cb, -8); |
863 | - $len%= 8; |
|
863 | + $len %= 8; |
|
864 | 864 | } |
865 | 865 | if ($len) { |
866 | 866 | $iv = mcrypt_generic($this->ecb, $iv); |
867 | - $plaintext.= $iv ^ substr($ciphertext, -$len); |
|
867 | + $plaintext .= $iv ^ substr($ciphertext, -$len); |
|
868 | 868 | $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); |
869 | 869 | $pos = $len; |
870 | 870 | } |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | function _generate_xor(&$iv) |
1033 | 1033 | { |
1034 | 1034 | $xor = $iv; |
1035 | - for ($j = 4; $j <= 8; $j+=4) { |
|
1035 | + for ($j = 4; $j <= 8; $j += 4) { |
|
1036 | 1036 | $temp = substr($iv, -$j, 4); |
1037 | 1037 | switch ($temp) { |
1038 | 1038 | case "\xFF\xFF\xFF\xFF": |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | */ |
1059 | 1059 | function inline_crypt_setup() |
1060 | 1060 | {/*{{{*/ |
1061 | - $lambda_functions =& Crypt_Blowfish::get_lambda_functions(); |
|
1061 | + $lambda_functions = & Crypt_Blowfish::get_lambda_functions(); |
|
1062 | 1062 | $block_size = 8; |
1063 | 1063 | $mode = $this->mode; |
1064 | 1064 | $code_hash = "$mode"; |
@@ -1075,8 +1075,8 @@ discard block |
||
1075 | 1075 | $l = $in[1]; |
1076 | 1076 | $r = $in[2]; |
1077 | 1077 | '; |
1078 | - for ($i = 0; $i < 16; $i+= 2) { |
|
1079 | - $_encryptBlock.= ' |
|
1078 | + for ($i = 0; $i < 16; $i += 2) { |
|
1079 | + $_encryptBlock .= ' |
|
1080 | 1080 | $l^= $p_'.($i).'; |
1081 | 1081 | $r^= ($sb_0[$l >> 24 & 0xff] + |
1082 | 1082 | $sb_1[$l >> 16 & 0xff] ^ |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | $sb_3[$r & 0xff]; |
1091 | 1091 | '; |
1092 | 1092 | } |
1093 | - $_encryptBlock.= ' |
|
1093 | + $_encryptBlock .= ' |
|
1094 | 1094 | $in = pack("N*", $r ^ $p_17, $l ^ $p_16); |
1095 | 1095 | '; |
1096 | 1096 | |
@@ -1101,8 +1101,8 @@ discard block |
||
1101 | 1101 | $r = $in[2]; |
1102 | 1102 | '; |
1103 | 1103 | |
1104 | - for ($i = 17; $i > 2; $i-= 2) { |
|
1105 | - $_decryptBlock.= ' |
|
1104 | + for ($i = 17; $i > 2; $i -= 2) { |
|
1105 | + $_decryptBlock .= ' |
|
1106 | 1106 | $l^= $p_'.($i).'; |
1107 | 1107 | $r^= ($sb_0[$l >> 24 & 0xff] + |
1108 | 1108 | $sb_1[$l >> 16 & 0xff] ^ |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | '; |
1118 | 1118 | } |
1119 | 1119 | |
1120 | - $_decryptBlock.= ' |
|
1120 | + $_decryptBlock .= ' |
|
1121 | 1121 | $in = pack("N*", $r ^ $p_0, $l ^ $p_1); |
1122 | 1122 | '; |
1123 | 1123 | |
@@ -1439,12 +1439,12 @@ discard block |
||
1439 | 1439 | break; |
1440 | 1440 | } |
1441 | 1441 | $fnc_head = '$action, &$self, $text'; |
1442 | - $fnc_body = $init_cryptBlock . 'if ($action == "encrypt") { ' . $encrypt . ' } else { ' . $decrypt . ' }'; |
|
1442 | + $fnc_body = $init_cryptBlock.'if ($action == "encrypt") { '.$encrypt.' } else { '.$decrypt.' }'; |
|
1443 | 1443 | |
1444 | 1444 | if (function_exists('create_function') && is_callable('create_function')) { |
1445 | 1445 | $lambda_functions[$code_hash] = create_function($fnc_head, $fnc_body); |
1446 | 1446 | } else { |
1447 | - eval('function ' . ($lambda_functions[$code_hash] = 'f' . md5(microtime())) . '(' . $fnc_head . ') { ' . $fnc_body . ' }'); |
|
1447 | + eval('function '.($lambda_functions[$code_hash] = 'f'.md5(microtime())).'('.$fnc_head.') { '.$fnc_body.' }'); |
|
1448 | 1448 | } |
1449 | 1449 | } |
1450 | 1450 | $this->inline_crypt = $lambda_functions[$code_hash]; |
@@ -545,8 +545,7 @@ |
||
545 | 545 | |
546 | 546 | if (!$keylength) { |
547 | 547 | $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; |
548 | - } |
|
549 | - elseif ($keylength > 56) { |
|
548 | + } elseif ($keylength > 56) { |
|
550 | 549 | $key = substr($key, 0, 56); |
551 | 550 | } |
552 | 551 |
@@ -563,6 +563,7 @@ discard block |
||
563 | 563 | * If not explictly set, CRYPT_TWOFISH_MODE_CBC will be used. |
564 | 564 | * |
565 | 565 | * @param optional Integer $mode |
566 | + * @param integer $mode |
|
566 | 567 | * @access public |
567 | 568 | */ |
568 | 569 | function Crypt_Twofish($mode = CRYPT_TWOFISH_MODE_CBC) |
@@ -1072,6 +1073,7 @@ discard block |
||
1072 | 1073 | * |
1073 | 1074 | * @see Crypt_Twofish::_unpad() |
1074 | 1075 | * @access private |
1076 | + * @param string $text |
|
1075 | 1077 | */ |
1076 | 1078 | function _pad($text) |
1077 | 1079 | { |
@@ -1099,6 +1101,7 @@ discard block |
||
1099 | 1101 | * |
1100 | 1102 | * @see Crypt_Twofish::_pad() |
1101 | 1103 | * @access private |
1104 | + * @param string $text |
|
1102 | 1105 | */ |
1103 | 1106 | function _unpad($text) |
1104 | 1107 | { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | function Crypt_RC4() |
173 | 173 | { |
174 | - if ( !defined('CRYPT_RC4_MODE') ) { |
|
174 | + if (!defined('CRYPT_RC4_MODE')) { |
|
175 | 175 | switch (true) { |
176 | 176 | case extension_loaded('mcrypt') && (defined('MCRYPT_ARCFOUR') || defined('MCRYPT_RC4')) && in_array('arcfour', mcrypt_list_algorithms()): |
177 | 177 | define('CRYPT_RC4_MODE', CRYPT_RC4_MODE_MCRYPT); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - switch ( CRYPT_RC4_MODE ) { |
|
184 | + switch (CRYPT_RC4_MODE) { |
|
185 | 185 | case CRYPT_RC4_MODE_MCRYPT: |
186 | 186 | switch (true) { |
187 | 187 | case defined('MCRYPT_ARCFOUR'): |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | { |
210 | 210 | $this->key = $key; |
211 | 211 | |
212 | - if ( CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT ) { |
|
212 | + if (CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT) { |
|
213 | 213 | mcrypt_generic_init($this->encryptStream, $this->key, ''); |
214 | 214 | mcrypt_generic_init($this->decryptStream, $this->key, ''); |
215 | 215 | return; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | switch ($method) { |
251 | 251 | default: // 'pbkdf2' |
252 | - list(, , $hash, $salt, $count) = func_get_args(); |
|
252 | + list(,, $hash, $salt, $count) = func_get_args(); |
|
253 | 253 | if (!isset($hash)) { |
254 | 254 | $hash = 'sha1'; |
255 | 255 | } |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | $hmac = new Crypt_Hash(); |
277 | 277 | $hmac->setHash($hash); |
278 | 278 | $hmac->setKey($password); |
279 | - $f = $u = $hmac->hash($salt . pack('N', $i++)); |
|
279 | + $f = $u = $hmac->hash($salt.pack('N', $i++)); |
|
280 | 280 | for ($j = 2; $j <= $count; $j++) { |
281 | 281 | $u = $hmac->hash($u); |
282 | - $f^= $u; |
|
282 | + $f ^= $u; |
|
283 | 283 | } |
284 | - $key.= $f; |
|
284 | + $key .= $f; |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | */ |
350 | 350 | function _crypt($text, $mode) |
351 | 351 | { |
352 | - if ( CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT ) { |
|
352 | + if (CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT) { |
|
353 | 353 | $keyStream = $mode == CRYPT_RC4_ENCRYPT ? 'encryptStream' : 'decryptStream'; |
354 | 354 | |
355 | 355 | if (!$this->continuousBuffer) { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | $keyStream[$i] = $keyStream[$j]; |
382 | 382 | $keyStream[$j] = $temp; |
383 | 383 | $temp = $keyStream[($keyStream[$i] + $keyStream[$j]) & 255]; |
384 | - $newText.= chr(ord($text[$k]) ^ $temp); |
|
384 | + $newText .= chr(ord($text[$k]) ^ $temp); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | if ($this->continuousBuffer) { |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | */ |
439 | 439 | function enableContinuousBuffer() |
440 | 440 | { |
441 | - if ( CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT ) { |
|
441 | + if (CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT) { |
|
442 | 442 | mcrypt_generic_init($this->encryptStream, $this->key, ''); |
443 | 443 | mcrypt_generic_init($this->decryptStream, $this->key, ''); |
444 | 444 | } |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | */ |
457 | 457 | function disableContinuousBuffer() |
458 | 458 | { |
459 | - if ( CRYPT_RC4_MODE == CRYPT_RC4_MODE_INTERNAL ) { |
|
459 | + if (CRYPT_RC4_MODE == CRYPT_RC4_MODE_INTERNAL) { |
|
460 | 460 | $this->encryptIndex = $this->decryptIndex = array(0, 0); |
461 | 461 | $this->encryptStream = $this->decryptStream = false; |
462 | 462 | } |
@@ -34,9 +34,9 @@ |
||
34 | 34 | public $search_did = 0; |
35 | 35 | public $audio = ""; |
36 | 36 | |
37 | - public function __construct($in_c_id=0, $in_id=0) |
|
37 | + public function __construct($in_c_id = 0, $in_id = 0) |
|
38 | 38 | { |
39 | - if ($in_c_id > 0 && $in_id >0) { |
|
39 | + if ($in_c_id > 0 && $in_id > 0) { |
|
40 | 40 | $item_view_table = Database::get_course_table(TABLE_LP_ITEM); |
41 | 41 | $sql = "SELECT * FROM $item_view_table |
42 | 42 | WHERE |
@@ -44,17 +44,17 @@ |
||
44 | 44 | ORDER BY name, id |
45 | 45 | LIMIT 11'; |
46 | 46 | $rs = Database::query($sql); |
47 | - $i=0; |
|
47 | + $i = 0; |
|
48 | 48 | while ($session = Database :: fetch_array($rs)) { |
49 | 49 | $i++; |
50 | - if ($i<=10) { |
|
50 | + if ($i <= 10) { |
|
51 | 51 | $return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />'; |
52 | 52 | } else { |
53 | 53 | $return .= '...<br />'; |
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
57 | - $xajax_response -> addAssign('ajax_list_courses','innerHTML',api_utf8_encode($return)); |
|
57 | + $xajax_response -> addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return)); |
|
58 | 58 | return $xajax_response; |
59 | 59 | } |
60 | 60 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * search string |
24 | 24 | * @param string Search string |
25 | 25 | * @param int Deprecated param |
26 | - * @return string Xajax response block |
|
26 | + * @return xajaxResponse Xajax response block |
|
27 | 27 | * @assert () === false |
28 | 28 | */ |
29 | 29 | function search_users($needle, $id) |
@@ -48,7 +48,7 @@ |
||
48 | 48 | while ($session = Database :: fetch_array($rs)) { |
49 | 49 | $i++; |
50 | 50 | if ($i<=10) { |
51 | - $return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />'; |
|
51 | + $return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />'; |
|
52 | 52 | } else { |
53 | 53 | $return .= '...<br />'; |
54 | 54 | } |
@@ -1819,7 +1819,9 @@ discard block |
||
1819 | 1819 | } |
1820 | 1820 | |
1821 | 1821 | global $_course; |
1822 | - if ($_course == '-1') $_course = array(); |
|
1822 | + if ($_course == '-1') { |
|
1823 | + $_course = array(); |
|
1824 | + } |
|
1823 | 1825 | return $_course; |
1824 | 1826 | } |
1825 | 1827 | |
@@ -4315,17 +4317,20 @@ discard block |
||
4315 | 4317 | switch ($lang_type) { |
4316 | 4318 | case 'platform_lang': |
4317 | 4319 | $temp_lang = api_get_setting('platformLanguage'); |
4318 | - if (!empty($temp_lang)) |
|
4319 | - $return = $temp_lang; |
|
4320 | + if (!empty($temp_lang)) { |
|
4321 | + $return = $temp_lang; |
|
4322 | + } |
|
4320 | 4323 | break; |
4321 | 4324 | case 'user_profil_lang': |
4322 | 4325 | $_user = api_get_user_info(); |
4323 | - if (isset($_user['language']) && !empty($_user['language'])) |
|
4324 | - $return = $_user['language']; |
|
4326 | + if (isset($_user['language']) && !empty($_user['language'])) { |
|
4327 | + $return = $_user['language']; |
|
4328 | + } |
|
4325 | 4329 | break; |
4326 | 4330 | case 'user_selected_lang': |
4327 | - if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) |
|
4328 | - $return = $_SESSION['user_language_choice']; |
|
4331 | + if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) { |
|
4332 | + $return = $_SESSION['user_language_choice']; |
|
4333 | + } |
|
4329 | 4334 | break; |
4330 | 4335 | case 'course_lang': |
4331 | 4336 | global $_course; |
@@ -4343,8 +4348,9 @@ discard block |
||
4343 | 4348 | } |
4344 | 4349 | } |
4345 | 4350 | $_course = api_get_course_info($cidReq); |
4346 | - if (isset($_course['language']) && !empty($_course['language'])) |
|
4347 | - $return = $_course['language']; |
|
4351 | + if (isset($_course['language']) && !empty($_course['language'])) { |
|
4352 | + $return = $_course['language']; |
|
4353 | + } |
|
4348 | 4354 | break; |
4349 | 4355 | default: |
4350 | 4356 | $return = false; |
@@ -5604,8 +5610,7 @@ discard block |
||
5604 | 5610 | $is_courseAdmin = false; |
5605 | 5611 | $is_courseCoach = true; |
5606 | 5612 | $is_sessionAdmin = false; |
5607 | - } |
|
5608 | - elseif ($row[0]['session_admin_id'] == $userid) { |
|
5613 | + } elseif ($row[0]['session_admin_id'] == $userid) { |
|
5609 | 5614 | $is_courseMember = false; |
5610 | 5615 | $is_courseTutor = false; |
5611 | 5616 | $is_courseAdmin = false; |
@@ -5885,7 +5890,9 @@ discard block |
||
5885 | 5890 | |
5886 | 5891 | if (!empty($course_code)) { |
5887 | 5892 | if (isset($_SESSION['_course']['sysCode'])) { |
5888 | - if ($course_code != $_SESSION['_course']['sysCode']) return false; |
|
5893 | + if ($course_code != $_SESSION['_course']['sysCode']) { |
|
5894 | + return false; |
|
5895 | + } |
|
5889 | 5896 | } else { |
5890 | 5897 | return false; |
5891 | 5898 | } |
@@ -5942,8 +5949,7 @@ discard block |
||
5942 | 5949 | elseif (isset($_ENV['OS'])) { |
5943 | 5950 | // Sometimes $_ENV['OS'] may not be present (bugs?) |
5944 | 5951 | $os = $_ENV['OS']; |
5945 | - } |
|
5946 | - elseif (defined('PHP_OS')) { |
|
5952 | + } elseif (defined('PHP_OS')) { |
|
5947 | 5953 | // PHP_OS means on which OS PHP was compiled, this is why |
5948 | 5954 | // using PHP_OS is the last choice for detection. |
5949 | 5955 | $os = PHP_OS; |
@@ -6007,12 +6013,10 @@ discard block |
||
6007 | 6013 | if ($delta_width > $delta_height) { |
6008 | 6014 | $result['width'] = ceil($image_width * $resize_factor_height); |
6009 | 6015 | $result['height'] = ceil($image_height * $resize_factor_height); |
6010 | - } |
|
6011 | - elseif ($delta_width < $delta_height) { |
|
6016 | + } elseif ($delta_width < $delta_height) { |
|
6012 | 6017 | $result['width'] = ceil($image_width * $resize_factor_width); |
6013 | 6018 | $result['height'] = ceil($image_height * $resize_factor_width); |
6014 | - } |
|
6015 | - else { |
|
6019 | + } else { |
|
6016 | 6020 | $result['width'] = ceil($target_width); |
6017 | 6021 | $result['height'] = ceil($target_height); |
6018 | 6022 | } |
@@ -6781,7 +6785,9 @@ discard block |
||
6781 | 6785 | } |
6782 | 6786 | $ip = trim($ip1); |
6783 | 6787 | } |
6784 | - if (!empty($debug)) error_log('Real IP: '.$ip); |
|
6788 | + if (!empty($debug)) { |
|
6789 | + error_log('Real IP: '.$ip); |
|
6790 | + } |
|
6785 | 6791 | return $ip; |
6786 | 6792 | } |
6787 | 6793 |
@@ -575,7 +575,6 @@ discard block |
||
575 | 575 | * Also, this function provides conversion between path types, in this case the input path points inside the Chamilo area too. |
576 | 576 | * |
577 | 577 | * See $_configuration['course_folder'] in the configuration.php to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters. |
578 | - * @param string $type The requested path type (a defined constant), see the examples. |
|
579 | 578 | * @param string $path (optional) A path which type is to be converted. Also, it may be a defined constant for a path. |
580 | 579 | * This parameter has meaning when $type parameter has one of the following values: TO_WEB, TO_SYS, TO_REL. Otherwise it is ignored. |
581 | 580 | * @return string The requested path or the converted path. |
@@ -1070,7 +1069,7 @@ discard block |
||
1070 | 1069 | * Checks the RFC 3986 syntax of a given URL. |
1071 | 1070 | * @param string $url The URL to be checked. |
1072 | 1071 | * @param bool $absolute Whether the URL is absolute (beginning with a scheme such as "http:"). |
1073 | - * @return bool Returns the URL if it is valid, FALSE otherwise. |
|
1072 | + * @return string|false Returns the URL if it is valid, FALSE otherwise. |
|
1074 | 1073 | * This function is an adaptation from the function valid_url(), Drupal CMS. |
1075 | 1074 | * @link http://drupal.org |
1076 | 1075 | * Note: The built-in function filter_var($urs, FILTER_VALIDATE_URL) has a bug for some versions of PHP. |
@@ -1650,6 +1649,7 @@ discard block |
||
1650 | 1649 | * Gets a course setting from the current course_setting table. Try always using integer values. |
1651 | 1650 | * @param string The name of the setting we want from the table |
1652 | 1651 | * @param string Optional: course code |
1652 | + * @param string $setting_name |
|
1653 | 1653 | * @return mixed The value of that setting in that table. Return -1 if not found. |
1654 | 1654 | */ |
1655 | 1655 | function api_get_course_setting($setting_name, $course_code = null) |
@@ -1957,7 +1957,7 @@ discard block |
||
1957 | 1957 | /** |
1958 | 1958 | * Checks a password to see wether it is OK to use. |
1959 | 1959 | * @param string $password |
1960 | - * @return true if the password is acceptable, false otherwise |
|
1960 | + * @return boolean if the password is acceptable, false otherwise |
|
1961 | 1961 | * Notes about what a password "OK to use" is: |
1962 | 1962 | * 1. The password should be at least 5 characters long. |
1963 | 1963 | * 2. Only English letters (uppercase or lowercase, it doesn't matter) and digits are allowed. |
@@ -2129,7 +2129,7 @@ discard block |
||
2129 | 2129 | * @author Hugues Peeters <[email protected]> |
2130 | 2130 | * @param string $failure_type - the type of failure |
2131 | 2131 | * @global array $api_failureList |
2132 | - * @return bolean false to stay consistent with the main script |
|
2132 | + * @return boolean false to stay consistent with the main script |
|
2133 | 2133 | */ |
2134 | 2134 | static function set_failure($failure_type) { |
2135 | 2135 | global $api_failureList; |
@@ -3196,8 +3196,8 @@ discard block |
||
3196 | 3196 | |
3197 | 3197 | /** |
3198 | 3198 | * Checks whether the user is allowed in a specific tool for a specific action |
3199 | -* @param $tool the tool we are checking if the user has a certain permission |
|
3200 | -* @param $action the action we are checking (add, edit, delete, move, visibility) |
|
3199 | +* @param string $tool the tool we are checking if the user has a certain permission |
|
3200 | +* @param string $action the action we are checking (add, edit, delete, move, visibility) |
|
3201 | 3201 | * @author Patrick Cool <[email protected]>, Ghent University |
3202 | 3202 | * @author Julio Montoya |
3203 | 3203 | * @version 1.0 |
@@ -3496,7 +3496,7 @@ discard block |
||
3496 | 3496 | /** |
3497 | 3497 | * Gets a UNIX timestamp from a database (MySQL) datetime format string |
3498 | 3498 | * @param $last_post_datetime standard output date in a sql query |
3499 | - * @return unix timestamp |
|
3499 | + * @return integer timestamp |
|
3500 | 3500 | * @author Toon Van Hoecke <[email protected]> |
3501 | 3501 | * @version October 2003 |
3502 | 3502 | * @desc convert sql date to unix timestamp |
@@ -3529,6 +3529,9 @@ discard block |
||
3529 | 3529 | * @param string Tool (learnpath, document, etc) |
3530 | 3530 | * @param int The item ID in the given tool |
3531 | 3531 | * @param int The session ID (optional) |
3532 | + * @param string $tool |
|
3533 | + * @param integer $user_id |
|
3534 | + * @param string $type |
|
3532 | 3535 | * @return int -1 on error, 0 if invisible, 1 if visible |
3533 | 3536 | */ |
3534 | 3537 | function api_get_item_visibility( |
@@ -3597,7 +3600,7 @@ discard block |
||
3597 | 3600 | * @param int $userId |
3598 | 3601 | * @param int $groupId |
3599 | 3602 | * @param int $sessionId |
3600 | - * @return void |
|
3603 | + * @return false|null |
|
3601 | 3604 | */ |
3602 | 3605 | function api_item_property_delete( |
3603 | 3606 | $courseInfo, |
@@ -3652,7 +3655,7 @@ discard block |
||
3652 | 3655 | * @param array $_course array with course properties |
3653 | 3656 | * @param string $tool tool id, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!) |
3654 | 3657 | * @param int $item_id id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool |
3655 | - * @param string $lastedit_type add or update action |
|
3658 | + * @param string $last_edit_type add or update action |
|
3656 | 3659 | * (1) message to be translated (in trad4all) : e.g. DocumentAdded, DocumentUpdated; |
3657 | 3660 | * (2) "delete" |
3658 | 3661 | * (3) "visible" |
@@ -3935,6 +3938,8 @@ discard block |
||
3935 | 3938 | * @param string tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!) |
3936 | 3939 | * @param int id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool |
3937 | 3940 | * @param int $session_id |
3941 | + * @param string $tool |
|
3942 | + * @param string $course_code |
|
3938 | 3943 | * @return array All fields from c_item_property (all rows found) or empty array |
3939 | 3944 | */ |
3940 | 3945 | function api_get_item_property_by_tool($tool, $course_code, $session_id = null) |
@@ -4197,7 +4202,7 @@ discard block |
||
4197 | 4202 | * Displays a form (drop down menu) so the user can select his/her preferred language. |
4198 | 4203 | * The form works with or without javascript |
4199 | 4204 | * @param boolean Hide form if only one language available (defaults to false = show the box anyway) |
4200 | - * @return void Display the box directly |
|
4205 | + * @return null|string Display the box directly |
|
4201 | 4206 | */ |
4202 | 4207 | function api_display_language_form($hide_if_no_choice = false) |
4203 | 4208 | { |
@@ -4477,6 +4482,7 @@ discard block |
||
4477 | 4482 | * and also when a user subscribes to courses (the new course is added at the end of the main category |
4478 | 4483 | * @author Patrick Cool <[email protected]>, Ghent University |
4479 | 4484 | * @param int $user_course_category: the id of the user_course_category |
4485 | + * @param integer $user_id |
|
4480 | 4486 | * @return int the value of the highest sort of the user_course_category |
4481 | 4487 | */ |
4482 | 4488 | function api_max_sort_value($user_course_category, $user_id) |
@@ -4685,6 +4691,8 @@ discard block |
||
4685 | 4691 | * @param the dest folder |
4686 | 4692 | * @param an array of excluded file_name (without extension) |
4687 | 4693 | * @param copied_files the returned array of copied files |
4694 | + * @param string $source |
|
4695 | + * @param string $dest |
|
4688 | 4696 | */ |
4689 | 4697 | function copyr($source, $dest, $exclude = array(), $copied_files = array()) { |
4690 | 4698 | if (empty($dest)) { return false; } |
@@ -4724,6 +4732,11 @@ discard block |
||
4724 | 4732 | } |
4725 | 4733 | |
4726 | 4734 | // TODO: Using DIRECTORY_SEPARATOR is not recommended, this is an obsolete approach. Documentation header to be added here. |
4735 | +/** |
|
4736 | + * @param string $pathname |
|
4737 | + * @param string $base_path_document |
|
4738 | + * @param integer $session_id |
|
4739 | + */ |
|
4727 | 4740 | function copy_folder_course_session( |
4728 | 4741 | $pathname, |
4729 | 4742 | $base_path_document, |
@@ -4809,6 +4822,9 @@ discard block |
||
4809 | 4822 | } |
4810 | 4823 | |
4811 | 4824 | // TODO: chmodr() is a better name. Some corrections are needed. Documentation header to be added here. |
4825 | +/** |
|
4826 | + * @param string $path |
|
4827 | + */ |
|
4812 | 4828 | function api_chmod_R($path, $filemode) { |
4813 | 4829 | if (!is_dir($path)) { |
4814 | 4830 | return chmod($path, $filemode); |
@@ -4891,7 +4907,7 @@ discard block |
||
4891 | 4907 | * version = VERSION |
4892 | 4908 | * @endverbatim |
4893 | 4909 | * </code> |
4894 | - * @param $filename |
|
4910 | + * @param string $filename |
|
4895 | 4911 | * The file we are parsing. Accepts file with relative or absolute path. |
4896 | 4912 | * @return |
4897 | 4913 | * The info array. |
@@ -4983,7 +4999,7 @@ discard block |
||
4983 | 4999 | /** |
4984 | 5000 | * Checks whether status given in parameter exists in the platform |
4985 | 5001 | * @param mixed the status (can be either int either string) |
4986 | - * @return true if the status exists, else returns false |
|
5002 | + * @return boolean if the status exists, else returns false |
|
4987 | 5003 | */ |
4988 | 5004 | function api_status_exists($status_asked) { |
4989 | 5005 | global $_status_list; |
@@ -5005,7 +5021,7 @@ discard block |
||
5005 | 5021 | |
5006 | 5022 | /** |
5007 | 5023 | * Gets the status langvars list |
5008 | - * @return array the list of status with their translations |
|
5024 | + * @return string[] the list of status with their translations |
|
5009 | 5025 | */ |
5010 | 5026 | function api_get_status_langvars() { |
5011 | 5027 | return array( |
@@ -5081,6 +5097,7 @@ discard block |
||
5081 | 5097 | * @param string The sub-variable if any (in most cases, this will remain null) |
5082 | 5098 | * @param string The category if any (in most cases, this will remain null) |
5083 | 5099 | * @param int The access_url for which this parameter is valid |
5100 | + * @param string $cat |
|
5084 | 5101 | */ |
5085 | 5102 | function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url = 1) |
5086 | 5103 | { |
@@ -5178,6 +5195,8 @@ discard block |
||
5178 | 5195 | * @param string Value |
5179 | 5196 | * @param int Access URL. Optional. Defaults to 1 |
5180 | 5197 | * @param array Optional array of filters on field type |
5198 | + * @param string $category |
|
5199 | + * @param string $value |
|
5181 | 5200 | */ |
5182 | 5201 | function api_set_settings_category($category, $value = null, $access_url = 1, $fieldtype = array()) |
5183 | 5202 | { |
@@ -5421,6 +5440,10 @@ discard block |
||
5421 | 5440 | * @param string The subkey text |
5422 | 5441 | * @param int The access_url for which this parameter is valid |
5423 | 5442 | * @param int The changeability of this setting for non-master urls |
5443 | + * @param string $val |
|
5444 | + * @param string $var |
|
5445 | + * @param string $sk |
|
5446 | + * @param string $c |
|
5424 | 5447 | * @return boolean true on success, false on failure |
5425 | 5448 | */ |
5426 | 5449 | function api_add_setting($val, $var, $sk = null, $type = 'textfield', $c = null, $title = '', $com = '', $sc = null, $skt = null, $a = 1, $v = 0) { |
@@ -5686,6 +5709,7 @@ discard block |
||
5686 | 5709 | * @param String the tool of the element |
5687 | 5710 | * @param int the element id in database |
5688 | 5711 | * @param int the session_id to compare with element session id |
5712 | + * @param string $tool |
|
5689 | 5713 | * @return boolean true if the element is in the session, false else |
5690 | 5714 | */ |
5691 | 5715 | function api_is_element_in_the_session($tool, $element_id, $session_id = null) { |
@@ -5731,8 +5755,6 @@ discard block |
||
5731 | 5755 | * Replaces "forbidden" characters in a filename string. |
5732 | 5756 | * |
5733 | 5757 | * @param string $filename |
5734 | - * @param int $length |
|
5735 | - * @param bool $file_name |
|
5736 | 5758 | * |
5737 | 5759 | * @return string |
5738 | 5760 | */ |
@@ -5968,6 +5990,7 @@ discard block |
||
5968 | 5990 | * @link http://php.net/manual/en/function.getimagesize.php |
5969 | 5991 | * @link http://www.dokeos.com/forum/viewtopic.php?t=12345 |
5970 | 5992 | * @link http://www.dokeos.com/forum/viewtopic.php?t=16355 |
5993 | + * @return integer |
|
5971 | 5994 | */ |
5972 | 5995 | function api_getimagesize($path) { |
5973 | 5996 | $image = new Image($path); |
@@ -6128,6 +6151,7 @@ discard block |
||
6128 | 6151 | * with his user id and the access_url_id=1 |
6129 | 6152 | * |
6130 | 6153 | * @author Julio Montoya |
6154 | + * @param integer $user_id |
|
6131 | 6155 | */ |
6132 | 6156 | function api_is_global_platform_admin($user_id = null) |
6133 | 6157 | { |
@@ -6189,7 +6213,7 @@ discard block |
||
6189 | 6213 | * @param int $admin_id_to_check |
6190 | 6214 | * @param int $my_user_id |
6191 | 6215 | * @param bool $allow_session_admin |
6192 | - * @return bool |
|
6216 | + * @return boolean|null |
|
6193 | 6217 | */ |
6194 | 6218 | function api_protect_super_admin($admin_id_to_check, $my_user_id = null, $allow_session_admin = false) |
6195 | 6219 | { |
@@ -6431,6 +6455,7 @@ discard block |
||
6431 | 6455 | |
6432 | 6456 | /** |
6433 | 6457 | * Returns the <link> HTML tag |
6458 | + * @param string $file |
|
6434 | 6459 | */ |
6435 | 6460 | function api_get_css($file, $media = 'screen') { |
6436 | 6461 | return '<link href="'.$file.'" rel="stylesheet" media="'.$media.'" type="text/css" />'."\n"; |
@@ -6568,7 +6593,8 @@ discard block |
||
6568 | 6593 | * This function relies on api_get_course_info() |
6569 | 6594 | * @param string The course code - optional (takes it from session if not given) |
6570 | 6595 | * @param int The session id - optional (takes it from session if not given) |
6571 | - * @return mixed The URL of the course or null if something does not work |
|
6596 | + * @param integer $session_id |
|
6597 | + * @return string|null The URL of the course or null if something does not work |
|
6572 | 6598 | * @author Julio Montoya <[email protected]> |
6573 | 6599 | */ |
6574 | 6600 | function api_get_course_url($course_code = null, $session_id = null) |
@@ -6683,7 +6709,7 @@ discard block |
||
6683 | 6709 | * @param int LINK_EXERCISE, LINK_STUDENTPUBLICATION, LINK_LEARNPATH LINK_FORUM_THREAD, LINK_ATTENDANCE |
6684 | 6710 | * see gradebook/lib/be/linkfactory |
6685 | 6711 | * @param string course code |
6686 | - * @return boolean |
|
6712 | + * @return false|null |
|
6687 | 6713 | */ |
6688 | 6714 | function api_block_course_item_locked_by_gradebook($item_id, $link_type, $course_code = null) { |
6689 | 6715 | if (api_is_platform_admin()) { |
@@ -6724,7 +6750,7 @@ discard block |
||
6724 | 6750 | /** |
6725 | 6751 | * Returns an array of global configuration settings which should be ignored |
6726 | 6752 | * when printing the configuration settings screens |
6727 | - * @return array Array of strings, each identifying one of the excluded settings |
|
6753 | + * @return string[] Array of strings, each identifying one of the excluded settings |
|
6728 | 6754 | */ |
6729 | 6755 | function api_get_locked_settings() { |
6730 | 6756 | return array( |
@@ -6767,7 +6793,7 @@ discard block |
||
6767 | 6793 | * false if he isn't. If the user ID is given and is an integer, then the same |
6768 | 6794 | * ID is simply returned |
6769 | 6795 | * @param integer User ID |
6770 | - * @return mixed Integer User ID is logged in, or false otherwise |
|
6796 | + * @return boolean Integer User ID is logged in, or false otherwise |
|
6771 | 6797 | */ |
6772 | 6798 | function api_user_is_login($user_id = null) { |
6773 | 6799 | $user_id = empty($user_id) ? api_get_user_id() : intval($user_id); |
@@ -6802,6 +6828,7 @@ discard block |
||
6802 | 6828 | * Checks whether an IP is included inside an IP range |
6803 | 6829 | * @param string IP address |
6804 | 6830 | * @param string IP range |
6831 | + * @param string $ip |
|
6805 | 6832 | * @return bool True if IP is in the range, false otherwise |
6806 | 6833 | * @author claudiu at cnixs dot com on http://www.php.net/manual/fr/ref.network.php#55230 |
6807 | 6834 | * @author Yannick Warnier for improvements and managment of multiple ranges |
@@ -7185,6 +7212,7 @@ discard block |
||
7185 | 7212 | /** |
7186 | 7213 | * Tries to set memory limit, if authorized and new limit is higher than current |
7187 | 7214 | * @param string New memory limit |
7215 | + * @param string $mem |
|
7188 | 7216 | * @return bool True on success, false on failure or current is higher than suggested |
7189 | 7217 | * @assert (null) === false |
7190 | 7218 | * @assert (-1) === false |
@@ -7241,7 +7269,6 @@ discard block |
||
7241 | 7269 | |
7242 | 7270 | /** |
7243 | 7271 | * Finds all the information about a user from username instead of user id |
7244 | - * @param string $username |
|
7245 | 7272 | * |
7246 | 7273 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
7247 | 7274 | * @author Yannick Warnier <[email protected]> |
@@ -7263,7 +7290,6 @@ discard block |
||
7263 | 7290 | |
7264 | 7291 | /** |
7265 | 7292 | * |
7266 | - * @param string $inputId the jquery id example: #password |
|
7267 | 7293 | * |
7268 | 7294 | * @return string |
7269 | 7295 | */ |
@@ -7388,6 +7414,7 @@ discard block |
||
7388 | 7414 | /** |
7389 | 7415 | * Remove tags from HTML anf return the $in_number_char first non-HTML char |
7390 | 7416 | * Postfix the text with "..." if it has been truncated. |
7417 | + * @param integer $in_number_char |
|
7391 | 7418 | * @return string |
7392 | 7419 | * @author hubert borderiou |
7393 | 7420 | */ |
@@ -7432,7 +7459,7 @@ discard block |
||
7432 | 7459 | /** |
7433 | 7460 | * @param string $tool |
7434 | 7461 | * @param string $setting |
7435 | - * @param mixed $defaultValue |
|
7462 | + * @param integer $defaultValue |
|
7436 | 7463 | * @return string |
7437 | 7464 | */ |
7438 | 7465 | function api_get_default_tool_setting($tool, $setting, $defaultValue) |
@@ -7557,7 +7584,7 @@ discard block |
||
7557 | 7584 | } |
7558 | 7585 | |
7559 | 7586 | /** |
7560 | - * @return true if course_code for direct course access after login is set |
|
7587 | + * @return boolean if course_code for direct course access after login is set |
|
7561 | 7588 | */ |
7562 | 7589 | function exist_firstpage_parameter() |
7563 | 7590 | { |
@@ -7849,7 +7876,7 @@ discard block |
||
7849 | 7876 | * @param array data file (path and filename) |
7850 | 7877 | * @param array data to attach a file (optional) |
7851 | 7878 | * @param bool True for attaching a embedded file inside content html (optional) |
7852 | - * @return returns true if mail was sent |
|
7879 | + * @return integer true if mail was sent |
|
7853 | 7880 | * @see class.phpmailer.php |
7854 | 7881 | */ |
7855 | 7882 | function api_mail_html( |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | define('PLATFORM_ADMIN', 11); |
40 | 40 | define('SESSION_COURSE_COACH', 12); |
41 | 41 | define('SESSION_GENERAL_COACH', 13); |
42 | -define('COURSE_STUDENT', 14); //student subscribed in a course |
|
43 | -define('SESSION_STUDENT', 15); //student subscribed in a session course |
|
42 | +define('COURSE_STUDENT', 14); //student subscribed in a course |
|
43 | +define('SESSION_STUDENT', 15); //student subscribed in a session course |
|
44 | 44 | define('COURSE_TUTOR', 16); // student is tutor of a course (NOT in session) |
45 | 45 | define('STUDENT_BOSS', 17); // student is boss |
46 | 46 | define('INVITEE', 20); |
47 | 47 | |
48 | 48 | // Table of status |
49 | -$_status_list[COURSEMANAGER] = 'teacher'; // 1 |
|
50 | -$_status_list[SESSIONADMIN] = 'session_admin'; // 3 |
|
51 | -$_status_list[DRH] = 'drh'; // 4 |
|
52 | -$_status_list[STUDENT] = 'user'; // 5 |
|
53 | -$_status_list[ANONYMOUS] = 'anonymous'; // 6 |
|
54 | -$_status_list[INVITEE] = 'invited'; // 20 |
|
49 | +$_status_list[COURSEMANAGER] = 'teacher'; // 1 |
|
50 | +$_status_list[SESSIONADMIN] = 'session_admin'; // 3 |
|
51 | +$_status_list[DRH] = 'drh'; // 4 |
|
52 | +$_status_list[STUDENT] = 'user'; // 5 |
|
53 | +$_status_list[ANONYMOUS] = 'anonymous'; // 6 |
|
54 | +$_status_list[INVITEE] = 'invited'; // 20 |
|
55 | 55 | |
56 | 56 | // COURSE VISIBILITY CONSTANTS |
57 | 57 | /** only visible for course admin */ |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | define('IS_WINDOWS_OS', api_is_windows_os()); |
264 | 264 | |
265 | 265 | // Checks for installed optional php-extensions. |
266 | -define('INTL_INSTALLED', function_exists('intl_get_error_code')); // intl extension (from PECL), it is installed by default as of PHP 5.3.0 |
|
267 | -define('ICONV_INSTALLED', function_exists('iconv')); // iconv extension, for PHP5 on Windows it is installed by default. |
|
268 | -define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension. |
|
266 | +define('INTL_INSTALLED', function_exists('intl_get_error_code')); // intl extension (from PECL), it is installed by default as of PHP 5.3.0 |
|
267 | +define('ICONV_INSTALLED', function_exists('iconv')); // iconv extension, for PHP5 on Windows it is installed by default. |
|
268 | +define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension. |
|
269 | 269 | |
270 | 270 | // Patterns for processing paths. // Examples: |
271 | -define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path); |
|
272 | -define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path); |
|
273 | -define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path); |
|
271 | +define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path); |
|
272 | +define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path); |
|
273 | +define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path); |
|
274 | 274 | |
275 | 275 | // Constants for api_get_path() and api_get_path_type(), etc. - registered path types. |
276 | 276 | define('WEB_PATH', 'WEB_PATH'); |
@@ -374,19 +374,19 @@ discard block |
||
374 | 374 | define('LINK_HOTPOTATOES', 9); |
375 | 375 | |
376 | 376 | // Score display types constants |
377 | -define('SCORE_DIV', 1); // X / Y |
|
378 | -define('SCORE_PERCENT', 2); // XX % |
|
379 | -define('SCORE_DIV_PERCENT', 3); // X / Y (XX %) |
|
380 | -define('SCORE_AVERAGE', 4); // XX % |
|
381 | -define('SCORE_DECIMAL', 5); // 0.50 (X/Y) |
|
382 | -define('SCORE_BAR', 6); // Uses the Display::bar_progress function |
|
383 | -define('SCORE_SIMPLE', 7); // X |
|
384 | -define('SCORE_IGNORE_SPLIT', 8); // ?? |
|
385 | -define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good! |
|
386 | -define('SCORE_CUSTOM', 10); // Good! |
|
387 | -define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good! |
|
388 | -define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good! |
|
389 | -define('SCORE_ONLY_SCORE', 13); // X - Good! |
|
377 | +define('SCORE_DIV', 1); // X / Y |
|
378 | +define('SCORE_PERCENT', 2); // XX % |
|
379 | +define('SCORE_DIV_PERCENT', 3); // X / Y (XX %) |
|
380 | +define('SCORE_AVERAGE', 4); // XX % |
|
381 | +define('SCORE_DECIMAL', 5); // 0.50 (X/Y) |
|
382 | +define('SCORE_BAR', 6); // Uses the Display::bar_progress function |
|
383 | +define('SCORE_SIMPLE', 7); // X |
|
384 | +define('SCORE_IGNORE_SPLIT', 8); // ?? |
|
385 | +define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good! |
|
386 | +define('SCORE_CUSTOM', 10); // Good! |
|
387 | +define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good! |
|
388 | +define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good! |
|
389 | +define('SCORE_ONLY_SCORE', 13); // X - Good! |
|
390 | 390 | |
391 | 391 | define('SCORE_BOTH', 1); |
392 | 392 | define('SCORE_ONLY_DEFAULT', 2); |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | define('TIMELINE_STATUS_INACTIVE', '2'); |
571 | 571 | |
572 | 572 | // Event email template class |
573 | -define ('EVENT_EMAIL_TEMPLATE_ACTIVE', 1); |
|
574 | -define ('EVENT_EMAIL_TEMPLATE_INACTIVE', 0); |
|
573 | +define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1); |
|
574 | +define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0); |
|
575 | 575 | |
576 | 576 | // Course home |
577 | 577 | define('SHORTCUTS_HORIZONTAL', 0); |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | |
748 | 748 | // To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php |
749 | 749 | if ($path_type == WEB_PATH) { |
750 | - if (isset($_configuration['access_url']) && $_configuration['access_url'] != 1) { |
|
750 | + if (isset($_configuration['access_url']) && $_configuration['access_url'] != 1) { |
|
751 | 751 | //we look into the DB the function api_get_access_url |
752 | 752 | $url_info = api_get_access_url($_configuration['access_url']); |
753 | 753 | $root_web = $url_info['active'] == 1 ? $url_info['url'] : $_configuration['root_web']; |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | : 'localhost'))); |
778 | 778 | if (isset($_SERVER['SERVER_PORT']) && !strpos($server_name, ':') |
779 | 779 | && (($server_protocol == 'http' |
780 | - && $_SERVER['SERVER_PORT'] != 80 ) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443 ))) { |
|
781 | - $server_name .= ":" . $_SERVER['SERVER_PORT']; |
|
780 | + && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443))) { |
|
781 | + $server_name .= ":".$_SERVER['SERVER_PORT']; |
|
782 | 782 | } |
783 | 783 | $root_web = $server_protocol.'://'.$server_name.$root_rel; |
784 | 784 | $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/'; |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | $sys_course_code = |
953 | 953 | isset($_SESSION['_course']['sysCode']) // User is inside a course? |
954 | 954 | ? $_SESSION['_course']['sysCode'] // Yes, then use course's directory name. |
955 | - : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later. |
|
955 | + : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later. |
|
956 | 956 | $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]); |
957 | 957 | } |
958 | 958 | } |
@@ -996,15 +996,15 @@ discard block |
||
996 | 996 | { |
997 | 997 | global $_configuration; |
998 | 998 | $web_root = api_get_path(WEB_PATH); |
999 | - $ext = substr($web_path,strrpos($web_path,'.')); |
|
999 | + $ext = substr($web_path, strrpos($web_path, '.')); |
|
1000 | 1000 | if (isset($ext[2])) { // faster version of strlen to check if len>2 |
1001 | 1001 | // Check for CDN definitions |
1002 | 1002 | if (!empty($_configuration['cdn_enable']) && !empty($ext)) { |
1003 | 1003 | foreach ($_configuration['cdn'] as $host => $exts) { |
1004 | - if (in_array($ext,$exts)) { |
|
1004 | + if (in_array($ext, $exts)) { |
|
1005 | 1005 | //Use host as defined in $_configuration['cdn'], without |
1006 | 1006 | // trailing slash |
1007 | - return str_replace($web_root,$host.'/',$web_path); |
|
1007 | + return str_replace($web_root, $host.'/', $web_path); |
|
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | } |
@@ -1453,10 +1453,10 @@ discard block |
||
1453 | 1453 | |
1454 | 1454 | if (isset($user['email'])) { |
1455 | 1455 | $result['mail'] = isset($user['email']) ? $user['email'] : null; |
1456 | - $result['email'] = isset($user['email'])? $user['email'] : null; |
|
1456 | + $result['email'] = isset($user['email']) ? $user['email'] : null; |
|
1457 | 1457 | } else { |
1458 | 1458 | $result['mail'] = isset($user['mail']) ? $user['mail'] : null; |
1459 | - $result['email'] = isset($user['mail'])? $user['mail'] : null; |
|
1459 | + $result['email'] = isset($user['mail']) ? $user['mail'] : null; |
|
1460 | 1460 | } |
1461 | 1461 | $user_id = intval($user['user_id']); |
1462 | 1462 | // Maintain the user_id index for backwards compatibility |
@@ -1932,7 +1932,7 @@ discard block |
||
1932 | 1932 | foreach ($param_list1 as $key => $enreg) { |
1933 | 1933 | list ($param_list1_keys[$key], $param_list1_vals[$key]) = explode('=', $enreg); |
1934 | 1934 | } |
1935 | - $param_list1 = array ('keys' => $param_list1_keys, 'vals' => $param_list1_vals); |
|
1935 | + $param_list1 = array('keys' => $param_list1_keys, 'vals' => $param_list1_vals); |
|
1936 | 1936 | foreach ($param_list2 as $enreg) { |
1937 | 1937 | $enreg = explode('=', $enreg); |
1938 | 1938 | $key = array_search($enreg[0], $param_list1['keys']); |
@@ -1962,7 +1962,7 @@ discard block |
||
1962 | 1962 | $length = 2; |
1963 | 1963 | } |
1964 | 1964 | $password = ''; |
1965 | - for ($i = 0; $i < $length; $i ++) { |
|
1965 | + for ($i = 0; $i < $length; $i++) { |
|
1966 | 1966 | $password .= $characters[rand() % strlen($characters)]; |
1967 | 1967 | } |
1968 | 1968 | return $password; |
@@ -1989,10 +1989,10 @@ discard block |
||
1989 | 1989 | $digits = 0; |
1990 | 1990 | $consequent_characters = 0; |
1991 | 1991 | $previous_character_code = 0; |
1992 | - for ($i = 0; $i < $password_length; $i ++) { |
|
1992 | + for ($i = 0; $i < $password_length; $i++) { |
|
1993 | 1993 | $current_character_code = api_ord(api_substr($password, $i, 1)); |
1994 | 1994 | if ($i && abs($current_character_code - $previous_character_code) <= 1) { |
1995 | - $consequent_characters ++; |
|
1995 | + $consequent_characters++; |
|
1996 | 1996 | if ($consequent_characters == 3) { |
1997 | 1997 | return false; |
1998 | 1998 | } |
@@ -2000,9 +2000,9 @@ discard block |
||
2000 | 2000 | $consequent_characters = 1; |
2001 | 2001 | } |
2002 | 2002 | if ($current_character_code >= 97 && $current_character_code <= 122) { |
2003 | - $letters ++; |
|
2003 | + $letters++; |
|
2004 | 2004 | } elseif ($current_character_code >= 48 && $current_character_code <= 57) { |
2005 | - $digits ++; |
|
2005 | + $digits++; |
|
2006 | 2006 | } else { |
2007 | 2007 | return false; |
2008 | 2008 | } |
@@ -2198,7 +2198,7 @@ discard block |
||
2198 | 2198 | if (empty($session_id)) { return null; } |
2199 | 2199 | } |
2200 | 2200 | $t = Database::get_main_table(TABLE_MAIN_SESSION); |
2201 | - $s = "SELECT name FROM $t WHERE id = ".(int)$session_id; |
|
2201 | + $s = "SELECT name FROM $t WHERE id = ".(int) $session_id; |
|
2202 | 2202 | $r = Database::query($s); |
2203 | 2203 | $c = Database::num_rows($r); |
2204 | 2204 | if ($c > 0) { |
@@ -2223,7 +2223,7 @@ discard block |
||
2223 | 2223 | $sql = "SELECT * FROM $tbl_session WHERE id = $session_id"; |
2224 | 2224 | $result = Database::query($sql); |
2225 | 2225 | |
2226 | - if (Database::num_rows($result)>0) { |
|
2226 | + if (Database::num_rows($result) > 0) { |
|
2227 | 2227 | $data = Database::fetch_array($result, 'ASSOC'); |
2228 | 2228 | } |
2229 | 2229 | } |
@@ -2383,9 +2383,9 @@ discard block |
||
2383 | 2383 | */ |
2384 | 2384 | function api_get_session_image($session_id, $status_id) |
2385 | 2385 | { |
2386 | - $session_id = (int)$session_id; |
|
2386 | + $session_id = (int) $session_id; |
|
2387 | 2387 | $session_img = ''; |
2388 | - if ((int)$status_id != 5) { //check whether is not a student |
|
2388 | + if ((int) $status_id != 5) { //check whether is not a student |
|
2389 | 2389 | if ($session_id > 0) { |
2390 | 2390 | $session_img = " ".Display::return_icon( |
2391 | 2391 | 'star.png', |
@@ -2500,7 +2500,7 @@ discard block |
||
2500 | 2500 | $filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content.txt'; |
2501 | 2501 | if (file_exists($filename)) { |
2502 | 2502 | $value = file_get_contents($filename); |
2503 | - return $value ; |
|
2503 | + return $value; |
|
2504 | 2504 | } else { |
2505 | 2505 | return ''; |
2506 | 2506 | } |
@@ -2509,7 +2509,7 @@ discard block |
||
2509 | 2509 | $filename = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt'; |
2510 | 2510 | if (file_exists($filename)) { |
2511 | 2511 | $value = file_get_contents($filename); |
2512 | - return $value ; |
|
2512 | + return $value; |
|
2513 | 2513 | } else { |
2514 | 2514 | return ''; |
2515 | 2515 | } |
@@ -2703,7 +2703,7 @@ discard block |
||
2703 | 2703 | } |
2704 | 2704 | $group_id = api_get_group_id(); |
2705 | 2705 | $course_id = api_get_course_int_id(); |
2706 | - $course_code= api_get_course_id(); |
|
2706 | + $course_code = api_get_course_id(); |
|
2707 | 2707 | $session_id = api_get_session_id(); |
2708 | 2708 | |
2709 | 2709 | //Group (in course) |
@@ -2711,7 +2711,7 @@ discard block |
||
2711 | 2711 | $group_status = array(); |
2712 | 2712 | $is_subscribed = GroupManager::is_subscribed($user_id, $group_id); |
2713 | 2713 | if ($is_subscribed) { |
2714 | - $group_status = array('id'=> $group_id , 'status' => 'student'); |
|
2714 | + $group_status = array('id'=> $group_id, 'status' => 'student'); |
|
2715 | 2715 | $is_tutor = GroupManager::is_tutor_of_group($user_id, $group_id); |
2716 | 2716 | if ($is_tutor) { |
2717 | 2717 | $group_status['status'] = 'tutor'; |
@@ -2745,7 +2745,7 @@ discard block |
||
2745 | 2745 | } |
2746 | 2746 | $status['session'] = $session_status; |
2747 | 2747 | |
2748 | - } elseif($course_id) { |
|
2748 | + } elseif ($course_id) { |
|
2749 | 2749 | //Course |
2750 | 2750 | $course_status = array(); |
2751 | 2751 | if ($course_id) { |
@@ -2753,7 +2753,7 @@ discard block |
||
2753 | 2753 | |
2754 | 2754 | if ($user_course_status) { |
2755 | 2755 | $course_status = array('id'=> $course_id); |
2756 | - switch($user_course_status) { |
|
2756 | + switch ($user_course_status) { |
|
2757 | 2757 | case 1; |
2758 | 2758 | $course_status['status'] = 'teacher'; |
2759 | 2759 | break; |
@@ -2783,7 +2783,7 @@ discard block |
||
2783 | 2783 | function api_is_course_session_coach($user_id, $courseId, $session_id) |
2784 | 2784 | { |
2785 | 2785 | $session_table = Database::get_main_table(TABLE_MAIN_SESSION); |
2786 | - $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
2786 | + $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
2787 | 2787 | |
2788 | 2788 | $user_id = intval($user_id); |
2789 | 2789 | $session_id = intval($session_id); |
@@ -2857,7 +2857,7 @@ discard block |
||
2857 | 2857 | ORDER BY access_start_date, access_end_date, name"; |
2858 | 2858 | $result = Database::query($sql); |
2859 | 2859 | if (!empty($sessionIsCoach)) { |
2860 | - $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result)); |
|
2860 | + $sessionIsCoach = array_merge($sessionIsCoach, Database::store_result($result)); |
|
2861 | 2861 | } else { |
2862 | 2862 | $sessionIsCoach = Database::store_result($result); |
2863 | 2863 | } |
@@ -3034,7 +3034,7 @@ discard block |
||
3034 | 3034 | return ''; |
3035 | 3035 | } |
3036 | 3036 | $sourceurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')); |
3037 | - $sourceurl = str_replace('newscorm/lp_header.php', 'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview']=='studentview' ? 'false' : 'true'), $sourceurl); |
|
3037 | + $sourceurl = str_replace('newscorm/lp_header.php', 'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview'] == 'studentview' ? 'false' : 'true'), $sourceurl); |
|
3038 | 3038 | //showinframes doesn't handle student view anyway... |
3039 | 3039 | //return ''; |
3040 | 3040 | $is_framed = true; |
@@ -3433,7 +3433,7 @@ discard block |
||
3433 | 3433 | } |
3434 | 3434 | $content .= '<div class="well_login">'; |
3435 | 3435 | $content .= $form->return_form(); |
3436 | - $content .='</div>'; |
|
3436 | + $content .= '</div>'; |
|
3437 | 3437 | if (api_is_cas_activated()) { |
3438 | 3438 | $content .= "</div>"; |
3439 | 3439 | } |
@@ -3452,7 +3452,7 @@ discard block |
||
3452 | 3452 | exit; |
3453 | 3453 | } |
3454 | 3454 | |
3455 | - if ($user_id !=0 && !api_is_anonymous()) { |
|
3455 | + if ($user_id != 0 && !api_is_anonymous()) { |
|
3456 | 3456 | $tpl->display_one_col_template(); |
3457 | 3457 | exit; |
3458 | 3458 | } |
@@ -3483,7 +3483,7 @@ discard block |
||
3483 | 3483 | } |
3484 | 3484 | $msg .= '<div class="well">'; |
3485 | 3485 | $msg .= $form->return_form(); |
3486 | - $msg .='</div>'; |
|
3486 | + $msg .= '</div>'; |
|
3487 | 3487 | if (api_is_cas_activated()) { |
3488 | 3488 | $msg .= "</div>"; |
3489 | 3489 | } |
@@ -3519,7 +3519,7 @@ discard block |
||
3519 | 3519 | list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime); |
3520 | 3520 | list ($year, $month, $day) = explode('-', $last_post_date); |
3521 | 3521 | list ($hour, $min, $sec) = explode(':', $last_post_time); |
3522 | - return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year); |
|
3522 | + return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year); |
|
3523 | 3523 | } |
3524 | 3524 | |
3525 | 3525 | /** |
@@ -3970,7 +3970,7 @@ discard block |
||
3970 | 3970 | c_id = $course_id AND |
3971 | 3971 | tool = '$tool' |
3972 | 3972 | $session_condition "; |
3973 | - $rs = Database::query($sql); |
|
3973 | + $rs = Database::query($sql); |
|
3974 | 3974 | $list = array(); |
3975 | 3975 | if (Database::num_rows($rs) > 0) { |
3976 | 3976 | while ($row = Database::fetch_array($rs, 'ASSOC')) { |
@@ -4050,7 +4050,7 @@ discard block |
||
4050 | 4050 | tool = '$tool' AND |
4051 | 4051 | ref = $ref |
4052 | 4052 | $sessionCondition"; |
4053 | - $rs = Database::query($sql); |
|
4053 | + $rs = Database::query($sql); |
|
4054 | 4054 | $item_property_id = ''; |
4055 | 4055 | if (Database::num_rows($rs) > 0) { |
4056 | 4056 | $row = Database::fetch_array($rs); |
@@ -4108,7 +4108,7 @@ discard block |
||
4108 | 4108 | WHERE item_property_id = $item_property_id AND course_id = $course_id |
4109 | 4109 | ORDER BY lastedit_date DESC"; |
4110 | 4110 | $result = Database::query($sql); |
4111 | - $result = Database::store_result($result,'ASSOC'); |
|
4111 | + $result = Database::store_result($result, 'ASSOC'); |
|
4112 | 4112 | return $result; |
4113 | 4113 | } |
4114 | 4114 | |
@@ -4158,7 +4158,7 @@ discard block |
||
4158 | 4158 | $rs = Database::query($sql); |
4159 | 4159 | $row = array(); |
4160 | 4160 | if (Database::num_rows($rs) > 0) { |
4161 | - $row = Database::fetch_array($rs,'ASSOC'); |
|
4161 | + $row = Database::fetch_array($rs, 'ASSOC'); |
|
4162 | 4162 | } |
4163 | 4163 | |
4164 | 4164 | return $row; |
@@ -4194,7 +4194,7 @@ discard block |
||
4194 | 4194 | $languages = $language_list['name']; |
4195 | 4195 | $folder = $language_list['folder']; |
4196 | 4196 | |
4197 | - $ret .= '<select name="' . $name . '" id="language_chosen" class="selectpicker show-tick form-control">'; |
|
4197 | + $ret .= '<select name="'.$name.'" id="language_chosen" class="selectpicker show-tick form-control">'; |
|
4198 | 4198 | foreach ($languages as $key => $value) { |
4199 | 4199 | if ($folder[$key] == $default) { |
4200 | 4200 | $selected = ' selected="selected"'; |
@@ -4247,8 +4247,8 @@ discard block |
||
4247 | 4247 | //--> |
4248 | 4248 | </script>'; |
4249 | 4249 | $html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">'; |
4250 | - $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>'; |
|
4251 | - $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >'; |
|
4250 | + $html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>'; |
|
4251 | + $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >'; |
|
4252 | 4252 | |
4253 | 4253 | foreach ($original_languages as $key => $value) { |
4254 | 4254 | if ($folder[$key] == $user_selected_language) { |
@@ -4256,13 +4256,13 @@ discard block |
||
4256 | 4256 | } else { |
4257 | 4257 | $option_end = '>'; |
4258 | 4258 | } |
4259 | - $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end; |
|
4259 | + $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end; |
|
4260 | 4260 | //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect. |
4261 | - $html .= $value.'</option>'; |
|
4261 | + $html .= $value.'</option>'; |
|
4262 | 4262 | } |
4263 | - $html .= '</select>'; |
|
4264 | - $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>'; |
|
4265 | - $html .= '</form>'; |
|
4263 | + $html .= '</select>'; |
|
4264 | + $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>'; |
|
4265 | + $html .= '</form>'; |
|
4266 | 4266 | return $html; |
4267 | 4267 | } |
4268 | 4268 | |
@@ -4379,7 +4379,7 @@ discard block |
||
4379 | 4379 | $rs = Database::query($sql); |
4380 | 4380 | $language_info = array(); |
4381 | 4381 | if (Database::num_rows($rs)) { |
4382 | - $language_info = Database::fetch_array($rs,'ASSOC'); |
|
4382 | + $language_info = Database::fetch_array($rs, 'ASSOC'); |
|
4383 | 4383 | } |
4384 | 4384 | return $language_info; |
4385 | 4385 | } |
@@ -4457,7 +4457,7 @@ discard block |
||
4457 | 4457 | * Note: Directory names (names of themes) in the file system should contain ASCII-characters only. |
4458 | 4458 | */ |
4459 | 4459 | function api_get_themes() { |
4460 | - $cssdir = api_get_path(SYS_CSS_PATH) . 'themes/'; |
|
4460 | + $cssdir = api_get_path(SYS_CSS_PATH).'themes/'; |
|
4461 | 4461 | $list_dir = array(); |
4462 | 4462 | $list_name = array(); |
4463 | 4463 | |
@@ -4648,7 +4648,7 @@ discard block |
||
4648 | 4648 | if (is_file($dirname) || is_link($dirname)) { |
4649 | 4649 | $res = unlink($dirname); |
4650 | 4650 | if ($res === false) { |
4651 | - error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0); |
|
4651 | + error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0); |
|
4652 | 4652 | } |
4653 | 4653 | return $res; |
4654 | 4654 | } |
@@ -4685,7 +4685,7 @@ discard block |
||
4685 | 4685 | if ($delete_only_content_in_folder == false) { |
4686 | 4686 | $res = rmdir($dirname); |
4687 | 4687 | if ($res === false) { |
4688 | - error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
4688 | + error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
4689 | 4689 | } |
4690 | 4690 | } |
4691 | 4691 | return $res; |
@@ -4763,7 +4763,7 @@ discard block |
||
4763 | 4763 | |
4764 | 4764 | $course_id = $course_info['real_id']; |
4765 | 4765 | |
4766 | - $folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname)); |
|
4766 | + $folders = explode(DIRECTORY_SEPARATOR, str_replace($base_path_document.DIRECTORY_SEPARATOR, '', $pathname)); |
|
4767 | 4767 | |
4768 | 4768 | $new_pathname = $base_path_document; |
4769 | 4769 | $path = ''; |
@@ -4781,7 +4781,7 @@ discard block |
||
4781 | 4781 | path = '$path' AND |
4782 | 4782 | filetype = 'folder' AND |
4783 | 4783 | session_id = '$session_id'"; |
4784 | - $rs1 = Database::query($sql); |
|
4784 | + $rs1 = Database::query($sql); |
|
4785 | 4785 | $num_rows = Database::num_rows($rs1); |
4786 | 4786 | |
4787 | 4787 | if ($num_rows == 0) { |
@@ -4938,7 +4938,7 @@ discard block |
||
4938 | 4938 | foreach (array('key', 'value1', 'value2', 'value3') as $var) { |
4939 | 4939 | $$var = isset($match[++$i]) ? $match[$i] : ''; |
4940 | 4940 | } |
4941 | - $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3; |
|
4941 | + $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3; |
|
4942 | 4942 | |
4943 | 4943 | // Parse array syntax. |
4944 | 4944 | $keys = preg_split('/\]?\[/', rtrim($key, ']')); |
@@ -4978,7 +4978,7 @@ discard block |
||
4978 | 4978 | */ |
4979 | 4979 | function api_get_version() { |
4980 | 4980 | global $_configuration; |
4981 | - return (string)$_configuration['system_version']; |
|
4981 | + return (string) $_configuration['system_version']; |
|
4982 | 4982 | } |
4983 | 4983 | |
4984 | 4984 | /** |
@@ -5104,7 +5104,7 @@ discard block |
||
5104 | 5104 | $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); |
5105 | 5105 | $var = Database::escape_string($var); |
5106 | 5106 | $value = Database::escape_string($value); |
5107 | - $access_url = (int)$access_url; |
|
5107 | + $access_url = (int) $access_url; |
|
5108 | 5108 | if (empty($access_url)) { $access_url = 1; } |
5109 | 5109 | $select = "SELECT id FROM $t_settings WHERE variable = '$var' "; |
5110 | 5110 | if (!empty($subvar)) { |
@@ -5126,7 +5126,7 @@ discard block |
||
5126 | 5126 | // Found item for this access_url. |
5127 | 5127 | $row = Database::fetch_array($res); |
5128 | 5128 | $sql = "UPDATE $t_settings SET selected_value = '$value' |
5129 | - WHERE id = ".$row['id'] ; |
|
5129 | + WHERE id = ".$row['id']; |
|
5130 | 5130 | Database::query($sql); |
5131 | 5131 | } else { |
5132 | 5132 | // Item not found for this access_url, we have to check if it exist with access_url = 1 |
@@ -5147,11 +5147,11 @@ discard block |
||
5147 | 5147 | $row = Database::fetch_array($res); |
5148 | 5148 | $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url) |
5149 | 5149 | VALUES |
5150 | - ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," . |
|
5151 | - "'".$row['type']."','".$row['category']."'," . |
|
5152 | - "'$value','".$row['title']."'," . |
|
5153 | - "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," . |
|
5154 | - "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)"; |
|
5150 | + ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",". |
|
5151 | + "'".$row['type']."','".$row['category']."',". |
|
5152 | + "'$value','".$row['title']."',". |
|
5153 | + "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",". |
|
5154 | + "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url)"; |
|
5155 | 5155 | Database::query($insert); |
5156 | 5156 | } else { // Such a setting does not exist. |
5157 | 5157 | error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all', 0); |
@@ -5171,16 +5171,16 @@ discard block |
||
5171 | 5171 | if ($row['access_url_changeable'] == 1) { |
5172 | 5172 | $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES |
5173 | 5173 | ('".$row['variable']."',". |
5174 | - (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," . |
|
5175 | - "'".$row['type']."','".$row['category']."'," . |
|
5176 | - "'$value','".$row['title']."'," . |
|
5174 | + (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",". |
|
5175 | + "'".$row['type']."','".$row['category']."',". |
|
5176 | + "'$value','".$row['title']."',". |
|
5177 | 5177 | "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",". |
5178 | - (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," . |
|
5178 | + (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",". |
|
5179 | 5179 | "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")"; |
5180 | 5180 | Database::query($insert); |
5181 | 5181 | } |
5182 | 5182 | } else { // Such a setting does not exist. |
5183 | - error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ',0); |
|
5183 | + error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ', 0); |
|
5184 | 5184 | } |
5185 | 5185 | } |
5186 | 5186 | } |
@@ -5206,10 +5206,10 @@ discard block |
||
5206 | 5206 | $value = Database::escape_string($value); |
5207 | 5207 | $sql = "UPDATE $t_s SET selected_value = '$value' |
5208 | 5208 | WHERE category = '$category' AND access_url = $access_url"; |
5209 | - if (is_array($fieldtype) && count($fieldtype)>0) { |
|
5209 | + if (is_array($fieldtype) && count($fieldtype) > 0) { |
|
5210 | 5210 | $sql .= " AND ( "; |
5211 | 5211 | $i = 0; |
5212 | - foreach ($fieldtype as $type){ |
|
5212 | + foreach ($fieldtype as $type) { |
|
5213 | 5213 | if ($i > 0) { |
5214 | 5214 | $sql .= ' OR '; |
5215 | 5215 | } |
@@ -5224,10 +5224,10 @@ discard block |
||
5224 | 5224 | } else { |
5225 | 5225 | $sql = "UPDATE $t_s SET selected_value = NULL |
5226 | 5226 | WHERE category = '$category' AND access_url = $access_url"; |
5227 | - if (is_array($fieldtype) && count($fieldtype)>0) { |
|
5227 | + if (is_array($fieldtype) && count($fieldtype) > 0) { |
|
5228 | 5228 | $sql .= " AND ( "; |
5229 | 5229 | $i = 0; |
5230 | - foreach ($fieldtype as $type){ |
|
5230 | + foreach ($fieldtype as $type) { |
|
5231 | 5231 | if ($i > 0) { |
5232 | 5232 | $sql .= ' OR '; |
5233 | 5233 | } |
@@ -5372,7 +5372,7 @@ discard block |
||
5372 | 5372 | function & api_get_settings_categories($exceptions = array(), $access_url = 1) { |
5373 | 5373 | $access_url = (int) $access_url; |
5374 | 5374 | $t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); |
5375 | - $list = "'".implode("','",$exceptions)."'"; |
|
5375 | + $list = "'".implode("','", $exceptions)."'"; |
|
5376 | 5376 | $sql = "SELECT DISTINCT category FROM $t_cs WHERE category is NOT NULL "; |
5377 | 5377 | if ($list != "'',''" && $list != "''" && !empty($list)) { |
5378 | 5378 | $sql .= " AND category NOT IN ($list) "; |
@@ -5468,12 +5468,12 @@ discard block |
||
5468 | 5468 | |
5469 | 5469 | // Item not found for this access_url, we have to check if the whole thing is missing |
5470 | 5470 | // (in which case we ignore the insert) or if there *is* a record but just for access_url = 1 |
5471 | - $insert = "INSERT INTO $t_settings " . |
|
5472 | - "(variable,selected_value," . |
|
5473 | - "type,category," . |
|
5474 | - "subkey,title," . |
|
5475 | - "comment,scope," . |
|
5476 | - "subkeytext,access_url,access_url_changeable)" . |
|
5471 | + $insert = "INSERT INTO $t_settings ". |
|
5472 | + "(variable,selected_value,". |
|
5473 | + "type,category,". |
|
5474 | + "subkey,title,". |
|
5475 | + "comment,scope,". |
|
5476 | + "subkeytext,access_url,access_url_changeable)". |
|
5477 | 5477 | " VALUES ('$var','$val',"; |
5478 | 5478 | if (isset($type)) { |
5479 | 5479 | $type = Database::escape_string($type); |
@@ -5639,7 +5639,7 @@ discard block |
||
5639 | 5639 | $result = Database::query($sql); |
5640 | 5640 | |
5641 | 5641 | //if ($row = Database::fetch_array($result)) { |
5642 | - if (Database::num_rows($result) > 0 ) { |
|
5642 | + if (Database::num_rows($result) > 0) { |
|
5643 | 5643 | $is_courseMember = true; |
5644 | 5644 | $is_courseTutor = true; |
5645 | 5645 | $is_courseCoach = true; |
@@ -5860,8 +5860,8 @@ discard block |
||
5860 | 5860 | { |
5861 | 5861 | $tbl_rel_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
5862 | 5862 | if (!empty($user_id) && !empty($courseId)) { |
5863 | - $user_id = intval($user_id); |
|
5864 | - $courseId = intval($courseId); |
|
5863 | + $user_id = intval($user_id); |
|
5864 | + $courseId = intval($courseId); |
|
5865 | 5865 | $sql = 'SELECT status |
5866 | 5866 | FROM '.$tbl_rel_course_user.' |
5867 | 5867 | WHERE user_id='.$user_id.' AND c_id = '.$courseId; |
@@ -5967,7 +5967,7 @@ discard block |
||
5967 | 5967 | } else { |
5968 | 5968 | return false; |
5969 | 5969 | } |
5970 | - return strtolower(substr((string)$os, 0, 3 )) == 'win'; |
|
5970 | + return strtolower(substr((string) $os, 0, 3)) == 'win'; |
|
5971 | 5971 | } |
5972 | 5972 | |
5973 | 5973 | /** |
@@ -6492,7 +6492,7 @@ discard block |
||
6492 | 6492 | function api_get_jquery_ui_js($include_jqgrid = false) { |
6493 | 6493 | $libraries = array(); |
6494 | 6494 | if ($include_jqgrid) { |
6495 | - $libraries[]='jqgrid'; |
|
6495 | + $libraries[] = 'jqgrid'; |
|
6496 | 6496 | } |
6497 | 6497 | return api_get_jquery_libraries_js($libraries); |
6498 | 6498 | } |
@@ -6516,12 +6516,12 @@ discard block |
||
6516 | 6516 | |
6517 | 6517 | //jqgrid js and css |
6518 | 6518 | if (in_array('jqgrid', $libraries)) { |
6519 | - $languaje = 'en'; |
|
6519 | + $languaje = 'en'; |
|
6520 | 6520 | $platform_isocode = strtolower(api_get_language_isocode()); |
6521 | 6521 | |
6522 | 6522 | //languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n |
6523 | 6523 | $jqgrid_langs = array( |
6524 | - 'bg', 'bg1251', 'cat','cn','cs','da','de','el','en','es','fa','fi','fr','gl','he','hu','is','it','ja','nl','no','pl','pt-br','pt','ro','ru','sk','sr','sv','tr','ua' |
|
6524 | + 'bg', 'bg1251', 'cat', 'cn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'gl', 'he', 'hu', 'is', 'it', 'ja', 'nl', 'no', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'tr', 'ua' |
|
6525 | 6525 | ); |
6526 | 6526 | |
6527 | 6527 | if (in_array($platform_isocode, $jqgrid_langs)) { |
@@ -6552,7 +6552,7 @@ discard block |
||
6552 | 6552 | |
6553 | 6553 | // jquery datepicker |
6554 | 6554 | if (in_array('datepicker', $libraries)) { |
6555 | - $languaje = 'en-GB'; |
|
6555 | + $languaje = 'en-GB'; |
|
6556 | 6556 | $platform_isocode = strtolower(api_get_language_isocode()); |
6557 | 6557 | |
6558 | 6558 | // languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n |
@@ -6654,7 +6654,7 @@ discard block |
||
6654 | 6654 | $clean_url = str_replace('/', '-', $clean_url); |
6655 | 6655 | $clean_url .= '/'; |
6656 | 6656 | |
6657 | - $home = 'app/home/' . $clean_url; |
|
6657 | + $home = 'app/home/'.$clean_url; |
|
6658 | 6658 | } |
6659 | 6659 | |
6660 | 6660 | return $home; |
@@ -6714,7 +6714,7 @@ discard block |
||
6714 | 6714 | * @return void |
6715 | 6715 | */ |
6716 | 6716 | function api_check_php_version($my_inc_path = null) { |
6717 | - if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) { |
|
6717 | + if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) { |
|
6718 | 6718 | $global_error_code = 1; |
6719 | 6719 | // Incorrect PHP version |
6720 | 6720 | $global_page = $my_inc_path.'global_error_message.inc.php'; |
@@ -6730,7 +6730,7 @@ discard block |
||
6730 | 6730 | */ |
6731 | 6731 | function api_check_archive_dir() { |
6732 | 6732 | if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) { |
6733 | - $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning'); |
|
6733 | + $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning'); |
|
6734 | 6734 | api_not_allowed(true, $message); |
6735 | 6735 | } |
6736 | 6736 | } |
@@ -6795,7 +6795,7 @@ discard block |
||
6795 | 6795 | * @author Jorge Frisancho Jibaja <[email protected]>, USIL - Some changes to allow the use of real IP using reverse proxy |
6796 | 6796 | * @version CEV CHANGE 24APR2012 |
6797 | 6797 | */ |
6798 | -function api_get_real_ip(){ |
|
6798 | +function api_get_real_ip() { |
|
6799 | 6799 | // Guess the IP if behind a reverse proxy |
6800 | 6800 | global $debug; |
6801 | 6801 | $ip = trim($_SERVER['REMOTE_ADDR']); |
@@ -6820,23 +6820,23 @@ discard block |
||
6820 | 6820 | * @author Yannick Warnier for improvements and managment of multiple ranges |
6821 | 6821 | * @todo check for IPv6 support |
6822 | 6822 | */ |
6823 | -function api_check_ip_in_range($ip,$range) |
|
6823 | +function api_check_ip_in_range($ip, $range) |
|
6824 | 6824 | { |
6825 | 6825 | if (empty($ip) or empty($range)) { |
6826 | 6826 | return false; |
6827 | 6827 | } |
6828 | - $ip_ip = ip2long ($ip); |
|
6828 | + $ip_ip = ip2long($ip); |
|
6829 | 6829 | // divide range param into array of elements |
6830 | - if (strpos($range,',')!==false) { |
|
6831 | - $ranges = explode(',',$range); |
|
6830 | + if (strpos($range, ',') !== false) { |
|
6831 | + $ranges = explode(',', $range); |
|
6832 | 6832 | } else { |
6833 | 6833 | $ranges = array($range); |
6834 | 6834 | } |
6835 | 6835 | foreach ($ranges as $range) { |
6836 | 6836 | $range = trim($range); |
6837 | 6837 | if (empty($range)) { continue; } |
6838 | - if (strpos($range,'/')===false) { |
|
6839 | - if (strcmp($ip,$range)===0) { |
|
6838 | + if (strpos($range, '/') === false) { |
|
6839 | + if (strcmp($ip, $range) === 0) { |
|
6840 | 6840 | return true; // there is a direct IP match, return OK |
6841 | 6841 | } |
6842 | 6842 | continue; //otherwise, get to the next range |
@@ -6844,7 +6844,7 @@ discard block |
||
6844 | 6844 | // the range contains a "/", so analyse completely |
6845 | 6845 | list ($net, $mask) = explode("/", $range); |
6846 | 6846 | |
6847 | - $ip_net = ip2long ($net); |
|
6847 | + $ip_net = ip2long($net); |
|
6848 | 6848 | // mask binary magic |
6849 | 6849 | $ip_mask = ~((1 << (32 - $mask)) - 1); |
6850 | 6850 | |
@@ -7205,14 +7205,14 @@ discard block |
||
7205 | 7205 | * @assert (0) === true |
7206 | 7206 | * @assert ('1G') === true |
7207 | 7207 | */ |
7208 | -function api_set_memory_limit($mem){ |
|
7208 | +function api_set_memory_limit($mem) { |
|
7209 | 7209 | //if ini_set() not available, this function is useless |
7210 | 7210 | if (!function_exists('ini_set') || is_null($mem) || $mem == -1) { |
7211 | 7211 | return false; |
7212 | 7212 | } |
7213 | 7213 | |
7214 | 7214 | $memory_limit = ini_get('memory_limit'); |
7215 | - if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){ |
|
7215 | + if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)) { |
|
7216 | 7216 | ini_set('memory_limit', $mem); |
7217 | 7217 | return true; |
7218 | 7218 | } |
@@ -7229,21 +7229,21 @@ discard block |
||
7229 | 7229 | * @assert ('1m') === 1048576 |
7230 | 7230 | * @assert ('100k') === 102400 |
7231 | 7231 | */ |
7232 | -function api_get_bytes_memory_limit($mem){ |
|
7233 | - $size = strtolower(substr($mem,-1)); |
|
7232 | +function api_get_bytes_memory_limit($mem) { |
|
7233 | + $size = strtolower(substr($mem, -1)); |
|
7234 | 7234 | |
7235 | 7235 | switch ($size) { |
7236 | 7236 | case 't': |
7237 | - $mem = intval(substr($mem,-1))*1024*1024*1024*1024; |
|
7237 | + $mem = intval(substr($mem, -1)) * 1024 * 1024 * 1024 * 1024; |
|
7238 | 7238 | break; |
7239 | 7239 | case 'g': |
7240 | - $mem = intval(substr($mem,0,-1))*1024*1024*1024; |
|
7240 | + $mem = intval(substr($mem, 0, -1)) * 1024 * 1024 * 1024; |
|
7241 | 7241 | break; |
7242 | 7242 | case 'm': |
7243 | - $mem = intval(substr($mem,0,-1))*1024*1024; |
|
7243 | + $mem = intval(substr($mem, 0, -1)) * 1024 * 1024; |
|
7244 | 7244 | break; |
7245 | 7245 | case 'k': |
7246 | - $mem = intval(substr($mem,0,-1))*1024; |
|
7246 | + $mem = intval(substr($mem, 0, -1)) * 1024; |
|
7247 | 7247 | break; |
7248 | 7248 | default: |
7249 | 7249 | // we assume it's integer only |
@@ -7298,7 +7298,7 @@ discard block |
||
7298 | 7298 | get_lang('PasswordVeryStrong'), |
7299 | 7299 | ); |
7300 | 7300 | $js = api_get_js('strength/strength.js'); |
7301 | - $js .= "<script> |
|
7301 | + $js .= "<script> |
|
7302 | 7302 | |
7303 | 7303 | var verdicts = ['".implode("','", $verdicts)."']; |
7304 | 7304 | var errorMessages = { |
@@ -7354,7 +7354,7 @@ discard block |
||
7354 | 7354 | return false; |
7355 | 7355 | } |
7356 | 7356 | $minutesToBlock = api_get_setting('captcha_time_to_block'); |
7357 | - $time = time() + $minutesToBlock*60; |
|
7357 | + $time = time() + $minutesToBlock * 60; |
|
7358 | 7358 | UserManager::update_extra_field_value( |
7359 | 7359 | $userInfo['user_id'], |
7360 | 7360 | 'captcha_blocked_until_date', |
@@ -7427,7 +7427,7 @@ discard block |
||
7427 | 7427 | $out_res = str_replace('"', "''", $out_res); |
7428 | 7428 | } |
7429 | 7429 | // avoid text stuck together when tags are removed, adding a space after > |
7430 | - $out_res = str_replace (">", "> ", $out_res); |
|
7430 | + $out_res = str_replace(">", "> ", $out_res); |
|
7431 | 7431 | $out_res = strip_tags($out_res); |
7432 | 7432 | |
7433 | 7433 | return $out_res; |
@@ -7537,12 +7537,12 @@ discard block |
||
7537 | 7537 | { |
7538 | 7538 | // Clean query |
7539 | 7539 | $bt = debug_backtrace(); |
7540 | - $caller = array_shift($bt);; |
|
7540 | + $caller = array_shift($bt); ; |
|
7541 | 7541 | if ($dump == 1) { |
7542 | 7542 | $string = print_r($string, 1); |
7543 | 7543 | } else { |
7544 | 7544 | $string = str_replace(array("\r", "\n", "\t", "\10"), '', $string); |
7545 | - $string = str_replace(' ',' ', $string); |
|
7545 | + $string = str_replace(' ', ' ', $string); |
|
7546 | 7546 | } |
7547 | 7547 | |
7548 | 7548 | error_log("-------------------------------------"); |
@@ -7652,7 +7652,7 @@ discard block |
||
7652 | 7652 | $body = get_lang('PortalName').': '.api_get_path(WEB_PATH)." \n "; |
7653 | 7653 | $body .= get_lang('PortalLimitType').': '.$limitName." \n "; |
7654 | 7654 | if (isset($hostingParams[$limitName])) { |
7655 | - $body .= get_lang('Value') . ': ' . $hostingParams[$limitName]; |
|
7655 | + $body .= get_lang('Value').': '.$hostingParams[$limitName]; |
|
7656 | 7656 | } |
7657 | 7657 | api_mail_html(null, $email, $subject, $body); |
7658 | 7658 | } |
@@ -7780,7 +7780,7 @@ discard block |
||
7780 | 7780 | */ |
7781 | 7781 | function api_set_site_use_cookie_warning_cookie() |
7782 | 7782 | { |
7783 | - setcookie("ChamiloUsesCookies", "ok", time()+31556926); |
|
7783 | + setcookie("ChamiloUsesCookies", "ok", time() + 31556926); |
|
7784 | 7784 | } |
7785 | 7785 | |
7786 | 7786 | /** |
@@ -7828,10 +7828,10 @@ discard block |
||
7828 | 7828 | return false; |
7829 | 7829 | } |
7830 | 7830 | |
7831 | - $fullPath = $parentDirectory . api_replace_dangerous_char($name); |
|
7831 | + $fullPath = $parentDirectory.api_replace_dangerous_char($name); |
|
7832 | 7832 | |
7833 | 7833 | if (mkdir($fullPath, api_get_permissions_for_new_directories(), true)) { |
7834 | - $fp = fopen($fullPath . '/index.html', 'w'); |
|
7834 | + $fp = fopen($fullPath.'/index.html', 'w'); |
|
7835 | 7835 | |
7836 | 7836 | if ($fp) { |
7837 | 7837 | if (fwrite($fp, '<html><head></head><body></body></html>')) { |
@@ -7896,7 +7896,7 @@ discard block |
||
7896 | 7896 | $mail->SMTPSecure = $platform_email['SMTP_SECURE']; |
7897 | 7897 | } |
7898 | 7898 | } |
7899 | - $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG'])?$platform_email['SMTP_DEBUG']:0; |
|
7899 | + $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG']) ? $platform_email['SMTP_DEBUG'] : 0; |
|
7900 | 7900 | |
7901 | 7901 | // 5 = low, 1 = high |
7902 | 7902 | $mail->Priority = 3; |
@@ -8048,11 +8048,11 @@ discard block |
||
8048 | 8048 | error_log('ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />'); |
8049 | 8049 | if ($mail->SMTPDebug) { |
8050 | 8050 | error_log( |
8051 | - "Connection details :: " . |
|
8052 | - "Protocol: " . $mail->Mailer . ' :: ' . |
|
8053 | - "Host/Port: " . $mail->Host . ':' . $mail->Port . ' :: ' . |
|
8054 | - "Authent/Open: " . ($mail->SMTPAuth?'Authent':'Open') . ' :: ' . |
|
8055 | - ($mail->SMTPAuth?" User/Pass: " . $mail->Username . ':' . $mail->Password:'') |
|
8051 | + "Connection details :: ". |
|
8052 | + "Protocol: ".$mail->Mailer.' :: '. |
|
8053 | + "Host/Port: ".$mail->Host.':'.$mail->Port.' :: '. |
|
8054 | + "Authent/Open: ".($mail->SMTPAuth ? 'Authent' : 'Open').' :: '. |
|
8055 | + ($mail->SMTPAuth ? " User/Pass: ".$mail->Username.':'.$mail->Password : '') |
|
8056 | 8056 | ); |
8057 | 8057 | } |
8058 | 8058 | return 0; |
@@ -8100,13 +8100,13 @@ discard block |
||
8100 | 8100 | * @param int $key key to find to compare |
8101 | 8101 | * |
8102 | 8102 | */ |
8103 | -function api_unique_multidim_array($array, $key){ |
|
8103 | +function api_unique_multidim_array($array, $key) { |
|
8104 | 8104 | $temp_array = array(); |
8105 | 8105 | $i = 0; |
8106 | 8106 | $key_array = array(); |
8107 | 8107 | |
8108 | - foreach($array as $val){ |
|
8109 | - if(!in_array($val[$key],$key_array)){ |
|
8108 | + foreach ($array as $val) { |
|
8109 | + if (!in_array($val[$key], $key_array)) { |
|
8110 | 8110 | $key_array[$i] = $val[$key]; |
8111 | 8111 | $temp_array[$i] = $val; |
8112 | 8112 | } |
@@ -625,7 +625,6 @@ discard block |
||
625 | 625 | * The other configuration parameters have not been changed. |
626 | 626 | * |
627 | 627 | * This is how we can get most used paths, for common purpose: |
628 | - |
|
629 | 628 | * api_get_path(REL_PATH) /chamilo/ |
630 | 629 | * api_get_path(REL_COURSE_PATH) /chamilo/courses/ |
631 | 630 | * api_get_path(REL_CODE_PATH) /chamilo/main/ |
@@ -1803,7 +1802,6 @@ discard block |
||
1803 | 1802 | |
1804 | 1803 | /** |
1805 | 1804 | * Returns the current course info array. |
1806 | - |
|
1807 | 1805 | * Now if the course_code is given, the returned array gives info about that |
1808 | 1806 | * particular course, not specially the current one. |
1809 | 1807 | * @param int $id Numeric ID of the course |
@@ -2734,7 +2732,7 @@ discard block |
||
2734 | 2732 | switch ($session_user_status) { |
2735 | 2733 | case 0: |
2736 | 2734 | $session_status['status'] = 'student'; |
2737 | - break; |
|
2735 | + break; |
|
2738 | 2736 | case 2: |
2739 | 2737 | $session_status['status'] = 'coach'; |
2740 | 2738 | break; |
@@ -6492,7 +6490,7 @@ discard block |
||
6492 | 6490 | function api_get_jquery_ui_js($include_jqgrid = false) { |
6493 | 6491 | $libraries = array(); |
6494 | 6492 | if ($include_jqgrid) { |
6495 | - $libraries[]='jqgrid'; |
|
6493 | + $libraries[]='jqgrid'; |
|
6496 | 6494 | } |
6497 | 6495 | return api_get_jquery_libraries_js($libraries); |
6498 | 6496 | } |