diff --git a/config/services.yml b/config/services.yml index 9a1c9a63..aabff3d5 100644 --- a/config/services.yml +++ b/config/services.yml @@ -102,6 +102,18 @@ services: tags: - { name: board3.module } + board3.module.forumlist: + class: \board3\portal\modules\forumlist + arguments: + - @auth + - @config + - @template + - %core.root_path% + - %core.php_ext% + - @user + tags: + - { name: board3.module } + board3.module.stylechanger: class: \board3\portal\modules\stylechanger arguments: diff --git a/modules/forumlist.php b/modules/forumlist.php new file mode 100644 index 00000000..faca085a --- /dev/null +++ b/modules/forumlist.php @@ -0,0 +1,117 @@ +lang}/mods/portal/" + */ + public $language = 'portal_forumlist_module'; + + /** + * custom acp template + * file must be in "adm/style/portal/" + */ + public $custom_acp_tpl = ''; + + /** @var \phpbb\auth\auth */ + protected $auth; + + /** @var \phpbb\config\config */ + protected $config; + + /** @var \phpbb\template */ + protected $template; + + /** @var php file extension */ + protected $php_ext; + + /** @var phpbb root path */ + protected $phpbb_root_path; + + /** @var \phpbb\user */ + protected $user; + + /** + * Construct a custom module object + * + * @param \phpbb\auth\auth $auth phpBB auth service + * @param \phpbb\config\config $config phpBB config + * @param \phpbb\template $template phpBB template + * @param string $phpEx php file extension + * @param string $phpbb_root_path phpBB root path + * @param \phpbb\user $user phpBB user object + */ + public function __construct($auth, $config, $template, $phpbb_root_path, $phpEx, $user) + { + $this->auth = $auth; + $this->config = $config; + $this->template = $template; + $this->php_ext = $phpEx; + $this->phpbb_root_path = $phpbb_root_path; + $this->user = $user; + } + + /** + * @inheritdoc + */ + public function get_template_center($module_id) + { + display_forums('', $this->config['load_moderators'], false); + + $this->template->assign_vars(array( + 'FORUM_IMG' => $this->user->img('forum_read', 'NO_NEW_POSTS'), + 'FORUM_NEW_IMG' => $this->user->img('forum_unread', 'NEW_POSTS'), + 'FORUM_LOCKED_IMG' => $this->user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'), + 'FORUM_NEW_LOCKED_IMG' => $this->user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'), + 'U_MARK_FORUMS' => ($this->user->data['is_registered'] || $this->config['load_anon_lastread']) ? append_sid("{$this->phpbb_root_path}index.{$this->php_ext}", 'hash=' . generate_link_hash('global') . '&mark=forums') : '', + 'U_MCP' => ($this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=main&mode=front', true, $this->user->session_id) : '', + )); + + return 'forumlist.html'; + } + + /** + * @inheritdoc + */ + public function get_template_acp($module_id) + { + return array( + 'title' => 'PORTAL_FORUMLIST', + 'vars' => array(), + ); + } +} diff --git a/portal/modules/portal_forumlist.php b/portal/modules/portal_forumlist.php deleted file mode 100644 index 028fc725..00000000 --- a/portal/modules/portal_forumlist.php +++ /dev/null @@ -1,94 +0,0 @@ -lang}/mods/portal/" - */ - public $language = 'portal_forumlist_module'; - - /** - * custom acp template - * file must be in "adm/style/portal/" - */ - public $custom_acp_tpl = ''; - - public function get_template_center($module_id) - { - global $config, $template, $user, $auth, $phpbb_root_path, $phpEx; - - display_forums('', $config['load_moderators'], false); - - $template->assign_vars(array( - 'FORUM_IMG' => $user->img('forum_read', 'NO_NEW_POSTS'), - 'FORUM_NEW_IMG' => $user->img('forum_unread', 'NEW_POSTS'), - 'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'), - 'FORUM_NEW_LOCKED_IMG' => $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'), - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums') : '', - 'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '', - )); - - return 'forumlist.html'; - } - - public function get_template_acp($module_id) - { - return array( - 'title' => 'PORTAL_FORUMLIST', - 'vars' => array(), - ); - } - - /** - * API functions - */ - public function install($module_id) - { - return true; - } - - public function uninstall($module_id, $db) - { - return true; - } -}