Added friends block

This commit is contained in:
Marc Alexander
2010-08-30 12:31:57 +00:00
parent cf4ba51ed6
commit 594560996a
4 changed files with 203 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
<?php
/**
* @package Portal - Friends
* @version $Id$
* @copyright (c) 2009, 2010 Board3 Portal Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
'FRIENDS' => 'Friends',
'FRIENDS_OFFLINE' => 'Offline',
'FRIENDS_ONLINE' => 'Online',
'NO_FRIENDS' => 'No friends currently defined',
'NO_FRIENDS_OFFLINE' => 'No friends offline',
'NO_FRIENDS_ONLINE' => 'No friends online',
// ACP
'ACP_PORTAL_FRIENDS_SETTINGS' => 'Friends Settings',
'ACP_PORTAL_FRIENDS_SETTINGS_EXP' => 'This is where you customize the friends block.',
'PORTAL_MAX_ONLINE_FRIENDS' => 'Limit of displayed friends',
'PORTAL_MAX_ONLINE_FRIENDS_EXP' => 'The maximum number of friends displayed.',
));
?>

View File

@@ -0,0 +1,138 @@
<?php
/**
* @package Portal - Friends
* @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 Friends
*/
class portal_friends_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
var $columns = 10;
/**
* Default modulename
*/
var $name = 'FRIENDS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
var $image_src = 'portal_friends.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
var $language = 'portal_friends_module';
function get_template_side($module_id)
{
global $config, $template, $db, $user;
$s_display_friends = false;
// Output listing of friends online
$update_time = $config['load_online_time'] * 60;
$sql = $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',
ZEBRA_TABLE => 'z'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(SESSIONS_TABLE => 's'),
'ON' => 's.session_user_id = z.zebra_id'
)
),
'WHERE' => 'z.user_id = ' . $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']);
while ($row = $db->sql_fetchrow($result))
{
$which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline';
$s_display_friends = ($row['user_id']) ? true : false;
$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']),
'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))
);
}
$db->sql_freeresult($result);
// Assign specific vars
$template->assign_vars(array(
'S_DISPLAY_FRIENDS' => $s_display_friends,
'S_ZEBRA_ENABLED' => true,
));
return 'friends_side.html';
}
function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_FRIENDS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_FRIENDS_SETTINGS',
'board3_max_online_friends' => array('lang' => 'PORTAL_MAX_ONLINE_FRIENDS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
)
);
}
/**
* API functions
*/
function install($module_id)
{
set_config('board3_max_online_friends', 8);
return true;
}
function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_max_online_friends',
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}
?>

View File

@@ -0,0 +1,17 @@
<!--version $Id$ //-->
{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{T_THEME_PATH}/images/portal/portal_friends.png" width="17" height="17" alt="" />&nbsp;<!-- ENDIF -->{L_FRIENDS}{$LR_BLOCK_H_R}
<strong style="color:green">{L_FRIENDS_ONLINE}</strong><br />
<!-- BEGIN b3p_friends_online -->
<span style="float:left;"><img src="{T_THEME_PATH}/images/portal/portal_user.png" width="16" height="16" alt="" /></span><span style="float:left; padding-left:5px; padding-top:2px;">{b3p_friends_online.USERNAME_FULL}</span><br style="clear:both" />
<!-- BEGINELSE -->
<span style="float:left; padding-left:5px; padding-top:2px;">{L_NO_FRIENDS_ONLINE}</span>
<br style="clear:both" />
<!-- END b3p_friends_online -->
<br style="clear:both" />
<strong style="color:red">{L_FRIENDS_OFFLINE}</strong><br />
<!-- BEGIN b3p_friends_offline -->
<span style="float:left;"><img src="{T_THEME_PATH}/images/portal/portal_user.png" width="16" height="16" alt="" /></span><span style="float:left; padding-left:5px; padding-top:2px;">{b3p_friends_offline.USERNAME_FULL}</span><br style="clear:both" />
<!-- BEGINELSE -->
<span style="float:left; padding-left:5px; padding-top:2px;">{L_NO_FRIENDS_OFFLINE}</span>
<!-- END b3p_friends_offline -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B