@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @assert () !== '' |
22 | 22 | * @assert ('abc','single') !== '' |
23 | 23 | */ |
24 | - function search_courses($needle,$type) |
|
24 | + function search_courses($needle, $type) |
|
25 | 25 | { |
26 | 26 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
27 | 27 | $xajax_response = new xajaxResponse(); |
28 | 28 | $return = ''; |
29 | - if(!empty($needle) && !empty($type)) { |
|
29 | + if (!empty($needle) && !empty($type)) { |
|
30 | 30 | // xajax send utf8 datas... datas in db can be non-utf8 datas |
31 | 31 | $charset = api_get_system_encoding(); |
32 | 32 | $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | $course_list = array(); |
39 | 39 | |
40 | 40 | $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
41 | - while($course = Database :: fetch_array($rs)) { |
|
41 | + while ($course = Database :: fetch_array($rs)) { |
|
42 | 42 | $course_list[] = $course['id']; |
43 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
43 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'], ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
44 | 44 | } |
45 | 45 | $return .= '</select>'; |
46 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
46 | + $xajax_response -> addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return)); |
|
47 | 47 | } |
48 | 48 | $_SESSION['course_list'] = $course_list; |
49 | 49 | return $xajax_response; |
@@ -25,29 +25,29 @@ |
||
25 | 25 | function search_courses($needle,$type) |
26 | 26 | { |
27 | 27 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
28 | - $xajax_response = new xajaxResponse(); |
|
29 | - $return = ''; |
|
30 | - if(!empty($needle) && !empty($type)) { |
|
31 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
32 | - $charset = api_get_system_encoding(); |
|
33 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
34 | - $needle = Database::escape_string($needle); |
|
28 | + $xajax_response = new xajaxResponse(); |
|
29 | + $return = ''; |
|
30 | + if(!empty($needle) && !empty($type)) { |
|
31 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
32 | + $charset = api_get_system_encoding(); |
|
33 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
34 | + $needle = Database::escape_string($needle); |
|
35 | 35 | |
36 | - $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
36 | + $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
37 | 37 | |
38 | - $rs = Database::query($sql); |
|
39 | - $course_list = array(); |
|
38 | + $rs = Database::query($sql); |
|
39 | + $course_list = array(); |
|
40 | 40 | |
41 | - $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
42 | - while($course = Database :: fetch_array($rs)) { |
|
43 | - $course_list[] = $course['id']; |
|
44 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
45 | - } |
|
46 | - $return .= '</select>'; |
|
47 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
48 | - } |
|
49 | - $_SESSION['course_list'] = $course_list; |
|
41 | + $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
42 | + while($course = Database :: fetch_array($rs)) { |
|
43 | + $course_list[] = $course['id']; |
|
44 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
45 | + } |
|
46 | + $return .= '</select>'; |
|
47 | + $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
48 | + } |
|
49 | + $_SESSION['course_list'] = $course_list; |
|
50 | 50 | |
51 | - return $xajax_response; |
|
52 | - } |
|
51 | + return $xajax_response; |
|
52 | + } |
|
53 | 53 | } |
@@ -666,7 +666,7 @@ |
||
666 | 666 | $res = Database::query($sql); |
667 | 667 | $count1 = Database::fetch_object($res); |
668 | 668 | $sql = "SELECT COUNT(*) AS n FROM $user_table as u $table ". |
669 | - "WHERE LENGTH(picture_uri) > 0 $url_condition2"; |
|
669 | + "WHERE LENGTH(picture_uri) > 0 $url_condition2"; |
|
670 | 670 | $res = Database::query($sql); |
671 | 671 | $count2 = Database::fetch_object($res); |
672 | 672 | // #users without picture |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | $course_user_table = Database:: get_main_table(TABLE_MAIN_COURSE_USER); |
105 | 105 | $course_table = Database:: get_main_table(TABLE_MAIN_COURSE); |
106 | 106 | $user_table = Database:: get_main_table(TABLE_MAIN_USER); |
107 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
107 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
108 | 108 | $current_url_id = api_get_current_access_url_id(); |
109 | - $active_filter = $onlyActive?' AND active=1':''; |
|
110 | - $status_filter = isset($status)?' AND status = '.intval($status):''; |
|
109 | + $active_filter = $onlyActive ? ' AND active=1' : ''; |
|
110 | + $status_filter = isset($status) ? ' AND status = '.intval($status) : ''; |
|
111 | 111 | |
112 | 112 | if (api_is_multiple_url_enabled()) { |
113 | 113 | $sql = "SELECT COUNT(DISTINCT(u.user_id)) AS number |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | FROM $user_table |
132 | 132 | WHERE 1=1 $status_filter $active_filter"; |
133 | 133 | if (isset($categoryCode)) { |
134 | - $status_filter = isset($status)?' AND status = '.intval($status):''; |
|
134 | + $status_filter = isset($status) ? ' AND status = '.intval($status) : ''; |
|
135 | 135 | $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number |
136 | 136 | FROM $course_user_table cu, $course_table c |
137 | 137 | WHERE |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | public static function countSessions() |
157 | 157 | { |
158 | 158 | $session_table = Database :: get_main_table(TABLE_MAIN_SESSION); |
159 | - $access_url_rel_session_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
159 | + $access_url_rel_session_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
160 | 160 | if (api_is_multiple_url_enabled()) { |
161 | 161 | $current_url_id = api_get_current_access_url_id(); |
162 | 162 | $sql = "SELECT COUNT(id) AS number |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | public static function getNumberOfActivities() |
180 | 180 | { |
181 | 181 | // Database table definitions |
182 | - $track_e_default = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); |
|
182 | + $track_e_default = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); |
|
183 | 183 | $table_user = Database::get_main_table(TABLE_MAIN_USER); |
184 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
184 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
185 | 185 | $current_url_id = api_get_current_access_url_id(); |
186 | 186 | if (api_is_multiple_url_enabled()) { |
187 | 187 | $sql = "SELECT count(default_id) AS total_number_of_items |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $from = intval($from); |
230 | 230 | $numberOfItems = intval($numberOfItems); |
231 | 231 | |
232 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
232 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
233 | 233 | $direction = 'DESC'; |
234 | 234 | } |
235 | 235 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $sql .= " LIMIT $from,$numberOfItems "; |
281 | 281 | |
282 | 282 | $res = Database::query($sql); |
283 | - $activities = array (); |
|
283 | + $activities = array(); |
|
284 | 284 | while ($row = Database::fetch_row($res)) { |
285 | 285 | if (strpos($row[1], '_object') === false && strpos($row[1], '_array') === false) { |
286 | 286 | $row[2] = $row[2]; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $sql = "SELECT code, name FROM $categoryTable |
350 | 350 | ORDER BY tree_pos"; |
351 | 351 | $res = Database::query($sql); |
352 | - $categories = array (); |
|
352 | + $categories = array(); |
|
353 | 353 | while ($category = Database::fetch_object($res)) { |
354 | 354 | $categories[$category->code] = $category->name; |
355 | 355 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $data_max = ($data_max < $value ? $value : $data_max); |
371 | 371 | } |
372 | 372 | reset($data); |
373 | - $result = array (); |
|
373 | + $result = array(); |
|
374 | 374 | $delta = $max / $data_max; |
375 | 375 | foreach ($data as $index => $value) { |
376 | 376 | $result[$index] = (int) round($value * $delta); |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | } else { |
405 | 405 | $number_label = Statistics::makeSizeString($number); |
406 | 406 | } |
407 | - $percentage = ($total>0?number_format(100*$number/$total, 1, ',', '.'):'0'); |
|
407 | + $percentage = ($total > 0 ? number_format(100 * $number / $total, 1, ',', '.') : '0'); |
|
408 | 408 | |
409 | - echo '<tr class="row_'.($i%2 == 0 ? 'odd' : 'even').'"> |
|
409 | + echo '<tr class="row_'.($i % 2 == 0 ? 'odd' : 'even').'"> |
|
410 | 410 | <td width="150">'.$subtitle.'</td> |
411 | 411 | <td width="550">'.Display::bar_progress($percentage, false).'</td> |
412 | 412 | <td align="right">'.$number_label.'</td>'; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | echo '<td align="right"> '.$percentage.'%</td>'; |
415 | 415 | } |
416 | 416 | echo '</tr>'; |
417 | - $i ++; |
|
417 | + $i++; |
|
418 | 418 | } |
419 | 419 | if ($showTotal) { |
420 | 420 | if (!$isFileSize) { |
@@ -434,17 +434,17 @@ discard block |
||
434 | 434 | public static function printLoginStats($type) |
435 | 435 | { |
436 | 436 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
437 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
437 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
438 | 438 | $current_url_id = api_get_current_access_url_id(); |
439 | 439 | |
440 | 440 | $table_url = null; |
441 | 441 | $where_url = null; |
442 | 442 | $now = api_get_utc_datetime(); |
443 | - $where_url_last = ' WHERE login_date > DATE_SUB("' . $now . '",INTERVAL 1 %s)'; |
|
443 | + $where_url_last = ' WHERE login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)'; |
|
444 | 444 | if (api_is_multiple_url_enabled()) { |
445 | 445 | $table_url = ", $access_url_rel_user_table"; |
446 | 446 | $where_url = " WHERE login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
447 | - $where_url_last = ' AND login_date > DATE_SUB("' . $now . '",INTERVAL 1 %s)'; |
|
447 | + $where_url_last = ' AND login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)'; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | $period = get_lang('PeriodMonth'); |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | GROUP BY stat_date |
464 | 464 | ORDER BY stat_date "; |
465 | 465 | $sql_last_x = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins |
466 | - FROM ".$table.$table_url.$where_url.sprintf($where_url_last,'DAY')." |
|
466 | + FROM ".$table.$table_url.$where_url.sprintf($where_url_last, 'DAY')." |
|
467 | 467 | GROUP BY stat_date |
468 | 468 | ORDER BY stat_date "; |
469 | 469 | break; |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | GROUP BY stat_date |
476 | 476 | ORDER BY DATE_FORMAT( login_date, '%w' ) "; |
477 | 477 | $sql_last_x = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date, count( login_id ) AS number_of_logins |
478 | - FROM ".$table.$table_url.$where_url.sprintf($where_url_last,'WEEK')." |
|
478 | + FROM ".$table.$table_url.$where_url.sprintf($where_url_last, 'WEEK')." |
|
479 | 479 | GROUP BY stat_date |
480 | 480 | ORDER BY DATE_FORMAT( login_date, '%w' ) "; |
481 | 481 | break; |
@@ -519,14 +519,14 @@ discard block |
||
519 | 519 | { |
520 | 520 | $totalLogin = array(); |
521 | 521 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
522 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
522 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
523 | 523 | $current_url_id = api_get_current_access_url_id(); |
524 | 524 | if (api_is_multiple_url_enabled()) { |
525 | 525 | $table_url = ", $access_url_rel_user_table"; |
526 | 526 | $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
527 | 527 | } else { |
528 | 528 | $table_url = ''; |
529 | - $where_url=''; |
|
529 | + $where_url = ''; |
|
530 | 530 | } |
531 | 531 | $now = api_get_utc_datetime(); |
532 | 532 | $field = 'login_user_id'; |
@@ -558,14 +558,14 @@ discard block |
||
558 | 558 | { |
559 | 559 | $totalLogin = []; |
560 | 560 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
561 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
561 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
562 | 562 | $current_url_id = api_get_current_access_url_id(); |
563 | 563 | if (api_is_multiple_url_enabled()) { |
564 | 564 | $table_url = ", $access_url_rel_user_table"; |
565 | 565 | $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
566 | 566 | } else { |
567 | 567 | $table_url = ''; |
568 | - $where_url=''; |
|
568 | + $where_url = ''; |
|
569 | 569 | } |
570 | 570 | $now = api_get_utc_datetime(); |
571 | 571 | $field = 'login_user_id'; |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | GROUP BY date(login_date)"; |
579 | 579 | |
580 | 580 | $res = Database::query($sql); |
581 | - while ($row = Database::fetch_array($res,'ASSOC')){ |
|
581 | + while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
582 | 582 | $totalLogin[$row['login_date']] = $row['number']; |
583 | 583 | } |
584 | 584 | |
@@ -672,13 +672,13 @@ discard block |
||
672 | 672 | public static function printUserPicturesStats() |
673 | 673 | { |
674 | 674 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
675 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
675 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
676 | 676 | $current_url_id = api_get_current_access_url_id(); |
677 | 677 | $url_condition = null; |
678 | 678 | $url_condition2 = null; |
679 | 679 | $table = null; |
680 | 680 | if (api_is_multiple_url_enabled()) { |
681 | - $url_condition = ", $access_url_rel_user_table as url WHERE url.user_id=u.user_id AND access_url_id='".$current_url_id."'"; |
|
681 | + $url_condition = ", $access_url_rel_user_table as url WHERE url.user_id=u.user_id AND access_url_id='".$current_url_id."'"; |
|
682 | 682 | $url_condition2 = " AND url.user_id=u.user_id AND access_url_id='".$current_url_id."'"; |
683 | 683 | $table = ", $access_url_rel_user_table as url "; |
684 | 684 | } |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | 'width=200px', |
711 | 711 | false |
712 | 712 | ); |
713 | - $renderer =& $form->defaultRenderer(); |
|
713 | + $renderer = & $form->defaultRenderer(); |
|
714 | 714 | $renderer->setCustomElementTemplate('<span>{element}</span> '); |
715 | 715 | $form->addElement('hidden', 'report', 'activities'); |
716 | 716 | $form->addElement('hidden', 'activities_direction', 'DESC'); |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | $columns[1] = 'access_date'; |
761 | 761 | $sql_order[SORT_ASC] = 'ASC'; |
762 | 762 | $sql_order[SORT_DESC] = 'DESC'; |
763 | - $per_page = isset($_GET['per_page'])?intval($_GET['per_page']) : 10; |
|
764 | - $page_nr = isset($_GET['page_nr'])?intval($_GET['page_nr']) : 1; |
|
765 | - $column = isset($_GET['column'])?intval($_GET['column']) : 0; |
|
766 | - $date_diff = isset($_GET['date_diff'])?intval($_GET['date_diff']) : 60; |
|
763 | + $per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10; |
|
764 | + $page_nr = isset($_GET['page_nr']) ? intval($_GET['page_nr']) : 1; |
|
765 | + $column = isset($_GET['column']) ? intval($_GET['column']) : 0; |
|
766 | + $date_diff = isset($_GET['date_diff']) ? intval($_GET['date_diff']) : 60; |
|
767 | 767 | $direction = isset($_GET['direction']) ? $_GET['direction'] : SORT_ASC; |
768 | 768 | |
769 | 769 | if (!in_array($direction, array(SORT_ASC, SORT_DESC))) { |
@@ -791,25 +791,25 @@ discard block |
||
791 | 791 | access_url_id='".$current_url_id."' |
792 | 792 | GROUP BY t.c_id |
793 | 793 | HAVING t.c_id <> '' |
794 | - AND DATEDIFF( '".api_get_utc_datetime()."' , access_date ) <= ". $date_diff; |
|
794 | + AND DATEDIFF( '".api_get_utc_datetime()."' , access_date ) <= ".$date_diff; |
|
795 | 795 | } else { |
796 | 796 | $sql = "SELECT * FROM $table |
797 | 797 | GROUP BY c_id |
798 | 798 | HAVING c_id <> '' |
799 | - AND DATEDIFF( '".api_get_utc_datetime()."' , access_date ) <= ". $date_diff; |
|
799 | + AND DATEDIFF( '".api_get_utc_datetime()."' , access_date ) <= ".$date_diff; |
|
800 | 800 | } |
801 | 801 | $sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction]; |
802 | - $from = ($page_nr -1) * $per_page; |
|
802 | + $from = ($page_nr - 1) * $per_page; |
|
803 | 803 | $sql .= ' LIMIT '.$from.','.$per_page; |
804 | 804 | |
805 | 805 | echo '<p>'.get_lang('LastAccess').' >= '.$date_diff.' '.get_lang('Days').'</p>'; |
806 | 806 | $res = Database::query($sql); |
807 | 807 | if (Database::num_rows($res) > 0) { |
808 | - $courses = array (); |
|
808 | + $courses = array(); |
|
809 | 809 | while ($obj = Database::fetch_object($res)) { |
810 | 810 | $courseInfo = api_get_course_info_by_id($obj->c_id); |
811 | - $course = array (); |
|
812 | - $course[]= '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['code'].'">'.$courseInfo['code'].' <a>'; |
|
811 | + $course = array(); |
|
812 | + $course[] = '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['code'].'">'.$courseInfo['code'].' <a>'; |
|
813 | 813 | // Allow sort by date hiding the numerical date |
814 | 814 | $course[] = '<span style="display:none;">'.$obj->access_date.'</span>'.api_convert_and_format_date($obj->access_date); |
815 | 815 | $courses[] = $course; |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | { |
888 | 888 | $user_friend_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
889 | 889 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
890 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
890 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
891 | 891 | $current_url_id = api_get_current_access_url_id(); |
892 | 892 | |
893 | 893 | if (api_is_multiple_url_enabled()) { |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | { |
927 | 927 | $totalLogin = array(); |
928 | 928 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
929 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
929 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
930 | 930 | $current_url_id = api_get_current_access_url_id(); |
931 | 931 | $total = self::countUsers(); |
932 | 932 | if (api_is_multiple_url_enabled()) { |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
935 | 935 | } else { |
936 | 936 | $table_url = ''; |
937 | - $where_url=''; |
|
937 | + $where_url = ''; |
|
938 | 938 | } |
939 | 939 | $now = api_get_utc_datetime(); |
940 | 940 | $sql[get_lang('ThisDay')] = |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | class OpenGraph implements Iterator |
20 | 20 | { |
21 | - /** |
|
22 | - * There are base schema's based on type, this is just |
|
23 | - * a map so that the schema can be obtained |
|
24 | - * |
|
25 | - */ |
|
21 | + /** |
|
22 | + * There are base schema's based on type, this is just |
|
23 | + * a map so that the schema can be obtained |
|
24 | + * |
|
25 | + */ |
|
26 | 26 | public static $TYPES = array( |
27 | 27 | 'activity' => array('activity', 'sport'), |
28 | 28 | 'business' => array('bar', 'company', 'cafe', 'hotel', 'restaurant'), |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | 'website' => array('blog', 'website'), |
35 | 35 | ); |
36 | 36 | |
37 | - /** |
|
38 | - * Holds all the Open Graph values we've parsed from a page |
|
39 | - * |
|
40 | - */ |
|
37 | + /** |
|
38 | + * Holds all the Open Graph values we've parsed from a page |
|
39 | + * |
|
40 | + */ |
|
41 | 41 | private $_values = array(); |
42 | 42 | |
43 | - /** |
|
44 | - * Fetches a URI and parses it for Open Graph data, returns |
|
45 | - * false on error. |
|
46 | - * |
|
47 | - * @param $URI URI to page to parse for Open Graph data |
|
48 | - * @return OpenGraph |
|
49 | - */ |
|
43 | + /** |
|
44 | + * Fetches a URI and parses it for Open Graph data, returns |
|
45 | + * false on error. |
|
46 | + * |
|
47 | + * @param $URI URI to page to parse for Open Graph data |
|
48 | + * @return OpenGraph |
|
49 | + */ |
|
50 | 50 | static public function fetch($URI) { |
51 | 51 | $curl = curl_init($URI); |
52 | 52 | |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * Parses HTML and extracts Open Graph data, this assumes |
|
74 | - * the document is at least well formed. |
|
75 | - * |
|
76 | - * @param $HTML HTML to parse |
|
77 | - * @return OpenGraph |
|
78 | - */ |
|
72 | + /** |
|
73 | + * Parses HTML and extracts Open Graph data, this assumes |
|
74 | + * the document is at least well formed. |
|
75 | + * |
|
76 | + * @param $HTML HTML to parse |
|
77 | + * @return OpenGraph |
|
78 | + */ |
|
79 | 79 | static private function _parse($HTML) { |
80 | 80 | $old_libxml_error = libxml_use_internal_errors(true); |
81 | 81 | |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | return $page; |
141 | 141 | } |
142 | 142 | |
143 | - /** |
|
144 | - * Helper method to access attributes directly |
|
145 | - * Example: |
|
146 | - * $graph->title |
|
147 | - * |
|
148 | - * @param $key Key to fetch from the lookup |
|
149 | - */ |
|
143 | + /** |
|
144 | + * Helper method to access attributes directly |
|
145 | + * Example: |
|
146 | + * $graph->title |
|
147 | + * |
|
148 | + * @param $key Key to fetch from the lookup |
|
149 | + */ |
|
150 | 150 | public function __get($key) { |
151 | 151 | if (array_key_exists($key, $this->_values)) { |
152 | 152 | return $this->_values[$key]; |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - /** |
|
165 | - * Return all the keys found on the page |
|
166 | - * |
|
167 | - * @return array |
|
168 | - */ |
|
164 | + /** |
|
165 | + * Return all the keys found on the page |
|
166 | + * |
|
167 | + * @return array |
|
168 | + */ |
|
169 | 169 | public function keys() { |
170 | 170 | return array_keys($this->_values); |
171 | 171 | } |
172 | 172 | |
173 | - /** |
|
174 | - * Helper method to check an attribute exists |
|
175 | - * |
|
176 | - * @param $key |
|
177 | - */ |
|
173 | + /** |
|
174 | + * Helper method to check an attribute exists |
|
175 | + * |
|
176 | + * @param $key |
|
177 | + */ |
|
178 | 178 | public function __isset($key) { |
179 | 179 | return array_key_exists($key, $this->_values); |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Will return true if the page has location data embedded |
|
184 | - * |
|
185 | - * @return boolean Check if the page has location data |
|
186 | - */ |
|
182 | + /** |
|
183 | + * Will return true if the page has location data embedded |
|
184 | + * |
|
185 | + * @return boolean Check if the page has location data |
|
186 | + */ |
|
187 | 187 | public function hasLocation() { |
188 | 188 | if (array_key_exists('latitude', $this->_values) && array_key_exists('longitude', $this->_values)) { |
189 | 189 | return true; |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | return $valid_address; |
198 | 198 | } |
199 | 199 | |
200 | - /** |
|
201 | - * Iterator code |
|
202 | - */ |
|
200 | + /** |
|
201 | + * Iterator code |
|
202 | + */ |
|
203 | 203 | private $_position = 0; |
204 | 204 | public function rewind() { reset($this->_values); $this->_position = 0; } |
205 | 205 | public function current() { return current($this->_values); } |
@@ -18,9 +18,11 @@ |
||
18 | 18 | |
19 | 19 | foreach ($event_config[$event_name]["actions"] as $func) { |
20 | 20 | $execute = true; |
21 | - if (!function_exists($func)) // if the function doesn't exist, we log |
|
21 | + if (!function_exists($func)) { |
|
22 | + // if the function doesn't exist, we log |
|
22 | 23 | { |
23 | 24 | error_log("EventsDispatcher warning : ".$func." does not exist."); |
25 | + } |
|
24 | 26 | $execute = false; |
25 | 27 | } |
26 | 28 |
@@ -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; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | if (!isset($used_lang_vars)) { |
102 | - $used_lang_vars = array(); |
|
102 | + $used_lang_vars = array(); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Caching results from some API functions, for speed. |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | static $text_direction = array(); |
289 | 289 | |
290 | 290 | if (empty($language)) { |
291 | - $language = api_get_interface_language(); |
|
291 | + $language = api_get_interface_language(); |
|
292 | 292 | } |
293 | 293 | if (!isset($text_direction[$language])) { |
294 | 294 | $text_direction[$language] = in_array(api_purify_language_id($language), |
@@ -1703,7 +1703,6 @@ discard block |
||
1703 | 1703 | |
1704 | 1704 | /** |
1705 | 1705 | * Return true a date is valid |
1706 | - |
|
1707 | 1706 | * @param string $date example: 2014-06-30 13:05:05 |
1708 | 1707 | * @param string $format example: "Y-m-d H:i:s" |
1709 | 1708 | * |
@@ -1973,15 +1972,15 @@ discard block |
||
1973 | 1972 | { |
1974 | 1973 | if ($showTime) { |
1975 | 1974 | if ($humanForm) { |
1976 | - return $date->format('j M Y H:i:s'); |
|
1975 | + return $date->format('j M Y H:i:s'); |
|
1977 | 1976 | } else { |
1978 | - return $date->format('Y-m-d H:i:s'); |
|
1977 | + return $date->format('Y-m-d H:i:s'); |
|
1979 | 1978 | } |
1980 | 1979 | } else { |
1981 | 1980 | if ($humanForm) { |
1982 | - return $date->format('j M Y'); |
|
1981 | + return $date->format('j M Y'); |
|
1983 | 1982 | } else { |
1984 | - return $date->format('Y-m-d'); |
|
1983 | + return $date->format('Y-m-d'); |
|
1985 | 1984 | } |
1986 | 1985 | } |
1987 | 1986 | } |
@@ -633,10 +633,10 @@ discard block |
||
633 | 633 | $date_format = str_replace( |
634 | 634 | array('%A', '%a', '%B', '%b'), |
635 | 635 | array( |
636 | - $translated['days_long'][(int)strftime('%w', $time)], |
|
637 | - $translated['days_short'][(int)strftime('%w', $time)], |
|
638 | - $translated['months_long'][(int)strftime('%m', $time) - 1], |
|
639 | - $translated['months_short'][(int)strftime('%m', $time) - 1], |
|
636 | + $translated['days_long'][(int) strftime('%w', $time)], |
|
637 | + $translated['days_short'][(int) strftime('%w', $time)], |
|
638 | + $translated['months_long'][(int) strftime('%m', $time) - 1], |
|
639 | + $translated['months_short'][(int) strftime('%m', $time) - 1], |
|
640 | 640 | ), |
641 | 641 | $date_format |
642 | 642 | ); |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | * @return string Returns the encoding identificator modified in suitable for comparison way. |
1584 | 1584 | */ |
1585 | 1585 | function api_refine_encoding_id($encoding) { |
1586 | - if (is_array($encoding)){ |
|
1586 | + if (is_array($encoding)) { |
|
1587 | 1587 | return array_map('api_refine_encoding_id', $encoding); |
1588 | 1588 | } |
1589 | 1589 | return strtoupper(str_replace('_', '-', $encoding)); |
@@ -107,14 +107,14 @@ |
||
107 | 107 | return $resu; |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * @author Sebastien Piraux <[email protected]> |
|
112 | - * @param sql : a sql query (as a string) |
|
113 | - * @return hours_array |
|
114 | - * @desc Return an assoc array. Keys are the hours, values are |
|
115 | - * the number of time this hours was found. |
|
116 | - * key 'total' return the sum of all number of time hours |
|
117 | - * appear |
|
110 | + /** |
|
111 | + * @author Sebastien Piraux <[email protected]> |
|
112 | + * @param sql : a sql query (as a string) |
|
113 | + * @return hours_array |
|
114 | + * @desc Return an assoc array. Keys are the hours, values are |
|
115 | + * the number of time this hours was found. |
|
116 | + * key 'total' return the sum of all number of time hours |
|
117 | + * appear |
|
118 | 118 | */ |
119 | 119 | public static function hoursTab($sql) |
120 | 120 | { |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $last_day = -1; |
156 | 156 | while ($row = Database::fetch_row($res)) { |
157 | 157 | $date_array = getdate($row[0]); |
158 | - $display_date = $date_array['mday'] . ' ' . $MonthsShort[$date_array['mon'] - 1] . ' ' . $date_array['year']; |
|
158 | + $display_date = $date_array['mday'].' '.$MonthsShort[$date_array['mon'] - 1].' '.$date_array['year']; |
|
159 | 159 | if ($date_array['mday'] == $last_day) { |
160 | 160 | $days_array[$display_date]++; |
161 | 161 | } else { |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | </td> |
223 | 223 | <td width='10%'> |
224 | - <b>" . get_lang('Hits') . "</b> |
|
224 | + <b>".get_lang('Hits')."</b> |
|
225 | 225 | </td> |
226 | 226 | <td width='15%'> |
227 | 227 | <b>%</b> |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | echo "<img src='".Display::returnIconPath('bar_1m.gif')."' width='1' height='12' alt='$periodPiece : $cpt hits – $pourcent %' />"; |
250 | 250 | } |
251 | 251 | if ($pourcent != 100) { |
252 | - echo "<img src='".Display::returnIconPath('bar_1r.gif')."' width='" . ($maxSize - $barwidth) . "' height='12' alt='$periodPiece : $cpt hits – $pourcent %' />"; |
|
252 | + echo "<img src='".Display::returnIconPath('bar_1r.gif')."' width='".($maxSize - $barwidth)."' height='12' alt='$periodPiece : $cpt hits – $pourcent %' />"; |
|
253 | 253 | } |
254 | 254 | echo "<img src='".Display::returnIconPath('bar_1.gif')."' width='1' height='12' alt='$periodPiece : $cpt hits – $pourcent %' /> |
255 | 255 | </td> |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | } |
266 | 266 | echo "<tr bgcolor='#E6E6E6'> |
267 | 267 | <td width='15%' align='center'> |
268 | - " . get_lang('Total') . " |
|
268 | + " . get_lang('Total')." |
|
269 | 269 | </td> |
270 | 270 | <td align='right' width='60%'> |
271 | 271 | |
272 | 272 | </td> |
273 | 273 | <td align='center' width='10%'> |
274 | - " . $period_array['total'] . " |
|
274 | + " . $period_array['total']." |
|
275 | 275 | </td> |
276 | 276 | <td width='15%'> |
277 | 277 | |
@@ -5,42 +5,42 @@ |
||
5 | 5 | * @deprecated Don't use this class |
6 | 6 | */ |
7 | 7 | class Rights { |
8 | - private static $rights_cache = array(); |
|
9 | - private static $rights = array ( |
|
10 | - 'show_tabs:reports' => |
|
11 | - array ( |
|
12 | - 'type' => 'const', |
|
13 | - 'const' => 'true' ) |
|
14 | - ); |
|
8 | + private static $rights_cache = array(); |
|
9 | + private static $rights = array ( |
|
10 | + 'show_tabs:reports' => |
|
11 | + array ( |
|
12 | + 'type' => 'const', |
|
13 | + 'const' => 'true' ) |
|
14 | + ); |
|
15 | 15 | |
16 | - // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | - // thus default return value is always true |
|
18 | - public static function hasRight($handler) { |
|
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
16 | + // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | + // thus default return value is always true |
|
18 | + public static function hasRight($handler) { |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | 21 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
22 | + if (!array_key_exists($handler, self::$rights)) |
|
23 | + return true; // handler does not exists |
|
24 | 24 | |
25 | - if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | - $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
36 | - return true; |
|
37 | - self::$rights_cache[$handler] = $result; |
|
38 | - return $result; |
|
39 | - } |
|
25 | + if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | + $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | + if (Database::num_rows($result) > 0) |
|
28 | + $result = true; |
|
29 | + else |
|
30 | + $result = false; |
|
31 | + } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | + $result = self::$rights[$handler]['const']; |
|
33 | + else if (self::$rights[$handler]['type'] == 'func') |
|
34 | + $result = self::$rights[$handler]['func'](); |
|
35 | + else // handler type not implemented |
|
36 | + return true; |
|
37 | + self::$rights_cache[$handler] = $result; |
|
38 | + return $result; |
|
39 | + } |
|
40 | 40 | |
41 | - public static function hasRightClosePageWithError($handler) { |
|
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
44 | - } |
|
41 | + public static function hasRightClosePageWithError($handler) { |
|
42 | + if (hasRight($handler) == false) |
|
43 | + die("You are not allowed here"); //FIXME |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
@@ -6,9 +6,9 @@ |
||
6 | 6 | */ |
7 | 7 | class Rights { |
8 | 8 | private static $rights_cache = array(); |
9 | - private static $rights = array ( |
|
9 | + private static $rights = array( |
|
10 | 10 | 'show_tabs:reports' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'type' => 'const', |
13 | 13 | 'const' => 'true' ) |
14 | 14 | ); |
@@ -16,31 +16,39 @@ |
||
16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
17 | 17 | // thus default return value is always true |
18 | 18 | public static function hasRight($handler) { |
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) { |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | + } |
|
21 | 22 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
23 | + if (!array_key_exists($handler, self::$rights)) { |
|
24 | + return true; |
|
25 | + } |
|
26 | + // handler does not exists |
|
24 | 27 | |
25 | 28 | if (self::$rights[$handler]['type'] == 'sql') { |
26 | 29 | $result = Database::query(self::$rights[$handler]['sql']); |
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
30 | + if (Database::num_rows($result) > 0) { |
|
31 | + $result = true; |
|
32 | + } else { |
|
33 | + $result = false; |
|
34 | + } |
|
35 | + } else if (self::$rights[$handler]['type'] == 'const') { |
|
36 | + $result = self::$rights[$handler]['const']; |
|
37 | + } else if (self::$rights[$handler]['type'] == 'func') { |
|
38 | + $result = self::$rights[$handler]['func'](); |
|
39 | + } else { |
|
40 | + // handler type not implemented |
|
36 | 41 | return true; |
42 | + } |
|
37 | 43 | self::$rights_cache[$handler] = $result; |
38 | 44 | return $result; |
39 | 45 | } |
40 | 46 | |
41 | 47 | public static function hasRightClosePageWithError($handler) { |
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
48 | + if (hasRight($handler) == false) { |
|
49 | + die("You are not allowed here"); |
|
50 | + } |
|
51 | + //FIXME |
|
44 | 52 | } |
45 | 53 | |
46 | 54 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | $new_data_order = array(); |
159 | 159 | if (!empty($docs_to_sort)) { |
160 | - foreach($docs_to_sort as $id => $document) { |
|
160 | + foreach ($docs_to_sort as $id => $document) { |
|
161 | 161 | if (isset($new_data[$id])) { |
162 | 162 | $new_data_order[] = $new_data[$id]; |
163 | 163 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | if (!empty($folder_to_sort)) { |
168 | - foreach($folder_to_sort as $id => $document) { |
|
168 | + foreach ($folder_to_sort as $id => $document) { |
|
169 | 169 | if (isset($new_data[$id])) { |
170 | 170 | $new_data_order[] = $new_data[$id]; |
171 | 171 | } |
@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | class TableSort |
16 | 16 | { |
17 | 17 | /** |
18 | - * Sorts 2-dimensional table. |
|
19 | - * @param array $data The data to be sorted. |
|
20 | - * @param int $column The column on which the data should be sorted (default = 0) |
|
21 | - * @param int $direction The direction to sort (SORT_ASC (default) or SORT_DESC) |
|
22 | - * @param int $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, |
|
23 | - * SORT_STRING,SORT_DATE,SORT_IMAGE) |
|
24 | - * @return array The sorted dataset |
|
25 | - * @author [email protected] |
|
26 | - */ |
|
27 | - public static function sort_table($data, $column = 0, $direction = SORT_ASC, $type = SORT_REGULAR) |
|
18 | + * Sorts 2-dimensional table. |
|
19 | + * @param array $data The data to be sorted. |
|
20 | + * @param int $column The column on which the data should be sorted (default = 0) |
|
21 | + * @param int $direction The direction to sort (SORT_ASC (default) or SORT_DESC) |
|
22 | + * @param int $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, |
|
23 | + * SORT_STRING,SORT_DATE,SORT_IMAGE) |
|
24 | + * @return array The sorted dataset |
|
25 | + * @author [email protected] |
|
26 | + */ |
|
27 | + public static function sort_table($data, $column = 0, $direction = SORT_ASC, $type = SORT_REGULAR) |
|
28 | 28 | { |
29 | 29 | if (!is_array($data) || empty($data)) { |
30 | 30 | return array(); |
@@ -71,20 +71,20 @@ discard block |
||
71 | 71 | usort($data, create_function('$a, $b', $compare_function)); |
72 | 72 | |
73 | 73 | return $data; |
74 | - } |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Sorts 2-dimensional table. It is possile changing the columns that will be shown and the way that the columns are to be sorted. |
|
78 | - * @param array $data The data to be sorted. |
|
79 | - * @param int $column The column on which the data should be sorted (default = 0) |
|
80 | - * @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC) |
|
81 | - * @param array $column_show The columns that we will show in the table i.e: $column_show = array('1','0','1') we will show the 1st and the 3th column. |
|
82 | - * @param array $column_order Changes how the columns will be sorted ie. $column_order = array('0','3','2','3') The column [1] will be sorted like the column [3] |
|
83 | - * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE) |
|
84 | - * @return array The sorted dataset |
|
85 | - * @author [email protected] |
|
86 | - */ |
|
87 | - public static function sort_table_config( |
|
76 | + /** |
|
77 | + * Sorts 2-dimensional table. It is possile changing the columns that will be shown and the way that the columns are to be sorted. |
|
78 | + * @param array $data The data to be sorted. |
|
79 | + * @param int $column The column on which the data should be sorted (default = 0) |
|
80 | + * @param string $direction The direction to sort (SORT_ASC (default) orSORT_DESC) |
|
81 | + * @param array $column_show The columns that we will show in the table i.e: $column_show = array('1','0','1') we will show the 1st and the 3th column. |
|
82 | + * @param array $column_order Changes how the columns will be sorted ie. $column_order = array('0','3','2','3') The column [1] will be sorted like the column [3] |
|
83 | + * @param constant $type How should data be sorted (SORT_REGULAR, SORT_NUMERIC, SORT_STRING, SORT_DATE, SORT_IMAGE) |
|
84 | + * @return array The sorted dataset |
|
85 | + * @author [email protected] |
|
86 | + */ |
|
87 | + public static function sort_table_config( |
|
88 | 88 | $data, |
89 | 89 | $column = 0, |
90 | 90 | $direction = SORT_ASC, |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | if (!empty($data)) { |
133 | 133 | foreach ($data as $document) { |
134 | 134 | if ($document['type'] == 'folder') { |
135 | - $docs_to_sort[$document['id']] = api_strtolower($document['name']); |
|
135 | + $docs_to_sort[$document['id']] = api_strtolower($document['name']); |
|
136 | 136 | } else { |
137 | - $folder_to_sort[$document['id']] = api_strtolower($document['name']); |
|
137 | + $folder_to_sort[$document['id']] = api_strtolower($document['name']); |
|
138 | 138 | } |
139 | 139 | $new_data[$document['id']] = $document; |
140 | 140 | } |
@@ -196,91 +196,91 @@ discard block |
||
196 | 196 | usort($data, create_function('$a, $b', $compare_function)); |
197 | 197 | } |
198 | 198 | |
199 | - if (is_array($column_show) && !empty($column_show)) { |
|
199 | + if (is_array($column_show) && !empty($column_show)) { |
|
200 | 200 | |
201 | - // We show only the columns data that were set up on the $column_show array |
|
202 | - $new_order_data = array(); |
|
203 | - $count_data = count($data); |
|
204 | - $count_column_show = count($column_show); |
|
205 | - for ($j = 0; $j < $count_data; $j++) { |
|
206 | - $k = 0; |
|
207 | - for ($i = 0; $i < $count_column_show; $i++) { |
|
208 | - if ($column_show[$i]) { |
|
209 | - $new_order_data[$j][$k] = $data[$j][$i]; |
|
210 | - } |
|
211 | - $k++; |
|
212 | - } |
|
213 | - } |
|
214 | - // Replace the multi-arrays |
|
215 | - $data = $new_order_data; |
|
216 | - } |
|
201 | + // We show only the columns data that were set up on the $column_show array |
|
202 | + $new_order_data = array(); |
|
203 | + $count_data = count($data); |
|
204 | + $count_column_show = count($column_show); |
|
205 | + for ($j = 0; $j < $count_data; $j++) { |
|
206 | + $k = 0; |
|
207 | + for ($i = 0; $i < $count_column_show; $i++) { |
|
208 | + if ($column_show[$i]) { |
|
209 | + $new_order_data[$j][$k] = $data[$j][$i]; |
|
210 | + } |
|
211 | + $k++; |
|
212 | + } |
|
213 | + } |
|
214 | + // Replace the multi-arrays |
|
215 | + $data = $new_order_data; |
|
216 | + } |
|
217 | 217 | |
218 | - return $data; |
|
219 | - } |
|
218 | + return $data; |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * Checks whether a column of a 2D-array contains only numeric values |
|
223 | - * @param array $data The data-array |
|
224 | - * @param int $column The index of the column to check |
|
225 | - * @return bool TRUE if column contains only dates, FALSE otherwise |
|
226 | - * @todo Take locale into account (eg decimal point or comma ?) |
|
227 | - * @author [email protected] |
|
228 | - */ |
|
229 | - private static function is_numeric_column(& $data, $column) |
|
221 | + /** |
|
222 | + * Checks whether a column of a 2D-array contains only numeric values |
|
223 | + * @param array $data The data-array |
|
224 | + * @param int $column The index of the column to check |
|
225 | + * @return bool TRUE if column contains only dates, FALSE otherwise |
|
226 | + * @todo Take locale into account (eg decimal point or comma ?) |
|
227 | + * @author [email protected] |
|
228 | + */ |
|
229 | + private static function is_numeric_column(& $data, $column) |
|
230 | 230 | { |
231 | - $is_numeric = true; |
|
232 | - foreach ($data as $index => & $row) { |
|
233 | - $is_numeric &= is_numeric(strip_tags($row[$column])); |
|
234 | - if (!$is_numeric) { |
|
235 | - break; |
|
236 | - } |
|
237 | - } |
|
238 | - return $is_numeric; |
|
239 | - } |
|
231 | + $is_numeric = true; |
|
232 | + foreach ($data as $index => & $row) { |
|
233 | + $is_numeric &= is_numeric(strip_tags($row[$column])); |
|
234 | + if (!$is_numeric) { |
|
235 | + break; |
|
236 | + } |
|
237 | + } |
|
238 | + return $is_numeric; |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Checks whether a column of a 2D-array contains only dates (GNU date syntax) |
|
243 | - * @param array $data The data-array |
|
244 | - * @param int $column The index of the column to check |
|
245 | - * @return bool TRUE if column contains only dates, FALSE otherwise |
|
246 | - * @author [email protected] |
|
247 | - */ |
|
248 | - private static function is_date_column(& $data, $column) |
|
241 | + /** |
|
242 | + * Checks whether a column of a 2D-array contains only dates (GNU date syntax) |
|
243 | + * @param array $data The data-array |
|
244 | + * @param int $column The index of the column to check |
|
245 | + * @return bool TRUE if column contains only dates, FALSE otherwise |
|
246 | + * @author [email protected] |
|
247 | + */ |
|
248 | + private static function is_date_column(& $data, $column) |
|
249 | 249 | { |
250 | - $is_date = true; |
|
251 | - foreach ($data as $index => & $row) { |
|
252 | - if (strlen(strip_tags($row[$column])) != 0) { |
|
253 | - $check_date = strtotime(strip_tags($row[$column])); |
|
254 | - // strtotime Returns a timestamp on success, FALSE otherwise. |
|
255 | - // Previous to PHP 5.1.0, this function would return -1 on failure. |
|
256 | - $is_date &= ($check_date != -1 && $check_date); |
|
257 | - } else { |
|
258 | - $is_date &= false; |
|
259 | - } |
|
260 | - if (!$is_date) { |
|
261 | - break; |
|
262 | - } |
|
263 | - } |
|
264 | - return $is_date; |
|
265 | - } |
|
250 | + $is_date = true; |
|
251 | + foreach ($data as $index => & $row) { |
|
252 | + if (strlen(strip_tags($row[$column])) != 0) { |
|
253 | + $check_date = strtotime(strip_tags($row[$column])); |
|
254 | + // strtotime Returns a timestamp on success, FALSE otherwise. |
|
255 | + // Previous to PHP 5.1.0, this function would return -1 on failure. |
|
256 | + $is_date &= ($check_date != -1 && $check_date); |
|
257 | + } else { |
|
258 | + $is_date &= false; |
|
259 | + } |
|
260 | + if (!$is_date) { |
|
261 | + break; |
|
262 | + } |
|
263 | + } |
|
264 | + return $is_date; |
|
265 | + } |
|
266 | 266 | |
267 | - /** |
|
268 | - * Checks whether a column of a 2D-array contains only images (<img src="path/file.ext" alt=".."/>) |
|
269 | - * @param array $data The data-array |
|
270 | - * @param int $column The index of the column to check |
|
271 | - * @return bool TRUE if column contains only images, FALSE otherwise |
|
272 | - * @author [email protected] |
|
273 | - */ |
|
274 | - private static function is_image_column(& $data, $column) |
|
267 | + /** |
|
268 | + * Checks whether a column of a 2D-array contains only images (<img src="path/file.ext" alt=".."/>) |
|
269 | + * @param array $data The data-array |
|
270 | + * @param int $column The index of the column to check |
|
271 | + * @return bool TRUE if column contains only images, FALSE otherwise |
|
272 | + * @author [email protected] |
|
273 | + */ |
|
274 | + private static function is_image_column(& $data, $column) |
|
275 | 275 | { |
276 | - $is_image = true; |
|
277 | - foreach ($data as $index => & $row) { |
|
278 | - $is_image &= strlen(trim(strip_tags($row[$column], '<img>'))) > 0; // at least one img-tag |
|
279 | - $is_image &= strlen(trim(strip_tags($row[$column]))) == 0; // and no text outside attribute-values |
|
280 | - if (!$is_image) { |
|
281 | - break; |
|
282 | - } |
|
283 | - } |
|
284 | - return $is_image; |
|
285 | - } |
|
276 | + $is_image = true; |
|
277 | + foreach ($data as $index => & $row) { |
|
278 | + $is_image &= strlen(trim(strip_tags($row[$column], '<img>'))) > 0; // at least one img-tag |
|
279 | + $is_image &= strlen(trim(strip_tags($row[$column]))) == 0; // and no text outside attribute-values |
|
280 | + if (!$is_image) { |
|
281 | + break; |
|
282 | + } |
|
283 | + } |
|
284 | + return $is_image; |
|
285 | + } |
|
286 | 286 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @param string $pluginName |
|
177 | - * @param int $urlId |
|
178 | - */ |
|
176 | + * @param string $pluginName |
|
177 | + * @param int $urlId |
|
178 | + */ |
|
179 | 179 | public function uninstall($pluginName, $urlId = null) |
180 | 180 | { |
181 | 181 | if (empty($urlId)) { |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * @param string $region |
|
256 | - * @param string $template |
|
257 | - * @param bool $forced |
|
258 | - * |
|
259 | - * @return null|string |
|
260 | - */ |
|
255 | + * @param string $region |
|
256 | + * @param string $template |
|
257 | + * @param bool $forced |
|
258 | + * |
|
259 | + * @return null|string |
|
260 | + */ |
|
261 | 261 | public function load_region($region, $template, $forced = false) |
262 | 262 | { |
263 | 263 | if ($region == 'course_tool_plugin') { |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | // Extra options |
427 | 427 | $plugin_settings = api_get_settings_params( |
428 | 428 | array( |
429 | - "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins','setting') |
|
429 | + "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins', 'setting') |
|
430 | 430 | ) |
431 | 431 | ); |
432 | 432 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | if (!empty($obj->course_settings)) { |
533 | 533 | if (is_file(api_get_path(SYS_CODE_PATH).'img/icons/'.ICON_SIZE_SMALL.'/'.$plugin_name.'.png')) { |
534 | 534 | $icon = Display::return_icon( |
535 | - $plugin_name . '.png', |
|
535 | + $plugin_name.'.png', |
|
536 | 536 | Security::remove_XSS($pluginTitle), |
537 | 537 | '', |
538 | 538 | ICON_SIZE_SMALL |
@@ -548,18 +548,18 @@ discard block |
||
548 | 548 | |
549 | 549 | $form->addHtml('<div class="panel panel-default">'); |
550 | 550 | $form->addHtml(' |
551 | - <div class="panel-heading" role="tab" id="heading-' . $plugin_name . '-settings"> |
|
551 | + <div class="panel-heading" role="tab" id="heading-' . $plugin_name.'-settings"> |
|
552 | 552 | <h4 class="panel-title"> |
553 | - <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-' . $plugin_name . '-settings" aria-expanded="false" aria-controls="collapse-' . $plugin_name . '-settings"> |
|
553 | + <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-' . $plugin_name.'-settings" aria-expanded="false" aria-controls="collapse-'.$plugin_name.'-settings"> |
|
554 | 554 | '); |
555 | - $form->addHtml($icon . ' ' . $pluginTitle); |
|
555 | + $form->addHtml($icon.' '.$pluginTitle); |
|
556 | 556 | $form->addHtml(' |
557 | 557 | </a> |
558 | 558 | </h4> |
559 | 559 | </div> |
560 | 560 | '); |
561 | 561 | $form->addHtml(' |
562 | - <div id="collapse-' . $plugin_name . '-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-' . $plugin_name . '-settings"> |
|
562 | + <div id="collapse-' . $plugin_name.'-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'.$plugin_name.'-settings"> |
|
563 | 563 | <div class="panel-body"> |
564 | 564 | '); |
565 | 565 |