From 0358044b7146931fa0805549bca3c9cae14f9406 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Sep 2014 13:52:14 -0400 Subject: [PATCH 01/10] adding option for hidding private exercises course -refs #7237 --- main/exercice/exercise.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index ed54b6b83e..294ae9b064 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1524,7 +1524,7 @@ function get_all_exercises($course_info = null, $session_id = 0, $check_publicat if ($session_id == 0) { $conditions = array('where'=>array($active_sql . ' session_id = ? AND c_id = ? '. $needle_where . $time_conditions => array($session_id, $course_id, $needle)), 'order'=>'title'); } else { - $conditions = array('where'=>array($active_sql . ' (session_id = 0 OR session_id = ? ) AND c_id = ? ' . $needle_where . $time_conditions => array($session_id, $course_id, $needle)), 'order'=>'title'); + $conditions = array('where'=>array($active_sql . ' (session_id = 0 OR session_id = ? ) AND active <> 0 AND c_id = ? ' . $needle_where . $time_conditions => array($session_id, $course_id, $needle)), 'order'=>'title'); } } From 2d0c08b3d3e3822baf1acda451c2e0240f70fcf0 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Sep 2014 13:37:19 +0200 Subject: [PATCH 02/10] Undo change: https://github.com/chamilo/chamilo-lms/pull/346 --- main/exercice/exercise.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 7816e08d69..852eea2d71 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1555,7 +1555,7 @@ function get_all_exercises($course_info = null, $session_id = 0, $check_publicat if ($session_id == 0) { $conditions = array('where'=>array($active_sql . ' session_id = ? AND c_id = ? '. $needle_where . $time_conditions => array($session_id, $course_id, $needle)), 'order'=>'title'); } else { - $conditions = array('where'=>array($active_sql . ' (session_id = 0 OR session_id = ? ) AND active <> 0 AND c_id = ? ' . $needle_where . $time_conditions => array($session_id, $course_id, $needle)), 'order'=>'title'); + $conditions = array('where'=>array($active_sql . ' (session_id = 0 OR session_id = ? ) AND c_id = ? ' . $needle_where . $time_conditions => array($session_id, $course_id, $needle)), 'order'=>'title'); } } From 592ccc6f65cf60b331394ace1835922cb7711689 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Sep 2014 13:39:38 +0200 Subject: [PATCH 03/10] Minor format code. --- main/exercice/exercise.lib.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 852eea2d71..91a61d0fde 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1504,7 +1504,9 @@ function convert_score($score, $weight) { } /** - * Getting all active exercises from a course from a session (if a session_id is provided we will show all the exercises in the course + all exercises in the session) + * Getting all active exercises from a course from a session + * (if a session_id is provided we will show all the exercises in the course + + * all exercises in the session) * @param array course data * @param int session id * @param boolean Check publications dates @@ -1516,7 +1518,14 @@ function convert_score($score, $weight) { * 3 = active <> -1 * @return array array with exercise data */ -function get_all_exercises($course_info = null, $session_id = 0, $check_publication_dates = false, $search_exercise = '', $search_all_sessions = false, $active = 2) { +function get_all_exercises( + $course_info = null, + $session_id = 0, + $check_publication_dates = false, + $search_exercise = '', + $search_all_sessions = false, + $active = 2 +) { $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST); $course_id = api_get_course_int_id(); @@ -1550,12 +1559,21 @@ function get_all_exercises($course_info = null, $session_id = 0, $check_publicat } if ($search_all_sessions == true) { - $conditions = array('where'=>array($active_sql . ' c_id = ? '. $needle_where . $time_conditions => array($course_id, $needle)), 'order'=>'title'); + $conditions = array( + 'where' => array($active_sql . ' c_id = ? '. $needle_where . $time_conditions => array($course_id, $needle)), + 'order' => 'title' + ); } else { if ($session_id == 0) { - $conditions = array('where'=>array($active_sql . ' session_id = ? AND c_id = ? '. $needle_where . $time_conditions => array($session_id, $course_id, $needle)), 'order'=>'title'); + $conditions = array( + 'where' => array($active_sql . ' session_id = ? AND c_id = ? '. $needle_where . $time_conditions => array($session_id, $course_id, $needle)), + 'order' =>'title' + ); } else { - $conditions = array('where'=>array($active_sql . ' (session_id = 0 OR session_id = ? ) AND c_id = ? ' . $needle_where . $time_conditions => array($session_id, $course_id, $needle)), 'order'=>'title'); + $conditions = array( + 'where' => array($active_sql . ' (session_id = 0 OR session_id = ? ) AND c_id = ? ' . $needle_where . $time_conditions => array($session_id, $course_id, $needle)), + 'order' => 'title' + ); } } From a552a2136194fe49af3cfe114bdeb878bf68da2b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Sep 2014 13:42:12 +0200 Subject: [PATCH 04/10] Show only visible exercises see BT#7237 --- main/inc/lib/tracking.lib.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index c631019ff3..77ccda5fde 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -3019,8 +3019,14 @@ class Tracking $exercise_graph_list = array(); foreach ($course_list as $course_data) { - - $exercise_list = get_all_exercises($course_data, $my_session_id); + $exercise_list = get_all_exercises( + $course_data, + $my_session_id, + false, + null, + false, + 1 + ); foreach ($exercise_list as $exercise_data) { $exercise_obj = new Exercise($course_data['id']); $exercise_obj->read($exercise_data['id']); From b8cd78874a63f4c2479bb1ebb344fcfc57407dff Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Sep 2014 14:03:57 +0200 Subject: [PATCH 05/10] Only active exercise see #7237 --- main/inc/lib/tracking.lib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 77ccda5fde..b57a185fc9 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -3358,7 +3358,14 @@ class Tracking //$exercise_list = get_all_exercises($course_info, $session_id, true); // Show exercise results of invisible exercises? see BT#4091 - $exercise_list = get_all_exercises($course_info, $session_id, false); + $exercise_list = get_all_exercises( + $course_info, + $session_id, + false, + null, + false, + 1 + ); $to_graph_exercise_result = array(); From 501e5bb1578cf24f53e248078c9fa29900859ada Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Sep 2014 14:41:52 +0200 Subject: [PATCH 06/10] Show only visible exercises see BT#8699 --- main/session/index.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main/session/index.php b/main/session/index.php index b371ae0b6d..b4936103bf 100755 --- a/main/session/index.php +++ b/main/session/index.php @@ -68,8 +68,15 @@ if (!empty($new_session_list)) { $course_info = api_get_course_info($my_course['code']); - //Getting all exercises from the current course - $exercise_list = get_all_exercises($course_info, $my_session_id, true); + // Getting all visible exercises from the current course + $exercise_list = get_all_exercises( + $course_info, + $my_session_id, + true, + null, + false, + 1 + ); $course['name'] = $course_info['name']; $course['id'] = $course_info['real_id']; From 74ce6a861aebcdda969ba98506b302892d38271e Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Sep 2014 14:45:49 +0200 Subject: [PATCH 07/10] Only active exercise see #7237 --- main/session/index.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main/session/index.php b/main/session/index.php index b4936103bf..81fcf53576 100755 --- a/main/session/index.php +++ b/main/session/index.php @@ -124,7 +124,6 @@ if (!empty($course_list)) { 'publicated_on ASC', true ); - $lp_list = $list->get_flat_list(); $lp_count = 0; @@ -138,7 +137,16 @@ if (!empty($course_list)) { } $course_info = api_get_course_info($course_data['code']); - $exercise_count = count(get_all_exercises($course_info, $session_id, true)); + $exercise_count = count( + get_all_exercises( + $course_info, + $session_id, + true, + null, + false, + 1 + ) + ); $max_mutation_date = ''; $last_date = Tracking::get_last_connection_date_on_the_course( From e66dbbc716564d07536840b01a62c1e51b7b7607 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Sep 2014 15:26:12 +0200 Subject: [PATCH 08/10] Minor - format code --- main/inc/ajax/course_home.ajax.php | 30 +++++++++++++++++++-------- main/inc/lib/model.lib.php | 2 ++ main/mySpace/lp_tracking.php | 7 +++---- main/newscorm/learnpathList.class.php | 10 ++++----- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/main/inc/ajax/course_home.ajax.php b/main/inc/ajax/course_home.ajax.php index 04b23d7dd0..54eef6df8e 100755 --- a/main/inc/ajax/course_home.ajax.php +++ b/main/inc/ajax/course_home.ajax.php @@ -119,6 +119,7 @@ switch ($action) { $session_id = intval($_REQUEST['session_id']); $course_id = intval($_REQUEST['course_id']); + //Filter users that does not belong to the session if (!api_is_platform_admin()) { $new_session_list = UserManager::get_personal_session_course_list(api_get_user_id()); @@ -135,22 +136,28 @@ switch ($action) { if (!$sidx) { $sidx = 1; } - $start = $limit*$page - $limit; - $course_list = SessionManager::get_course_list_by_session_id($session_id); + $course_list = SessionManager::get_course_list_by_session_id($session_id); $count = 0; - + $temp = array(); foreach ($course_list as $item) { - $list = new LearnpathList(api_get_user_id(), $item['code'], $session_id); + $list = new LearnpathList(api_get_user_id(), $item['code'], $session_id); $flat_list = $list->get_flat_list(); $lps[$item['code']] = $flat_list; $course_url = api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id; - $item['title'] = Display::url($item['title'], $course_url, array('target'=>SESSION_LINK_TARGET)); + $item['title'] = Display::url($item['title'], $course_url, array('target' => SESSION_LINK_TARGET)); - foreach($flat_list as $lp_id => $lp_item) { + foreach ($flat_list as $lp_id => $lp_item) { $temp[$count]['id']= $lp_id; $lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view'; - $last_date = Tracking::get_last_connection_date_on_the_course(api_get_user_id(),$item['code'], $session_id, false); + + $last_date = Tracking::get_last_connection_date_on_the_course( + api_get_user_id(), + $item['code'], + $session_id, + false + ); + if ($lp_item['modified_on'] == '0000-00-00 00:00:00' || empty($lp_item['modified_on'])) { $lp_date = api_get_local_time($lp_item['created_on']); $image = 'new.gif'; @@ -160,6 +167,7 @@ switch ($action) { $image = 'moderator_star.png'; $label = get_lang('LearnpathUpdated'); } + if (strtotime($last_date) < strtotime($lp_date)) { $icons = Display::return_icon($image, get_lang('TitleNotification').': '.$label.' - '.$lp_date); } @@ -170,7 +178,7 @@ switch ($action) { $date = '-'; } - //Checking LP publicated and expired_on dates + // Checking LP publicated and expired_on dates if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') { if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) { continue; @@ -183,7 +191,11 @@ switch ($action) { } } - $temp[$count]['cell']=array($date, $item['title'], Display::url($icons.' '.$lp_item['lp_name'], $lp_url, array('target'=>SESSION_LINK_TARGET))); + $temp[$count]['cell'] = array( + $date, + $item['title'], + Display::url($icons.' '.$lp_item['lp_name'], $lp_url, array('target'=>SESSION_LINK_TARGET)) + ); $temp[$count]['course'] = strip_tags($item['title']); $temp[$count]['lp'] = $lp_item['lp_name']; $temp[$count]['date'] = $lp_item['publicated_on']; diff --git a/main/inc/lib/model.lib.php b/main/inc/lib/model.lib.php index 1d92b31374..b3d86b0ca7 100755 --- a/main/inc/lib/model.lib.php +++ b/main/inc/lib/model.lib.php @@ -170,12 +170,14 @@ class Model return $id; } } + return false; } /** * Updates the obj in the database. The $params['id'] must exist in order to update a record * @param array $values + * * @return bool * */ diff --git a/main/mySpace/lp_tracking.php b/main/mySpace/lp_tracking.php index fbbc173fbb..be080f4e8f 100755 --- a/main/mySpace/lp_tracking.php +++ b/main/mySpace/lp_tracking.php @@ -41,12 +41,12 @@ if (isset($_GET['course'])) { $user_infos = UserManager :: get_user_info_by_id($user_id); $name = api_get_person_name($user_infos['firstname'], $user_infos['lastname']); -if (!api_is_platform_admin(true) && !CourseManager :: is_course_teacher(api_get_user_id(), $cidReq) && !Tracking :: is_allowed_to_coach_student(api_get_user_id(), $_GET['student_id']) && !api_is_drh() && !api_is_course_tutor()) { - api_not_allowed(); +if (!api_is_platform_admin(true) && !CourseManager :: is_course_teacher(api_get_user_id(), $cidReq) && !Tracking :: is_allowed_to_coach_student(api_get_user_id(), $_GET['student_id']) && !api_is_drh() && !api_is_course_tutor()) { + api_not_allowed(); } $course_exits = CourseManager::course_exists($cidReq); -if (!empty($course_exits)) { +if (!empty($course_exits)) { $course_info = api_get_course_info($cidReq); } else { api_not_allowed(); @@ -96,7 +96,6 @@ $list = learnpath :: get_flat_ordered_items_list($lp_id, 0, $course_info['real_i $origin = 'tracking'; if ($export_csv) { require_once api_get_path(SYS_CODE_PATH).'newscorm/lp_stats.php'; - //Export :: export_table_csv($csv_content, 'reporting_student'); } else { ob_start(); require_once api_get_path(SYS_CODE_PATH).'newscorm/lp_stats.php'; diff --git a/main/newscorm/learnpathList.class.php b/main/newscorm/learnpathList.class.php index 8cbc76d6ca..5efd130f34 100755 --- a/main/newscorm/learnpathList.class.php +++ b/main/newscorm/learnpathList.class.php @@ -31,7 +31,7 @@ class learnpathList * @param int Optional session id (otherwise we use api_get_session_id()) * @return void */ - function __construct($user_id, $course_code = '', $session_id = null, $order_by = null, $check_publication_dates = false) + public function __construct($user_id, $course_code = '', $session_id = null, $order_by = null, $check_publication_dates = false) { $course_info = api_get_course_info($course_code); $lp_table = Database::get_course_table(TABLE_LP_MAIN); @@ -65,10 +65,10 @@ class learnpathList if ($check_publication_dates) { $time_conditions = " AND ( - (publicated_on <> '0000-00-00 00:00:00' AND publicated_on < '$now' AND expired_on <> '0000-00-00 00:00:00' AND expired_on > '$now' ) OR - (publicated_on <> '0000-00-00 00:00:00' AND publicated_on < '$now' AND expired_on = '0000-00-00 00:00:00') OR - (publicated_on = '0000-00-00 00:00:00' AND expired_on <> '0000-00-00 00:00:00' AND expired_on > '$now') OR - (publicated_on = '0000-00-00 00:00:00' AND expired_on = '0000-00-00 00:00:00' )) + (publicated_on <> '0000-00-00 00:00:00' AND publicated_on < '$now' AND expired_on <> '0000-00-00 00:00:00' AND expired_on > '$now' ) OR + (publicated_on <> '0000-00-00 00:00:00' AND publicated_on < '$now' AND expired_on = '0000-00-00 00:00:00') OR + (publicated_on = '0000-00-00 00:00:00' AND expired_on <> '0000-00-00 00:00:00' AND expired_on > '$now') OR + (publicated_on = '0000-00-00 00:00:00' AND expired_on = '0000-00-00 00:00:00' )) "; } From f168c7253a154a114ec50cc63c1120a25dbd867e Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Sep 2014 16:18:21 +0200 Subject: [PATCH 09/10] Fixing session special page see BT#8700 --- main/inc/ajax/course_home.ajax.php | 39 +++++++++++++----------------- main/inc/lib/main_api.lib.php | 2 ++ main/inc/lib/tracking.lib.php | 4 --- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/main/inc/ajax/course_home.ajax.php b/main/inc/ajax/course_home.ajax.php index 54eef6df8e..526fbb31d9 100755 --- a/main/inc/ajax/course_home.ajax.php +++ b/main/inc/ajax/course_home.ajax.php @@ -5,7 +5,6 @@ * Responses to AJAX calls */ $action = $_GET['a']; -$now = time(); switch ($action) { case 'set_visibility': @@ -108,10 +107,11 @@ switch ($action) { require_once '../global.inc.php'; require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; - + $now = time(); $page = intval($_REQUEST['page']); //page $limit = intval($_REQUEST['rows']); // quantity of rows - $sidx = $_REQUEST['sidx']; //index to filter + //index to filter + $sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id'; $sord = $_REQUEST['sord']; //asc or desc if (!in_array($sord, array('asc','desc'))) { $sord = 'desc'; @@ -133,9 +133,6 @@ switch ($action) { } } - if (!$sidx) { - $sidx = 1; - } $start = $limit*$page - $limit; $course_list = SessionManager::get_course_list_by_session_id($session_id); $count = 0; @@ -232,16 +229,16 @@ switch ($action) { $response->records = $count; echo json_encode($response); break; - case 'session_courses_lp_by_week': - require_once '../global.inc.php'; require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; + $now = time(); $page = intval($_REQUEST['page']); //page $limit = intval($_REQUEST['rows']); // quantity of rows - $sidx = $_REQUEST['sidx']; //index to filter - if (empty($sidx)) $sidx = 'course'; + $sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'course'; + $sidx = str_replace(array('week desc,', ' '), '', $sidx); + $sord = $_REQUEST['sord']; //asc or desc if (!in_array($sord, array('asc','desc'))) { $sord = 'desc'; @@ -280,7 +277,7 @@ switch ($action) { $lps[$item['code']] = $flat_list; $item['title'] = Display::url($item['title'],api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id,array('target'=>SESSION_LINK_TARGET)); - foreach($flat_list as $lp_id => $lp_item) { + foreach ($flat_list as $lp_id => $lp_item) { $temp[$count]['id']= $lp_id; $lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$item['code'].'&id_session='.$session_id.'&lp_id='.$lp_id.'&action=view'; @@ -327,8 +324,9 @@ switch ($action) { $count++; } } - - $temp = msort($temp, $sidx, $sord); + if (!empty($sidx)) { + $temp = msort($temp, $sidx, $sord); + } $response = new stdClass(); $i =0; @@ -360,10 +358,12 @@ switch ($action) { case 'session_courses_lp_by_course': require_once '../global.inc.php'; require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; - + $now = time(); $page = intval($_REQUEST['page']); //page $limit = intval($_REQUEST['rows']); // quantity of rows - $sidx = $_REQUEST['sidx']; //index to filter + $sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id'; + $sidx = str_replace(array('course asc,', ' '), '', $sidx); + $sord = $_REQUEST['sord']; //asc or desc if (!in_array($sord, array('asc','desc'))) { $sord = 'desc'; @@ -384,13 +384,8 @@ switch ($action) { } } - if (!$sidx) { - $sidx = 1; - } - $start = $limit*$page - $limit; $course_list = SessionManager::get_course_list_by_session_id($session_id); - $count = 0; foreach ($course_list as $item) { @@ -457,12 +452,12 @@ switch ($action) { $response = new stdClass(); $i =0; - foreach($temp as $key=>$row) { + foreach ($temp as $key=>$row) { $row = $row['cell']; if (!empty($row)) { if ($key >= $start && $key < ($start + $limit)) { $response->rows[$i]['id']= $key; - $response->rows[$i]['cell']=array($row[0], $row[1], $row[2],$row[3]); + $response->rows[$i]['cell']=array($row[0], $row[1], $row[2]); $i++; } } diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 161dc36b4f..843f4c2b1d 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -69,6 +69,8 @@ define('SESSION_VISIBLE', 2); define('SESSION_INVISIBLE', 3); // not available define('SESSION_AVAILABLE', 4); +define('SESSION_LINK_TARGET','_self'); + define('SUBSCRIBE_ALLOWED', 1); define('SUBSCRIBE_NOT_ALLOWED', 0); define('UNSUBSCRIBE_ALLOWED', 1); diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index b57a185fc9..bfe2a1d9cc 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -7,10 +7,6 @@ * @package chamilo.library * @author Julio Montoya (Score average fixes) */ -/** - * Code - */ -define('SESSION_LINK_TARGET','_self'); require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php'; require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; From e46caa104054b99246c36fa3a0500a227843621d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Sep 2014 16:18:49 +0200 Subject: [PATCH 10/10] Minor - removing whitespaces. --- main/inc/lib/array.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main/inc/lib/array.lib.php b/main/inc/lib/array.lib.php index 77230ac549..c7bc36de07 100755 --- a/main/inc/lib/array.lib.php +++ b/main/inc/lib/array.lib.php @@ -13,7 +13,7 @@ * * @param array a dimensional array * @return array an array with unique values - * + * */ function array_unique_dimensional($array) { if(!is_array($array)) @@ -32,9 +32,9 @@ function array_unique_dimensional($array) { } /** - * + * * Sort multidimensional arrays - * + * * @param array unsorted multidimensional array * @param string key to be sorted * @return array result array @@ -84,16 +84,16 @@ function array_walk_recursive_limited(&$array, $function, $apply_to_keys_also = unset($array[$key]); } } - } + } $recursive_counter--; } function utf8_sort($array) { - $old_locale = setlocale(LC_ALL, null); + $old_locale = setlocale(LC_ALL, null); $code = api_get_language_isocode(); $locale_list = array($code.'.utf8', 'en.utf8','en_US.utf8','en_GB.utf8'); $try_sort = false; - + foreach($locale_list as $locale) { $my_local = setlocale(LC_COLLATE, $locale); if ($my_local) { @@ -101,11 +101,11 @@ function utf8_sort($array) { break; } } - + if ($try_sort) { uasort($array, 'strcoll'); } - setlocale(LC_COLLATE, $old_locale); + setlocale(LC_COLLATE, $old_locale); return $array; } @@ -114,4 +114,4 @@ function array_to_string($array, $separator = ',') { return ''; } return implode($separator.' ', $array); -} \ No newline at end of file +}