From a0618dc58b78065b94e3218a20f39d1a7c62a288 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Wed, 2 Sep 2009 19:26:33 +0300 Subject: [PATCH] Bug #3646 and Issue #306 - Platform administrator's tools: Fixing person name order and sorting to be dependable on the internationalization settings, Part 2. --- main/admin/course_add.php | 7 +- main/admin/course_edit.php | 67 +-- main/admin/course_import.php | 6 +- main/admin/ldap_form_add_users_group.php | 20 +- main/admin/ldap_users_list.php | 24 +- main/admin/resume_session.php | 13 +- main/admin/session_add.php | 34 +- main/admin/session_course_edit.php | 7 +- main/admin/session_course_user_list.php | 329 ++++++------ main/admin/session_edit.php | 642 +++++++++++------------ main/admin/session_list.php | 4 +- main/auth/ldap/authldap.php | 13 +- 12 files changed, 609 insertions(+), 557 deletions(-) diff --git a/main/admin/course_add.php b/main/admin/course_add.php index 18970531bd..9ee9a7751d 100644 --- a/main/admin/course_add.php +++ b/main/admin/course_add.php @@ -60,14 +60,15 @@ $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAd global $_configuration; // Get all possible teachers +$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname'; $table_user = Database :: get_main_table(TABLE_MAIN_USER); -$sql = "SELECT user_id,lastname,firstname FROM $table_user WHERE status=1 ORDER BY lastname,firstname"; +$sql = "SELECT user_id,lastname,firstname FROM $table_user WHERE status=1".$order_clause; //filtering teachers when creating a course if ($_configuration['multiple_access_urls']==true){ $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $sql = "SELECT u.user_id,lastname,firstname FROM $table_user as u INNER JOIN $access_url_rel_user_table url_rel_user - ON (u.user_id=url_rel_user.user_id) WHERE url_rel_user.access_url_id=".api_get_current_access_url_id()." AND status=1 ORDER BY lastname,firstname "; + ON (u.user_id=url_rel_user.user_id) WHERE url_rel_user.access_url_id=".api_get_current_access_url_id()." AND status=1".$order_clause; } $res = api_sql_query($sql,__FILE__,__LINE__); @@ -75,7 +76,7 @@ $teachers = array(); $teachers[0] = '-- '.get_lang('NoManager').' --'; while($obj = mysql_fetch_object($res)) { - $teachers[$obj->user_id] = $obj->lastname.' '.$obj->firstname; + $teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname); } diff --git a/main/admin/course_edit.php b/main/admin/course_edit.php index 36dd9800b3..6b1f79ab8a 100644 --- a/main/admin/course_edit.php +++ b/main/admin/course_edit.php @@ -11,7 +11,7 @@ ============================================================================== */ -// name of the language file that needs to be included +// name of the language file that needs to be included $language_file = 'admin'; $cidReset = true; include ('../inc/global.inc.php'); @@ -61,32 +61,33 @@ $course = Database::fetch_array($result,'ASSOC'); // Get course teachers $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); -$sql = "SELECT user.user_id,lastname,firstname FROM $table_user as user,$table_course_user as course_user WHERE course_user.status='1' AND course_user.user_id=user.user_id AND course_user.course_code='".$course_code."' ORDER BY lastname,firstname"; +$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname'; +$sql = "SELECT user.user_id,lastname,firstname FROM $table_user as user,$table_course_user as course_user WHERE course_user.status='1' AND course_user.user_id=user.user_id AND course_user.course_code='".$course_code."'".$order_clause; $res = api_sql_query($sql,__FILE__,__LINE__); $course_teachers = array(); while($obj = Database::fetch_object($res)) { - $course_teachers[$obj->user_id] = $obj->lastname.' '.$obj->firstname; + $course_teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname); } // Get all possible teachers without the course teachers -$sql = "SELECT user_id,lastname,firstname FROM $table_user WHERE status='1' ORDER BY lastname,firstname"; +$sql = "SELECT user_id,lastname,firstname FROM $table_user WHERE status='1'".$order_clause; $res = api_sql_query($sql,__FILE__,__LINE__); $teachers = array(); $platform_teachers[0] = '-- '.get_lang('NoManager').' --'; while($obj = Database::fetch_object($res)) -{ +{ if(!array_key_exists($obj->user_id,$course_teachers)){ - $teachers[$obj->user_id] = $obj->lastname.' '.$obj->firstname; + $teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname); } - + if($course['tutor_name']==$course_teachers[$obj->user_id]){ $course['tutor_name']=$obj->user_id; } - //We add in the array platform teachers - $platform_teachers[$obj->user_id] = $obj->lastname.' '.$obj->firstname; + //We add in the array platform teachers + $platform_teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname); } //Case where there is no teacher in the course @@ -127,7 +128,7 @@ $element_template = << EOT; - + $renderer = $form->defaultRenderer(); $renderer -> setElementTemplate($element_template, 'group'); $form -> addGroup($group,'group',get_lang('CourseTeachers'),'

