diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index a2614dbfd1..6108d3f592 100644 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -937,8 +937,16 @@ function get_course_groups() { * @return html code */ function show_to_form($to_already_selected) { - $user_list = get_course_users(); - $group_list = get_course_groups(); + /*$user_list = get_course_users(); + $group_list = get_course_groups();*/ + $order = 'lastname'; + if (api_is_western_name_order) { + $order = 'firstname'; + } + + $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), null, $order); + $group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id()); + construct_not_selected_select_form($group_list, $user_list, $to_already_selected); } @@ -976,10 +984,10 @@ function construct_not_selected_select_form($group_list=null, $user_list=null, $ echo ''; foreach($user_list as $this_user) { // $to_already_selected is the array containing the users (and groups) that are already selected - if (!is_array($to_already_selected) || !in_array("USER:".$this_user['uid'],$to_already_selected)) { + if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'],$to_already_selected)) { $username = api_htmlentities(sprintf(get_lang('LoginX'), $this_user['username']), ENT_QUOTES); - $user_info = api_get_person_name($this_user['firstName'], $this_user['lastName']).' ('.$this_user['username'].')'; - echo ""; + $user_info = api_get_person_name($this_user['firstname'], $this_user['lastname']).' ('.$this_user['username'].')'; + echo ""; } } echo ""; diff --git a/main/calendar/agenda.lib.php b/main/calendar/agenda.lib.php index 4d777cf0b2..cfb5d404ff 100644 --- a/main/calendar/agenda.lib.php +++ b/main/calendar/agenda.lib.php @@ -682,7 +682,7 @@ class Agenda { if (is_array($group_list)) { $html .= ''; } - foreach($user_list as $this_user) { + foreach ($user_list as $this_user) { // $to_already_selected is the array containing the users (and groups) that are already selected if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'],$to_already_selected)) { $username = api_htmlentities(sprintf(get_lang('LoginX'), $this_user['username']), ENT_QUOTES); diff --git a/main/calendar/agenda_js.php b/main/calendar/agenda_js.php index 93e7938ae8..de00712d9c 100644 --- a/main/calendar/agenda_js.php +++ b/main/calendar/agenda_js.php @@ -96,8 +96,11 @@ $course_code = api_get_course_id(); if (api_is_allowed_to_edit() && $course_code != '-1' && $type == 'course') { - - $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id()); + $order = 'lastname'; + if (api_is_western_name_order) { + $order = 'firstname'; + } + $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), null, $order); $group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id()); $agenda = new Agenda();