aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-05-10 04:23:18 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2012-11-17 16:39:59 -0500
commit1b36fc3a6074a661a1b32c015fb9931f3470c61c (patch)
tree58343cd7f3e701742ace297a474c472b27f9a903 /phpBB
parent45a1219886b039fbb4bda740accbfbbdbf971022 (diff)
downloadforums-1b36fc3a6074a661a1b32c015fb9931f3470c61c.tar
forums-1b36fc3a6074a661a1b32c015fb9931f3470c61c.tar.gz
forums-1b36fc3a6074a661a1b32c015fb9931f3470c61c.tar.bz2
forums-1b36fc3a6074a661a1b32c015fb9931f3470c61c.tar.xz
forums-1b36fc3a6074a661a1b32c015fb9931f3470c61c.zip
[feature/template-events] Handle user access correctly.
Pass through $user from template to filter. Allow $user to be null for standalone usage of the template engine. PHPBB3-9550
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/template/compile.php4
-rw-r--r--phpBB/includes/template/filter.php20
2 files changed, 21 insertions, 3 deletions
diff --git a/phpBB/includes/template/compile.php b/phpBB/includes/template/compile.php
index 06ff60387a..e2e9a095dc 100644
--- a/phpBB/includes/template/compile.php
+++ b/phpBB/includes/template/compile.php
@@ -40,8 +40,9 @@ class phpbb_template_compile
* @param phpbb_style_resource_locator $locator Resource locator
* @param string $phpbb_root_path Path to phpBB root directory
* @param phpbb_extension_manager $extension_manager Extension manager to use for finding template fragments in extensions; if null, template hooks will not be invoked
+ * @param phpbb_user $user Current user
*/
- public function __construct($allow_php, $template_name, $locator, $phpbb_root_path, $extension_manager = null)
+ public function __construct($allow_php, $template_name, $locator, $phpbb_root_path, $extension_manager = null, $user = null)
{
$this->filter_params = array(
'allow_php' => $allow_php,
@@ -49,6 +50,7 @@ class phpbb_template_compile
'locator' => $locator,
'phpbb_root_path' => $phpbb_root_path,
'extension_manager' => $extension_manager,
+ 'user' => $user,
'template_compile' => $this,
);
}
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index 2706eb9040..ed81c4cd8a 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -105,6 +105,12 @@ class phpbb_template_filter extends php_user_filter
private $extension_manager;
/**
+ * Current user
+ * @var phpbb_user
+ */
+ private $user;
+
+ /**
* Template compiler.
*
* @var phpbb_template_compile
@@ -174,6 +180,10 @@ class phpbb_template_filter extends php_user_filter
$this->phpbb_root_path = $this->params['phpbb_root_path'];
$this->template_name = $this->params['template_name'];
$this->extension_manager = $this->params['extension_manager'];
+ if (isset($this->params['user']))
+ {
+ $this->user = $this->params['user'];
+ }
$this->template_compile = $this->params['template_compile'];
return true;
}
@@ -878,8 +888,14 @@ class phpbb_template_filter extends php_user_filter
if (!preg_match('/^\w+$/', $tag_args))
{
// The hook location is wrongly formatted,
- global $user;
- trigger_error($user->lang('ERR_TEMPLATE_EVENT_LOCATION', $tag_args), E_USER_ERROR);
+ if ($this->user)
+ {
+ trigger_error($this->user->lang('ERR_TEMPLATE_EVENT_LOCATION', $tag_args), E_USER_ERROR);
+ }
+ else
+ {
+ trigger_error(sprintf('The specified template event location <em>[%s]</em> is wrongly formatted.', $tag_args), E_USER_ERROR);
+ }
}
$location = $tag_args;