aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/user.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-08-01 11:07:34 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-08-01 11:07:34 +0200
commitd152c20e4b53f26bfcf9425f1efed9d9d4ccef9f (patch)
treeb781a661a48aa23341e53b19892f3a34c160a02a /phpBB/includes/user.php
parent01369dd7f826a27e9970e0c0acb126cb2349c87c (diff)
downloadforums-d152c20e4b53f26bfcf9425f1efed9d9d4ccef9f.tar
forums-d152c20e4b53f26bfcf9425f1efed9d9d4ccef9f.tar.gz
forums-d152c20e4b53f26bfcf9425f1efed9d9d4ccef9f.tar.bz2
forums-d152c20e4b53f26bfcf9425f1efed9d9d4ccef9f.tar.xz
forums-d152c20e4b53f26bfcf9425f1efed9d9d4ccef9f.zip
[feature/php-events] Add core.user_setup event
This event can be used to load language files globally so it fixes PHPBB3-8270 PHPBB3-8270 PHPBB3-9550
Diffstat (limited to 'phpBB/includes/user.php')
-rw-r--r--phpBB/includes/user.php36
1 files changed, 29 insertions, 7 deletions
diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php
index fcbfaaddfa..93557f3558 100644
--- a/phpBB/includes/user.php
+++ b/phpBB/includes/user.php
@@ -76,18 +76,18 @@ class phpbb_user extends phpbb_session
function setup($lang_set = false, $style_id = false)
{
global $db, $phpbb_style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
+ global $phpbb_dispatcher;
if ($this->data['user_id'] != ANONYMOUS)
{
- $this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);
-
- $this->date_format = $this->data['user_dateformat'];
+ $user_lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);
+ $user_date_format = $this->data['user_dateformat'];
$user_timezone = $this->data['user_timezone'];
}
else
{
- $this->lang_name = basename($config['default_lang']);
- $this->date_format = $config['default_dateformat'];
+ $user_lang_name = basename($config['default_lang']);
+ $user_date_format = $config['default_dateformat'];
$user_timezone = $config['board_timezone'];
/**
@@ -107,7 +107,7 @@ class phpbb_user extends phpbb_session
if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx"))
{
- $this->lang_name = $config['default_lang'] = $accept_lang;
+ $user_lang_name = $config['default_lang'] = $accept_lang;
break;
}
else
@@ -118,7 +118,7 @@ class phpbb_user extends phpbb_session
if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx"))
{
- $this->lang_name = $config['default_lang'] = $accept_lang;
+ $user_lang_name = $config['default_lang'] = $accept_lang;
break;
}
}
@@ -127,6 +127,28 @@ class phpbb_user extends phpbb_session
*/
}
+ $user_data = $this->data;
+
+ /**
+ * Event to load language files and modify user data on every page
+ *
+ * @event core.user_setup
+ * @var array user_data Array with user's data row
+ * @var string user_lang_name Basename of the user's langauge
+ * @var string user_date_format User's date/time format
+ * @var string user_timezone User's timezone, should be one of
+ * http://www.php.net/manual/en/timezones.php
+ * @var mixed lang_set String or array of language files
+ * @var mixed style_id Style we are going to display
+ * @since 3.1-A1
+ */
+ $vars = array('user_data', 'user_lang_name', 'user_date_format', 'user_timezone', 'lang_set', 'style_id');
+ extract($phpbb_dispatcher->trigger_event('core.user_setup', compact($vars)));
+
+ $this->data = $user_data;
+ $this->lang_name = $user_lang_name;
+ $this->date_format = $user_date_format;
+
try
{
$this->timezone = new DateTimeZone($user_timezone);