aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authormrgoldy <gijsmartens1@gmail.com>2018-12-09 23:52:50 +0100
committerMarc Alexander <admin@m-a-styles.de>2019-09-25 20:07:09 +0200
commit7989f3f71fd665aa743d947c7487d41c6f0a33d4 (patch)
tree4d2fe00e8c520c13400c193c994bb26070ae8044 /phpBB/phpbb
parent012fe1887963adecc30fa46b7c7069a29600666d (diff)
downloadforums-7989f3f71fd665aa743d947c7487d41c6f0a33d4.tar
forums-7989f3f71fd665aa743d947c7487d41c6f0a33d4.tar.gz
forums-7989f3f71fd665aa743d947c7487d41c6f0a33d4.tar.bz2
forums-7989f3f71fd665aa743d947c7487d41c6f0a33d4.tar.xz
forums-7989f3f71fd665aa743d947c7487d41c6f0a33d4.zip
[ticket/15905] Try with existing phpbb extension
PHPBB3-15905
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/template/twig/extension.php48
-rw-r--r--phpBB/phpbb/template/twig/extension/auth.php91
-rw-r--r--phpBB/phpbb/template/twig/extension/username.php1
3 files changed, 46 insertions, 94 deletions
diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php
index c5b3db1aaf..5bb0c67291 100644
--- a/phpBB/phpbb/template/twig/extension.php
+++ b/phpBB/phpbb/template/twig/extension.php
@@ -15,6 +15,9 @@ namespace phpbb\template\twig;
class extension extends \Twig_Extension
{
+ /** @var \phpbb\auth\auth */
+ protected $auth;
+
/** @var \phpbb\template\context */
protected $context;
@@ -27,13 +30,14 @@ class extension extends \Twig_Extension
/**
* Constructor
*
+ * @param \phpbb\auth\auth $auth
* @param \phpbb\template\context $context
* @param \phpbb\template\twig\environment $environment
* @param \phpbb\language\language $language
- * @return \phpbb\template\twig\extension
*/
- public function __construct(\phpbb\template\context $context, \phpbb\template\twig\environment $environment, $language)
+ public function __construct(\phpbb\auth\auth $auth, \phpbb\template\context $context, \phpbb\template\twig\environment $environment, $language)
{
+ $this->auth = $auth;
$this->context = $context;
$this->environment = $environment;
$this->language = $language;
@@ -91,6 +95,8 @@ class extension extends \Twig_Extension
return array(
new \Twig_SimpleFunction('lang', array($this, 'lang')),
new \Twig_SimpleFunction('lang_defined', array($this, 'lang_defined')),
+ new \Twig_SimpleFunction('auth', array($this, 'get_auth')),
+ new \Twig_SimpleFunction('auth_global', array($this, 'get_auth_global')),
);
}
@@ -198,4 +204,42 @@ class extension extends \Twig_Extension
{
return call_user_func_array([$this->language, 'is_set'], [$key]);
}
+
+ /**
+ * Look up permission option(s).
+ *
+ * How to use in a template:
+ * - {{ auth(options, forum_id) }}
+ *
+ * The options are required, either as a single string 'a_' or as a twig array ['a_', 'm_'].
+ * The forum identifier is optional.
+ *
+ * @return bool
+ */
+ public function get_auth()
+ {
+ $args = func_get_args();
+
+ $options = $args[0];
+ $forum_id = isset($args[1]) ? (int) $args[1] : 0;
+
+ return is_array($options) ? $this->auth->acl_gets($options, $forum_id) : $this->auth->acl_get($options, $forum_id);
+ }
+
+ /**
+ * Look up permission option(s) for any forum
+ *
+ * How to use in a template:
+ * - {{ auth_global(options) }}
+ *
+ * The options are required, either as a single string 'a_' or as a twig array ['a_', 'm_'].
+ *
+ * @return bool
+ */
+ public function get_auth_global()
+ {
+ $args = func_get_args();
+
+ return $this->auth->acl_getf_global($args);
+ }
}
diff --git a/phpBB/phpbb/template/twig/extension/auth.php b/phpBB/phpbb/template/twig/extension/auth.php
deleted file mode 100644
index 9dbe306782..0000000000
--- a/phpBB/phpbb/template/twig/extension/auth.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-/**
- *
- * This file is part of the phpBB Forum Software package.
- *
- * @copyright (c) phpBB Limited <https://www.phpbb.com>
- * @license GNU General Public License, version 2 (GPL-2.0)
- *
- * For full copyright and license information, please see
- * the docs/CREDITS.txt file.
- *
- */
-
-namespace phpbb\template\twig\extension;
-
-class auth extends \Twig_Extension
-{
- /** @var \phpbb\auth\auth */
- protected $auth;
-
- /**
- * Constructor.
- *
- * @param \phpbb\auth\auth $auth Authentication object
- */
- public function __construct(\phpbb\auth\auth $auth)
- {
- $this->auth = $auth;
- }
-
- /**
- * Get the name of this extension
- *
- * @return string
- */
- public function getName()
- {
- return 'auth';
- }
-
- /**
- * Returns a list of global functions to add to the existing list.
- *
- * @return array An array of global functions
- */
- public function getFunctions()
- {
- return array(
- new \Twig_SimpleFunction('auth', array($this, 'get_auth')),
- new \Twig_SimpleFunction('auth_global', array($this, 'get_auth_global')),
- );
- }
-
- /**
- * Look up permission option(s).
- *
- * How to use in a template:
- * - {{ auth(options, forum_id) }}
- *
- * The options are required, either as a single string 'a_' or as a twig array ['a_', 'm_'].
- * The forum identifier is optional.
- *
- * @return bool
- */
- public function get_auth()
- {
- $args = func_get_args();
-
- $options = $args[0];
- $forum_id = isset($args[1]) ? (int) $args[1] : 0;
-
- return is_array($options) ? $this->auth->acl_gets($options, $forum_id) : $this->auth->acl_get($options, $forum_id);
- }
-
- /**
- * Look up permission option(s) for any forum
- *
- * How to use in a template:
- * - {{ auth_global(options) }}
- *
- * The options are required, either as a single string 'a_' or as a twig array ['a_', 'm_'].
- *
- * @return bool
- */
- public function get_auth_global()
- {
- $args = func_get_args();
-
- return $this->auth->acl_getf_global($args);
- }
-}
diff --git a/phpBB/phpbb/template/twig/extension/username.php b/phpBB/phpbb/template/twig/extension/username.php
index c80396b116..ef149693a0 100644
--- a/phpBB/phpbb/template/twig/extension/username.php
+++ b/phpBB/phpbb/template/twig/extension/username.php
@@ -79,7 +79,6 @@ class username extends \Twig_Extension
$custom_profile_url = isset($args[5]) ? $args[5] : false;
}
-
return get_username_string($mode, $user_id, $username, $user_colour, $guest_username, $custom_profile_url);
}
}