Added birthday block;

Added stylechanger block;
This commit is contained in:
Marc Alexander
2010-08-29 12:49:25 +00:00
parent 1581394c39
commit 6a182d6638
8 changed files with 386 additions and 12 deletions

View File

@@ -0,0 +1,46 @@
<?php
/**
* @package Portal - Attachments
* @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(
'BIRTHDAYS_AHEAD' => 'In the next %s days',
'NO_BIRTHDAYS_AHEAD' => 'No members have a birthday within this period of time.',
// ACP
'ACP_PORTAL_BIRTHDAYS_SETTINGS' => 'Birthdays Settings',
'ACP_PORTAL_BIRTHDAYS_SETTINGS_EXP' => 'This is where you customize the birthday block.',
'PORTAL_BIRTHDAYS' => 'Birthday block',
'PORTAL_BIRTHDAYS_EXP' => 'Display this block on the portal.',
'PORTAL_BIRTHDAYS_AHEAD' => 'Birthdays ahead days',
'PORTAL_BIRTHDAYS_AHEAD_EXP' => 'How many days to look ahead for future birthdays.<br />"0" will disable the ahead birthdays list.',
));
?>

View File

@@ -0,0 +1,38 @@
<?php
/**
* @package Portal - Attachments
* @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(
'BOARD_STYLE' => 'Board style',
'STYLE_CHOOSE' => 'Select a style',
));
?>

View File

@@ -0,0 +1,159 @@
<?php
/**
* @package Portal - Birthday List
* @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 Birthday List
*/
class portal_birthday_list_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 = 'BIRTHDAYS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
var $image_src = 'portal_birthday.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
var $language = 'portal_birthday_list_module';
function get_template_side($module_id)
{
global $config, $template, $db, $user;
// Generate birthday list if required ... / borrowed from index.php 3.0.6
$birthday_list = $birthday_ahead_list = '';
if ($config['load_birthdays'] && $config['allow_birthdays'])
{
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
$cache_days = $config['board3_birthdays_ahead'];
$sql_days = '';
while ($cache_days > 0)
{
$day = getdate(time() + 86400 * $cache_days + $user->timezone + $user->dst - date('Z'));
$sql_days .= " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $day['mday'], $day['mon'])) . "%'";
$cache_days--;
}
switch ($db->sql_layer)
{
case 'mssql':
case 'mssql_odbc':
$order_by = 'u.user_birthday ASC';
break;
default:
$order_by = 'SUBSTRING(u.user_birthday FROM 4 FOR 2) ASC, SUBSTRING(u.user_birthday FROM 1 FOR 2) ASC, u.username_clean ASC';
break;
}
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
FROM ' . USERS_TABLE . ' u
LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
WHERE (b.ban_id IS NULL
OR b.ban_exclude = 1)
AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$sql_days})
AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
ORDER BY ' . $order_by;
$result = $db->sql_query($sql);
$today = sprintf('%2d-%2d-', $now['mday'], $now['mon']);
while ($row = $db->sql_fetchrow($result))
{
if (substr($row['user_birthday'], 0, 6) == $today)
{
$birthday_list .= '<span style="float:left;"><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/portal_user.png" width="16" height="16" alt="" /></span><span style="float:left; padding-left:5px; padding-top:2px;">' . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) . '</span><span style="float: right;">';
if ($age = (int) substr($row['user_birthday'], -4))
{
$birthday_list .= ' (' . ($now['year'] - $age) . ')';
}
$birthday_list .= '</span><br style="clear: both" />';
}
elseif ($config['board3_birthdays_ahead'] > 0)
{
$birthday_ahead_list .= '<span style="float:left;"><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/portal_user.png" width="16" height="16" alt="" /></span><span style="float:left; padding-left:5px; padding-top:2px;"><span title="' . format_birthday($row['user_birthday'], 'd M') . '">' . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) . '</span></span><span style="float: right;">';
if ($age = (int) substr($row['user_birthday'], -4))
{
$birthday_ahead_list .= ' (' . ($now['year'] - $age) . ')';
}
$birthday_ahead_list .= '</span><br style="clear: both" />';
}
}
$db->sql_freeresult($result);
}
// Assign index specific vars
$template->assign_vars(array(
'BIRTHDAY_LIST' => $birthday_list,
'BIRTHDAYS_AHEAD_LIST' => ($config['board3_birthdays_ahead']) ? $birthday_ahead_list : '',
'L_BIRTHDAYS_AHEAD' => sprintf($user->lang['BIRTHDAYS_AHEAD'], $config['board3_birthdays_ahead']),
'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false,
'S_DISPLAY_BIRTHDAY_AHEAD_LIST' => ($config['board3_birthdays_ahead'] > 0) ? true : false,
));
return 'birthdays_side.html';
}
function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_BIRTHDAYS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_BIRTHDAYS_SETTINGS',
'board3_birthdays_ahead' => array('lang' => 'PORTAL_BIRTHDAYS_AHEAD', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
),
);
}
/**
* API functions
*/
function install($module_id)
{
set_config('board3_birthdays_ahead', 30);
return true;
}
function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_birthdays_ahead',
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}
?>

