[feature/module_services] Move whois_online to module services

This commit is contained in:
Marc Alexander
2013-11-17 01:52:24 +01:00
parent 06bc28ed5a
commit 64ee68568b
3 changed files with 73 additions and 39 deletions

View File

@@ -319,3 +319,15 @@ services:
- %core.php_ext%
tags:
- { name: board3.module }
board3.module.whois_online:
class: \board3\portal\modules\whois_online
arguments:
- @auth
- @dbal.conn
- @template
- @user
- %core.root_path%
- %core.php_ext%
tags:
- { name: board3.module }

View File

@@ -457,7 +457,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
'module_classname' => 'whois_online',
'module_classname' => '\board3\portal\modules\whois_online',
'module_column' => 2,
'module_order' => 6,
'module_name' => 'PORTAL_WHOIS_ONLINE',

View File

@@ -1,24 +1,18 @@
<?php
/**
*
* @package Board3 Portal v2 - Who is online
* @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
namespace board3\portal\modules;
/**
* @package Who is online
*/
class portal_whois_online_module extends \board3\portal\modules\module_base
class whois_online extends module_base
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -53,12 +47,51 @@ class portal_whois_online_module extends \board3\portal\modules\module_base
*/
public $custom_acp_tpl = '';
/** @var \phpbb\auth\auth */
protected $auth;
/** @var \phpbb\db\driver */
protected $db;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/** @var phpbb root path */
protected $phpbb_root_path;
/** @var php file extension */
protected $php_ext;
/**
* Construct a user menu object
*
* @param \phpbb\auth\auth $auth phpBB auth
* @param \phpbb\db\driver $db phpBB db driver
* @param \phpbb\template $template phpBB template
* @param \phpbb\user $user phpBB user
* @param string $phpbb_root_path phpBB root path
* @param string $phpEx php file extension
*/
public function __construct($auth, $db, $template, $user, $phpbb_root_path, $phpEx)
{
$this->auth = $auth;
$this->db = $db;
$this->template = $template;
$this->user = $user;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $phpEx;
}
/**
* @inheritdoc
*/
public function get_template_center($module_id)
{
global $config, $template, $user, $auth, $db, $phpbb_root_path, $phpEx;
// Grab group details for legend display
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
$sql = 'SELECT group_id, group_name, group_colour, group_type
FROM ' . GROUPS_TABLE . '
@@ -72,48 +105,50 @@ class portal_whois_online_module extends \board3\portal\modules\module_base
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
ON (
g.group_id = ug.group_id
AND ug.user_id = ' . $user->data['user_id'] . '
AND ug.user_id = ' . $this->user->data['user_id'] . '
AND ug.user_pending = 0
)
WHERE g.group_legend = 1
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $this->user->data['user_id'] . ')
ORDER BY g.group_name ASC';
}
$result = $db->sql_query($sql);
$result = $this->db->sql_query($sql);
$legend = array();
while ($row = $db->sql_fetchrow($result))
while ($row = $this->db->sql_fetchrow($result))
{
$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'];
if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
if ($row['group_name'] == 'BOTS' || ($this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile')))
{
$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
}
else
{
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
}
}
$db->sql_freeresult($result);
$this->db->sql_freeresult($result);
$legend = implode(', ', $legend);
$template->assign_var('PORTAL_LEGEND', $legend);
$this->template->assign_var('PORTAL_LEGEND', $legend);
return 'whois_online_center.html';
}
/**
* @inheritdoc
*/
public function get_template_side($module_id)
{
global $config, $template, $user, $auth, $db, $phpbb_root_path, $phpEx;
// No legend on the side so just return the template file
return 'whois_online_side.html';
}
/**
* @inheritdoc
*/
public function get_template_acp($module_id)
{
return array(
@@ -121,17 +156,4 @@ class portal_whois_online_module extends \board3\portal\modules\module_base
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id, $db)
{
return true;
}
}