[feature/module_services] Move friends module to module services
This commit is contained in:
@@ -114,6 +114,17 @@ services:
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.friends:
|
||||
class: \board3\portal\modules\friends
|
||||
arguments:
|
||||
- @auth
|
||||
- @config
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- @user
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.stylechanger:
|
||||
class: \board3\portal\modules\stylechanger
|
||||
arguments:
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - Friends
|
||||
* @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 Friends
|
||||
*/
|
||||
class portal_friends_module extends \board3\portal\modules\module_base
|
||||
class friends extends module_base
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
@@ -47,16 +41,50 @@ class portal_friends_module extends \board3\portal\modules\module_base
|
||||
*/
|
||||
public $language = 'portal_friends_module';
|
||||
|
||||
/** @var \phpbb\auth\auth */
|
||||
protected $auth;
|
||||
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/** @var \phpbb\db\driver */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Construct a friends object
|
||||
*
|
||||
* @param \phpbb\auth\auth $auth phpBB auth service
|
||||
* @param \phpbb\config\config $config phpBB config
|
||||
* @param \phpbb\db\driver $db phpBB db driver
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param \phpbb\user $user phpBB user object
|
||||
*/
|
||||
public function __construct($auth, $config, $db, $template, $user)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
global $config, $template, $db, $user, $auth;
|
||||
|
||||
$s_display_friends = false;
|
||||
|
||||
// Output listing of friends online
|
||||
$update_time = $config['load_online_time'] * 60;
|
||||
$update_time = $this->config['load_online_time'] * 60;
|
||||
|
||||
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
|
||||
$sql = $this->db->sql_build_query('SELECT_DISTINCT', array(
|
||||
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
|
||||
'FROM' => array(
|
||||
USERS_TABLE => 'u',
|
||||
@@ -70,21 +98,21 @@ class portal_friends_module extends \board3\portal\modules\module_base
|
||||
)
|
||||
),
|
||||
|
||||
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
|
||||
'WHERE' => 'z.user_id = ' . $this->user->data['user_id'] . '
|
||||
AND z.friend = 1
|
||||
AND u.user_id = z.zebra_id',
|
||||
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.username_clean, u.user_allow_viewonline, u.user_colour',
|
||||
'ORDER_BY' => 'u.username_clean ASC',
|
||||
));
|
||||
|
||||
$result = $db->sql_query_limit($sql, $config['board3_max_online_friends_' . $module_id]);
|
||||
$result = $this->db->sql_query_limit($sql, $this->config['board3_max_online_friends_' . $module_id]);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline';
|
||||
$which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $this->auth->acl_get('u_viewonline'))) ? 'online' : 'offline';
|
||||
$s_display_friends = ($row['user_id']) ? true : false;
|
||||
|
||||
$template->assign_block_vars("b3p_friends_{$which}", array(
|
||||
$this->template->assign_block_vars("b3p_friends_{$which}", array(
|
||||
'USER_ID' => $row['user_id'],
|
||||
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
@@ -92,16 +120,19 @@ class portal_friends_module extends \board3\portal\modules\module_base
|
||||
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
// Assign specific vars
|
||||
$template->assign_vars(array(
|
||||
$this->template->assign_vars(array(
|
||||
'S_DISPLAY_FRIENDS' => $s_display_friends,
|
||||
));
|
||||
|
||||
return 'friends_side.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
@@ -114,7 +145,7 @@ class portal_friends_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
@@ -122,6 +153,9 @@ class portal_friends_module extends \board3\portal\modules\module_base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
$del_config = array(
|
||||
Reference in New Issue
Block a user