View File

@@ -0,0 +1,119 @@
<?php
/**
* @package Portal - Stylechanger
* @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 Stylechanger
*/
class portal_stylechanger_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 = 'BOARD_STYLE';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
var $image_src = 'portal_style.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
var $language = 'portal_stylechanger_module';
function get_template_side($module_id)
{
global $config, $template, $db, $phpEx;
$style_count = 0;
$style_select = '';
$sql = 'SELECT style_id, style_name
FROM ' . STYLES_TABLE . '
WHERE style_active = 1
ORDER BY LOWER(style_name) ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$style = request_var('style', 0);
if($style)
{
$url = str_replace('style=' . $style, 'style=' . $row['style_id'], append_sid("{$phpbb_root_path}portal.$phpEx"));
}
else
{
$url = append_sid("{$phpbb_root_path}portal.$phpEx", 'style=' . $row['style_id']);
}
++$style_count;
$style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $user->theme['style_id'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($row['style_name']) . '</option>';
}
$db->sql_freeresult($result);
if(strlen($style_select))
{
$template->assign_var('STYLE_SELECT', $style_select);
}
// Assign specific vars
$template->assign_vars(array(
'S_STYLE_OPTIONS' => ($config['override_user_style'] || $style_count < 2) ? '' : style_select($user->data['user_style']),
'S_DISPLAY_CHANGE_STYLE' => true,
));
return 'stylechanger_side.html';
}
function get_template_acp($module_id)
{
return array();
}
/**
* API functions
*/
function install($module_id)
{
set_config('portal_' . $module_id . '_configname', 'Hello World!');
set_config('portal_' . $module_id . '_configname2', 1337);
return true;
}
function uninstall($module_id)
{
global $db;
$del_config = array(
'portal_' . $module_id . '_configname',
'portal_' . $module_id . '_configname2',
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}
?>

View File

@@ -1,15 +1,18 @@
<!--version $Id$ //-->
{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{T_THEME_PATH}/images/portal/portal_birthday.png" width="16" height="16" alt="" />&nbsp;<!-- ENDIF -->{L_BIRTHDAYS}{$LR_BLOCK_H_R}
<!-- IF BIRTHDAY_LIST -->
<strong>{L_CONGRATULATIONS}:</strong><br /> {BIRTHDAY_LIST}
<!-- ELSE -->
{L_NO_BIRTHDAYS}
<!-- ENDIF -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
{$LR_BLOCK_H_L}{L_BIRTHDAYS_AHEAD}{$LR_BLOCK_H_R}
<!-- IF BIRTHDAYS_AHEAD_LIST -->
{BIRTHDAYS_AHEAD_LIST}
<!-- ELSE -->
{L_NO_BIRTHDAYS_AHEAD}
<!-- ENDIF -->
<!-- IF BIRTHDAY_LIST -->
<strong>{L_CONGRATULATIONS}:</strong><br /> {BIRTHDAY_LIST}
<!-- ELSE -->
{L_NO_BIRTHDAYS}
<!-- ENDIF -->
<!-- IF S_DISPLAY_BIRTHDAY_AHEAD_LIST -->
<hr class="dashed" />
<strong>{L_BIRTHDAYS_AHEAD}</strong>
<br />
<!-- IF BIRTHDAYS_AHEAD_LIST -->
{BIRTHDAYS_AHEAD_LIST}
<!-- ELSE -->
{L_NO_BIRTHDAYS_AHEAD}
<!-- ENDIF -->
<!-- ENDIF -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}

View File

@@ -0,0 +1,9 @@
<!--version $Id$ //-->
<!-- IF S_STYLE_OPTIONS and S_DISPLAY_CHANGE_STYLE -->
{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{T_THEME_PATH}/images/portal/portal_style.png" width="16" height="16" alt="" />&nbsp;<!-- ENDIF -->{L_BOARD_STYLE}{$LR_BLOCK_H_R}
<select style="width: 150px;" name="demo" id="demo" onchange="document.location.href = this.options[this.selectedIndex].value;">
{STYLE_SELECT}
</select>
<br />
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
<!-- ENDIF -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB