[ticket/504] Order who is online based on phpBB ACP setting

B3P-504
This commit is contained in:
Marc Alexander
2015-03-15 09:00:20 +01:00
parent 9ca1e197ee
commit 22e48beb8f
2 changed files with 15 additions and 7 deletions

View File

@@ -311,6 +311,7 @@ services:
class: board3\portal\modules\whois_online class: board3\portal\modules\whois_online
arguments: arguments:
- @auth - @auth
- @config
- @dbal.conn - @dbal.conn
- @template - @template
- @user - @user

View File

@@ -50,10 +50,13 @@ class whois_online extends module_base
/** @var \phpbb\auth\auth */ /** @var \phpbb\auth\auth */
protected $auth; protected $auth;
/** @var \phpbb\db\driver */ /** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\db\driver\driver_interface */
protected $db; protected $db;
/** @var \phpbb\template */ /** @var \phpbb\template\template */
protected $template; protected $template;
/** @var \phpbb\user */ /** @var \phpbb\user */
@@ -69,15 +72,17 @@ class whois_online extends module_base
* Construct a user menu object * Construct a user menu object
* *
* @param \phpbb\auth\auth $auth phpBB auth * @param \phpbb\auth\auth $auth phpBB auth
* @param \phpbb\db\driver $db phpBB db driver * @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template * @param \phpbb\db\driver\driver_interface $db phpBB db driver
* @param \phpbb\template\template $template phpBB template
* @param \phpbb\user $user phpBB user * @param \phpbb\user $user phpBB user
* @param string $phpbb_root_path phpBB root path * @param string $phpbb_root_path phpBB root path
* @param string $phpEx php file extension * @param string $phpEx php file extension
*/ */
public function __construct($auth, $db, $template, $user, $phpbb_root_path, $phpEx) public function __construct($auth, $config, $db, $template, $user, $phpbb_root_path, $phpEx)
{ {
$this->auth = $auth; $this->auth = $auth;
$this->config = $config;
$this->db = $db; $this->db = $db;
$this->template = $template; $this->template = $template;
$this->user = $user; $this->user = $user;
@@ -90,13 +95,15 @@ class whois_online extends module_base
*/ */
public function get_template_center($module_id) public function get_template_center($module_id)
{ {
$order_legend = ($this->config['legend_sort_groupname']) ? 'group_name' : 'group_legend';
// Grab group details for legend display // Grab group details for legend display
if ($this->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 $sql = 'SELECT group_id, group_name, group_colour, group_type
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE group_legend > 0 WHERE group_legend > 0
ORDER BY group_name ASC'; ORDER BY ' . $order_legend . ' ASC';
} }
else else
{ {
@@ -110,7 +117,7 @@ class whois_online extends module_base
) )
WHERE g.group_legend > 0 WHERE g.group_legend > 0
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $this->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'; ORDER BY g.' . $order_legend . ' ASC';
} }
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);