'); @@ -165,7 +166,7 @@ $form->addElement('style_submit_button', 'button', get_lang('ModifyCourseInfo'), // Set some default values $course_db_name = $course['db_name']; -$course['title']=api_html_entity_decode($course['title'],ENT_QUOTES,$charset); +$course['title'] = api_html_entity_decode($course['title'], ENT_QUOTES, $charset); $form->setDefaults($course); // Validate form if( $form->validate()) @@ -174,7 +175,7 @@ if( $form->validate()) $dbName = $_POST['dbName']; $course_code = $course['code']; $visual_code = $course['visual_code']; - + // Check if the visual code is already used by *another* course $visual_code_is_used = false; error_log($visual_code); @@ -190,12 +191,12 @@ if( $form->validate()) } $warn = substr($warn,0,-1); } - + $tutor_id = $course['tutor_name']; $tutor_name=$platform_teachers[$tutor_id]; - + $teachers = $course['group']['course_teachers']; - + $title = $course['title']; $category_code = $course['category_code']; $department_name = $course['department_name']; @@ -217,12 +218,12 @@ if( $form->validate()) department_name='".Database::escape_string($department_name)."', department_url='".Database::escape_string($department_url)."', disk_quota='".Database::escape_string($disk_quota)."', - visibility = '".Database::escape_string($visibility)."', + visibility = '".Database::escape_string($visibility)."', subscribe = '".Database::escape_string($subscribe)."', unsubscribe='".Database::escape_string($unsubscribe)."' WHERE code='".Database::escape_string($course_code)."'"; api_sql_query($sql, __FILE__, __LINE__); - + //Delete only teacher relations that doesn't match the selected teachers $cond=''; if(count($teachers)>0){ @@ -230,14 +231,14 @@ if( $form->validate()) } $sql='DELETE FROM '.$course_user_table.' WHERE course_code="'.Database::escape_string($course_code).'" AND status="1"'.$cond; api_sql_query($sql, __FILE__, __LINE__); - + if(count($teachers)>0){ foreach($teachers as $key){ - + //We check if the teacher is already subscribed in this course $sql_select_teacher = 'SELECT 1 FROM '.$course_user_table.' WHERE user_id = "'.$key.'" AND course_code = "'.$course_code.'"'; $result = api_sql_query($sql_select_teacher, __FILE__, __LINE__); - + if(Database::num_rows($result) == 1){ $sql = 'UPDATE '.$course_user_table.' SET status = "1" WHERE course_code = "'.$course_code.'" AND user_id = "'.$key.'"'; } @@ -252,11 +253,11 @@ if( $form->validate()) user_course_cat='0'"; } api_sql_query($sql, __FILE__, __LINE__); - + } - + } - + $sql = "INSERT IGNORE INTO ".$course_user_table . " SET course_code = '".Database::escape_string($course_code). "', user_id = '".$tutor_id . "', @@ -266,7 +267,7 @@ if( $form->validate()) sort='0', user_course_cat='0'"; api_sql_query($sql, __FILE__, __LINE__); - + $forum_config_table = Database::get_course_table(TOOL_FORUM_CONFIG_TABLE,$course_db_name); $sql = "UPDATE ".$forum_config_table." SET default_lang='".Database::escape_string($course_language)."'"; if ($visual_code_is_used == true) { @@ -280,30 +281,30 @@ Display::display_header($tool_name); echo " - + + +    + + + +    + + + + + + /> + + + +    + + + / + + / + + + + +    + + + / + + / + + + + + +   + + + +
+
+  
+   +
+
+ + + +   + + + + + + + + + + + diff --git a/main/admin/session_list.php b/main/admin/session_list.php index c8acd4081a..0b530b6205 100644 --- a/main/admin/session_list.php +++ b/main/admin/session_list.php @@ -286,8 +286,8 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
-  -  - +  -  + diff --git a/main/auth/ldap/authldap.php b/main/auth/ldap/authldap.php index 6032d23fc4..c97cf9bfc0 100644 --- a/main/auth/ldap/authldap.php +++ b/main/auth/ldap/authldap.php @@ -516,6 +516,7 @@ function ldap_get_number_of_users() function ldap_get_user_data($from, $number_of_items, $column, $direction) { $users = array(); + $is_western_name_order = api_is_western_name_order(); if (isset($_GET['submit'])) { $info = ldap_get_users(); @@ -532,8 +533,16 @@ function ldap_get_user_data($from, $number_of_items, $column, $direction) //$user[] = $dn_array[0]; // uid is first key $user[] = $info[$key]['uid'][0]; $user[] = $info[$key]['uid'][0]; - $user[] = api_convert_encoding($info[$key]['givenname'][0], api_get_system_encoding(), 'UTF-8'); - $user[] = api_convert_encoding($info[$key]['sn'][0], api_get_system_encoding(), 'UTF-8'); + if ($is_western_name_order) + { + $user[] = api_convert_encoding($info[$key]['givenname'][0], api_get_system_encoding(), 'UTF-8'); + $user[] = api_convert_encoding($info[$key]['sn'][0], api_get_system_encoding(), 'UTF-8'); + } + else + { + $user[] = api_convert_encoding($info[$key]['sn'][0], api_get_system_encoding(), 'UTF-8'); + $user[] = api_convert_encoding($info[$key]['givenname'][0], api_get_system_encoding(), 'UTF-8'); + } $user[] = $info[$key]['mail'][0]; $outab[] = $info[$key]['eduPersonPrimaryAffiliation'][0]; // Ici "student" $users[] = $user;