Added Who is online? Block

This commit is contained in:
Marc Alexander
2010-11-06 14:10:33 +00:00
parent 9dbd30e909
commit bd81d0163c
3 changed files with 177 additions and 0 deletions

View File

@@ -0,0 +1,129 @@
<?php
/**
* @package Portal - Who is online
* @version $Id$
* @copyright (c) 2009, 2010 Board3 Portal Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Who is online
*/
class portal_whois_online_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
var $columns = 21;
/**
* Default modulename
*/
var $name = 'PORTAL_WHOIS_ONLINE';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
var $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
var $language = 'portal_whois_online_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
var $custom_acp_tpl = '';
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'))
{
$sql = 'SELECT group_id, group_name, group_colour, group_type
FROM ' . GROUPS_TABLE . '
WHERE group_legend = 1
ORDER BY group_name ASC';
}
else
{
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
ON (
g.group_id = ug.group_id
AND ug.user_id = ' . $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'] . ')
ORDER BY g.group_name ASC';
}
$result = $db->sql_query($sql);
$legend = array();
while ($row = $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'];
if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$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>';
}
}
$db->sql_freeresult($result);
$legend = implode(', ', $legend);
$template->assign_var('PORTAL_LEGEND', $legend);
return 'whois_online_center.html';
}
function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_WHOIS_ONLINE',
'vars' => array(),
);
}
/**
* API functions
*/
function install($module_id)
{
return true;
}
function uninstall($module_id)
{
return true;
}
}
?>