Adding user_name_sort_by support.

skala
Julio Montoya 11 years ago
parent 7174c85158
commit 52f2a806cf
  1. 18
      main/inc/lib/internationalization.lib.php

@ -1096,16 +1096,9 @@ function api_get_person_name($first_name, $last_name, $title = null, $format = n
switch ($format) { switch ($format) {
case PERSON_NAME_COMMON_CONVENTION: case PERSON_NAME_COMMON_CONVENTION:
$valid[$format][$language] = _api_get_person_name_convention($language, 'format'); $valid[$format][$language] = _api_get_person_name_convention($language, 'format');
$usernameOrderFromDatabase = api_get_setting('user_name_order');
$username_order_from_database = api_get_setting('user_name_order'); if (isset($usernameOrderFromDatabase) && !empty($usernameOrderFromDatabase)) {
if (isset($username_order_from_database) && !empty($username_order_from_database)) { $valid[$format][$language] = $usernameOrderFromDatabase;
if (strpos($username_order_from_database, '%t') == false || strpos(
$username_order_from_database,
'%l'
) == false || strpos($username_order_from_database, '%f') == false
) {
$valid[$format][$language] = $username_order_from_database;
}
} }
break; break;
case PERSON_NAME_WESTERN_ORDER: case PERSON_NAME_WESTERN_ORDER:
@ -1182,6 +1175,11 @@ function api_is_western_name_order($format = null, $language = null)
*/ */
function api_sort_by_first_name($language = null) function api_sort_by_first_name($language = null)
{ {
$userNameSortBy = api_get_setting('user_name_sort_by');
if (!empty($userNameSortBy) && in_array($userNameSortBy, array('firstname', 'lastname'))) {
return $userNameSortBy == 'firstname' ? true : false;
}
static $sort_by_first_name = array(); static $sort_by_first_name = array();
$language_is_supported = api_is_language_supported($language); $language_is_supported = api_is_language_supported($language);

Loading…
Cancel
Save