aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-26 12:44:22 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-26 12:44:22 +0000
commitf750cdf33e7717fdb4fc6caf72361e76385fd6ae (patch)
tree9dc0fd85e1fc9e89ab9fe65060fe76a8378cf164
parent890f6ac71bb19a9693b92584f4c3989303769785 (diff)
downloadelgg-f750cdf33e7717fdb4fc6caf72361e76385fd6ae.tar.gz
elgg-f750cdf33e7717fdb4fc6caf72361e76385fd6ae.tar.bz2
Closes #92: Settings: Set user language
http://trac.elgg.org/elgg/ticket/92 git-svn-id: https://code.elgg.org/elgg/trunk@1145 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--actions/user/language.php40
-rw-r--r--engine/lib/languages.php5
-rw-r--r--engine/lib/users.php6
-rw-r--r--languages/en.php7
-rw-r--r--views/default/user/settings/language.php38
5 files changed, 93 insertions, 3 deletions
diff --git a/actions/user/language.php b/actions/user/language.php
new file mode 100644
index 000000000..f6a815858
--- /dev/null
+++ b/actions/user/language.php
@@ -0,0 +1,40 @@
+<?php
+ /**
+ * Action for changing a user's personal language settings
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ global $CONFIG;
+
+ gatekeeper();
+
+ $language = get_input('language');
+ $user_id = get_input('guid');
+ $user = "";
+
+ if (!$user_id)
+ $user = $_SESSION['user'];
+ else
+ $user = get_entity($user_id);
+
+ if (($user) && ($language))
+ {
+ $user->language = $language;
+ if ($user->save())
+ system_message(elgg_echo('user:language:success'));
+ else
+ system_message(elgg_echo('user:language:fail'));
+ }
+ else
+ system_message(elgg_echo('user:language:fail'));
+
+ forward($_SERVER['HTTP_REFERER']);
+ exit;
+?> \ No newline at end of file
diff --git a/engine/lib/languages.php b/engine/lib/languages.php
index be3cf6e54..781fe2e6e 100644
--- a/engine/lib/languages.php
+++ b/engine/lib/languages.php
@@ -57,7 +57,10 @@
function elgg_echo($message_key, $language = "") {
global $CONFIG;
-
+
+ if ((empty($language)) && ($_SESSION['user']->language))
+ $language = $_SESSION['user']->language;
+
if ((empty($language)) && (isset($CONFIG->language)))
$language = $CONFIG->language;
diff --git a/engine/lib/users.php b/engine/lib/users.php
index b3ed4be55..644c5000b 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -925,7 +925,11 @@
// Add email settings
extend_elgg_settings_page('user/settings/email', 'usersettings/user', 1);
- register_action("email/save");
+ register_action("email/save");
+
+ // Add language settings
+ extend_elgg_settings_page('user/settings/language', 'usersettings/user', 1);
+ register_action("user/language");
}
//register actions *************************************************************
diff --git a/languages/en.php b/languages/en.php
index d073ace1a..7b05f1141 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -250,7 +250,12 @@
'user:password:success' => "Password changed",
'user:password:fail' => "Could not change your password on the system.",
'user:password:fail:notsame' => "The two passwords are not the same!",
- 'user:password:fail:tooshort' => "Password is too short!",
+ 'user:password:fail:tooshort' => "Password is too short!",
+
+ 'user:set:language' => "Language settings",
+ 'user:language:label' => "Your language",
+ 'user:language:success' => "Your language settings have been updated.",
+ 'user:language:fail' => "Your language settings could not be saved.",
/**
* Administration
diff --git a/views/default/user/settings/language.php b/views/default/user/settings/language.php
new file mode 100644
index 000000000..476f21924
--- /dev/null
+++ b/views/default/user/settings/language.php
@@ -0,0 +1,38 @@
+<?php
+ /**
+ * Provide a way of setting your language prefs
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ global $CONFIG;
+ $user = $_SESSION['user'];
+
+ if ($user) {
+?>
+ <h2><?php echo elgg_echo('user:set:language'); ?></h2>
+ <form action="<?php echo $vars['url']; ?>action/user/language" method="post">
+ <p>
+ <?php echo elgg_echo('user:language:label'); ?> : <input type="text" name="language" value="<?php
+ if ($user->language)
+ echo $user->language;
+ else
+ echo $CONFIG->language;
+ ?>" />
+ </p>
+
+ <p>
+ <input type="submit" value="<?php
+
+ echo elgg_echo('save');
+
+ ?>" />
+ </p>
+ </form>
+
+<?php } ?> \ No newline at end of file