From b9f2f2355d8491c302473886d4262bb9d5adf16a Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 26 Jul 2011 10:32:13 +0000 Subject: [PATCH] 2011-07-26 Sergio Martin * pandoradb_data.sql pandoradb.data.postgreSQL.sql pandoradb.data.oracle.sql: Set as default the language of the admin when install * include/config_process.php include/functions.php index.php operation/users/user_edit.php general/pandora_help.php godmode/users/configure_user.php: Added default option in the language combo when edit a user. If this option is choose, this user will has the general setup language Fixed too the problem of the help screens language Bug: 3375174 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4623 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 19 ++++++++++ pandora_console/general/pandora_help.php | 4 +- .../godmode/users/configure_user.php | 17 +++++---- pandora_console/include/config_process.php | 13 ++----- pandora_console/include/functions.php | 38 +++++++++++++++++++ pandora_console/index.php | 10 ++--- pandora_console/operation/users/user_edit.php | 8 ++-- pandora_console/pandoradb.data.oracle.sql | 4 +- pandora_console/pandoradb.data.postgreSQL.sql | 4 +- pandora_console/pandoradb_data.sql | 4 +- 10 files changed, 85 insertions(+), 36 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 405c9d1439..7ece964394 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,22 @@ +2011-07-26 Sergio Martin + + * pandoradb_data.sql + pandoradb.data.postgreSQL.sql + pandoradb.data.oracle.sql: Set as default + the language of the admin when install + + * include/config_process.php + include/functions.php + index.php + operation/users/user_edit.php + general/pandora_help.php + godmode/users/configure_user.php: Added default + option in the language combo when edit a user. If + this option is choose, this user will has the + general setup language + Fixed too the problem of the help screens language + Bug: 3375174 + 2011-07-22 Miguel de Dios * include/functions.php: fixed the not login when open new window in some diff --git a/pandora_console/general/pandora_help.php b/pandora_console/general/pandora_help.php index 1559bcb91d..3cff12249d 100644 --- a/pandora_console/general/pandora_help.php +++ b/pandora_console/general/pandora_help.php @@ -29,8 +29,10 @@ require_once ("../include/functions_html.php"); data[1][1] = html_print_input_text_extended ('fullname', $user_info['ful $table->data[2][0] = __('Language'); $table->data[2][1] = html_print_select_from_sql ('SELECT id_language, name FROM tlanguage', - 'language', $user_info["language"], '', '', '', true); + 'language', $user_info['language'], '', __('Default'), 'default', true); if ($config['user_can_update_password']) { $table->data[4][0] = __('Password'); @@ -367,7 +364,11 @@ $table->data[11][1] = html_print_select($values, 'flash_charts', $user_info["fla $table->data[12][0] = __('Block size for pagination'); $table->data[12][1] = html_print_input_text ('block_size', $user_info["block_size"], '', 5, 5, true); -echo '
'; +if($id == $config['id_user']) { + $table->data[12][1] .= html_print_input_hidden('quick_language_change', 1, true); +} + +echo ''; html_print_table ($table); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 2f72a220f0..523e938d9e 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -28,8 +28,6 @@ $pandora_version = 'v4.0dev'; /* Help to debug problems. Override global PHP configuration */ if (!isset($develop_bypass)) $develop_bypass = 0; -$develop_bypass = 1; - if ($develop_bypass != 1) { // error_reporting(E_ALL); @@ -89,7 +87,6 @@ if (isset($_SERVER['REMOTE_ADDR'])) { else { $config["remote_addr"] = null; } -$config['user_language'] = $config["language"]; // Set a the system timezone default if ((!isset($config["timezone"])) OR ($config["timezone"] == "")){ @@ -98,12 +95,8 @@ if ((!isset($config["timezone"])) OR ($config["timezone"] == "")){ date_default_timezone_set($config["timezone"]); -// Set user language if provided, overriding System language if (isset ($config['id_user'])){ $userinfo = get_user_info ($config['id_user']); - if ($userinfo["language"] != ""){ - $config['user_language'] = $userinfo["language"]; - } // If block_size or flash_chart are provided then override global settings if (!empty($userinfo["block_size"]) && ($userinfo["block_size"] != 0)) @@ -121,8 +114,10 @@ if (isset ($config['id_user'])){ $l10n = NULL; -if (file_exists ($config["homedir"] . '/include/languages/'.$config["user_language"].'.mo')) { - $l10n = new gettext_reader (new CachedFileReader ($config["homedir"] . '/include/languages/'.$config["user_language"].'.mo')); +$user_language = get_user_language (); + +if (file_exists ($config["homedir"] . '/include/languages/'.$user_language.'.mo')) { + $l10n = new gettext_reader (new CachedFileReader ($config["homedir"] . '/include/languages/'.$user_language.'.mo')); $l10n->load_tables(); } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 971a82e7c6..a094f2edd3 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -312,6 +312,44 @@ function get_system_time () { } } +/** + * This function provide the user language configuration if is not default, otherwise return the system language + * + * @param int $id_user + * + * @return string user active language code + */ +function get_user_language ($id_user = false) { + global $config; + + $quick_language = get_parameter('quick_language_change', 0); + + if($quick_language) { + $language = get_parameter('language', 0); + + if($language === 'default') { + return $config['language']; + } + + if($language !== 0) { + return $language; + } + } + + if($id_user === false && isset($config['id_user'])) { + $id_user = $config['id_user']; + } + + if($id_user !== false) { + $userinfo = get_user_info ($id_user); + if ($userinfo['language'] != 'default'){ + return $userinfo['language']; + } + } + + return $config['language']; +} + /** * INTERNAL (use ui_print_timestamp for output): Transform an amount of time in seconds into a human readable * strings of minutes, hours or days. diff --git a/pandora_console/index.php b/pandora_console/index.php index a2b036637a..4d3f3f309a 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -179,15 +179,11 @@ elseif (! isset ($config['id_user']) && isset ($_GET["login"])) { //Remove everything that might have to do with people's passwords or logins unset ($_GET['pass'], $pass, $_POST['pass'], $_REQUEST['pass'], $login_good); - // Set user language if provided, overriding System language - $userinfo = get_user_info ($config['id_user']); - if ($userinfo["language"] != ""){ - $config['language'] = $userinfo["language"]; - } + $user_language = get_user_language ($config['id_user']); $l10n = NULL; - if (file_exists ('./include/languages/'.$config["language"].'.mo')) { - $l10n = new gettext_reader (new CachedFileReader ('./include/languages/'.$config["language"].'.mo')); + if (file_exists ('./include/languages/'.$user_language.'.mo')) { + $l10n = new gettext_reader (new CachedFileReader ('./include/languages/'.$user_language.'.mo')); $l10n->load_tables(); } } diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index d2928f50c6..89183915b0 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -24,11 +24,8 @@ include_once($config['homedir'] . '/include/functions_users.php'); include_once ($config['homedir'] . '/include/functions_groups.php'); $id = get_parameter_get ("id", $config["id_user"]); // ID given as parameter -$user_info = get_user_info ($id); -if ($user_info["language"] == ""){ - $user_info["language"] = $config["language"]; -} +$user_info = get_user_info ($id); $id = $user_info["id_user"]; //This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem) if ((!check_acl ($config["id_user"], users_get_groups ($id), "UM")) AND ($id != $config["id_user"])){ @@ -138,10 +135,11 @@ html_print_input_text_extended ("phone", $user_info["phone"], '', '', '10', '30' echo ''.__('Language').''; echo html_print_select_from_sql ('SELECT id_language, name FROM tlanguage', - 'language', $user_info["language"], '', '', '', true); + 'language', $user_info["language"], '', __('Default'), 'default', true); echo ''.__('Comments').''; html_print_textarea ("comments", 2, 60, $user_info["comments"], ($view_mode ? 'readonly="readonly"' : '')); +html_print_input_hidden('quick_language_change', 1); $own_info = get_user_info ($config['id_user']); if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) diff --git a/pandora_console/pandoradb.data.oracle.sql b/pandora_console/pandoradb.data.oracle.sql index 758ae16e61..525f97fdf1 100644 --- a/pandora_console/pandoradb.data.oracle.sql +++ b/pandora_console/pandoradb.data.oracle.sql @@ -269,8 +269,8 @@ END;; -- BEGIN LOCK TABLE tusuario IN EXCLUSIVE MODE; -INSERT INTO tusuario (id_user, fullname, firstname, lastname, middlename, password, comments, last_connect, registered, email, phone, is_admin, flash_chart) VALUES -('admin', 'Pandora', 'Pandora', 'Admin', ' ', '1da7ee7d45b96d0e1f45ee4ee23da560', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, -1); +INSERT INTO tusuario (id_user, fullname, firstname, lastname, middlename, password, comments, last_connect, registered, email, phone, is_admin, flash_chart, language) VALUES +('admin', 'Pandora', 'Pandora', 'Admin', ' ', '1da7ee7d45b96d0e1f45ee4ee23da560', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, -1, 'default'); COMMIT; END;; diff --git a/pandora_console/pandoradb.data.postgreSQL.sql b/pandora_console/pandoradb.data.postgreSQL.sql index 3d0d87b6a7..b569a4b009 100644 --- a/pandora_console/pandoradb.data.postgreSQL.sql +++ b/pandora_console/pandoradb.data.postgreSQL.sql @@ -247,8 +247,8 @@ SELECT setval('ttipo_modulo_id_tipo_seq', (SELECT (SELECT MAX(id_tipo) FROM ttip -- -- Dumping data for table "tusuario" -- -INSERT INTO "tusuario" ("id_user", "fullname", "firstname", "lastname", "middlename", "password", "comments", "last_connect", "registered", "email", "phone", "is_admin", "flash_chart") VALUES -('admin', 'Pandora', 'Pandora', 'Admin', '', '1da7ee7d45b96d0e1f45ee4ee23da560', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, -1); +INSERT INTO "tusuario" ("id_user", "fullname", "firstname", "lastname", "middlename", "password", "comments", "last_connect", "registered", "email", "phone", "is_admin", "flash_chart", "language") VALUES +('admin', 'Pandora', 'Pandora', 'Admin', '', '1da7ee7d45b96d0e1f45ee4ee23da560', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, -1, 'default'); -- -- Dumping data for table "tusuario_perfil" diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 629d3fa5b6..04ede81ef8 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -250,8 +250,8 @@ INSERT INTO `ttipo_modulo` VALUES -- -- Dumping data for table `tusuario` -- -INSERT INTO `tusuario` (`id_user`, `fullname`, `firstname`, `lastname`, `middlename`, `password`, `comments`, `last_connect`, `registered`, `email`, `phone`, `is_admin`, `flash_chart`) VALUES -('admin', 'Pandora', 'Pandora', 'Admin', '', '1da7ee7d45b96d0e1f45ee4ee23da560', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, -1); +INSERT INTO `tusuario` (`id_user`, `fullname`, `firstname`, `lastname`, `middlename`, `password`, `comments`, `last_connect`, `registered`, `email`, `phone`, `is_admin`, `flash_chart`, `language`) VALUES +('admin', 'Pandora', 'Pandora', 'Admin', '', '1da7ee7d45b96d0e1f45ee4ee23da560', 'Admin Pandora', 1232642121, 0, 'admin@example.com', '555-555-5555', 1, -1, 'default'); -- -- Dumping data for table `tusuario_perfil`