[fix/folders] move files back to root

This commit is contained in:
Marc Alexander
2013-10-29 18:18:10 +01:00
parent de3bfbd7dd
commit 6695373e0b
268 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?php
/**
*
* @package Board3 Portal v2
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
if (!defined('IN_PHPBB'))
{
exit;
}
global $table_prefix;
// Config constants
define('B3_MODULE_DISABLED', 0);
define('B3_MODULE_ENABLED', 1);
// Tables and paths
define('PORTAL_ROOT_PATH', 'portal/');
define('PORTAL_MODULES_TABLE', $table_prefix . 'portal_modules');
define('PORTAL_CONFIG_TABLE', $table_prefix . 'portal_config');

View File

@@ -0,0 +1,874 @@
<?php
/**
*
* @package Board3 Portal v2
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
if (!defined('IN_PHPBB') && !defined('UMIL_AUTO') && !defined('IN_INSTALL'))
{
exit;
}
// Get portal config
function obtain_portal_config()
{
global $db, $cache, $portal_config;
if (($portal_config = $cache->get('portal_config')) === false)
{
$portal_config = $portal_cached_config = array();
$sql = 'SELECT config_name, config_value
FROM ' . PORTAL_CONFIG_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$portal_cached_config[$row['config_name']] = $row['config_value'];
$portal_config[$row['config_name']] = $row['config_value'];
}
$db->sql_freeresult($result);
$cache->put('portal_config', $portal_cached_config);
}
return $portal_config;
}
/**
* Set config value. Creates missing config entry.
* Only use this if your config value might exceed 255 characters, otherwise please use set_config
*/
function set_portal_config($config_name, $config_value)
{
global $db, $cache, $portal_config;
$sql = 'UPDATE ' . PORTAL_CONFIG_TABLE . "
SET config_value = '" . $db->sql_escape($config_value) . "'
WHERE config_name = '" . $db->sql_escape($config_name) . "'";
$db->sql_query($sql);
if (!$db->sql_affectedrows() && !isset($portal_config[$config_name]))
{
$sql = 'INSERT INTO ' . PORTAL_CONFIG_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'config_name' => $config_name,
'config_value' => $config_value));
$db->sql_query($sql);
}
$portal_config[$config_name] = $config_value;
$cache->destroy('portal_config');
}
/**
* Get portal modules
*/
function obtain_portal_modules()
{
global $db, $cache, $portal_modules;
if (($portal_modules = $cache->get('portal_modules')) === false)
{
$portal_modules = $portal_cached_modules = array();
$sql = 'SELECT *
FROM ' . PORTAL_MODULES_TABLE . '
ORDER BY module_order ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$portal_cached_modules[] = $row;
$portal_modules[] = $row;
}
$db->sql_freeresult($result);
$cache->put('portal_modules', $portal_cached_modules);
}
return $portal_modules;
}
// fetch post for news & announce
function phpbb_fetch_posts($module_id, $forum_from, $permissions, $number_of_posts, $text_length, $time, $type, $start = 0, $invert = false)
{
global $db, $phpbb_root_path, $auth, $user, $bbcode_bitfield, $bbcode, $portal_config, $config;
$posts = $update_count = array();
$post_time = ($time == 0) ? '' : 'AND t.topic_time > ' . (time() - $time * 86400);
$forum_from = (strpos($forum_from, ',') !== FALSE) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
$str_where = '';
$topic_icons = array(0);
$have_icons = 0;
if ($permissions == true)
{
$disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
}
else
{
$disallow_access = array();
}
if ($invert == true)
{
$disallow_access = array_merge($disallow_access, $forum_from);
$forum_from = array();
}
$global_f = 0;
if (sizeof($forum_from))
{
$disallow_access = array_diff($forum_from, $disallow_access);
if (!sizeof($disallow_access))
{
return array();
}
foreach ($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "t.forum_id = $acc_id OR ";
if ($type == 'announcements' && $global_f < 1 && $acc_id > 0)
{
$global_f = $acc_id;
}
}
}
else
{
foreach ($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "t.forum_id <> $acc_id AND ";
}
}
switch($type)
{
case "announcements":
$topic_type = '((t.topic_type = ' . POST_ANNOUNCE . ') OR (t.topic_type = ' . POST_GLOBAL . '))';
$str_where = (strlen($str_where) > 0) ? 'AND (t.forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
$user_link = 't.topic_poster = u.user_id';
$post_link = 't.topic_first_post_id = p.post_id';
$topic_order = 't.topic_time DESC';
break;
case "news":
$topic_type = 't.topic_type = ' . POST_NORMAL;
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
$user_link = ($config['board3_news_style_' . $module_id]) ? 't.topic_poster = u.user_id' : (($config['board3_news_show_last_' . $module_id]) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
$post_link = ($config['board3_news_style_' . $module_id]) ? 't.topic_first_post_id = p.post_id' : (($config['board3_news_show_last_' . $module_id]) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
$topic_order = ($config['board3_news_show_last_' . $module_id]) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
break;
case "news_all":
$topic_type = '(t.topic_type <> ' . POST_ANNOUNCE . ') AND (t.topic_type <> ' . POST_GLOBAL . ')';
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
$user_link = ($config['board3_news_style_' . $module_id]) ? 't.topic_poster = u.user_id' : (($config['board3_news_show_last_' . $module_id]) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
$post_link = ($config['board3_news_style_' . $module_id]) ? 't.topic_first_post_id = p.post_id' : (($config['board3_news_show_last_' . $module_id]) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
$topic_order = ($config['board3_news_show_last_' . $module_id]) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
break;
default:
$topic_type = $str_where = $user_link = $post_link = '';
$topic_order = 't.topic_time DESC';
// maybe use trigger_error here, as this shouldn't happen
}
if ($type == 'announcements' && $global_f < 1)
{
$sql = 'SELECT
forum_id
FROM
' . FORUMS_TABLE . '
WHERE
forum_type = ' . FORUM_POST . '
' . str_replace('t.', '', $str_where) . '
ORDER BY
forum_id';
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!sizeof($row))
{
return array();
}
$global_f = $row['forum_id'];
}
$sql_array = array(
'SELECT' => 't.forum_id,
t.topic_id,
t.topic_last_post_id,
t.topic_last_post_time,
t.topic_time,
t.topic_title,
t.topic_attachment,
t.topic_views,
t.poll_title,
t.topic_posts_approved,
t.topic_posts_unapproved,
t.topic_posts_softdeleted,
t.topic_poster,
t.topic_type,
t.topic_status,
t.topic_last_poster_name,
t.topic_last_poster_id,
t.topic_last_poster_colour,
t.icon_id,
u.username,
u.user_id,
u.user_type,
u.user_colour,
p.post_id,
p.poster_id,
p.post_time,
p.post_text,
p.post_attachment,
p.post_username,
p.enable_smilies,
p.enable_bbcode,
p.enable_magic_url,
p.bbcode_bitfield,
p.bbcode_uid,
f.forum_name,
f.enable_icons',
'FROM' => array(
TOPICS_TABLE => 't',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(USERS_TABLE => 'u'),
'ON' => $user_link,
),
array(
'FROM' => array(FORUMS_TABLE => 'f'),
'ON' => 't.forum_id=f.forum_id',
),
array(
'FROM' => array(POSTS_TABLE => 'p'),
'ON' => $post_link,
),
),
'WHERE' => $topic_type . '
' . $post_time . '
AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_visibility = 1
AND t.topic_moved_id = 0
' . $str_where,
'ORDER_BY' => $topic_order,
);
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']);
$sql_array['SELECT'] .= ', tp.topic_posted';
$sql = $db->sql_build_query('SELECT', $sql_array);
if ($number_of_posts != 0)
{
$result = $db->sql_query_limit($sql, $number_of_posts, $start);
}
else
{
$result = $db->sql_query($sql);
}
$i = 0;
while ($row = $db->sql_fetchrow($result))
{
$attachments = array();
if (($auth->acl_get('u_download') && ($auth->acl_get('f_download', $row['forum_id']) || $row['forum_id'] == 0)) && $config['allow_attachments'] && $row['post_id'] && $row['post_attachment'])
{
// Pull attachment data
$sql2 = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE post_msg_id = '. $row['post_id'] .'
AND in_message = 0
ORDER BY filetime DESC';
$result2 = $db->sql_query($sql2);
while ($row2 = $db->sql_fetchrow($result2))
{
$attachments[] = $row2;
}
$db->sql_freeresult($result2);
}
$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
$len_check = $row['post_text'];
$maxlen = $text_length;
if (($text_length != 0) && (strlen($len_check) > $text_length))
{
$message = str_replace(array("\n", "\r"), array('<br />', "\n"), $row['post_text']);
$message = get_sub_taged_string($message, $row['bbcode_uid'], $maxlen);
$posts[$i]['striped'] = true;
}
else
{
$message = str_replace("\n", '<br/> ', $row['post_text']);
}
$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) + (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) + (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
$message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
if (!empty($attachments))
{
parse_attachments($row['forum_id'], $message, $attachments, $update_count);
}
if ($global_f < 1)
{
$global_f = $row['forum_id'];
}
$topic_icons[] = $row['enable_icons'];
$have_icons = ($row['icon_id'] > 0) ? 1 : $have_icons;
$posts[$i] = array_merge($posts[$i], array(
'post_text' => ap_validate($message),
'topic_id' => $row['topic_id'],
'topic_last_post_id' => $row['topic_last_post_id'],
'topic_type' => $row['topic_type'],
'topic_posted' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false,
'icon_id' => $row['icon_id'],
'topic_status' => $row['topic_status'],
'forum_id' => $row['forum_id'],
'topic_replies' => $row['topic_posts_approved'] + $row['topic_posts_unapproved'] + $row['topic_posts_softdeleted'],
'topic_replies_real' => $row['topic_posts_approved'],
'topic_time' => $user->format_date($row['post_time']),
'topic_last_post_time' => $row['topic_last_post_time'],
'topic_title' => $row['topic_title'],
'username' => $row['username'],
'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $row['post_username']),
'username_full_last' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour'], $row['topic_last_poster_name']),
'user_id' => $row['user_id'],
'user_type' => $row['user_type'],
'user_colour' => $row['user_colour'],
'poll' => ($row['poll_title']) ? true : false,
'attachment' => ($row['topic_attachment']) ? true : false,
'topic_views' => $row['topic_views'],
'forum_name' => $row['forum_name'],
'attachments' => (!empty($attachments)) ? $attachments : array(),
));
$posts['global_id'] = $global_f;
++$i;
}
$db->sql_freeresult($result);
$posts['topic_icons'] = ((max($topic_icons) > 0) && $have_icons) ? true : false;
$posts['topic_count'] = $i;
if ($global_f < 1)
{
return array();
}
else
{
return $posts;
}
}
/**
* Censor title, return short title
*
* @param $title string title to censor
* @param $limit int short title character limit
*
*/
function character_limit(&$title, $limit = 0)
{
$title = censor_text($title);
if ($limit > 0)
{
return (strlen(utf8_decode($title)) > $limit + 3) ? truncate_string($title, $limit) . '...' : $title;
}
else
{
return $title;
}
}
/**
* Cut post text to given length
*
* @param $message string post text
* @param $bbcode_uid string bbcode uid
* @param $length int The desired length
*/
function get_sub_taged_string($message, $bbcode_uid, $length)
{
global $portal_root_path, $phpEx;
if(!class_exists('phpbb_trim_message'))
{
include($portal_root_path . 'includes/trim_message/trim_message.' . $phpEx);
}
if(!class_exists('phpbb_trim_message_bbcodes'))
{
include($portal_root_path . 'includes/trim_message/bbcodes.' . $phpEx);
}
$object = new phpbb_trim_message($message, $bbcode_uid, $length);
// Ready to get parsed:
return $object->message();
}
function ap_validate($str)
{
$s = str_replace('<br />', '<br/>', $str);
return str_replace('</li><br/>', '</li>', $s);
}
/**
* Pagination routine, generates archive number sequence
*/
function generate_portal_pagination($base_url, $num_items, $per_page, $start_item, $type, $add_prevnext_text = false, $tpl_prefix = '')
{
global $template, $user;
switch($type)
{
case "announcements":
$pagination_type = 'ap';
$anker = '#a';
break;
case "news":
case "news_all":
$pagination_type = 'np';
$anker = '#n';
break;
default:
// this shouldn't happend @todo: use trigger_error()
$pagination_type = 'ap';
$anker = '#a';
}
// Make sure $per_page is a valid value
$per_page = ($per_page <= 0) ? 1 : $per_page;
$seperator = '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
$total_pages = ceil($num_items / $per_page);
if ($total_pages == 1 || !$num_items)
{
return false;
}
$on_page = floor($start_item / $per_page) + 1;
$url_delim = (strpos($base_url, '?') === false) ? '?' : '&amp;';
$page_string = ($on_page == 1) ? '<strong>1</strong>' : '<a href="' . $base_url . $anker .'">1</a>';
if ($total_pages > 5)
{
$start_cnt = min(max(1, $on_page - 4), $total_pages - 5);
$end_cnt = max(min($total_pages, $on_page + 4), 6);
$page_string .= ($start_cnt > 1) ? ' ... ' : $seperator;
for ($i = $start_cnt + 1; $i < $end_cnt; ++$i)
{
$page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($i - 1) * $per_page) . $anker . '">' . $i . '</a>';
if ($i < $end_cnt - 1)
{
$page_string .= $seperator;
}
}
$page_string .= ($end_cnt < $total_pages) ? ' ... ' : $seperator;
}
else
{
$page_string .= $seperator;
for ($i = 2; $i < $total_pages; ++$i)
{
$page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($i - 1) * $per_page) . $anker . '">' . $i . '</a>';
if ($i < $total_pages)
{
$page_string .= $seperator;
}
}
}
$page_string .= ($on_page == $total_pages) ? '<strong>' . $total_pages . '</strong>' : '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($total_pages - 1) * $per_page) . $anker . '">' . $total_pages . '</a>';
if ($add_prevnext_text)
{
if ($on_page != 1)
{
$page_string = '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($on_page - 2) * $per_page) . $anker . '">' . $user->lang['PREVIOUS'] . '</a>&nbsp;&nbsp;' . $page_string;
}
if ($on_page != $total_pages)
{
$page_string .= '&nbsp;&nbsp;<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . ($on_page * $per_page) . $anker . '">' . $user->lang['NEXT'] . '</a>';
}
}
$template->assign_vars(array(
$tpl_prefix . 'BASE_URL' => $base_url,
'A_' . $tpl_prefix . 'BASE_URL' => addslashes($base_url),
$tpl_prefix . 'PER_PAGE' => $per_page,
$tpl_prefix . 'PREVIOUS_PAGE' => ($on_page == 1) ? '' : $base_url . "{$url_delim}" . $pagination_type . '=' . (($on_page - 2) * $per_page) . $anker,
$tpl_prefix . 'NEXT_PAGE' => ($on_page == $total_pages) ? '' : $base_url . "{$url_delim}" . $pagination_type . '=' . ($on_page * $per_page) . $anker,
$tpl_prefix . 'TOTAL_PAGES' => $total_pages,
));
return $page_string;
}
/**
* Check if table exists
* @copyright (c) 2007 phpBB Group
*
* @param string $table_name The table name to check for
* @return bool true if table exists, else false
*/
function sql_table_exists($table_name)
{
global $db;
$db->sql_return_on_error(true);
$result = $db->sql_query_limit('SELECT * FROM ' . $db->sql_escape($table_name), 1);
$db->sql_return_on_error(false);
if ($result)
{
$db->sql_freeresult($result);
return true;
}
return false;
}
/**
* get topic tracking info for news
* based on get_complete_tracking_info of phpBB3
* this should reduce the queries for the news and announcements block
*/
function get_portal_tracking_info($fetch_news)
{
global $config, $user;
$last_read = $topic_ids = $forum_ids = $tracking_info = $rev_forum_ids = array();
/**
* group everything by the forum IDs
*/
$count = $fetch_news['topic_count'];
for ($i = 0; $i < $count; ++$i)
{
$tracking_info[$fetch_news[$i]['forum_id']][] = $fetch_news[$i]['topic_id'];
$topic_ids[] = $fetch_news[$i]['topic_id'];
$forum_ids[] = $fetch_news[$i]['forum_id'];
$rev_forum_ids[$fetch_news[$i]['topic_id']] = $fetch_news[$i]['forum_id']; // the other way round also helps
}
foreach ($tracking_info as $forum_id => $current_forum)
{
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
global $db;
$mark_time = array();
$sql = 'SELECT topic_id, mark_time
FROM ' . TOPICS_TRACK_TABLE . "
WHERE user_id = {$user->data['user_id']}
AND " . $db->sql_in_set('topic_id', $current_forum);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$last_read[$row['topic_id']] = $row['mark_time'];
}
$db->sql_freeresult($result);
$current_forum = array_diff($current_forum, array_keys($last_read));
if (sizeof($topic_ids))
{
$sql = 'SELECT forum_id, mark_time
FROM ' . FORUMS_TRACK_TABLE . "
WHERE user_id = {$user->data['user_id']}
AND " . $db->sql_in_set('forum_id', $forum_ids);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$mark_time[$row['forum_id']] = $row['mark_time'];
}
$db->sql_freeresult($result);
// @todo: do not use $current_forum here as this is already used by the outside foreach
foreach($forum_ids as $current_forum)
{
$user_lastmark[$current_forum] = (isset($mark_time[$current_forum])) ? $mark_time[$current_forum] : $user->data['user_lastmark'];
}
// @todo: also check if $user_lastmark has been defined for this specific forum_id
foreach ($topic_ids as $topic_id)
{
$last_read[$topic_id] = (!isset($last_read[$topic_id]) || $user_lastmark[$rev_forum_ids[$topic_id]] > $last_read[$topic_id]) ? $user_lastmark[$rev_forum_ids[$topic_id]] : $last_read[$topic_id];
}
}
}
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
{
global $tracking_topics;
if (!isset($tracking_topics) || !sizeof($tracking_topics))
{
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
}
if (!$user->data['is_registered'])
{
$user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0;
}
else
{
$user_lastmark = $user->data['user_lastmark'];
}
foreach ($topic_ids as $topic_id)
{
$topic_id36 = base_convert($topic_id, 10, 36);
if (isset($tracking_topics['t'][$topic_id36]))
{
$last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate'];
}
}
$topic_ids = array_diff($topic_ids, array_keys($last_read));
if (sizeof($topic_ids))
{
$mark_time = array();
if (isset($tracking_topics['f'][$forum_id]))
{
$mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate'];
}
$user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user_lastmark;
foreach ($topic_ids as $topic_id)
{
$last_read[$topic_id] = $user_lastmark;
}
}
}
}
return $last_read;
}
/**
* This function will install the basic set of portal modules
*
* only set $purge_modules to false if you already know that the table is empty
* set $u_action to where the user should be redirected after this
* note that already existing data won't be deleted from the config and portal_config
* just to make sure we don't overwrite anything, the IDs won't be reset
* !! this function should usually only be executed once upon installing the portal !!
* DO NOT set $purge_modules to false unless you want to auto-add all modules again after deleting them (i.e. if your database was corrupted)
*/
function board3_basic_install($mode = 'install', $purge_modules = true, $u_action = '')
{
global $db, $phpbb_root_path, $phpEx, $cache, $user, $table_prefix, $config;
// Shouldn't happen but we should check this nonetheless
if (!defined('PORTAL_MODULES_TABLE'))
{
include($phpbb_root_path . 'portal/includes/constants.' . $phpEx);
}
if ($mode == 'install')
{
$directory = $phpbb_root_path . 'portal/modules/';
if ($purge_modules)
{
$sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE;
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
}
/*
* this is a list of the basic modules that will be installed
* module_name => array(module_column, module_order)
*/
$modules_ary = array(
// left column
'portal_main_menu' => array(1, 1),
'portal_stylechanger' => array(1, 2),
'portal_birthday_list' => array(1, 3),
'portal_clock' => array(1, 4),
'portal_search' => array(1, 5),
'portal_attachments' => array(1, 7),
'portal_topposters' => array(1, 8),
'portal_latest_members' => array(1, 9),
'portal_link_us' => array(1, 10),
// center column
'portal_welcome' => array(2, 1),
'portal_recent' => array(2, 2),
'portal_announcements' => array(2, 3),
'portal_news' => array(2, 4),
'portal_poll' => array(2, 5),
'portal_whois_online' => array(2, 6),
// right column
'portal_user_menu' => array(3, 1),
'portal_statistics' => array(3, 2),
'portal_calendar' => array(3, 3),
'portal_leaders' => array(3, 4),
'portal_latest_bots' => array(3, 5),
'portal_links' => array(3, 6),
);
foreach ($modules_ary as $module_name => $module_data)
{
$class_name = $module_name . '_module';
if (!class_exists($class_name))
{
include($directory . $module_name . '.' . $phpEx);
}
if (!class_exists($class_name))
{
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
}
$c_class = new $class_name();
$sql_ary = array(
'module_classname' => substr($module_name, 7),
'module_column' => $module_data[0],
'module_order' => $module_data[1],
'module_name' => $c_class->name,
'module_image_src' => $c_class->image_src,
'module_group_ids' => '',
'module_image_width' => 16,
'module_image_height' => 16,
'module_status' => B3_MODULE_ENABLED,
);
$sql = 'INSERT INTO ' . PORTAL_MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$c_class->install($db->sql_nextid());
}
// Make sure we get rid of old data
$cache->destroy('portal_modules');
return $user->lang['PORTAL_BASIC_INSTALL'];
}
else
{
$skip_entries = array(
'board3_right_column_width',
'board3_left_column_width',
'board3_forum_index',
'board3_version_check',
'board3_right_column',
'board3_left_column',
'board3_enable',
'board3_portal_version',
'board3_phpbb_menu',
'board3_display_jumpbox',
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE config_name ' . $db->sql_like_expression(utf8_clean_string('board3_') . $db->any_char) . '
AND ' . $db->sql_in_set('config_name', $skip_entries, true);
$db->sql_query($sql);
return $user->lang['PORTAL_BASIC_UNINSTALL'];
}
}
/**
* check if the entered source file actually exists
*/
function check_file_src($value, $key, $module_id, $force_error = true)
{
global $db, $phpbb_root_path, $phpEx, $user;
$error = '';
// We check if the chosen file is present in all active styles
$sql = 'SELECT st.theme_path
FROM ' . STYLES_THEME_TABLE . ' st
LEFT JOIN ' . STYLES_TABLE . ' s
ON (st.theme_id = s.style_id)
WHERE s.style_active = 1';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if (!file_exists($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/images/portal/' . $value))
{
$error .= $user->lang['B3P_FILE_NOT_FOUND'] . ': styles/' . $row['theme_path'] . '/theme/images/portal/' . $value . '<br />';
}
}
$db->sql_freeresult($result);
if (!empty($error))
{
if ($force_error)
{
trigger_error($error . adm_back_link(append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=portal&amp;mode=config&amp;module_id=' . $module_id)), E_USER_WARNING );
}
else
{
return $error;
}
}
else
{
return false;
}
}
/**
* Get the groups a user is in
*
* @return array Array containing the user's groups
*/
function get_user_groups()
{
global $cache, $db, $user;
$groups_ary = $cache->get('_user_groups_' . $user->data['user_id']);
if ($groups_ary === false)
{
// get user's groups
$sql = 'SELECT group_id
FROM ' . USER_GROUP_TABLE . '
WHERE user_id = ' . (int) $user->data['user_id'] . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
$db->sql_freeresult($result);
// save data in cache for 60 seconds
$cache->put('_user_groups_' . $user->data['user_id'], $groups_ary, 60);
}
return $groups_ary;
}

View File

@@ -0,0 +1,70 @@
<?php
/**
*
* @package Board3 Portal v2
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
if (!defined('IN_PHPBB'))
{
exit;
}
function column_num_string($column)
{
switch ($column)
{
case 1:
return 'left';
case 2:
return 'center';
case 3:
return 'right';
case 4:
return 'top';
case 5:
return 'bottom';
default:
return 0;
}
}
function column_string_num($column)
{
switch ($column)
{
case 'left':
return 1;
case 'center':
return 2;
case 'right':
return 3;
case 'top':
return 4;
case 'bottom':
return 5;
default:
return 0;
}
}
function column_string_const($column)
{
switch ($column)
{
case 'top':
return 1;
case 'left':
return 2;
case 'center':
return 4;
case 'right':
return 8;
case 'bottom':
return 16;
default:
return 0;
}
}

View File

@@ -0,0 +1,357 @@
<?php
/**
*
* @package Board3 Portal v2
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @ignore
*/
class portal_upload
{
/*
* pre-defined vars
*/
private $upload_path;
private $u_action;
/*
* constructor function
*/
public function __construct($path, $u_action)
{
// This shouldn't happen, but we check for it anyways
if(is_dir($path))
{
$this->upload_path = $path;
$this->u_action = $u_action;
$this->upload_file();
}
}
/**
* upload module zip
*/
private function upload_file()
{
global $user, $phpbb_root_path, $phpEx, $phpbb_admin_path, $template;
// Upload part
$user->add_lang('posting'); // For error messages
include($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
$upload = new fileupload();
// Only allow ZIP files
$upload->set_allowed_extensions(array('zip'));
$file = $upload->form_upload('modupload');
// this is for module zips so don't allow anything else
if (empty($file->filename) || !preg_match('.zip.', $file->get('realname')))
{
trigger_error($user->lang['NO_FILE_B3P'] . adm_back_link($this->u_action), E_USER_WARNING);
}
else
{
if (!$file->init_error && !sizeof($file->error))
{
$file->clean_filename('real');
$file->move_file(str_replace($phpbb_root_path, '', $this->upload_path), true, true);
if (!sizeof($file->error))
{
include($phpbb_root_path . 'includes/functions_compress.' . $phpEx);
$mod_dir = $this->upload_path . str_replace('.zip', '', $file->get('realname'));
// make sure we don't already have the new folder
if(is_dir($mod_dir))
{
$this->directory_delete($mod_dir);
}
$compress = new compress_zip('r', $file->destination_file);
$compress->extract($mod_dir . '_tmp/');
$compress->close();
$folder_contents = $this->cut_folder(scandir($mod_dir . '_tmp/', 1)); // This ensures dir is at index 0
// We need to check if there's a main directory inside the temp MOD directory
if (sizeof($folder_contents) == 1)
{
// We need to move that directory then
$this->directory_move($mod_dir . '_tmp/' . $folder_contents[0], $this->upload_path . $folder_contents[0]);
$new_mod_dir = $this->upload_path . $folder_contents[0];
}
else if (!is_dir($mod_dir))
{
// Change the name of the directory by moving to directory without _tmp in it
$this->directory_move($mod_dir . '_tmp/', $mod_dir);
$new_mod_dir = $mod_dir;
}
$this->directory_delete($mod_dir . '_tmp/');
// make sure we set $mod_dir to the correct folder after the above step
$mod_dir = (isset($new_mod_dir)) ? $new_mod_dir : $mod_dir;
// if we got until here set $actions['NEW_FILES']
$actions['NEW_FILES'] = array();
// Now we need to get the files inside the folders
//$folder_contents = $this->cut_folder(scandir($mod_dir));
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($mod_dir, FilesystemIterator::SKIP_DOTS)); // requires PHP 5
foreach($iterator as $cur_file)
{
$cur_path = $cur_file->getPathname();
$cur_path = str_replace('\\', '/', $cur_path); // we want unix-like paths
$cur_path = str_replace($mod_dir . '/', '', $cur_path);
$cut_pos = strpos($cur_path, '/');
// Only allow files in adm, language, portal and styles folder and a license.txt
if(!in_array(substr($cur_path, 0, $cut_pos), array('adm', 'language', 'portal', 'styles')) && $cur_file->getFilename() != 'license.txt')
{
$file->remove();
$this->directory_delete($mod_dir);
trigger_error($user->lang['MODULE_CORRUPTED'] . adm_back_link(append_sid("{$phpbb_admin_path}index.$phpEx", 'i=portal&amp;mode=modules')), E_USER_WARNING);
}
else
{
$actions['NEW_FILES'][$mod_dir . '/' . $cur_path] = $phpbb_root_path . $cur_path;
}
}
if (!sizeof($file->error))
{
// Let's start moving our files where they belong
foreach ($actions['NEW_FILES'] as $source => $target)
{
/*
* make sure we don't try to copy folders
* folders will be created if necessary in copy_content
*/
if(is_dir($source))
{
continue;
}
$status = $this->copy_content($source, $target);
if ($status !== true && !is_null($status))
{
$module_installed = false;
}
$template->assign_block_vars('new_files', array(
'S_SUCCESS' => ($status === true) ? true : false,
'S_NO_COPY_ATTEMPT' => (is_null($status)) ? true : false,
'SOURCE' => $source,
'TARGET' => $target,
));
}
$template->assign_vars(array(
'S_MOD_SUCCESSBOX' => true,
'MESSAGE' => $user->lang['MODULE_UPLOADED'],
'U_RETURN' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=portal&amp;mode=modules'),
'S_INSTALL' => true,
));
}
}
}
$file->remove();
$this->directory_delete($mod_dir);
if ($file->init_error || sizeof($file->error))
{
trigger_error((sizeof($file->error) ? implode('<br />', $file->error) : $user->lang['MOD_UPLOAD_INIT_FAIL']) . adm_back_link($this->u_action), E_USER_WARNING);
}
$this->tpl_name = 'portal/acp_portal_upload_module';
$this->page_title = $user->lang['ACP_PORTAL_UPLOAD'];
$template->assign_vars(array(
'L_TITLE' => $user->lang['ACP_PORTAL_UPLOAD'],
'L_TITLE_EXPLAIN' => '',
'S_ERROR' => false, // if we get here, there was no error or we can ignore it
'ERROR_MSG' => '',
'U_ACTION' => $this->u_action,
));
}
}
/**
* Cuts the unneeded '.' and '..' from the folder content info scandir returns
*
* @return: cut array
*/
private function cut_folder($folder_content)
{
$cut_array = array('.', '..');
$folder_content = array_diff($folder_content, $cut_array);
return $folder_content;
}
private function directory_move($src, $dest)
{
$src_contents = scandir($src);
if (!is_dir($dest) && is_dir($src))
{
mkdir($dest . '/', 0755);
}
foreach ($src_contents as $src_entry)
{
if ($src_entry != '.' && $src_entry != '..')
{
if (is_dir($src . '/' . $src_entry) && !is_dir($dest . '/' . $src_entry))
{
$this->directory_move($src . '/' . $src_entry, $dest . '/' . $src_entry);
}
else if (is_file($src . '/' . $src_entry) && !is_file($dest . '/' . $src_entry))
{
@copy($src . '/' . $src_entry, $dest . '/' . $src_entry);
@chmod($dest . '/' . $src_entry, 0644);
}
}
}
}
/**
* the following functions are from the AutoMOD package
* @copyright (c) 2008 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
private function directory_delete($dir)
{
if (!file_exists($dir))
{
return true;
}
if (!is_dir($dir) && is_file($dir))
{
@chmod($dir, 0644);
return @unlink($dir);
}
foreach (scandir($dir) as $item)
{
if ($item == '.' || $item == '..')
{
continue;
}
if (!$this->directory_delete($dir . "/" . $item))
{
@chmod($dir . "/" . $item, 0644);
if (!$this->directory_delete($dir . "/" . $item))
{
return false;
}
}
}
return @rmdir($dir);
}
/**
* Moves files or complete directories
*
* @param $from string Can be a file or a directory. Will move either the file or all files within the directory
* @param $to string Where to move the file(s) to. If not specified then will get moved to the root folder
* @param $strip Used for FTP only
* @return mixed: Bool true on success, error string on failure, NULL if no action was taken
*
* NOTE: function should preferably not return in case of failure on only one file.
* The current method makes error handling difficult
*/
private function copy_content($from, $to = '', $strip = '')
{
global $phpbb_root_path, $user, $config;
if (strpos($from, $phpbb_root_path) !== 0)
{
$from = $phpbb_root_path . $from;
}
if (strpos($to, $phpbb_root_path) !== 0)
{
$to = $phpbb_root_path . $to;
}
$dirname_check = dirname($to);
if (!is_dir($dirname_check))
{
if ($this->recursive_mkdir($dirname_check) === false)
{
return sprintf($user->lang['MODULE_UPLOAD_MKDIR_FAILURE'], $dirname_check);
}
}
// leave a backup file if it already exists
if(file_exists($to))
{
// remove old backup file first
if(file_exists($to . '.bak'))
{
@chmod($to . '.bak', 0644);
unlink($to . '.bak');
}
@rename($to, $to . '.bak');
@chmod($to, 0644);
}
if (!@copy($from, $to))
{
return sprintf($user->lang['MODULE_COPY_FAILURE'], $to);
}
@chmod($to, 0644);
return true;
}
/**
* @author Michal Nazarewicz (from the php manual)
* Creates all non-existant directories in a path
* @param $path - path to create
* @param $mode - CHMOD the new dir to these permissions
* @return bool
*/
private function recursive_mkdir($path, $mode = false)
{
if (!$mode)
{
$mode = octdec(0777);
}
$dirs = explode('/', $path);
$count = sizeof($dirs);
$path = '.';
for ($i = 0; $i < $count; $i++)
{
$path .= '/' . $dirs[$i];
if (!is_dir($path))
{
@mkdir($path, $mode);
@chmod($path, $mode);
if (!is_dir($path))
{
return false;
}
}
}
return true;
}
}

View File

@@ -0,0 +1,189 @@
<?php
/**
*
* @package Board3 Portal v2
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* A copy of Handyman` s MOD version check, to view it on the gallery overview
*/
function mod_version_check($phpbb_root_path, $root_path, $return_version = false)
{
global $user, $template;
global $phpEx;
if (!function_exists('get_remote_file'))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
}
// load version files
$class_functions = array();
include($root_path . 'adm/mods/board3_portal_check_version.' . $phpEx);
$class_name = 'board3_portal_check_version';
$version_check = new $class_name();
$var = call_user_func(array($version_check, 'version'));
// Get current and latest version
$errstr = '';
$errno = 0;
if (!$return_version)
{
$mod_version = $user->lang['NO_INFO'];
$data = array(
'title' => $var['title'],
'description' => $user->lang['NO_INFO'],
'download' => $user->lang['NO_INFO'],
'announcement' => $user->lang['NO_INFO'],
);
}
$file = get_remote_file($var['file'][0], '/' . $var['file'][1], $var['file'][2], $errstr, $errno);
if ($file)
{
if (version_compare(PHP_VERSION, '5.0.0', '<'))
{
$row = array();
$data_array = mvc_setup_array($file);
$row = $data_array['mods'][$var['tag']];
$mod_version = $row['mod_version'];
$mod_version = $mod_version['major'] . '.' . $mod_version['minor'] . '.' . $mod_version['revision'] . $mod_version['release'];
$data = array(
'title' => $row['title'],
'description' => $row['description'],
'download' => $row['download'],
'announcement' => $row['announcement'],
);
}
else
{
// let's not stop the page from loading if a mod author messed up their mod check file
// also take care of one of the easiest ways to mess up an xml file: "&"
$mod = @simplexml_load_string(str_replace('&', '&amp;', $file));
if (isset($mod->$var['tag']))
{
$row = $mod->$var['tag'];
$mod_version = $row->mod_version->major . '.' . $row->mod_version->minor . '.' . $row->mod_version->revision . $row->mod_version->release;
$data = array(
'title' => $row->title,
'description' => $row->description,
'download' => $row->download,
'announcement' => $row->announcement,
);
}
}
}
// remove spaces from the version in the mod file stored locally
$version = str_replace(' ', '', $var['version']);
if ($return_version)
{
return $version;
}
$version_compare = (version_compare($version, $mod_version, '<')) ? false : true;
$template->assign_block_vars('mods', array(
'ANNOUNCEMENT' => $data['announcement'],
'AUTHOR' => $var['author'],
'CURRENT_VERSION' => $version,
'DESCRIPTION' => $data['description'],
'DOWNLOAD' => $data['download'],
'LATEST_VERSION' => $mod_version,
'TITLE' => $data['title'],
'UP_TO_DATE' => sprintf((!$version_compare) ? $user->lang['NOT_UP_TO_DATE'] : $user->lang['UP_TO_DATE'], $data['title']),
'S_UP_TO_DATE' => $version_compare,
'U_AUTHOR' => 'http://www.phpbb.com/community/memberlist.php?mode=viewprofile&un=' . $var['author'],
));
}
/**
* this is for php4 only
* kind of a dirty hack, but since I get the say on how the xml is done, I can have 4 levels max
*/
function mvc_setup_array($xml)
{
// Fire up the built-in XML parser
$values = $index = array();
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
// this takes care of one possible xml error
$xml = str_replace('&', '&amp;', $xml);
// Set tag names and values
xml_parse_into_struct($parser, $xml, $values, $index);
// Close down XML parser
xml_parser_free($parser);
$ary = array();
foreach ($values as $value)
{
switch (trim($value['level']))
{
case 1:
if ($value['type'] == 'open')
{
$one = $value['tag'];
}
else if ($value['type'] == 'complete')
{
$ary[$value['tag']] = $value['value'];
}
break;
case 2:
if ($value['type'] == 'open')
{
$two = $value['tag'];
}
else if ($value['type'] == 'complete')
{
$ary[$one][$value['tag']] = $value['value'];
}
break;
case 3:
if ($value['type'] == 'open')
{
$three = $value['tag'];
}
else if ($value['type'] == 'complete')
{
$ary[$one][$two][$value['tag']] = $value['value'];
}
break;
case 4:
if ($value['type'] == 'complete')
{
$ary[$one][$two][$three][$value['tag']] = isset($value['value']) ? $value['value'] : '';
}
break;
}
}
return $ary;
}

View File

@@ -0,0 +1,7 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>

7
root/portal/index.html Normal file
View File

@@ -0,0 +1,7 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>

View File

@@ -0,0 +1,470 @@
<?php
/**
*
* @package Board3 Portal v2 - Announcements
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Modulname
*/
class portal_announcements_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'GLOBAL_ANNOUNCEMENTS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_announcements_module';
public function get_template_center($module_id)
{
global $config, $template, $db, $user, $auth, $cache, $phpEx, $phpbb_root_path;
$announcement = request_var('announcement', -1);
$announcement = ($announcement > $config['board3_announcements_length_' . $module_id] -1) ? -1 : $announcement;
$start = request_var('ap', 0);
$start = ($start < 0) ? 0 : $start;
// Fetch announcements from portal/includes/functions.php with check if "read full" is requested.
$portal_announcement_length = ($announcement < 0) ? $config['board3_announcements_length_' . $module_id] : 0;
$fetch_news = phpbb_fetch_posts($module_id, $config['board3_global_announcements_forum_' . $module_id], $config['board3_announcements_permissions_' . $module_id], $config['board3_number_of_announcements_' . $module_id], $portal_announcement_length, $config['board3_announcements_day_' . $module_id], 'announcements', $start, $config['board3_announcements_forum_exclude_' . $module_id]);
// Any announcements present? If not terminate it here.
if (sizeof($fetch_news) == 0)
{
$template->assign_block_vars('announcements_center_row', array(
'S_NO_TOPICS' => true,
'S_NOT_LAST' => false
));
$template->assign_var('S_CAN_READ', false);
}
else
{
// Count number of posts for announcements archive, considering if permission check is dis- or enabled.
if ($config['board3_announcements_archive_' . $module_id])
{
$permissions = $config['board3_announcements_permissions_' . $module_id];
$forum_from = $config['board3_global_announcements_forum_' . $module_id];
$forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
$time = ($config['board3_announcements_day_' . $module_id] == 0) ? 0 : $config['board3_announcements_day_' . $module_id];
$post_time = ($time == 0) ? '' : 'AND topic_time > ' . (time() - $time * 86400);
$str_where = '';
if($permissions == true)
{
$disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
}
else
{
$disallow_access = array();
}
if($config['board3_announcements_forum_exclude_' . $module_id] == true)
{
$disallow_access = array_merge($disallow_access, $forum_from);
$forum_from = array();
}
$global_f = 0;
if(sizeof($forum_from))
{
$disallow_access = array_diff($forum_from, $disallow_access);
if(!sizeof($disallow_access))
{
return array();
}
foreach($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "forum_id = $acc_id OR ";
if($global_f < 1 && $acc_id > 0)
{
$global_f = $acc_id;
}
}
}
else
{
foreach($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "forum_id <> $acc_id AND ";
}
}
$str_where = (strlen($str_where) > 0) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
$sql = 'SELECT COUNT(topic_id) AS num_topics
FROM ' . TOPICS_TABLE . '
WHERE ((topic_type = ' . POST_GLOBAL . ')
OR topic_type = ' . POST_ANNOUNCE . ')
AND topic_visibility = 1
AND topic_moved_id = 0
' . $post_time . '
' . $str_where;
$result = $db->sql_query($sql);
$total_announcements = (int) $db->sql_fetchfield('num_topics');
$db->sql_freeresult($result);
}
$topic_tracking_info = (get_portal_tracking_info($fetch_news));
if($announcement < 0)
// Show the announcements overview
{
$count = $fetch_news['topic_count'];
for ($i = 0; $i < $count; $i++)
{
if(isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true)
{
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $user->lang['READ_FULL'];
}
else
{
$open_bracket = '';
$close_bracket = '';
$read_full = '';
}
// unread?
$forum_id = $fetch_news[$i]['forum_id'];
$topic_id = $fetch_news[$i]['topic_id'];
//$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
$read_full_url = (isset($_GET['ap'])) ? 'ap='. $start . '&amp;announcement=' . $i . '#a' . $i : 'announcement=' . $i . '#a' . $i;
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
if ($config['board3_announcements_archive_' . $module_id])
{
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
}
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
$folder_img = $folder_alt = $topic_type = $folder = $folder_new = '';
switch ($fetch_news[$i]['topic_type'])
{
case POST_GLOBAL:
$folder = 'global_read';
$folder_new = 'global_unread';
break;
case POST_ANNOUNCE:
$folder = 'announce_read';
$folder_new = 'announce_unread';
break;
default:
$folder = 'topic_read';
$folder_new = 'topic_unread';
if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
{
$folder .= '_hot';
$folder_new .= '_hot';
}
break;
}
if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED)
{
$folder .= '_locked';
$folder_new .= '_locked';
}
if ($fetch_news[$i]['topic_type'] == POST_GLOBAL)
{
$global_announce_list[$fetch_news[$i]['topic_id']] = true;
}
if ($fetch_news[$i]['topic_posted'])
{
$folder .= '_mine';
$folder_new .= '_mine';
}
$folder_img = ($unread_topic) ? $folder_new : $folder;
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
// Grab icons
$icons = $cache->obtain_icons();
$template->assign_block_vars('announcements_center_row', array(
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
'POSTER_FULL' => $fetch_news[$i]['username_full'],
'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'],
'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $fetch_news[$i]['user_id']) : '',
'TIME' => $fetch_news[$i]['topic_time'],
'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']),
'TEXT' => $fetch_news[$i]['post_text'],
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'A_ID' => $i,
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt],
'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'),
'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '',
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id . '&amp;p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id . '&amp;view=unread#unread'),
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&amp;' . (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url),
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false,
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
if(!empty($fetch_news[$i]['attachments']))
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
$template->assign_block_vars('announcements_center_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
if ($config['board3_number_of_announcements_' . $module_id] != 0 && $config['board3_announcements_archive_' . $module_id])
{
$template->assign_vars(array(
'AP_PAGINATION' => $pagination,
'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
'AP_PAGE_NUMBER' => on_page($total_announcements, $config['board3_number_of_announcements_' . $module_id], $start))
);
}
}
}
else
// Show "read full" page
{
$i = $announcement;
/**
* redirect to portal page if the specified announcement does not exist
* force #top anchor in order to get rid of the #a anchor
*/
if (!isset($fetch_news[$i]))
{
redirect(append_sid($phpbb_root_path . 'portal.' . $phpEx, '#top'));
}
$forum_id = $fetch_news[$i]['forum_id'];
$topic_id = $fetch_news[$i]['topic_id'];
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $user->lang['BACK'];
$real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
$read_full_url = (isset($_GET['ap'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "ap=$start#a$i") : append_sid("{$phpbb_root_path}portal.$phpEx#a$i");
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
if ($config['board3_announcements_archive_' . $module_id])
{
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
}
$template->assign_block_vars('announcements_center_row', array(
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
'POSTER_FULL' => $fetch_news[$i]['username_full'],
'TIME' => $fetch_news[$i]['topic_time'],
'TEXT' => $fetch_news[$i]['post_text'],
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'A_ID' => $i,
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id . '&amp;p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&amp;' . (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'U_READ_FULL' => $read_full_url,
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
if(!empty($fetch_news[$i]['attachments']))
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
$template->assign_block_vars('announcements_center_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
if ($config['board3_number_of_announcements_' . $module_id] <> 0 && $config['board3_announcements_archive_' . $module_id])
{
$template->assign_vars(array(
'AP_PAGINATION' => $pagination,
'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
'AP_PAGE_NUMBER' => on_page($total_announcements, $config['board3_number_of_announcements_' . $module_id], $start))
);
}
}
}
$topic_icons = false;
if(!empty($fetch_news['topic_icons']))
{
$topic_icons = true;
}
$template->assign_vars(array(
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'),
'S_DISPLAY_ANNOUNCEMENTS_RVS' => ($config['board3_show_announcements_replies_views_' . $module_id]) ? true : false,
'S_TOPIC_ICONS' => $topic_icons,
));
if ($config['board3_announcements_style_' . $module_id])
{
return 'announcements_center_compact.html';
}
else
{
return 'announcements_center.html';
}
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
'board3_announcements_style_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_number_of_announcements_' . $module_id => array('lang' => 'PORTAL_NUMBER_OF_ANNOUNCEMENTS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_announcements_day_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_DAY' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_announcements_length_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_global_announcements_forum_' . $module_id => array('lang' => 'PORTAL_GLOBAL_ANNOUNCEMENTS_FORUM' , 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'),
'board3_announcements_forum_exclude_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_FORUM_EXCLUDE', 'validate' => 'string', 'type' => 'radio:yes_no', 'explain' => true),
'board3_announcements_archive_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_ARCHIVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_announcements_permissions_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_PERMISSIONS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_show_announcements_replies_views_' . $module_id => array('lang' => 'PORTAL_SHOW_REPLIES_VIEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_announcements_style_' . $module_id, 0);
set_config('board3_number_of_announcements_' . $module_id, 1);
set_config('board3_announcements_day_' . $module_id, 0);
set_config('board3_announcements_length_' . $module_id, 200);
set_config('board3_global_announcements_forum_' . $module_id, '');
set_config('board3_announcements_forum_exclude_' . $module_id, 0);
set_config('board3_announcements_archive_' . $module_id, 1);
set_config('board3_announcements_permissions_' . $module_id, 1);
set_config('board3_show_announcements_replies_views_' . $module_id, 1);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_announcements_style_' . $module_id,
'board3_number_of_announcements_' . $module_id,
'board3_announcements_day_' . $module_id,
'board3_announcements_length_' . $module_id,
'board3_global_announcements_forum_' . $module_id,
'board3_announcements_forum_exclude_' . $module_id,
'board3_announcements_archive_' . $module_id,
'board3_announcements_permissions_' . $module_id,
'board3_show_announcements_replies_views_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
// Create forum select box
public function select_forums($value, $key, $module_id)
{
global $user, $config;
$forum_list = make_forum_select(false, false, true, true, true, false, true);
$selected = array();
if(isset($config[$key]) && strlen($config[$key]) > 0)
{
$selected = explode(',', $config[$key]);
}
// Build forum options
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
foreach ($forum_list as $f_id => $f_row)
{
$s_forum_options .= '<option value="' . $f_id . '"' . ((in_array($f_id, $selected)) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
}
$s_forum_options .= '</select>';
return $s_forum_options;
}
// Store selected forums
public function store_selected_forums($key, $module_id)
{
global $db, $cache;
// Get selected forums
$values = request_var($key, array(0 => ''));
$news = implode(',', $values);
set_config($key, $news);
}
}

View File

@@ -0,0 +1,296 @@
<?php
/**
*
* @package Board3 Portal v2 - Attachments
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Modulname
*/
class portal_attachments_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 31;
/**
* Default modulename
*/
public $name = 'PORTAL_ATTACHMENTS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_attach.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_attachments_module';
public function get_template_center($module_id)
{
return $this->parse_template($module_id, 'center');
}
public function get_template_side($module_id)
{
return $this->parse_template($module_id, 'side');
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_ATTACHMENTS_NUMBER_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_ATTACHMENTS_NUMBER_SETTINGS',
'board3_attachments_number_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_NUMBER' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_attach_max_length_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_MAX_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_attachments_forum_ids_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_FORUM_IDS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'),
'board3_attachments_forum_exclude_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_FORUM_EXCLUDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_attachments_filetype_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_FILETYPE', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_filetype', 'submit' => 'store_filetypes'),
'board3_attachments_exclude_' . $module_id => array('lang' => 'PORTAL_ATTACHMENTS_EXCLUDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_attachments_number_' . $module_id, 8);
set_config('board3_attach_max_length_' . $module_id, 15);
set_config('board3_attachments_forum_ids_' . $module_id, '');
set_config('board3_attachments_forum_exclude_' . $module_id, 0);
set_config('board3_attachments_filetype_' . $module_id, '');
set_config('board3_attachments_exclude_' . $module_id, 0);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_attachments_number_' . $module_id,
'board3_attach_max_length_' . $module_id,
'board3_attachments_forum_ids_' . $module_id,
'board3_attachments_forum_exclude_' . $module_id,
'board3_attachments_filetype_' . $module_id,
'board3_attachments_exclude_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
// Create select box for attachment filetype
public function select_filetype($value, $key, $module_id)
{
global $db, $user, $config;
// Get extensions
$sql = 'SELECT *
FROM ' . EXTENSIONS_TABLE . '
ORDER BY extension ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$extensions[] = $row;
}
$selected = array();
if(isset($config['board3_attachments_filetype_' . $module_id]) && strlen($config['board3_attachments_filetype_' . $module_id]) > 0)
{
$selected = explode(',', $config['board3_attachments_filetype_' . $module_id]);
}
// Build options
$ext_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
foreach ($extensions as $id => $ext)
{
$ext_options .= '<option value="' . $ext['extension'] . '"' . ((in_array($ext['extension'], $selected)) ? ' selected="selected"' : '') . '>' . $ext['extension'] . '</option>';
}
$ext_options .= '</select>';
return $ext_options;
}
// Store selected filetypes
public function store_filetypes($key, $module_id)
{
global $db, $cache;
// Get selected extensions
$values = request_var($key, array(0 => ''));
$filetypes = implode(',', $values);
set_config('board3_attachments_filetype_' . $module_id, $filetypes);
}
// Create forum select box
public function select_forums($value, $key)
{
global $user, $config;
$forum_list = make_forum_select(false, false, true, true, true, false, true);
$selected = array();
if(isset($config[$key]) && strlen($config[$key]) > 0)
{
$selected = explode(',', $config[$key]);
}
// Build forum options
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
foreach ($forum_list as $f_id => $f_row)
{
$s_forum_options .= '<option value="' . $f_id . '"' . ((in_array($f_id, $selected)) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
}
$s_forum_options .= '</select>';
return $s_forum_options;
}
// Store selected forums
public function store_selected_forums($key)
{
global $db, $cache;
// Get selected extensions
$values = request_var($key, array(0 => ''));
$news = implode(',', $values);
set_config($key, $news);
}
/**
* Parse template variables for module
*
* @param int $module_id Module ID
* @param string $type Module type (center or side)
*/
protected function parse_template($module_id, $type)
{
global $config, $template, $db, $user, $auth, $phpEx, $phpbb_root_path;
$attach_forums = false;
$where = '';
$filetypes = array();
// Get filetypes and put them into an array
if(isset($config['board3_attachments_filetype_' . $module_id]) && strlen($config['board3_attachments_filetype_' . $module_id]) > 0)
{
$filetypes = explode(',', $config['board3_attachments_filetype_' . $module_id]);
}
if($config['board3_attachments_forum_ids_' . $module_id] !== '')
{
$attach_forums_config = (strpos($config['board3_attachments_forum_ids_' . $module_id], ',') !== false) ? explode(',', $config['board3_attachments_forum_ids_' . $module_id]) : array($config['board3_attachments_forum_ids_' . $module_id]);
$forum_list = array_unique(array_keys($auth->acl_getf('f_read', true)));
if($config['board3_attachments_forum_exclude_' . $module_id])
{
$forum_list = array_unique(array_diff($forum_list, $attach_forums_config));
}
else
{
$forum_list = array_unique(array_intersect($attach_forums_config, $forum_list));
}
}
else
{
$forum_list = array_unique(array_keys($auth->acl_getf('f_read', true)));
}
if(sizeof($forum_list))
{
$attach_forums = true;
$where = 'AND ' . $db->sql_in_set('t.forum_id', $forum_list);
}
if(sizeof($filetypes))
{
if($config['board3_attachments_exclude_' . $module_id])
{
$where .= ' AND ' . $db->sql_in_set('a.extension', $filetypes, true);
}
else
{
$where .= ' AND ' . $db->sql_in_set('a.extension', $filetypes);
}
}
if($attach_forums === true)
{
// Just grab all attachment info from database
$sql = 'SELECT
a.*,
t.forum_id
FROM
' . ATTACHMENTS_TABLE . ' a,
' . TOPICS_TABLE . ' t
WHERE
a.topic_id <> 0
AND a.topic_id = t.topic_id
' . $where . '
ORDER BY
filetime ' . ((!$config['display_order']) ? 'DESC' : 'ASC') . ', post_msg_id ASC';
$result = $db->sql_query_limit($sql, $config['board3_attachments_number_' . $module_id]);
while ($row = $db->sql_fetchrow($result))
{
$size_lang = ($row['filesize'] >= 1048576) ? $user->lang['MIB'] : (($row['filesize'] >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);
$row['filesize'] = ($row['filesize'] >= 1048576) ? round((round($row['filesize'] / 1048576 * 100) / 100), 2) : (($row['filesize'] >= 1024) ? round((round($row['filesize'] / 1024 * 100) / 100), 2) : $row['filesize']);
$raw_filename = utf8_substr($row['real_filename'], 0, strrpos($row['real_filename'], '.'));
$replace = character_limit($raw_filename, $config['board3_attach_max_length_' . $module_id]);
$template->assign_block_vars('attach_' . $type, array(
'FILESIZE' => $row['filesize'] . ' ' . $size_lang,
'FILETIME' => $user->format_date($row['filetime']),
'DOWNLOAD_COUNT' => (int) $row['download_count'], // grab downloads count
'FILENAME' => $replace,
'REAL_FILENAME' => $row['real_filename'],
'PHYSICAL_FILENAME' => basename($row['physical_filename']),
'ATTACH_ID' => $row['attach_id'],
'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? $post_ids[$row['attach_id']] : '',
'POST_MSG_ID' => $row['post_msg_id'], // grab post ID to redirect to post
'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $row['attach_id']),
'U_TOPIC' => append_sid($phpbb_root_path . 'viewtopic.'.$phpEx, 'p='.$row['post_msg_id'].'#p'.$row['post_msg_id']),
));
}
$db->sql_freeresult($result);
$template->assign_var('S_DISPLAY_ATTACHMENTS', true);
}
else
{
$template->assign_var('S_DISPLAY_ATTACHMENTS', false);
}
return 'attachments_' . $type . '.html';
}
}

View File

@@ -0,0 +1,181 @@
<?php
/**
*
* @package Board3 Portal v2 - Birthday List
* @copyright (c) Board3 Group ( www.board3.de )
* @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
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'BIRTHDAYS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_birthday.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_birthday_list_module';
public function get_template_side($module_id)
{
global $config, $template, $db, $user, $phpbb_root_path;
// Generate birthday list if required ... / borrowed from index.php 3.0.6
$birthday_list = $birthday_ahead_list = '';
if ($config['load_birthdays'] && $config['allow_birthdays'])
{
$time = $user->create_datetime();
$now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
$cache_days = $config['board3_birthdays_ahead_' . $module_id];
$sql_days = '';
while ($cache_days > 0)
{
$day = phpbb_gmgetdate($time->getTimestamp() + 86400 * $cache_days + $time->getOffset());
$like_expression = $db->sql_like_expression($db->any_char . (sprintf('%2d-%2d-', $day['mday'], $day['mon'])) . $db->any_char);
$sql_days .= " OR u.user_birthday " . $like_expression . "";
$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;
}
$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 = true;
$template->assign_block_vars('board3_birthday_list', array(
'USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : '',
));
}
elseif ($config['board3_birthdays_ahead_' . $module_id] > 0)
{
$birthday_ahead_list = true;
$template->assign_block_vars('board3_birthday_ahead_list', array(
'USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : '',
'DATE' => $this->format_birthday($user, $row['user_birthday'], 'd M'),
));
}
}
$db->sql_freeresult($result);
}
// Assign index specific vars
$template->assign_vars(array(
'BIRTHDAY_LIST' => $birthday_list,
'BIRTHDAYS_AHEAD_LIST' => ($config['board3_birthdays_ahead_' . $module_id]) ? $birthday_ahead_list : '',
'L_BIRTHDAYS_AHEAD' => sprintf($user->lang['BIRTHDAYS_AHEAD'], $config['board3_birthdays_ahead_' . $module_id]),
'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false,
'S_DISPLAY_BIRTHDAY_AHEAD_LIST' => ($config['board3_birthdays_ahead_' . $module_id] > 0) ? true : false,
));
return 'birthdays_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_BIRTHDAYS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_BIRTHDAYS_SETTINGS',
'board3_birthdays_ahead_' . $module_id => array('lang' => 'PORTAL_BIRTHDAYS_AHEAD', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_birthdays_ahead_' . $module_id, 30);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_birthdays_ahead_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
/**
* Format birthday for span title
*
* @param object $user phpBB user object
* @param string $birthday User's birthday from database
* @param string $date_settings Settings for date() function
*/
protected function format_birthday($user, $birthday, $date_settings)
{
if (!preg_match('/(?:[0-9])+-+(?:[0-9]{2})+-+(?:[0-9]{4})/', $birthday, $match))
{
return '';
}
$date = explode('-', $birthday);
$time = mktime(0, 0, 0, $date[1], $date[0], $date[2]);
$lang_dates = array_filter($user->lang['datetime'], 'is_string');
return strtr(date($date_settings, $time), $lang_dates);
}
}

View File

@@ -0,0 +1,691 @@
<?php
/**
*
* @package Board3 Portal v2 - Calendar
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Calendar
*/
class portal_calendar_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'PORTAL_CALENDAR';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_calendar.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_calendar_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = 'acp_portal_calendar';
/**
* additional variables
*/
private $mini_cal_fdow;
/**
* User datetime object
*/
private $time;
/**
* constants
*/
const TIME_DAY = 86400;
const DAYS_PER_WEEK = 6; // indexes start at 0
const MONTHS_PER_YEAR = 12;
public function get_template_side($module_id)
{
global $config, $template, $user, $phpbb_root_path, $phpEx, $db, $portal_root_path;
$portal_config = obtain_portal_config();
// 0 = Sunday first - 1 = Monday first. ;-)
if ($config['board3_sunday_first_' . $module_id])
{
$this->mini_cal_fdow = 0;
}
else
{
$this->mini_cal_fdow = 1;
}
// get the calendar month
$this->mini_cal_month = 0;
if(isset($_GET['m' . $module_id]) || isset($_POST['m' . $module_id]))
{
$this->mini_cal_month = request_var('m' . $module_id, 0);
}
// initialise some variables
$this->time = $user->create_datetime();
$now = phpbb_gmgetdate($this->time->getTimestamp() + $this->time->getOffset());
$today_timestamp = $now[0];
$mini_cal_today = date('Ymd', $today_timestamp - date('Z'));
$this->stamp = $today_timestamp;
$s_cal_month = ($this->mini_cal_month != 0) ? $this->mini_cal_month . ' month' : $mini_cal_today;
$this->getMonth($s_cal_month);
$mini_cal_count = $this->mini_cal_fdow;
$mini_cal_this_year = $this->dateYYYY;
$mini_cal_this_month = $this->dateMM;
$mini_cal_this_day = $this->dateDD;
$mini_cal_month_days = $this->daysMonth;
// output our general calendar bits
$down = $this->mini_cal_month - 1;
$up = $this->mini_cal_month + 1;
$prev_month = '<a href="' . append_sid("{$phpbb_root_path}app.$phpEx", "controller=portal&amp;m$module_id=$down#minical$module_id") . '"><img src="./../' . $portal_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_left_arrow.png' . '" title="' . $user->lang['VIEW_PREVIOUS_MONTH'] . '" height="16" width="16" alt="&lt;&lt;" /></a>';
$next_month = '<a href="' . append_sid("{$phpbb_root_path}app.$phpEx", "controller=portal&amp;m$module_id=$up#minical$module_id") . '"><img src="./../' . $portal_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_right_arrow.png' . '" title="' . $user->lang['VIEW_NEXT_MONTH'] . '" height="16" width="16" alt="&gt;&gt;" /></a>';
$template->assign_block_vars('minical', array(
'S_SUNDAY_FIRST' => ($config['board3_sunday_first_' . $module_id]) ? true : false,
'L_MINI_CAL_MONTH' => (($config['board3_long_month_' . $module_id]) ? $user->lang['mini_cal']['long_month'][$this->day[0][1]] : $user->lang['mini_cal']['month'][$this->day[0][1]]) . " " . $this->day[0][2],
'L_MINI_CAL_SUN' => '<span style="color: ' . $config['board3_calendar_sunday_color_' . $module_id] . ';">' . $user->lang['mini_cal']['day'][1] . '</span>',
'L_MINI_CAL_MON' => $user->lang['mini_cal']['day'][2],
'L_MINI_CAL_TUE' => $user->lang['mini_cal']['day'][3],
'L_MINI_CAL_WED' => $user->lang['mini_cal']['day'][4],
'L_MINI_CAL_THU' => $user->lang['mini_cal']['day'][5],
'L_MINI_CAL_FRI' => $user->lang['mini_cal']['day'][6],
'L_MINI_CAL_SAT' => $user->lang['mini_cal']['day'][7],
'U_PREV_MONTH' => $prev_month,
'U_NEXT_MONTH' => $next_month,
'S_DISPLAY_EVENTS' => ($config['board3_display_events_' . $module_id]) ? true : false,
'MODULE_ID' => $module_id,
));
// output the days for the current month
for($i = 0; $i < $mini_cal_month_days;)
{
// is this the first day of the week?
if($mini_cal_count == $this->mini_cal_fdow)
{
$template->assign_block_vars('minical.mini_cal_row', array(
'MODULE_ID' => $module_id,
));
}
// is this a valid weekday?
if($mini_cal_count == ($this->day[$i][3]))
{
$mini_cal_this_day = $this->day[$i][0];
$d_mini_cal_today = $mini_cal_this_year . (($mini_cal_this_month <= 9) ? '0' . $mini_cal_this_month : $mini_cal_this_month) . (($mini_cal_this_day <= 9) ? '0' . $mini_cal_this_day : $mini_cal_this_day);
$mini_cal_day = ($mini_cal_today == $d_mini_cal_today) ? '<span style="font-weight: bold; color: ' . $config['board3_calendar_today_color_' . $module_id] . ';">' . $mini_cal_this_day . '</span>' : $mini_cal_this_day;
$template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array(
'MINI_CAL_DAY' => ($mini_cal_count == 0) ? '<span style="color: ' . $config['board3_calendar_sunday_color_' . $module_id] . ';">' . $mini_cal_day . '</span>' : $mini_cal_day)
);
$i++;
}
// no day
else
{
$template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array(
'MINI_CAL_DAY' => ' ')
);
}
// is this the last day of the week?
if ($mini_cal_count == self::DAYS_PER_WEEK)
{
// if so then reset the count
$mini_cal_count = 0;
}
else
{
// otherwise increment the count
$mini_cal_count++;
}
}
// fill table with empty strings
while ($mini_cal_count <= self::DAYS_PER_WEEK)
{
$template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array(
'MINI_CAL_DAY' => ' ')
);
$mini_cal_count++;
}
/*
* Let's start displaying the events
* make sure we only display events in the future
*/
$events = $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]);
if(!empty($events) && $config['board3_display_events_' . $module_id])
{
// we sort the $events array by the start time
foreach($events as $key => $cur_event)
{
$time_ary[$key] = $cur_event['start_time'];
}
array_multisort($time_ary, SORT_NUMERIC, $events);
$groups_ary = get_user_groups();
foreach($events as $key => $cur_event)
{
if(($cur_event['start_time'] + $user->timezone + $user->dst) >= $today_timestamp ||
($cur_event['end_time'] + $user->timezone + $user->dst) >= $today_timestamp ||
(($cur_event['start_time'] + $user->timezone + $user->dst + self::TIME_DAY) >= $today_timestamp && $cur_event['all_day']))
{
$cur_permissions = explode(',', $cur_event['permission']);
$permission_check = array_intersect($groups_ary, $cur_permissions);
if(!empty($permission_check) || $cur_event['permission'] == '')
{
// check if this is an external link
if (isset($cur_event['url']) && strpos($cur_event['url'], generate_board_url()) === false)
{
$is_external = true;
}
else
{
$is_external = false;
}
/**
* Current events
*
* Events are treated as current if the following is met:
* - We have an all day event and the start of that event is less than 1 day (86400 seconds) away
* - We have a normal event with a start that is less then 1 day away and that hasn't ended yet
*/
if((($cur_event['start_time'] + $user->timezone + $user->dst - $today_timestamp) <= self::TIME_DAY && $cur_event['all_day']) ||
(($cur_event['start_time'] + $user->timezone + $user->dst - $today_timestamp) <= self::TIME_DAY && ($cur_event['end_time'] + $user->timezone + $user->dst) >= $today_timestamp))
{
$template->assign_block_vars('minical.cur_events', array(
'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '',
'EVENT_TITLE' => $cur_event['title'],
'START_TIME' => $user->format_date($cur_event['start_time'], 'j. M Y, H:i'),
'END_TIME' => (!empty($cur_event['end_time'])) ? $user->format_date($cur_event['end_time'], 'j. M Y, H:i') : false,
'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '',
'ALL_DAY' => ($cur_event['all_day']) ? true : false,
'MODULE_ID' => $module_id,
'EVENT_URL_NEW_WINDOW' => ($is_external && $config['board3_events_url_new_window_' . $module_id]) ? true : false,
));
}
else
{
$template->assign_block_vars('minical.upcoming_events', array(
'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '',
'EVENT_TITLE' => $cur_event['title'],
'START_TIME' => $user->format_date($cur_event['start_time'], 'j. M Y, H:i'),
'END_TIME' => (!$cur_event['all_day']) ? $user->format_date($cur_event['end_time'], 'j. M Y, H:i') : '',
'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '',
'ALL_DAY' => (($cur_event['start_time'] - $cur_event['end_time']) == 1) ? true : false,
'MODULE_ID' => $module_id,
'EVENT_URL_NEW_WINDOW' => ($is_external && $config['board3_events_url_new_window_' . $module_id]) ? true : false,
));
}
}
}
}
}
return 'calendar_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_CALENDAR',
'vars' => array(
'legend1' => 'ACP_PORTAL_CALENDAR',
'board3_calendar_today_color_' . $module_id => array('lang' => 'PORTAL_CALENDAR_TODAY_COLOR' , 'validate' => 'string', 'type' => 'text:10:10', 'explain' => true),
'board3_calendar_sunday_color_' . $module_id => array('lang' => 'PORTAL_CALENDAR_SUNDAY_COLOR' , 'validate' => 'string', 'type' => 'text:10:10', 'explain' => true),
'board3_long_month_' . $module_id => array('lang' => 'PORTAL_LONG_MONTH' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_sunday_first_' . $module_id => array('lang' => 'PORTAL_SUNDAY_FIRST' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_display_events_' . $module_id => array('lang' => 'PORTAL_DISPLAY_EVENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_events_url_new_window_' . $module_id => array('lang' => 'PORTAL_EVENTS_URL_NEW_WINDOW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'board3_events_' . $module_id => array('lang' => 'PORTAL_EVENTS_MANAGE', 'validate' => 'string', 'type' => 'custom', 'explain' => false, 'method' => 'manage_events', 'submit' => 'update_events'),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_sunday_first_' . $module_id, 1);
set_config('board3_calendar_today_color_' . $module_id, '#000000');
set_config('board3_calendar_sunday_color_' . $module_id, '#FF0000');
set_config('board3_long_month_' . $module_id, 0);
set_config('board3_display_events_' . $module_id, 0);
set_config('board3_events_' . $module_id, '');
set_config('board3_events_url_new_window_' . $module_id, 0);
set_portal_config('board3_calendar_events_' . $module_id, '');
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_calendar_events_' . $module_id,
);
$sql = 'DELETE FROM ' . PORTAL_CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
$db->sql_query($sql);
$del_config = array(
'board3_sunday_first_' . $module_id,
'board3_calendar_today_color_' . $module_id,
'board3_calendar_sunday_color_' . $module_id,
'board3_long_month_' . $module_id,
'board3_display_events_' . $module_id,
'board3_events_' . $module_id,
'board3_events_url_new_window_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
public function manage_events($value, $key, $module_id)
{
global $db, $portal_config, $config, $template, $user, $phpEx, $phpbb_admin_path;
$action = request_var('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action;
$action = (isset($_POST['save'])) ? 'save' : $action;
$link_id = request_var('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach
$portal_config = obtain_portal_config();
$events = (strlen($portal_config['board3_calendar_events_' . $module_id]) >= 1) ? $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]) : array();
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id);
switch($action)
{
// Save changes
case 'save':
if (!check_form_key('acp_portal'))
{
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
}
$event_title = utf8_normalize_nfc(request_var('event_title', ' ', true));
$event_desc = utf8_normalize_nfc(request_var('event_desc', ' ', true));
$event_start_day = trim(request_var('event_start_day', ''));
$event_start_time = trim(request_var('event_start_time', ''));
$event_end_day = trim(request_var('event_end_day', ''));
$event_end_time = trim(request_var('event_end_time', ''));
$event_all_day = request_var('event_all_day', false); // default to false
$event_url = request_var('event_url', ' ');
$event_permission = request_var('permission-setting-calendar', array(0 => ''));
$groups_ary = array();
/*
* parse the event time
* first check for obvious errors, we don't want to waste server resources
*/
if(strlen($event_start_day) < 9 || strlen($event_start_day) > 10 || (strlen($event_start_time) < 4 && !$event_all_day) || strlen($event_start_time) > 5)
{
trigger_error($user->lang['ACP_PORTAL_CALENDAR_START_INCORRECT']. adm_back_link($u_action), E_USER_WARNING);
}
elseif((strlen($event_end_day) < 9 || strlen($event_end_day) > 10 || strlen($event_end_time) < 4 || strlen($event_end_time) > 5) && !$event_all_day)
{
trigger_error($user->lang['ACP_PORTAL_CALENDAR_END_INCORRECT']. adm_back_link($u_action), E_USER_WARNING);
}
// Now get the needed numbers out of the entered information
$first_start_hyphen = strpos($event_start_day, '-', 0);
$second_start_hyphen = strpos($event_start_day, '-', $first_start_hyphen + 1);
$start_colon_pos = strpos($event_start_time, ':', 0);
$start_day_length = strlen($event_start_day);
$start_time_length = strlen($event_start_time);
$start_day = (int) substr($event_start_day, 0, $first_start_hyphen);
$start_month = (int) substr($event_start_day, $first_start_hyphen + 1, ($second_start_hyphen - $first_start_hyphen - 1));
$start_year = (int) substr($event_start_day, $second_start_hyphen + 1, $start_day_length - $second_start_hyphen);
$start_hour = (int) substr($event_start_time, 0, $start_colon_pos);
$start_minute = (int) substr($event_start_time, $start_colon_pos + 1, ($start_time_length - $start_colon_pos) - 1);
if(!$event_all_day)
{
$first_end_hyphen = strpos($event_end_day, '-', 0);
$second_end_hyphen = strpos($event_end_day, '-', $first_end_hyphen + 1);
$end_colon_pos = strpos($event_end_time, ':', 0);
$end_day_length = strlen($event_end_day);
$end_time_length = strlen($event_end_time);
$end_day = (int) substr($event_end_day, 0, $first_end_hyphen);
$end_month = (int) substr($event_end_day, $first_end_hyphen + 1, ($second_end_hyphen - $first_end_hyphen - 1));
$end_year = (int) substr($event_end_day, $second_end_hyphen + 1, $end_day_length - $second_end_hyphen);
$end_hour = (int) substr($event_end_time, 0, $end_colon_pos);
$end_minute = (int) substr($event_end_time, $end_colon_pos + 1, ($end_time_length - $end_colon_pos) - 1);
}
// UNIX timestamps
$start_time = gmmktime($start_hour, $start_minute, 0, $start_month, $start_day, $start_year) - $user->timezone - $user->dst;
$end_time = (!$event_all_day) ? gmmktime($end_hour, $end_minute, 0, $end_month, $end_day, $end_year) - $user->timezone - $user->dst : '';
if(($end_time) <= time() && !(($start_time + self::TIME_DAY) >= time() && $event_all_day))
{
trigger_error($user->lang['ACP_PORTAL_CALENDAR_EVENT_PAST']. adm_back_link($u_action), E_USER_WARNING);
}
elseif($end_time < $start_time && !$event_all_day)
{
trigger_error($user->lang['ACP_PORTAL_CALENDAR_EVENT_START_FIRST']. adm_back_link($u_action), E_USER_WARNING);
}
// get groups and check if the selected groups actually exist
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
$db->sql_freeresult($result);
$event_permission = array_intersect($event_permission, $groups_ary);
$event_permission = implode(',', $event_permission);
// Check for errors
if (!$event_title)
{
trigger_error($user->lang['NO_EVENT_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
}
if (!$start_time || $start_time == 0)
{
trigger_error($user->lang['NO_EVENT_START'] . adm_back_link($u_action), E_USER_WARNING);
}
// overwrite already existing events and make sure we don't try to save an event outside of the normal array size of $events
if (isset($link_id) && $link_id < sizeof($events))
{
$message = $user->lang['EVENT_UPDATED'];
$events[$link_id] = array(
'title' => $event_title,
'desc' => $event_desc,
'start_time' => $start_time,
'end_time' => $end_time,
'all_day' => $event_all_day,
'permission' => $event_permission,
'url' => htmlspecialchars_decode($event_url),
);
add_log('admin', 'LOG_PORTAL_EVENT_UPDATED', $event_title);
}
else
{
$message = $user->lang['EVENT_ADDED'];
$events[] = array(
'title' => $event_title,
'desc' => $event_desc,
'start_time' => $start_time,
'end_time' => $end_time,
'all_day' => $event_all_day,
'permission' => $event_permission,
'url' => $event_url, // optional
);
add_log('admin', 'LOG_PORTAL_EVENT_ADDED', $event_title);
}
// we sort the $events array by the start time
foreach($events as $key => $cur_event)
{
$time_ary[$key] = $cur_event['start_time'];
}
array_multisort($time_ary, SORT_NUMERIC, $events);
$board3_events_array = serialize($events);
set_portal_config('board3_calendar_events_' . $module_id, $board3_events_array);
trigger_error($message . adm_back_link($u_action));
break;
// Delete link
case 'delete':
if (!isset($link_id) && $link_id >= sizeof($events))
{
trigger_error($user->lang['NO_EVENT'] . adm_back_link($u_action), E_USER_WARNING);
}
if (confirm_box(true))
{
$cur_event_title = $events[$link_id]['title'];
// delete the selected link and reset the array numbering afterwards
array_splice($events, $link_id, 1);
$events = array_merge($events);
$board3_events_array = serialize($events);
set_portal_config('board3_calendar_events_' . $module_id, $board3_events_array);
add_log('admin', 'LOG_PORTAL_EVENT_REMOVED', $cur_event_title);
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'link_id' => $link_id,
'action' => 'delete',
)));
}
break;
// Edit or add menu item
case 'edit':
case 'add':
$event_all_day = (isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true) ? true : false;
$template->assign_vars(array(
'EVENT_TITLE' => (isset($events[$link_id]['title']) && $action != 'add') ? $events[$link_id]['title'] : '',
'EVENT_DESC' => (isset($events[$link_id]['desc']) && $action != 'add') ? $events[$link_id]['desc'] : '',
'EVENT_START_DAY' => ($action != 'add') ? $user->format_date($events[$link_id]['start_time'], 'd-m-Y') : '',
'EVENT_START_TIME' => ($action != 'add') ? $user->format_date($events[$link_id]['start_time'], 'G:i') : '',
'EVENT_END_DAY' => ($action != 'add' && !$event_all_day) ? $user->format_date($events[$link_id]['end_time'], 'd-m-Y') : '',
'EVENT_END_TIME' => ($action != 'add' && !$event_all_day) ? $user->format_date($events[$link_id]['end_time'], 'G:i') : '',
'EVENT_ALL_DAY' => (isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true) ? true : false,
'EVENT_URL' => (isset($events[$link_id]['url']) && $action != 'add') ? $events[$link_id]['url'] : '',
//'U_BACK' => $u_action,
'U_ACTION' => $u_action . '&amp;id=' . $link_id,
'S_EDIT' => true,
));
$groups_ary = (isset($events[$link_id]['permission'])) ? explode(',', $events[$link_id]['permission']) : array();
// get group info from database and assign the block vars
$sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('permission_setting_calendar', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'],
));
}
$db->sql_freeresult($result);
return;
break;
}
for ($i = 0; $i < sizeof($events); $i++)
{
$event_all_day = ($events[$i]['all_day'] == true) ? true : false;
$start_time_format = (!intval($user->format_date($events[$i]['start_time'], 'H')) && !intval($user->format_date($events[$i]['start_time'], 'i'))) ? 'j. M Y' : 'j. M Y, H:i';
$end_time_format = (!intval($user->format_date($events[$i]['end_time'], 'H')) && !intval($user->format_date($events[$i]['end_time'], 'i'))) ? 'j. M Y' : 'j. M Y, H:i';
$template->assign_block_vars('events', array(
'EVENT_TITLE' => ($action != 'add') ? ((isset($user->lang[$events[$i]['title']])) ? $user->lang[$events[$i]['title']] : $events[$i]['title']) : '',
'EVENT_DESC' => ($action != 'add') ? $events[$i]['desc'] : '',
'EVENT_START' => ($action != 'add') ? $user->format_date($events[$i]['start_time'], $start_time_format) : '',
'EVENT_END' => ($action != 'add' && !$event_all_day) ? $user->format_date($events[$i]['end_time'], $end_time_format) : '',
'EVENT_URL' => ($action != 'add' && isset($events[$i]['url']) && !empty($events[$i]['url'])) ? $this->validate_url($events[$i]['url']) : '',
'EVENT_URL_RAW' => ($action != 'add' && isset($events[$i]['url']) && !empty($events[$i]['url'])) ? $events[$i]['url'] : '',
'U_EDIT' => $u_action . '&amp;action=edit&amp;id=' . $i,
'U_DELETE' => $u_action . '&amp;action=delete&amp;id=' . $i,
'EVENT_ALL_DAY' => $event_all_day,
));
}
}
public function update_events($key, $module_id)
{
$this->manage_events('', $key, $module_id);
}
private $dateYYY; // year in numeric format (YYYY)
private $dateMM; // month in numeric format (MM)
private $dateDD; // day in numeric format (DD)
private $ext_dateMM; // extended month (e.g. February)
private $daysMonth; // count of days in month
private $stamp; // timestamp
private $day; // return array s.a.
/**
* convert date->timestamp
**/
private function makeTimestamp($date)
{
$this->stamp = strtotime($date);
return ($this->stamp);
}
/**
* get date listed in array
**/
private function getMonth($callDate)
{
global $user;
$this->makeTimestamp($callDate);
// last or first day of some months need to be treated in a special way
if (!empty($this->mini_cal_month))
{
$time = $user->create_datetime();
$now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
$today_timestamp = $now[0];
$cur_month = date("n", $today_timestamp);
$correct_month = $cur_month + $this->mini_cal_month;
// move back or forth the correct number of years
while ($correct_month < 1 || $correct_month > self::MONTHS_PER_YEAR)
{
if ($correct_month < 1)
{
$correct_month = $correct_month + self::MONTHS_PER_YEAR;
}
else
{
$correct_month = $correct_month - self::MONTHS_PER_YEAR;
}
}
// fix incorrect months
while (date("n", $this->stamp) != $correct_month)
{
if (date("n", $this->stamp) > $correct_month)
{
$this->stamp = $this->stamp - self::TIME_DAY; // go back one day
}
else
{
$this->stamp = $this->stamp + self::TIME_DAY; // move forward one day
}
}
}
$this->dateYYYY = date("Y", $this->stamp);
$this->dateMM = date("n", $this->stamp);
$this->ext_dateMM = date("F", $this->stamp);
$this->dateDD = date("d", $this->stamp);
$this->daysMonth = date("t", $this->stamp);
for ($i = 1; $i < $this->daysMonth + 1; $i++)
{
$this->makeTimestamp("$i {$this->ext_dateMM} {$this->dateYYYY}");
$this->day[] = array(
'0' => "$i",
'1' => $this->dateMM,
'2' => $this->dateYYYY,
'3' => date('w', $this->stamp)
);
}
}
// Unserialize links array
private function utf_unserialize($serial_str)
{
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
return unserialize($out);
}
/**
* validate URLs and execute apppend_sid if necessary
*/
private function validate_url($url)
{
global $config;
$url = str_replace("\r\n", "\n", str_replace('\"', '"', trim($url)));
$url = str_replace(' ', '%20', $url);
$url = str_replace('&', '&amp;', $url);
// if there is no scheme, then add http schema
if (!preg_match('#^[a-z][a-z\d+\-.]*:/{2}#i', $url))
{
$url = 'http://' . $url;
}
// Is this a link to somewhere inside this board? If so then run reapply_sid()
if (strpos($url, generate_board_url()) !== false)
{
$url = reapply_sid($url);
}
return $url;
}
}

View File

@@ -0,0 +1,75 @@
<?php
/**
*
* @package Board3 Portal v2 - Clock
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Clock
*/
class portal_clock_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'CLOCK';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_clock.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_clock_module';
public function get_template_side($module_id)
{
return 'clock_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_CLOCK_SETTINGS',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
}

View File

@@ -0,0 +1,347 @@
<?php
/**
*
* @package Board3 Portal v2 - Custom
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Custom
*/
class portal_custom_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 31;
/**
* Default modulename
*/
public $name = 'PORTAL_CUSTOM';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_custom.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_custom_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = 'acp_portal_custom';
public function get_template_center($module_id)
{
return $this->parse_template($module_id);
}
public function get_template_side($module_id)
{
return $this->parse_template($module_id, 'side');
}
public function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_CUSTOM',
'vars' => array(
'legend1' => 'PORTAL_CUSTOM',
'board3_custom_' . $module_id . '_code' => array('lang' => 'PORTAL_CUSTOM', 'validate' => 'string', 'type' => 'custom', 'method' => 'manage_custom', 'submit' => 'update_custom', 'explain' => true),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_portal_config('board3_custom_' . $module_id . '_code', '');
set_config('board3_custom_' . $module_id . '_code', '');
set_config('board3_custom_' . $module_id . '_bbcode', 1);
set_config('board3_custom_' . $module_id . '_title', '');
set_config('board3_custom_' . $module_id . '_image_src', '');
set_config('board3_custom_' . $module_id . '_uid', '');
set_config('board3_custom_' . $module_id . '_bitfield', '');
set_config('board3_custom_' . $module_id . '_permission', '');
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_custom_' . $module_id . '_code',
);
$sql = 'DELETE FROM ' . PORTAL_CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
$check = $db->sql_query($sql);
$del_config = array(
'board3_custom_' . $module_id . '_bbcode',
'board3_custom_' . $module_id . '_title',
'board3_custom_' . $module_id . '_image_src',
'board3_custom_' . $module_id . '_uid',
'board3_custom_' . $module_id . '_bitfield',
'board3_custom_' . $module_id . '_permission',
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return ((!$check) ? $check : $db->sql_query($sql)); // if something went wrong, make sure we are aware of the first query
}
public function manage_custom($value, $key, $module_id)
{
global $db, $portal_config, $config, $template, $user, $phpEx, $phpbb_admin_path, $phpbb_root_path;
$action = (isset($_POST['reset'])) ? 'reset' : '';
$action = (isset($_POST['submit'])) ? 'save' : $action;
$action = (isset($_POST['preview'])) ? 'preview' : $action;
$portal_config = obtain_portal_config();
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id);
switch($action)
{
// Save changes
case 'save':
if (!check_form_key('acp_portal'))
{
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
}
$custom_code = utf8_normalize_nfc(request_var('custom_code', '', true));
$custom_bbcode = request_var('custom_use_bbcode', 1); // default to BBCode
$custom_permission = request_var('permission-setting', array(0 => ''));
$custom_title = utf8_normalize_nfc(request_var('module_name', '', true));
$custom_image_src = utf8_normalize_nfc(request_var('module_image', ''));
$groups_ary = array();
$uid = $bitfield = $flags = '';
$options = 7;
if($custom_bbcode)
{
generate_text_for_storage($custom_code, $uid, $bitfield, $flags, true, true, true);
}
// first check for obvious errors, we don't want to waste server resources
if(empty($custom_code))
{
trigger_error($user->lang['ACP_PORTAL_CUSTOM_CODE_SHORT']. adm_back_link($u_action), E_USER_WARNING);
}
// get groups and check if the selected groups actually exist
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
$db->sql_freeresult($result);
$custom_permission = array_intersect($custom_permission, $groups_ary);
$custom_permission = implode(',', $custom_permission);
if (isset($user->lang[$custom_title]))
{
$log_title = $user->lang[$custom_title];
}
else
{
$log_title = $custom_title;
}
add_log('admin', 'LOG_PORTAL_CONFIG', $user->lang['PORTAL_CUSTOM'] . ':&nbsp;' . $log_title);
// set_portal_config will take care of escaping the welcome message
set_portal_config('board3_custom_' . $module_id . '_code', $custom_code);
set_config('board3_custom_' . $module_id . '_bbcode', $custom_bbcode);
set_config('board3_custom_' . $module_id . '_title', $custom_title);
set_config('board3_custom_' . $module_id . '_image_src', $custom_image_src);
set_config('board3_custom_' . $module_id . '_uid', $uid);
set_config('board3_custom_' . $module_id . '_bitfield', $bitfield);
set_config('board3_custom_' . $module_id . '_permission', $custom_permission);
//trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link(($module_id) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=portal&mode=modules') : $u_action));
break;
case 'preview':
$custom_code = $text = utf8_normalize_nfc(request_var('custom_code', '', true));
$custom_bbcode = request_var('custom_use_bbcode', 1); // default to BBCode
$custom_permission = request_var('permission-setting', array(0 => ''));
$custom_title = utf8_normalize_nfc(request_var('module_name', ''));
$custom_image_src = utf8_normalize_nfc(request_var('module_image', ''));
$groups_ary = array();
// first check for obvious errors, we don't want to waste server resources
if(empty($custom_code))
{
trigger_error($user->lang['ACP_PORTAL_CUSTOM_CODE_SHORT']. adm_back_link($u_action), E_USER_WARNING);
}
if (!class_exists('parse_message'))
{
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
}
if($custom_bbcode)
{
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
$uid = (isset($config['board3_custom_' . $module_id . '_uid'])) ? $config['board3_custom_' . $module_id . '_uid'] : '';
$bitfield = (isset($config['board3_custom_' . $module_id . '_bitfield'])) ? $config['board3_custom_' . $module_id . '_bitfield'] : '';
$options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
$text = generate_text_for_display($text, $uid, $bitfield, $options);
}
else
{
$text = htmlspecialchars_decode($text, ENT_QUOTES);
}
$template->assign_vars(array(
'PREVIEW_TEXT' => $text,
'S_PREVIEW' => true,
));
// get groups and check if the selected groups actually exist
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
$db->sql_freeresult($result);
$temp_permissions = array_intersect($custom_permission, $groups_ary);
// Edit or add menu item
case 'reset':
default:
if(!isset($custom_code))
{
$custom_code = generate_text_for_edit($portal_config['board3_custom_' . $module_id . '_code'], $config['board3_custom_' . $module_id . '_uid'], '');
}
$template->assign_vars(array(
'CUSTOM_CODE' => (is_array($custom_code)) ? $custom_code['text'] : $custom_code,
'CUSTOM_USE_BBCODE' => (isset($custom_bbcode)) ? $custom_bbcode : (($config['board3_custom_' . $module_id . '_bbcode'] != '') ? $config['board3_custom_' . $module_id . '_bbcode'] : true), // BBCodes are selected by default
//'U_BACK' => $u_action,
'U_ACTION' => $u_action,
'S_EDIT' => true,
'S_LINKS_ALLOWED' => true,
'S_BBCODE_IMG' => true,
'S_BBCODE_FLASH' => true,
'S_BBCODE_QUOTE' => true,
'S_BBCODE_ALLOWED' => true,
'MAX_FONT_SIZE' => (int) $config['max_post_font_size'],
));
$groups_ary = (isset($temp_permissions)) ? $temp_permissions : ((isset($config['board3_custom_' . $module_id . '_permission'])) ? explode(',', $config['board3_custom_' . $module_id . '_permission']) : array());
// get group info from database and assign the block vars
$sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('permission_setting', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'],
));
}
$db->sql_freeresult($result);
if(!function_exists('display_forums'))
{
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}
// Build custom bbcodes array
display_custom_bbcodes();
$user->add_lang('posting');
break;
}
}
public function update_custom($key, $module_id)
{
$this->manage_custom('', $key, $module_id);
}
/**
* Parse template for custom blocks
*
* @param int $module_id Module ID of current module
* @param string $type Type of module (center or side), default to
* center to not show module image unless wanted
* @return array An array containing the custom module data
*/
protected function parse_template($module_id, $type = 'center')
{
global $config, $template, $portal_config, $user;
/*
* Run generate_text_for_display if the user uses BBCode for designing his custom block
* HTML won't be parsed if the user chooses to use BBCodes in the ACP
* If BBCodes are turned off, the custom Block code will be directly assigned and HTML will be parsed
*/
if ($config['board3_custom_' . $module_id . '_bbcode'])
{
// Generate text for display and assign template vars
$uid = $config['board3_custom_' . $module_id . '_uid'];
$bitfield = $config['board3_custom_' . $module_id . '_bitfield'];
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
$assign_code = generate_text_for_display($portal_config['board3_custom_' . $module_id . '_code'], $uid, $bitfield, $bbcode_options);
}
else
{
$assign_code = htmlspecialchars_decode($portal_config['board3_custom_' . $module_id . '_code'], ENT_QUOTES);
}
$title = (!empty($config['board3_custom_' . $module_id . '_title'])) ? ((isset($user->lang[$config['board3_custom_' . $module_id . '_title']])) ? $user->lang[$config['board3_custom_' . $module_id . '_title']] : $config['board3_custom_' . $module_id . '_title']) : $user->lang[$this->name];
if(!empty($assign_code))
{
return array(
'template' => 'custom_' . $type . '.html',
'title' => $title,
'code' => $assign_code,
// no image for center blocks
'image_src' => ($type === 'center') ? '' : ((!empty($config['board3_custom_' . $module_id . '_image_src'])) ? $config['board3_custom_' . $module_id . '_image_src'] : $this->image_src),
);
}
}
}

View File

@@ -0,0 +1,117 @@
<?php
/**
*
* @package Board3 Portal v2 - Default
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Modulname
*/
class portal_modulename_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 0;
/**
* Default modulename
*/
public $name = 'MODULENAME';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'modulename.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = '';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
/**
* hide module name in ACP configuration page
*/
public $hide_name = false;
public function get_template_center($module_id)
{
global $config, $template;
$template->assign_vars(array(
'EXAMPLE' => $config['board3_configname_' . $module_id],
));
return 'modulename_center.html';
}
public function get_template_side($module_id)
{
global $config, $template;
$template->assign_vars(array(
'EXAMPLE' => $config['board3_configname2_' . $module_id],
));
return 'modulename_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_CONFIG_MODULENAME',
'vars' => array(
'legend1' => 'ACP_MODULENAME_CONFIGLEGEND',
'board3_configname_' . $module_id => array('lang' => 'MODULENAME_CONFIGNAME', 'validate' => 'string', 'type' => 'text:10:200', 'explain' => false),
'board3_configname2_' . $module_id => array('lang' => 'MODULENAME_CONFIGNAME2', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_configname_' . $module_id, 'Hello World!');
set_config('board3_configname2_' . $module_id, 1337);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_configname_' . $module_id,
'board3_configname2_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}

View File

@@ -0,0 +1,108 @@
<?php
/**
*
* @package Board3 Portal v2 - Donation
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Donation
*/
class portal_donation_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 31;
/**
* Default modulename
*/
public $name = 'DONATION';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_donation.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_donation_module';
public function get_template_center($module_id)
{
global $config, $template, $user;
$template->assign_vars(array(
'PAY_ACC_CENTER' => $config['board3_pay_acc_' . $module_id],
'PAY_CUSTOM_CENTER' => (!empty($config['board3_pay_custom_' . $module_id])) ? $user->data['username_clean'] : false,
));
return 'donation_center.html';
}
public function get_template_side($module_id)
{
global $config, $template, $user;
$template->assign_vars(array(
'PAY_ACC_SIDE' => $config['board3_pay_acc_' . $module_id],
'PAY_CUSTOM_SIDE' => (!empty($config['board3_pay_custom_' . $module_id])) ? $user->data['username_clean'] : false,
));
return 'donation_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_PAYPAL_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_PAYPAL_SETTINGS',
'board3_pay_acc_' . $module_id => array('lang' => 'PORTAL_PAY_ACC', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true),
'board3_pay_custom_' . $module_id => array('lang' => 'PORTAL_PAY_CUSTOM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
)
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_pay_acc_' . $module_id, 'your@paypal.com');
set_config('board3_pay_custom_' . $module_id, true);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_pay_acc_' . $module_id,
'board3_pay_custom_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}

View File

@@ -0,0 +1,94 @@
<?php
/**
*
* @package Board3 Portal v2 - Forumlist
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Forumlist
*/
class portal_forumlist_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'PORTAL_FORUMLIST';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_forumlist_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
public function get_template_center($module_id)
{
global $config, $template, $user, $auth, $phpbb_root_path, $phpEx;
display_forums('', $config['load_moderators'], false);
$template->assign_vars(array(
'FORUM_IMG' => $user->img('forum_read', 'NO_NEW_POSTS'),
'FORUM_NEW_IMG' => $user->img('forum_unread', 'NEW_POSTS'),
'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'),
'FORUM_NEW_LOCKED_IMG' => $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'),
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '',
'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '',
));
return 'forumlist.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_FORUMLIST',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
}

View File

@@ -0,0 +1,136 @@
<?php
/**
*
* @package Board3 Portal v2 - Friends
* @copyright (c) Board3 Group ( www.board3.de )
* @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
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'FRIENDS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_friends.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_friends_module';
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;
$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_' . $module_id]);
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,
));
return 'friends_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_FRIENDS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_FRIENDS_SETTINGS',
'board3_max_online_friends_' . $module_id => array('lang' => 'PORTAL_MAX_ONLINE_FRIENDS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
)
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_max_online_friends_' . $module_id, 8);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_max_online_friends_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}

View File

@@ -0,0 +1,117 @@
<?php
/**
*
* @package Board3 Portal v2 - Latest Bots
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Latest Bots
*/
class portal_latest_bots_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'LATEST_BOTS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_bots.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_latest_bots_module';
/**
* hide module name in ACP configuration page
*/
public $hide_name = false;
public function get_template_side($module_id)
{
global $config, $template, $db, $user;
// Last x visited bots
$sql = 'SELECT username, user_colour, user_lastvisit
FROM ' . USERS_TABLE . '
WHERE user_type = ' . USER_IGNORE . '
AND user_lastvisit > 0
ORDER BY user_lastvisit DESC';
$result = $db->sql_query_limit($sql, $config['board3_last_visited_bots_number_' . $module_id]);
$show_module = false;
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('last_visited_bots', array(
'BOT_NAME' => get_username_string('full', '', $row['username'], $row['user_colour']),
'LAST_VISIT_DATE' => $user->format_date($row['user_lastvisit']),
));
$show_module = true;
}
$db->sql_freeresult($result);
if($show_module)
{
return 'latest_bots_side.html';
}
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_BOTS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_BOTS_SETTINGS',
'board3_last_visited_bots_number_' . $module_id => array('lang' => 'PORTAL_LAST_VISITED_BOTS_NUMBER' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
)
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_last_visited_bots_number_' . $module_id, 1);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_last_visited_bots_number_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
*
* @package Board3 Portal v2 - Latest Members
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Modulname
*/
class portal_latest_members_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'LATEST_MEMBERS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_members.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_latest_members_module';
public function get_template_side($module_id)
{
global $config, $template, $db, $user;
$sql = 'SELECT user_id, username, user_regdate, user_colour
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . '
AND user_inactive_time = 0
ORDER BY user_regdate DESC';
$result = $db->sql_query_limit($sql, $config['board3_max_last_member_' . $module_id]);
while(($row = $db->sql_fetchrow($result)) && ($row['username']))
{
$template->assign_block_vars('latest_members', array(
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'JOINED' => $user->format_date($row['user_regdate'], $format = 'd M'),
));
}
$db->sql_freeresult($result);
return 'latest_members_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_MEMBERS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_MEMBERS_SETTINGS',
'board3_max_last_member_' . $module_id => array('lang' => 'PORTAL_MAX_LAST_MEMBER' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
)
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_max_last_member_' . $module_id, 8);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_max_last_member_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}

View File

@@ -0,0 +1,240 @@
<?php
/**
*
* @package Board3 Portal v2 - Leaders
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Leaders
*/
class portal_leaders_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'THE_TEAM';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_team.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_leaders_module';
public function get_template_side($module_id)
{
global $config, $template, $user, $auth, $db, $phpEx, $phpbb_root_path;
// Display a listing of board admins, moderators
$user->add_lang('groups');
if($config['board3_leaders_ext_' . $module_id])
{
$legends = array();
$groups = array();
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);
while ($row = $db->sql_fetchrow($result))
{
$groups[$row['group_id']] = array(
'group_name' => $row['group_name'],
'group_colour' => $row['group_colour'],
'group_type' => $row['group_type'],
'group_users' => array(),
);
$legends[] = $row['group_id'];
}
$db->sql_freeresult($result);
if(sizeof($legends))
{
$sql = 'SELECT
u.user_id AS user_id, u.username AS username, u.username_clean AS username_clean,
u.user_colour AS user_colour, ug.group_id AS group_id
FROM
' . USERS_TABLE . ' AS u,
' . USER_GROUP_TABLE . ' AS ug
WHERE
ug.user_id = u.user_id
AND '. $db->sql_in_set('ug.group_id', $legends) . '
ORDER BY u.username_clean ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$groups[$row['group_id']]['group_users'][] = array(
'user_id' => $row['user_id'],
'username' => $row['username'],
'user_colour' => $row['user_colour'],
);
}
$db->sql_freeresult($result);
}
if(sizeof($groups))
{
foreach($groups as $group_id => $group)
{
if(sizeof($group['group_users']))
{
$group_name = ($group['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group['group_name']] : $group['group_name'];
$u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $group_id);
$template->assign_block_vars('group', array(
'GROUP_NAME' => $group_name,
'GROUP_COLOUR' => $group['group_colour'],
'U_GROUP' => $u_group,
));
foreach($group['group_users'] as $group_user)
{
$template->assign_block_vars('group.member', array(
'USER_ID' => $group_user['user_id'],
'USERNAME_FULL' => get_username_string('full', $group_user['user_id'], $group_user['username'], $group_user['user_colour']),
));
}
}
}
}
return 'leaders_ext_side.html';
}
else
{
$sql = $db->sql_build_query('SELECT', array(
'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.user_colour, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id',
'FROM' => array(
USERS_TABLE => 'u',
GROUPS_TABLE => 'g'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(USER_GROUP_TABLE => 'ug'),
'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id']
)),
'WHERE' => 'u.group_id = g.group_id AND ' . $db->sql_in_set('g.group_name', array('ADMINISTRATORS', 'GLOBAL_MODERATORS')),
'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC'
));
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if ($row['group_name'] == 'ADMINISTRATORS')
{
$which_row = 'b3p_admins';
}
elseif ($row['group_name'] == 'GLOBAL_MODERATORS')
{
$which_row = 'b3p_moderators';
}
if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
{
$group_name = $user->lang['GROUP_UNDISCLOSED'];
$u_group = '';
}
else
{
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
$u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']);
}
$template->assign_block_vars($which_row, array(
'USER_ID' => $row['user_id'],
'GROUP_NAME' => $group_name,
'GROUP_COLOR' => $row['group_colour'],
'U_GROUP' => $u_group,
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
));
}
$db->sql_freeresult($result);
return 'leaders_side.html';
}
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_LEADERS',
'vars' => array(
'legend1' => 'ACP_PORTAL_LEADERS',
'board3_leaders_ext_' . $module_id => array('lang' => 'PORTAL_LEADERS_EXT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
// Show normal team block by default
set_config('board3_leaders_ext_' . $module_id, 0);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_leaders_ext_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}

View File

@@ -0,0 +1,86 @@
<?php
/**
*
* @package Board3 Portal v2 - Link us
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Clock
*/
class portal_link_us_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'LINK_US';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_link_us.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_link_us_module';
public function get_template_side($module_id)
{
global $config, $template, $user;
//doing the easy way ;)
$u_link = generate_board_url();
// Assign specific vars
$template->assign_vars(array(
'LINK_US_TXT' => sprintf($user->lang['LINK_US_TXT'], $config['sitename']),
'U_LINK_US' => '&lt;a&nbsp;href=&quot;' . $u_link . '&quot;&nbsp;' . (($config['site_desc']) ? 'title=&quot;' . $config['site_desc'] . '&quot;' : '' ) . '&gt;' . (($config['sitename']) ? $config['sitename'] : $u_link ) . '&lt;/a&gt;',
));
return 'link_us_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'LINK_US',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
}

View File

@@ -0,0 +1,413 @@
<?php
/**
*
* @package Board3 Portal v2 - Links
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Links
*/
class portal_links_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'PORTAL_LINKS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_links.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_links_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = 'acp_portal_links';
/**
* constants
*/
const LINK_INT = 1;
const LINK_EXT = 2;
public function get_template_side($module_id)
{
global $config, $template, $phpEx, $phpbb_root_path, $user, $db;
$links = array();
$portal_config = obtain_portal_config();
$links = $this->utf_unserialize($portal_config['board3_links_array_' . $module_id]);
// get user's groups
$groups_ary = get_user_groups();
for ($i = 0; $i < sizeof($links); $i++)
{
if($links[$i]['type'] == self::LINK_INT)
{
$links[$i]['url'] = str_replace('&', '&amp;', $links[$i]['url']); // we need to do this in order to prevent XHTML validation errors
$cur_url = append_sid($phpbb_root_path . $links[$i]['url']); // the user should know what kind of file it is
}
else
{
$cur_url = $links[$i]['url'];
}
$cur_permissions = explode(',', $links[$i]['permission']);
$permission_check = array_intersect($groups_ary, $cur_permissions);
if(!empty($permission_check) || $links[$i]['permission'] == '')
{
$template->assign_block_vars('portallinks', array(
'LINK_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'],
'LINK_URL' => $cur_url,
'MODULE_ID' => $module_id,
'NEW_WINDOW' => ($links[$i]['type'] != self::LINK_INT && $config['board3_links_url_new_window_' . $module_id]) ? true : false,
));
}
}
return 'links_side.html';
}
public function get_template_acp($module_id)
{
// do not remove this as it is needed in order to run manage_links
return array(
'title' => 'ACP_PORTAL_LINKS',
'vars' => array(
'legend1' => 'ACP_PORTAL_LINKS',
'board3_links_' . $module_id => array('lang' => 'ACP_PORTAL_MENU_MANAGE', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'manage_links', 'submit' => 'update_links'),
'board3_links_url_new_window_' . $module_id => array('lang' => 'ACP_PORTAL_LINKS_NEW_WINDOW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
global $phpbb_root_path, $db;
$links = array();
$links_titles = array(
'Board3.de',
'phpBB.com',
);
$links_types = array(
self::LINK_EXT,
self::LINK_EXT,
);
$links_urls = array(
'http://www.board3.de/',
'http://www.phpbb.com/',
);
$links_permissions = array(
'',
'',
);
foreach($links_urls as $i => $url)
{
$links[] = array(
'title' => $links_titles[$i],
'url' => $links_urls[$i],
'type' => $links_types[$i],
'permission' => $links_permissions[$i],
);
}
$board3_menu_array = serialize($links);
set_portal_config('board3_links_array_' . $module_id, $board3_menu_array);
set_config('board3_links_' . $module_id, '');
set_config('board3_links_url_new_window_' . $module_id, 0);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_links_array_' . $module_id,
);
$sql = 'DELETE FROM ' . PORTAL_CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
$db->sql_query($sql);
$del_config = array(
'board3_links_' . $module_id,
'board3_links_url_new_window_' . $module_id
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
// Manage the menu links
public function manage_links($value, $key, $module_id)
{
global $config, $phpbb_admin_path, $user, $phpEx, $db, $template;
$action = request_var('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action;
$action = (isset($_POST['save'])) ? 'save' : $action;
$link_id = request_var('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach
$portal_config = obtain_portal_config();
$links = array();
$links = $this->utf_unserialize($portal_config['board3_links_array_' . $module_id]);
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id);
switch ($action)
{
// Save changes
case 'save':
if (!check_form_key('acp_portal'))
{
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
}
$link_title = utf8_normalize_nfc(request_var('link_title', ' ', true));
$link_type = request_var('link_type', 2); // default to B3_LINK_EXT, no categories in Links block
$link_url = utf8_normalize_nfc(request_var('link_url', ' ', true));
$link_url = str_replace('&amp;', '&', $link_url);
$link_permission = request_var('permission-setting-link', array(0 => ''));
$groups_ary = array();
// get groups and check if the selected groups actually exist
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
$db->sql_freeresult($result);
$link_permissions = array_intersect($link_permission, $groups_ary);
$link_permissions = implode(',', $link_permissions);
// Check for errors
if (!$link_title)
{
trigger_error($user->lang['NO_LINK_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
}
if (!$link_url)
{
trigger_error($user->lang['NO_LINK_URL'] . adm_back_link($u_action), E_USER_WARNING);
}
// overwrite already existing links and make sure we don't try to save a link outside of the normal array size of $links
if (isset($link_id) && $link_id < sizeof($links))
{
$message = $user->lang['LINK_UPDATED'];
$links[$link_id] = array(
'title' => $link_title,
'url' => htmlspecialchars_decode($link_url),
'type' => $link_type,
'permission' => $link_permissions,
);
add_log('admin', 'LOG_PORTAL_LINK_UPDATED', $link_title);
}
else
{
$message = $user->lang['LINK_ADDED'];
$links[] = array(
'title' => $link_title,
'url' => htmlspecialchars_decode($link_url),
'type' => $link_type,
'permission' => $link_permissions,
);
add_log('admin', 'LOG_PORTAL_LINK_ADDED', $link_title);
}
$board3_links_array = serialize($links);
set_portal_config('board3_links_array_' . $module_id, $board3_links_array);
trigger_error($message . adm_back_link($u_action));
break;
// Delete link
case 'delete':
if (!isset($link_id) && $link_id >= sizeof($links))
{
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
}
if (confirm_box(true))
{
$cur_link_title = $links[$link_id]['title'];
// delete the selected link and reset the array numbering afterwards
array_splice($links, $link_id, 1);
$links = array_merge($links);
$board3_links_array = serialize($links);
set_portal_config('board3_links_array_' . $module_id, $board3_links_array);
add_log('admin', 'LOG_PORTAL_LINK_REMOVED', $cur_link_title);
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'link_id' => $link_id,
'action' => 'delete',
)));
}
break;
// Move items up or down
case 'move_up':
case 'move_down':
if (!isset($link_id) && $link_id >= sizeof($links))
{
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
}
// make sure we don't try to move a link where it can't be moved
if (($link_id == 0 && $action == 'move_up') || ($link_id == (sizeof($links) - 1) && $action == 'move_down'))
{
break;
}
/*
* on move_down, switch position with next order_id...
* on move_up, switch position with previous order_id...
* move up means a lower ID, move down means a higher ID
*/
$switch_order_id = ($action == 'move_down') ? $link_id + 1 : $link_id - 1;
// back up the info of the link we want to move
$cur_link = array(
'title' => $links[$link_id]['title'],
'url' => $links[$link_id]['url'],
'type' => $links[$link_id]['type'],
'permission' => $links[$link_id]['permission'],
);
// move the info of the links we replace in the order
$links[$link_id] = array(
'title' => $links[$switch_order_id]['title'],
'url' => $links[$switch_order_id]['url'],
'type' => $links[$switch_order_id]['type'],
'permission' => $links[$switch_order_id]['permission'],
);
// insert the info of the moved link
$links[$switch_order_id] = $cur_link;
$board3_links_array = serialize($links);
set_portal_config('board3_links_array_' . $module_id, $board3_links_array);
break;
// Edit or add menu item
case 'edit':
case 'add':
$template->assign_vars(array(
'LINK_TITLE' => (isset($links[$link_id]['title']) && $action != 'add') ? $links[$link_id]['title'] : '',
'LINK_URL' => (isset($links[$link_id]['url']) && $action != 'add') ? str_replace('&', '&amp;', $links[$link_id]['url']) : '',
//'U_BACK' => $u_action,
'U_ACTION' => $u_action . '&amp;id=' . $link_id,
'S_EDIT' => true,
'S_LINK_IS_INT' => (isset($links[$link_id]['type']) && $links[$link_id]['type'] == self::LINK_INT) ? true : false,
));
$groups_ary = (isset($links[$link_id]['permission'])) ? explode(',', $links[$link_id]['permission']) : array();
// get group info from database and assign the block vars
$sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('permission_setting_link', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'],
));
}
$db->sql_freeresult($result);
return;
break;
}
for ($i = 0; $i < sizeof($links); $i++)
{
$template->assign_block_vars('links', array(
'LINK_TITLE' => ($action != 'add') ? ((isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title']) : '',
'LINK_URL' => ($action != 'add') ? str_replace('&', '&amp;', $links[$i]['url']) : '',
'U_EDIT' => $u_action . '&amp;action=edit&amp;id=' . $i,
'U_DELETE' => $u_action . '&amp;action=delete&amp;id=' . $i,
'U_MOVE_UP' => $u_action . '&amp;action=move_up&amp;id=' . $i,
'U_MOVE_DOWN' => $u_action . '&amp;action=move_down&amp;id=' . $i,
));
}
}
public function update_links($key, $module_id)
{
$this->manage_links('', $key, $module_id);
}
// Unserialize links array
private function utf_unserialize($serial_str)
{
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
return unserialize($out);
}
}

View File

@@ -0,0 +1,477 @@
<?php
/**
*
* @package Board3 Portal v2 - Main Menu
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Main Menu
*/
class portal_main_menu_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'M_MENU';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_menu.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_main_menu_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = 'acp_portal_menu';
/**
* constants
*/
const LINK_CAT = 0;
const LINK_INT = 1;
const LINK_EXT = 2;
public function get_template_side($module_id)
{
global $config, $template, $phpEx, $phpbb_root_path, $user, $db;
$links = array();
$portal_config = obtain_portal_config();
$links = $this->utf_unserialize($portal_config['board3_menu_array_' . $module_id]);
// get user's groups
$groups_ary = get_user_groups();
for ($i = 0; $i < sizeof($links); $i++)
{
if($links[$i]['type'] == self::LINK_CAT)
{
$template->assign_block_vars('portalmenu', array(
'CAT_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'],
'MODULE_ID' => $module_id,
));
}
else
{
if($links[$i]['type'] == self::LINK_INT)
{
$links[$i]['url'] = str_replace('&', '&amp;', $links[$i]['url']); // we need to do this in order to prevent XHTML validation errors
$cur_url = append_sid($phpbb_root_path . $links[$i]['url']); // the user should know what kind of file it is
}
else
{
$cur_url = $links[$i]['url'];
}
$cur_permissions = explode(',', $links[$i]['permission']);
$permission_check = array_intersect($groups_ary, $cur_permissions);
if(!empty($permission_check) || $links[$i]['permission'] == '')
{
$template->assign_block_vars('portalmenu.links', array(
'LINK_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'],
'LINK_URL' => $cur_url,
'NEW_WINDOW' => ($links[$i]['type'] != self::LINK_INT && $config['board3_menu_url_new_window_' . $module_id]) ? true : false,
));
}
}
}
return 'main_menu_side.html';
}
public function get_template_acp($module_id)
{
// do not remove this as it is needed in order to run manage_links
return array(
'title' => 'ACP_PORTAL_MENU',
'vars' => array(
'legend1' => 'ACP_PORTAL_MENU',
'board3_menu_' . $module_id => array('lang' => 'ACP_PORTAL_MENU_MANAGE', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'manage_links', 'submit' => 'update_links'),
'board3_menu_url_new_window_' . $module_id => array('lang' => 'ACP_PORTAL_MENU_EXT_NEW_WINDOW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
global $phpbb_root_path, $phpEx, $db;
// get the correct group IDs from the database
$in_ary = array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA');
$sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' WHERE ' . $db->sql_in_set('group_name', $in_ary);
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[$row['group_name']] = $row['group_id'];
}
$links = array();
$links_titles = array(
'M_CONTENT',
'INDEX',
'SEARCH',
'REGISTER',
'MEMBERLIST',
'THE_TEAM',
'M_HELP',
'FAQ',
'M_BBCODE',
'M_TERMS',
'M_PRV',
);
$links_types = array(
self::LINK_CAT,
self::LINK_INT,
self::LINK_INT,
self::LINK_INT,
self::LINK_INT,
self::LINK_INT,
self::LINK_CAT,
self::LINK_INT,
self::LINK_INT,
self::LINK_INT,
self::LINK_INT,
);
$links_urls = array(
'',
'index.' . $phpEx,
'search.' . $phpEx,
'ucp.' . $phpEx . '?mode=register',
'memberlist.' . $phpEx,
'memberlist.' . $phpEx . '?mode=leaders',
'',
'faq.' . $phpEx,
'faq.' . $phpEx . '?mode=bbcode',
'ucp.' . $phpEx . '?mode=terms',
'ucp.' . $phpEx . '?mode=privacy',
);
$links_permissions = array(
'',
'',
'',
$groups_ary['GUESTS'],
$groups_ary['REGISTERED'] . ',' . $groups_ary['REGISTERED_COPPA'],
$groups_ary['REGISTERED'] . ',' . $groups_ary['REGISTERED_COPPA'],
'',
'',
'',
'',
'',
);
foreach($links_urls as $i => $url)
{
$links[] = array(
'title' => $links_titles[$i],
'url' => $links_urls[$i],
'type' => $links_types[$i],
'permission' => $links_permissions[$i],
);
}
$board3_menu_array = serialize($links);
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
set_config('board3_menu_' . $module_id, '');
set_config('board3_menu_url_new_window_' . $module_id, 0);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_menu_array_' . $module_id,
);
$sql = 'DELETE FROM ' . PORTAL_CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
$db->sql_query($sql);
$del_config = array(
'board3_menu_' . $module_id,
'board3_menu_url_new_window_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
// Manage the menu links
public function manage_links($value, $key, $module_id)
{
global $config, $phpbb_admin_path, $user, $phpEx, $db, $template;
$action = request_var('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action;
$action = (isset($_POST['save'])) ? 'save' : $action;
$link_id = request_var('id', 99999999); // 0 will trigger unwanted behavior, therefore we set a number we should never reach
$portal_config = obtain_portal_config();
$links = array();
$links = $this->utf_unserialize($portal_config['board3_menu_array_' . $module_id]);
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id);
switch ($action)
{
// Save changes
case 'save':
if (!check_form_key('acp_portal'))
{
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
}
$link_title = utf8_normalize_nfc(request_var('link_title', ' ', true));
$link_is_cat = request_var('link_is_cat', false);
$link_type = (!$link_is_cat) ? request_var('link_type', self::LINK_INT) : self::LINK_CAT;
$link_url = ($link_is_cat) ? ' ' : utf8_normalize_nfc(request_var('link_url', ' ', true));
$link_url = str_replace('&amp;', '&', $link_url);
$link_permission = request_var('permission-setting-menu', array(0 => ''));
$groups_ary = array();
// get groups and check if the selected groups actually exist
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
$db->sql_freeresult($result);
$link_permissions = array_intersect($link_permission, $groups_ary);
$link_permissions = implode(',', $link_permissions);
// Check for errors
if (!$link_title)
{
trigger_error($user->lang['NO_LINK_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
}
if (!$link_is_cat && !$link_url)
{
trigger_error($user->lang['NO_LINK_URL'] . adm_back_link($u_action), E_USER_WARNING);
}
// overwrite already existing links and make sure we don't try to save a link outside of the normal array size of $links
if (isset($link_id) && $link_id < sizeof($links))
{
$message = $user->lang['LINK_UPDATED'];
$links[$link_id] = array(
'title' => $link_title,
'url' => htmlspecialchars_decode($link_url),
'type' => $link_type,
'permission' => $link_permissions,
);
add_log('admin', 'LOG_PORTAL_LINK_UPDATED', $link_title);
}
else
{
$message = $user->lang['LINK_ADDED'];
if($link_type != self::LINK_CAT && sizeof($links) < 1)
{
trigger_error($user->lang['ACP_PORTAL_MENU_CREATE_CAT'] . adm_back_link($u_action), E_USER_WARNING);
}
$links[] = array(
'title' => $link_title,
'url' => htmlspecialchars_decode($link_url),
'type' => $link_type,
'permission' => $link_permissions,
);
add_log('admin', 'LOG_PORTAL_LINK_ADDED', $link_title);
}
$board3_menu_array = serialize($links);
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
trigger_error($message . adm_back_link($u_action));
break;
// Delete link
case 'delete':
if (!isset($link_id) && $link_id >= sizeof($links))
{
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
}
if (confirm_box(true))
{
$cur_link_title = $links[$link_id]['title'];
// delete the selected link and reset the array numbering afterwards
array_splice($links, $link_id, 1);
$links = array_merge($links);
$board3_menu_array = serialize($links);
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
add_log('admin', 'LOG_PORTAL_LINK_REMOVED', $cur_link_title);
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'link_id' => $link_id,
'action' => 'delete',
)));
}
break;
// Move items up or down
case 'move_up':
case 'move_down':
if (!isset($link_id) && $link_id >= sizeof($links))
{
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
}
// make sure we don't try to move a link where it can't be moved
if (($link_id == 0 && $action == 'move_up') || ($link_id == (sizeof($links) - 1) && $action == 'move_down'))
{
break;
}
/*
* on move_down, switch position with next order_id...
* on move_up, switch position with previous order_id...
* move up means a lower ID, move down means a higher ID
*/
$switch_order_id = ($action == 'move_down') ? $link_id + 1 : $link_id - 1;
// back up the info of the link we want to move
$cur_link = array(
'title' => $links[$link_id]['title'],
'url' => $links[$link_id]['url'],
'type' => $links[$link_id]['type'],
'permission' => $links[$link_id]['permission'],
);
// move the info of the links we replace in the order
$links[$link_id] = array(
'title' => $links[$switch_order_id]['title'],
'url' => $links[$switch_order_id]['url'],
'type' => $links[$switch_order_id]['type'],
'permission' => $links[$switch_order_id]['permission'],
);
// insert the info of the moved link
$links[$switch_order_id] = $cur_link;
$board3_menu_array = serialize($links);
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
break;
// Edit or add menu item
case 'edit':
case 'add':
$template->assign_vars(array(
'LINK_TITLE' => (isset($links[$link_id]['title']) && $action != 'add') ? $links[$link_id]['title'] : '',
'LINK_URL' => (isset($links[$link_id]['url']) && $links[$link_id]['type'] != self::LINK_CAT && $action != 'add') ? str_replace('&', '&amp;', $links[$link_id]['url']) : '',
//'U_BACK' => $u_action,
'U_ACTION' => $u_action . '&amp;id=' . $link_id,
'S_EDIT' => true,
'S_LINK_IS_CAT' => (!isset($links[$link_id]['type']) || $links[$link_id]['type'] == self::LINK_CAT) ? true : false,
'S_LINK_IS_INT' => (isset($links[$link_id]['type']) && $links[$link_id]['type'] == self::LINK_INT) ? true : false,
));
$groups_ary = (isset($links[$link_id]['permission'])) ? explode(',', $links[$link_id]['permission']) : array();
// get group info from database and assign the block vars
$sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('permission_setting_menu', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'],
));
}
$db->sql_freeresult($result);
return;
break;
}
for ($i = 0; $i < sizeof($links); $i++)
{
$template->assign_block_vars('links', array(
'LINK_TITLE' => ($action != 'add') ? ((isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title']) : '',
'LINK_URL' => ($action != 'add') ? str_replace('&', '&amp;', $links[$i]['url']) : '',
'U_EDIT' => $u_action . '&amp;action=edit&amp;id=' . $i,
'U_DELETE' => $u_action . '&amp;action=delete&amp;id=' . $i,
'U_MOVE_UP' => $u_action . '&amp;action=move_up&amp;id=' . $i,
'U_MOVE_DOWN' => $u_action . '&amp;action=move_down&amp;id=' . $i,
'S_LINK_IS_CAT' => ($links[$i]['type'] == self::LINK_CAT) ? true : false,
));
}
}
public function update_links($key, $module_id)
{
$this->manage_links('', $key, $module_id);
}
// Unserialize links array
private function utf_unserialize($serial_str)
{
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
return unserialize($out);
}
}

View File

@@ -0,0 +1,455 @@
<?php
/**
*
* @package Board3 Portal v2 - News
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package News
*/
class portal_news_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'LATEST_NEWS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_news_module';
public function get_template_center($module_id)
{
global $config, $template, $db, $user, $auth, $cache, $phpEx, $phpbb_root_path;
$news = request_var('news', -1);
$news = ($news > $config['board3_number_of_news_' . $module_id] -1) ? -1 : $news;
$user->add_lang('viewforum');
$start = request_var('np', 0);
$start = ($start < 0) ? 0 : $start;
// Fetch news from portal/includes/functions.php with check if "read full" is requested.
$portal_news_length = ($news < 0) ? $config['board3_news_length_' . $module_id] : 0;
$fetch_news = phpbb_fetch_posts($module_id, $config['board3_news_forum_' . $module_id], $config['board3_news_permissions_' . $module_id], $config['board3_number_of_news_' . $module_id], $portal_news_length, 0, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $start, $config['board3_news_exclude_' . $module_id]);
// Any news present? If not terminate it here.
if (sizeof($fetch_news) == 0)
{
$template->assign_block_vars('news_row', array(
'S_NO_TOPICS' => true,
'S_NOT_LAST' => false,
));
}
else
{
// Count number of posts for news archive, considering if permission check is dis- or enabled.
if ($config['board3_news_archive_' . $module_id])
{
$permissions = $config['board3_news_permissions_' . $module_id];
$forum_from = $config['board3_news_forum_' . $module_id];
$forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
$str_where = '';
if($permissions == true)
{
$disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
}
else
{
$disallow_access = array();
}
if($config['board3_news_exclude_' . $module_id] == true)
{
$disallow_access = array_merge($disallow_access, $forum_from);
$forum_from = array();
}
if(sizeof($forum_from))
{
$disallow_access = array_diff($forum_from, $disallow_access);
if(!sizeof($disallow_access))
{
return array();
}
foreach($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "forum_id = $acc_id OR ";
}
}
else
{
foreach($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "forum_id <> $acc_id AND ";
}
}
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
$topic_type = ($config['board3_show_all_news_' . $module_id]) ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL;
$sql = 'SELECT COUNT(topic_id) AS num_topics
FROM ' . TOPICS_TABLE . '
WHERE ' . $topic_type . '
AND topic_visibility = ' . ITEM_APPROVED . '
AND topic_moved_id = 0
' . $str_where;
$result = $db->sql_query($sql);
$total_news = (int) $db->sql_fetchfield('num_topics');
$db->sql_freeresult($result);
}
$topic_tracking_info = get_portal_tracking_info($fetch_news);
if($news < 0)
// Show the news overview
{
$count = $fetch_news['topic_count'];
for ($i = 0; $i < $count; $i++)
{
if(isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true)
{
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $user->lang['READ_FULL'];
}
else
{
$open_bracket = '';
$close_bracket = '';
$read_full = '';
}
// unread?
$forum_id = $fetch_news[$i]['forum_id'];
$topic_id = $fetch_news[$i]['topic_id'];
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$read_full_url = (isset($_GET['np'])) ? 'np='. $start . '&amp;news=' . $i . '#n' . $i : 'news=' . $i . '#n' . $i;
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
if ($config['board3_news_archive_' . $module_id])
{
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news_' . $module_id], $start, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news');
}
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
$folder_img = $folder_alt = $topic_type = $folder = $folder_new = '';
switch ($fetch_news[$i]['topic_type'])
{
case POST_STICKY:
$folder = 'sticky_read';
$folder_new = 'sticky_unread';
break;
case POST_ANNOUNCE:
$folder = 'announce_read';
$folder_new = 'announce_unread';
break;
default:
$folder = 'topic_read';
$folder_new = 'topic_unread';
if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
{
$folder .= '_hot';
$folder_new .= '_hot';
}
break;
}
if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED)
{
$folder .= '_locked';
$folder_new .= '_locked';
}
if ($fetch_news[$i]['topic_posted'])
{
$folder .= '_mine';
$folder_new .= '_mine';
}
$folder_img = ($unread_topic) ? $folder_new : $folder;
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
// Grab icons
$icons = $cache->obtain_icons();
phpbb_generate_template_pagination($template, $view_topic_url, 'pagination', 'np', $fetch_news[$i]['topic_replies'], $config['board3_number_of_news_' . $module_id], $start);
$template->assign_block_vars('news_row', array(
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
'POSTER_FULL' => $fetch_news[$i]['username_full'],
'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'],
'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $fetch_news[$i]['user_id']) : '',
'TIME' => $fetch_news[$i]['topic_time'],
'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']),
'TEXT' => $fetch_news[$i]['post_text'],
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'N_ID' => $i,
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
'TOPIC_IMG_STYLE' => $folder_img,
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt],
'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '',
'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'),
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id'] . '&amp;p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id']),
'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id'] . '&amp;view=unread#unread'),
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&amp;f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id']),
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url),
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false,
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
if(!empty($fetch_news[$i]['attachments']))
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
$template->assign_block_vars('news_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
if ($config['board3_number_of_news_' . $module_id] <> 0 && $config['board3_news_archive_' . $module_id])
{
$template->assign_vars(array(
'NP_PAGINATION' => $pagination,
'TOTAL_NEWS' => ($total_news == 1) ? sprintf($user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($user->lang['VIEW_FORUM_TOPICS'][2], $total_news),
'NP_PAGE_NUMBER' => phpbb_on_page($template, $user, $view_topic_url, $total_news, $config['board3_number_of_news_' . $module_id], $start))
);
}
}
}
else
// Show "read full" page
{
$i = $news;
$forum_id = $fetch_news[$i]['forum_id'];
$topic_id = $fetch_news[$i]['topic_id'];
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $user->lang['BACK'];
$read_full_url = (isset($_GET['np'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "np=$start#n$i") : append_sid("{$phpbb_root_path}portal.$phpEx#n$i");
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
if ($config['board3_news_archive_' . $module_id])
{
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news_' . $module_id], $start, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news');
}
$template->assign_block_vars('news_row', array(
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
'POSTER_FULL' => $fetch_news[$i]['username_full'],
'TIME' => $fetch_news[$i]['topic_time'],
'TEXT' => $fetch_news[$i]['post_text'],
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'N_ID' => $i,
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id']),
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&amp;f=' . $fetch_news[$i]['forum_id'] . '&amp;t=' . $fetch_news[$i]['topic_id']),
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'U_READ_FULL' => $read_full_url,
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
if(!empty($fetch_news[$i]['attachments']))
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
$template->assign_block_vars('news_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
if ($config['board3_number_of_news_' . $module_id] <> 0 && $config['board3_news_archive_' . $module_id])
{
$template->assign_vars(array(
'NP_PAGINATION' => $pagination,
'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news),
'NP_PAGE_NUMBER' => on_page($total_news, $config['board3_number_of_news_' . $module_id], $start))
);
}
}
}
$topic_icons = false;
if(!empty($fetch_news['topic_icons']))
{
$topic_icons = true;
}
$template->assign_vars(array(
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'),
'S_NEWEST_OR_FIRST' => ($config['board3_news_show_last_' . $module_id]) ? $user->lang['JUMP_NEWEST'] : $user->lang['JUMP_FIRST'],
'POSTED_BY_TEXT' => ($config['board3_news_show_last_' . $module_id]) ? $user->lang['LAST_POST'] : $user->lang['POSTED'],
'S_DISPLAY_NEWS_RVS' => ($config['board3_show_news_replies_views_' . $module_id]) ? true : false,
'S_TOPIC_ICONS' => $topic_icons,
));
if($config['board3_news_style_' . $module_id])
{
return 'news_compact_center.html';
}
else
{
return 'news_center.html';
}
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_NEWS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_NEWS_SETTINGS',
'board3_news_style_' . $module_id => array('lang' => 'PORTAL_NEWS_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_show_all_news_' . $module_id => array('lang' => 'PORTAL_SHOW_ALL_NEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_number_of_news_' . $module_id => array('lang' => 'PORTAL_NUMBER_OF_NEWS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_news_length_' . $module_id => array('lang' => 'PORTAL_NEWS_LENGTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_news_forum_' . $module_id => array('lang' => 'PORTAL_NEWS_FORUM', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'),
'board3_news_exclude_' . $module_id => array('lang' => 'PORTAL_NEWS_EXCLUDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_news_show_last_' . $module_id => array('lang' => 'PORTAL_NEWS_SHOW_LAST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_news_archive_' . $module_id => array('lang' => 'PORTAL_NEWS_ARCHIVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_news_permissions_' . $module_id => array('lang' => 'PORTAL_NEWS_PERMISSIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_show_news_replies_views_' . $module_id => array('lang' => 'PORTAL_SHOW_REPLIES_VIEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
)
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_news_length_' . $module_id, 250);
set_config('board3_news_forum_' . $module_id, '');
set_config('board3_news_permissions_' . $module_id, 1);
set_config('board3_number_of_news_' . $module_id, 5);
set_config('board3_show_all_news_' . $module_id, 1);
set_config('board3_news_exclude_' . $module_id, 0);
set_config('board3_news_archive_' . $module_id, 1);
set_config('board3_news_show_last_' . $module_id, 0);
set_config('board3_show_news_replies_views_' . $module_id, 1);
set_config('board3_news_style_' . $module_id, 1);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_news_length_' . $module_id,
'board3_news_forum_' . $module_id,
'board3_news_permissions_' . $module_id,
'board3_number_of_news_' . $module_id,
'board3_show_all_news_' . $module_id,
'board3_news_exclude_' . $module_id,
'board3_news_archive_' . $module_id,
'board3_news_show_last_' . $module_id,
'board3_show_news_replies_views_' . $module_id,
'board3_news_style_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
// Create forum select box
public function select_forums($value, $key, $module_id)
{
global $user, $config;
$forum_list = make_forum_select(false, false, true, true, true, false, true);
$selected = array();
if(isset($config[$key]) && strlen($config[$key]) > 0)
{
$selected = explode(',', $config[$key]);
}
// Build forum options
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
foreach ($forum_list as $f_id => $f_row)
{
$s_forum_options .= '<option value="' . $f_id . '"' . ((in_array($f_id, $selected)) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
}
$s_forum_options .= '</select>';
return $s_forum_options;
}
// Store selected forums
public function store_selected_forums($key, $module_id)
{
global $db, $cache;
// Get selected extensions
$values = request_var($key, array(0 => ''));
$news = implode(',', $values);
set_config($key, $news);
}
}

View File

@@ -0,0 +1,533 @@
<?php
/**
*
* @package Board3 Portal v2 - Poll
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Poll
*/
class portal_poll_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'PORTAL_POLL';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_poll.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_poll_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
public function get_template_center($module_id)
{
return $this->parse_template($module_id);
}
public function get_template_side($module_id)
{
return $this->parse_template($module_id, 'side');
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_POLLS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_POLLS_SETTINGS',
'board3_poll_topic_id_' . $module_id => array('lang' => 'PORTAL_POLL_TOPIC_ID' , 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'),
'board3_poll_exclude_id_' . $module_id => array('lang' => 'PORTAL_POLL_EXCLUDE_ID' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_poll_limit_' . $module_id => array('lang' => 'PORTAL_POLL_LIMIT' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_poll_allow_vote_' . $module_id => array('lang' => 'PORTAL_POLL_ALLOW_VOTE' , 'validate' => 'ibool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_poll_hide_' . $module_id => array('lang' => 'PORTAL_POLL_HIDE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
)
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_poll_allow_vote_' . $module_id, 1);
set_config('board3_poll_topic_id_' . $module_id, '');
set_config('board3_poll_exclude_id_' . $module_id, 0);
set_config('board3_poll_hide_' . $module_id, 0);
set_config('board3_poll_limit_' . $module_id, 3);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_poll_allow_vote_' . $module_id,
'board3_poll_topic_id_' . $module_id,
'board3_poll_exclude_id_' . $module_id,
'board3_poll_hide_' . $module_id,
'board3_poll_limit_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
// Create forum select box
public function select_forums($value, $key, $module_id)
{
global $user, $config;
$forum_list = make_forum_select(false, false, true, true, true, false, true);
$selected = array();
if(isset($config[$key]) && strlen($config[$key]) > 0)
{
$selected = explode(',', $config[$key]);
}
// Build forum options
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
foreach ($forum_list as $f_id => $f_row)
{
$s_forum_options .= '<option value="' . $f_id . '"' . ((in_array($f_id, $selected)) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
}
$s_forum_options .= '</select>';
return $s_forum_options;
}
// Store selected forums
public function store_selected_forums($key, $module_id)
{
global $db, $cache;
// Get selected forums
$values = request_var($key, array(0 => ''));
$news = implode(',', $values);
set_config($key, $news);
}
/**
* Parse template variables for module
*
* @param int $module_id Module ID
* @param string $type Module type (center or side)
*/
protected function parse_template($module_id, $type = '')
{
global $config, $template, $db, $user, $auth, $phpbb_root_path, $phpEx;
$user->add_lang('viewtopic');
// check if we need to include the bbcode class
if(!class_exists('bbcode'))
{
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
}
$view = request_var('view', '');
$update = request_var('update', false);
$poll_view = request_var('polls', '');
$poll_view_ar = (strpos($poll_view, ',') !== FALSE) ? explode(',', $poll_view) : (($poll_view != '') ? array($poll_view) : array());
if ($update && $config['board3_poll_allow_vote_' . $module_id])
{
$up_topic_id = request_var('t', 0);
$up_forum_id = request_var('f', 0);
$voted_id = request_var('vote_id', array('' => 0));
$cur_voted_id = array();
if ($user->data['is_registered'])
{
$sql = 'SELECT poll_option_id
FROM ' . POLL_VOTES_TABLE . '
WHERE topic_id = ' . $up_topic_id . '
AND vote_user_id = ' . $user->data['user_id'];
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$cur_voted_id[] = $row['poll_option_id'];
}
$db->sql_freeresult($result);
}
else
{
// Cookie based guest tracking ... I don't like this but hum ho
// it's oft requested. This relies on "nice" users who don't feel
// the need to delete cookies to mess with results.
if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $up_topic_id]))
{
$cur_voted_id = explode(',', request_var($config['cookie_name'] . '_poll_' . $up_topic_id, 0, false, true));
$cur_voted_id = array_map('intval', $cur_voted_id);
}
}
$sql = 'SELECT t.poll_length, t.poll_start, t.poll_vote_change, t.topic_status, f.forum_status, t.poll_max_options
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
WHERE t.forum_id = f.forum_id AND t.topic_id = " . (int) $up_topic_id . " AND t.forum_id = " . (int) $up_forum_id;
$result = $db->sql_query_limit($sql, 1);
$topic_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$s_can_up_vote = (((!sizeof($cur_voted_id) && $auth->acl_get('f_vote', $up_forum_id)) ||
($auth->acl_get('f_votechg', $up_forum_id) && $topic_data['poll_vote_change'])) &&
(($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) &&
$topic_data['topic_status'] != ITEM_LOCKED &&
$topic_data['forum_status'] != ITEM_LOCKED) ? true : false;
if($s_can_up_vote)
{
if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id))
{
$redirect_url = append_sid("{$phpbb_root_path}portal.$phpEx");
meta_refresh(5, $redirect_url);
if (!sizeof($voted_id))
{
$message = 'NO_VOTE_OPTION';
}
else if (sizeof($voted_id) > $topic_data['poll_max_options'])
{
$message = 'TOO_MANY_VOTE_OPTIONS';
}
else
{
$message = 'VOTE_CONVERTED';
}
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>');
trigger_error($message);
}
foreach ($voted_id as $option)
{
if (in_array($option, $cur_voted_id))
{
continue;
}
$sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
SET poll_option_total = poll_option_total + 1
WHERE poll_option_id = ' . (int) $option . '
AND topic_id = ' . (int) $up_topic_id;
$db->sql_query($sql);
if ($user->data['is_registered'])
{
$sql_ary = array(
'topic_id' => (int) $up_topic_id,
'poll_option_id' => (int) $option,
'vote_user_id' => (int) $user->data['user_id'],
'vote_user_ip' => (string) $user->ip,
);
$sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
}
foreach ($cur_voted_id as $option)
{
if (!in_array($option, $voted_id))
{
$sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
SET poll_option_total = poll_option_total - 1
WHERE poll_option_id = ' . (int) $option . '
AND topic_id = ' . (int) $up_topic_id;
$db->sql_query($sql);
if ($user->data['is_registered'])
{
$sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
WHERE topic_id = ' . (int) $up_topic_id . '
AND poll_option_id = ' . (int) $option . '
AND vote_user_id = ' . (int) $user->data['user_id'];
$db->sql_query($sql);
}
}
}
if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot'])
{
$user->set_cookie('poll_' . $up_topic_id, implode(',', $voted_id), time() + 31536000);
}
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET poll_last_vote = ' . time() . "
WHERE topic_id = $up_topic_id";
//, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
$db->sql_query($sql);
$redirect_url = append_sid("{$phpbb_root_path}portal.$phpEx");
meta_refresh(5, $redirect_url);
trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>'));
}
}
$where = '';
$poll_forums = false;
// Get readable forums
$forum_list = array();
$forum_list = array_unique(array_keys($auth->acl_getf('f_read', true)));
if($config['board3_poll_topic_id_' . $module_id] !== '')
{
$poll_forums_config = explode(',' ,$config['board3_poll_topic_id_' . $module_id]);
if($config['board3_poll_exclude_id_' . $module_id])
{
$forum_list = array_unique(array_diff($forum_list, $poll_forums_config));
}
else
{
$forum_list = array_unique(array_intersect($poll_forums_config, $forum_list));
}
}
$where = '';
if(sizeof($forum_list))
{
$poll_forums = true;
$where = 'AND ' . $db->sql_in_set('t.forum_id', $forum_list);
}
if ($config['board3_poll_hide_' . $module_id])
{
$portal_poll_hide = "AND (t.poll_start + t.poll_length > ". time() ." OR t.poll_length = 0)";
}
else
{
$portal_poll_hide = '';
}
if ($poll_forums === true)
{
$sql = 'SELECT t.poll_title, t.poll_start, t.topic_id, t.topic_first_post_id, t.forum_id, t.poll_length, t.poll_vote_change, t.poll_max_options, t.topic_status, f.forum_status, p.bbcode_bitfield, p.bbcode_uid
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f
WHERE t.forum_id = f.forum_id AND t.topic_visibility = 1 AND t.poll_start > 0
{$where}
AND t.topic_moved_id = 0
AND p.post_id = t.topic_first_post_id
{$portal_poll_hide}
ORDER BY t.poll_start DESC";
$limit = (isset($config['board3_poll_limit_' . $module_id])) ? $config['board3_poll_limit_' . $module_id] : 3;
$result = $db->sql_query_limit($sql, $limit);
$has_poll = false;
if ($result)
{
while($data = $db->sql_fetchrow($result))
{
$has_poll = true;
$poll_has_options = false;
$topic_id = (int) $data['topic_id'];
$forum_id = (int) $data['forum_id'];
$cur_voted_id = array();
if($config['board3_poll_allow_vote_' . $module_id])
{
if ($user->data['is_registered'])
{
$vote_sql = 'SELECT poll_option_id
FROM ' . POLL_VOTES_TABLE . '
WHERE topic_id = ' . $topic_id . '
AND vote_user_id = ' . $user->data['user_id'];
$vote_result = $db->sql_query($vote_sql);
while ($row = $db->sql_fetchrow($vote_result))
{
$cur_voted_id[] = $row['poll_option_id'];
}
$db->sql_freeresult($vote_result);
}
else
{
// Cookie based guest tracking ... I don't like this but hum ho
// it's oft requested. This relies on "nice" users who don't feel
// the need to delete cookies to mess with results.
if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]))
{
$cur_voted_id = explode(',', request_var($config['cookie_name'] . '_poll_' . $topic_id, 0, false, true));
$cur_voted_id = array_map('intval', $cur_voted_id);
}
}
$s_can_vote = (((!sizeof($cur_voted_id) && $auth->acl_get('f_vote', $forum_id)) ||
($auth->acl_get('f_votechg', $forum_id) && $data['poll_vote_change'])) &&
(($data['poll_length'] != 0 && $data['poll_start'] + $data['poll_length'] > time()) || $data['poll_length'] == 0) &&
$data['topic_status'] != ITEM_LOCKED &&
$data['forum_status'] != ITEM_LOCKED) ? true : false;
}
else
{
$s_can_vote = false;
}
$s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || ($view == 'viewpoll' && in_array($topic_id, $poll_view_ar))) ? true : false;
$poll_sql = 'SELECT po.poll_option_id, po.poll_option_text, po.poll_option_total
FROM ' . POLL_OPTIONS_TABLE . " po
WHERE po.topic_id = {$topic_id}
ORDER BY po.poll_option_id";
$poll_result = $db->sql_query($poll_sql);
$poll_total_votes = 0;
$poll_data = array();
if ($poll_result)
{
while($polls_data = $db->sql_fetchrow($poll_result))
{
$poll_has_options = true;
$poll_data[] = $polls_data;
$poll_total_votes += $polls_data['poll_option_total'];
}
}
$db->sql_freeresult($poll_result);
$make_poll_view = array();
if(in_array($topic_id, $poll_view_ar) === FALSE)
{
$make_poll_view[] = $topic_id;
$make_poll_view = array_merge($poll_view_ar, $make_poll_view);
}
$poll_view_str = urlencode(implode(',', $make_poll_view));
$portalpoll_url= append_sid("{$phpbb_root_path}portal.$phpEx", "polls=$poll_view_str");
$portalvote_url= append_sid("{$phpbb_root_path}portal.$phpEx", "f=$forum_id&amp;t=$topic_id");
$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id");
$poll_end = $data['poll_length'] + $data['poll_start'];
// Parse BBCode title
if ($data['bbcode_bitfield'])
{
$poll_bbcode = new bbcode();
}
else
{
$poll_bbcode = false;
}
$data['poll_title'] = censor_text($data['poll_title']);
if ($poll_bbcode !== false)
{
$poll_bbcode->bbcode_second_pass($data['poll_title'], $data['bbcode_uid'], $data['bbcode_bitfield']);
}
$data['poll_title'] = bbcode_nl2br($data['poll_title']);
$data['poll_title'] = smiley_text($data['poll_title']);
unset($poll_bbcode);
$template->assign_block_vars(($type !== '') ? 'poll_' . $type : 'poll', array(
'S_POLL_HAS_OPTIONS' => $poll_has_options,
'POLL_QUESTION' => $data['poll_title'],
'U_POLL_TOPIC' => append_sid($phpbb_root_path . 'viewtopic.' . $phpEx . '?t=' . $topic_id . '&amp;f=' . $forum_id),
'POLL_LENGTH' => $data['poll_length'],
'TOPIC_ID' => $topic_id,
'TOTAL_VOTES' => $poll_total_votes,
'L_MAX_VOTES' => ($data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $data['poll_max_options']),
'L_POLL_LENGTH' => ($data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '',
'S_CAN_VOTE' => $s_can_vote,
'S_DISPLAY_RESULTS' => $s_display_results,
'S_IS_MULTI_CHOICE' => ($data['poll_max_options'] > 1) ? true : false,
'S_POLL_ACTION' => $portalvote_url,
'U_VIEW_RESULTS' => $portalpoll_url . '&amp;view=viewpoll#viewpoll',
'U_VIEW_TOPIC' => $viewtopic_url,
));
foreach($poll_data as $pd)
{
$option_pct = ($poll_total_votes > 0) ? $pd['poll_option_total'] / $poll_total_votes : 0;
$option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
// Parse BBCode option text
if ($data['bbcode_bitfield'])
{
$poll_bbcode = new bbcode();
}
else
{
$poll_bbcode = false;
}
$pd['poll_option_text'] = censor_text($pd['poll_option_text']);
if ($poll_bbcode !== false)
{
$poll_bbcode->bbcode_second_pass($pd['poll_option_text'], $data['bbcode_uid'], $data['bbcode_bitfield']);
}
$pd['poll_option_text'] = bbcode_nl2br($pd['poll_option_text']);
$pd['poll_option_text'] = smiley_text($pd['poll_option_text']);
unset($poll_bbcode);
$template->assign_block_vars((($type !== '') ? 'poll_' . $type : 'poll') . '.poll_option', array(
'POLL_OPTION_ID' => $pd['poll_option_id'],
'POLL_OPTION_CAPTION' => $pd['poll_option_text'],
'POLL_OPTION_RESULT' => $pd['poll_option_total'],
'POLL_OPTION_PERCENT' => $option_pct_txt,
'POLL_OPTION_PCT' => round($option_pct * 100),
'POLL_OPTION_IMG' => $user->img('poll_center', $option_pct_txt, round($option_pct * 35) . 'px'),
'POLL_OPTION_VOTED' => (in_array($pd['poll_option_id'], $cur_voted_id)) ? true : false
));
}
}
}
$db->sql_freeresult($result);
$template->assign_vars(array(
'S_HAS_POLL' => $has_poll,
'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),
'POLL_RIGHT_CAP_IMG' => $user->img('poll_right'),
));
}
return (($type !== '') ? 'poll_' . $type : 'poll_center') . '.html';
}
}

View File

@@ -0,0 +1,142 @@
<?php
/**
*
* @package Board3 Portal v2 - Random Member
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Random Member
*/
class portal_random_member_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'PORTAL_RANDOM_MEMBER';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_random_member.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_random_member_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
public function get_template_side($module_id)
{
global $config, $template, $db, $user;
switch ($db->sql_layer)
{
case 'postgres':
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . '
AND user_type <> ' . USER_INACTIVE . '
ORDER BY RANDOM()';
break;
case 'mssql':
case 'mssql_odbc':
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . '
AND user_type <> ' . USER_INACTIVE . '
ORDER BY NEWID()';
break;
default:
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . '
AND user_type <> ' . USER_INACTIVE . '
ORDER BY RAND()';
break;
}
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$avatar_img = get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']);
$rank_title = $rank_img = '';
get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src);
$username = $row['username'];
$user_id = (int) $row['user_id'];
$colour = $row['user_colour'];
$template->assign_block_vars('random_member', array(
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour),
'USERNAME' => get_username_string('username', $user_id, $username, $colour),
'USER_COLOR' => get_username_string('colour', $user_id, $username, $colour),
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour),
'RANK_TITLE' => $rank_title,
'RANK_IMG' => $rank_img,
'RANK_IMG_SRC' => $rank_img_src,
'USER_POSTS' => (int) $row['user_posts'],
'AVATAR_IMG' => $avatar_img,
'JOINED' => $user->format_date($row['user_regdate'], 'd.M.Y'),
'USER_OCC' => censor_text($row['user_occ']),
'USER_FROM' => censor_text($row['user_from']),
'U_WWW' => censor_text($row['user_website']),
));
$db->sql_freeresult($result);
return 'random_member_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_RANDOM_MEMBER',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
}

View File

@@ -0,0 +1,251 @@
<?php
/**
*
* @package Board3 Portal v2 - Recent
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Recent
*/
class portal_recent_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'PORTAL_RECENT';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_recent_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
public function get_template_center($module_id)
{
global $config, $template, $db, $auth, $phpbb_root_path, $phpEx;
//
// Exclude forums
//
$sql_where = '';
if ($config['board3_recent_forum_' . $module_id] > 0)
{
$exclude_forums = explode(',', $config['board3_recent_forum_' . $module_id]);
$sql_where = ' AND ' . $db->sql_in_set('forum_id', array_map('intval', $exclude_forums), ($config['board3_recent_exclude_forums_' . $module_id]) ? true : false);
}
// Get a list of forums the user cannot read
$forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true)));
// Determine first forum the user is able to read (must not be a category)
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST;
$forum_sql = '';
if (sizeof($forum_ary))
{
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
$forum_sql = ' AND ' . $db->sql_in_set('t.forum_id', $forum_ary, true);
}
$result = $db->sql_query_limit($sql, 1);
$g_forum_id = (int) $db->sql_fetchfield('forum_id');
$db->sql_freeresult($result);
//
// Recent announcements
//
$sql = 'SELECT topic_title, forum_id, topic_id
FROM ' . TOPICS_TABLE . ' t
WHERE topic_status <> ' . FORUM_LINK . '
AND topic_visibility = ' . ITEM_APPROVED . '
AND (topic_type = ' . POST_ANNOUNCE . ' OR topic_type = ' . POST_GLOBAL . ')
AND topic_moved_id = 0
' . $sql_where . '' . $forum_sql . '
ORDER BY topic_time DESC';
$result = $db->sql_query_limit($sql, $config['board3_max_topics_' . $module_id]);
while(($row = $db->sql_fetchrow($result)) && ($row['topic_title']))
{
// auto auth
if (($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0'))
{
$template->assign_block_vars('latest_announcements', array(
'TITLE' => character_limit($row['topic_title'], $config['board3_recent_title_limit_' . $module_id]),
'FULL_TITLE' => censor_text($row['topic_title']),
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id'] == 0) ? $g_forum_id : $row['forum_id']) . '&amp;t=' . $row['topic_id'])
));
}
}
$db->sql_freeresult($result);
//
// Recent hot topics
//
$sql = 'SELECT topic_title, forum_id, topic_id
FROM ' . TOPICS_TABLE . ' t
WHERE topic_visibility = ' . ITEM_APPROVED . '
AND topic_posts_approved >' . $config['hot_threshold'] . '
AND topic_moved_id = 0
' . $sql_where . '' . $forum_sql . '
ORDER BY topic_time DESC';
$result = $db->sql_query_limit($sql, $config['board3_max_topics_' . $module_id]);
while(($row = $db->sql_fetchrow($result)) && ($row['topic_title']))
{
// auto auth
if (($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0'))
{
$template->assign_block_vars('latest_hot_topics', array(
'TITLE' => character_limit($row['topic_title'], $config['board3_recent_title_limit_' . $module_id]),
'FULL_TITLE' => censor_text($row['topic_title']),
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id'] == 0) ? $g_forum_id : $row['forum_id']) . '&amp;t=' . $row['topic_id'])
));
}
}
$db->sql_freeresult($result);
//
// Recent topic (only show normal topic)
//
$sql = 'SELECT topic_title, forum_id, topic_id
FROM ' . TOPICS_TABLE . ' t
WHERE topic_status <> ' . ITEM_MOVED . '
AND topic_visibility = ' . ITEM_APPROVED . '
AND topic_type = ' . POST_NORMAL . '
AND topic_moved_id = 0
' . $sql_where . '' . $forum_sql . '
ORDER BY topic_time DESC';
$result = $db->sql_query_limit($sql, $config['board3_max_topics_' . $module_id]);
while(($row = $db->sql_fetchrow($result)) && ($row['topic_title']))
{
// auto auth
if (($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0'))
{
$template->assign_block_vars('latest_topics', array(
'TITLE' => character_limit($row['topic_title'], $config['board3_recent_title_limit_' . $module_id]),
'FULL_TITLE' => censor_text($row['topic_title']),
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'])
));
}
}
$db->sql_freeresult($result);
return 'recent_center.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_RECENT_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_RECENT_SETTINGS',
'board3_max_topics_' . $module_id => array('lang' => 'PORTAL_MAX_TOPIC', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_recent_title_limit_' . $module_id => array('lang' => 'PORTAL_RECENT_TITLE_LIMIT', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_recent_forum_' . $module_id => array('lang' => 'PORTAL_RECENT_FORUM', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'),
'board3_recent_exclude_forums_' . $module_id => array('lang' => 'PORTAL_EXCLUDE_FORUM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
)
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_max_topics_' . $module_id, 10);
set_config('board3_recent_title_limit_' . $module_id, 100);
set_config('board3_recent_forum_' . $module_id, '');
set_config('board3_recent_exclude_forums_' . $module_id, 1);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_max_topics_' . $module_id,
'board3_recent_title_limit_' . $module_id,
'board3_recent_forum_' . $module_id,
'board3_recent_exclude_forums_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
// Create forum select box
public function select_forums($value, $key, $module_id)
{
global $user, $config;
$forum_list = make_forum_select(false, false, true, true, true, false, true);
$selected = array();
if(isset($config[$key]) && strlen($config[$key]) > 0)
{
$selected = explode(',', $config[$key]);
}
// Build forum options
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
foreach ($forum_list as $f_id => $f_row)
{
$s_forum_options .= '<option value="' . $f_id . '"' . ((in_array($f_id, $selected)) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
}
$s_forum_options .= '</select>';
return $s_forum_options;
}
// Store selected forums
public function store_selected_forums($key, $module_id)
{
global $db, $cache;
// Get selected extensions
$values = request_var($key, array(0 => ''));
$news = implode(',', $values);
set_config($key, $news);
}
}

View File

@@ -0,0 +1,85 @@
<?php
/**
*
* @package Board3 Portal v2 - Search
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Search
*/
class portal_search_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'PORTAL_SEARCH';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_search.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_search_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
public function get_template_side($module_id)
{
global $template, $phpbb_root_path, $phpEx;
$template->assign_var('S_SEARCH_ACTION', append_sid("{$phpbb_root_path}search.$phpEx"));
return 'search_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_SEARCH',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
}

View File

@@ -0,0 +1,197 @@
<?php
/**
*
* @package Board3 Portal v2 - Statistics
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Statistics
*/
class portal_statistics_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'STATISTICS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_statistics.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_statistics_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
public function get_template_side($module_id)
{
global $config, $template, $user;
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts = $config['num_posts'];
$total_topics = $config['num_topics'];
$total_users = $config['num_users'];
$total_files = $config['num_files'];
$l_total_user_s = ($total_users == 0) ? sprintf($user->lang['TOTAL_USERS_ZERO'], $total_users) : sprintf($user->lang['TOTAL_USERS'][2], $total_users);
$l_total_post_s = ($total_posts == 0) ? sprintf($user->lang['TOTAL_POSTS_ZERO'], $total_posts) : sprintf($user->lang['TOTAL_POSTS_COUNT'][2], $total_posts);
$l_total_topic_s = ($total_topics == 0) ? sprintf($user->lang['TOTAL_TOPICS_ZERO'], $total_topics) : sprintf($user->lang['TOTAL_TOPICS'][2], $total_topics);
// avarage stat
$board_days = (time() - $config['board_startdate']) / 86400;
$topics_per_day = ($total_topics) ? round($total_topics / $board_days, 0) : 0;
$posts_per_day = ($total_posts) ? round($total_posts / $board_days, 0) : 0;
$users_per_day = round($total_users / $board_days, 0);
$topics_per_user = ($total_topics) ? round($total_topics / $total_users, 0) : 0;
$posts_per_user = ($total_posts) ? round($total_posts / $total_users, 0) : 0;
$posts_per_topic = ($total_topics) ? round($total_posts / $total_topics, 0) : 0;
if ($topics_per_day > $total_topics)
{
$topics_per_day = $total_topics;
}
if ($posts_per_day > $total_posts)
{
$posts_per_day = $total_posts;
}
if ($users_per_day > $total_users)
{
$users_per_day = $total_users;
}
if ($topics_per_user > $total_topics)
{
$topics_per_user = $total_topics;
}
if ($posts_per_user > $total_posts)
{
$posts_per_user = $total_posts;
}
if ($posts_per_topic > $total_posts)
{
$posts_per_topic = $total_posts;
}
$l_topics_per_day_s = ($total_topics == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
$l_posts_per_day_s = ($total_posts == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
$l_users_per_day_s = ($total_users == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
$l_topics_per_user_s = ($total_topics == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
$l_posts_per_user_s = ($total_posts == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
$l_posts_per_topic_s = ($total_posts == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';
$topics_count = $this->get_topics_count();
// Assign specific vars
$template->assign_vars(array(
'B3_TOTAL_POSTS' => $l_total_post_s,
'B3_TOTAL_TOPICS' => $l_total_topic_s,
'B3_TOTAL_USERS' => $l_total_user_s,
'B3_NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
'B3_ANNOUNCE_COUNT' => $topics_count[POST_ANNOUNCE],
'B3_STICKY_COUNT' => $topics_count[POST_STICKY],
'B3_TOTAL_ATTACH' => ($config['allow_attachments']) ? $total_files : 0,
// average stat
'B3_TOPICS_PER_DAY' => sprintf($user->lang[$l_topics_per_day_s], $topics_per_day),
'B3_POSTS_PER_DAY' => sprintf($user->lang[$l_posts_per_day_s], $posts_per_day),
'B3_USERS_PER_DAY' => sprintf($user->lang[$l_users_per_day_s], $users_per_day),
'B3_TOPICS_PER_USER' => sprintf($user->lang[$l_topics_per_user_s], $topics_per_user),
'B3_POSTS_PER_USER' => sprintf($user->lang[$l_posts_per_user_s], $posts_per_user),
'B3_POSTS_PER_TOPIC' => sprintf($user->lang[$l_posts_per_topic_s], $posts_per_topic),
));
return 'statistics_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'STATISTICS',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
// Better function with only one query
public function get_topics_count()
{
global $db, $user;
$return_ary = array(
POST_ANNOUNCE => 0,
POST_STICKY => 0,
);
$sql_in = array(
POST_ANNOUNCE,
POST_STICKY,
);
$sql = 'SELECT DISTINCT(topic_id) AS topic_id, topic_type AS type
FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_type', $sql_in, false);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
switch($row['type'])
{
case POST_ANNOUNCE:
++$return_ary[POST_ANNOUNCE];
break;
case POST_STICKY:
++$return_ary[POST_STICKY];
break;
}
}
$db->sql_freeresult($result);
return $return_ary;
}
}

View File

@@ -0,0 +1,110 @@
<?php
/**
*
* @package Board3 Portal v2 - Stylechanger
* @copyright (c) Board3 Group ( www.board3.de )
* @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
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'BOARD_STYLE';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_style.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_stylechanger_module';
public function get_template_side($module_id)
{
global $config, $template, $db, $phpEx, $phpbb_root_path, $user;
$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 (!empty($style))
{
$url = str_replace('style=' . $style, 'style=' . $row['style_id'], append_sid("{$phpbb_root_path}app.$phpEx", 'controller=portal'));
}
else
{
$url = append_sid("{$phpbb_root_path}app.$phpEx", 'controller=portal&amp;style=' . $row['style_id']);
}
++$style_count;
$style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $user->style['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']),
));
return 'stylechanger_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'BOARD_STYLE',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
}

View File

@@ -0,0 +1,112 @@
<?php
/**
*
* @package Board3 Portal v2 - Topposters
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Topposters
*/
class portal_topposters_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'TOPPOSTERS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_top_poster.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_topposters_module';
public function get_template_center($module_id)
{
return false;
}
public function get_template_side($module_id)
{
global $config, $db, $template;
global $phpbb_root_path, $phpEx;
$sql = 'SELECT user_id, username, user_posts, user_colour
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . "
AND user_posts <> 0
AND username <> ''
ORDER BY user_posts DESC";
$result = $db->sql_query_limit($sql, $config['board3_topposters_' . $module_id]);
while (($row = $db->sql_fetchrow($result)))
{
$template->assign_block_vars('topposters', array(
'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $row['user_id'] . '&amp;sr=posts'),
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'POSTER_POSTS' => $row['user_posts'],
));
}
$db->sql_freeresult($result);
return 'topposters_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'TOPPOSTERS_CONFIG',
'vars' => array(
'legend1' => 'TOPPOSTERS',
'board3_topposters_' . $module_id => array('lang' => 'NUM_TOPPOSTERS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_topposters_' . $module_id, 5);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_topposters_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}

View File

@@ -0,0 +1,181 @@
<?php
/**
*
* @package Board3 Portal v2 - User Menu
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Modulname
*/
class portal_user_menu_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'USER_MENU';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_user.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_user_menu_module';
public function get_template_side($module_id)
{
global $config, $template, $user, $auth, $db, $phpEx, $phpbb_root_path;
if (!function_exists('get_user_avatar'))
{
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}
if ($user->data['is_registered'])
{
//
// + new posts since last visit & you post number
//
$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
if ($auth->acl_get('m_approve'))
{
$m_approve_fid_ary = array(-1);
$m_approve_fid_sql = '';
}
else if ($auth->acl_getf_global('m_approve'))
{
$m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
}
else
{
$m_approve_fid_ary = array();
$m_approve_fid_sql = ' AND p.post_approved = 1';
}
$sql = 'SELECT COUNT(distinct t.topic_id) as total
FROM ' . TOPICS_TABLE . ' t
WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
AND t.topic_moved_id = 0
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
$result = $db->sql_query($sql);
$new_posts_count = (int) $db->sql_fetchfield('total');
$db->sql_freeresult($result);
// unread posts
$sql_where = 'AND t.topic_moved_id = 0
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
$unread_list = array();
$unread_list = get_unread_topics($user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC');
$unread_posts_count = sizeof($unread_list);
// Get user avatar and rank
$user_id = $user->data['user_id'];
$username = $user->data['username'];
$colour = $user->data['user_colour'];
$avatar_img = get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']);
$rank_title = $rank_img = '';
get_user_rank($user->data['user_rank'], $user->data['user_posts'], $rank_title, $rank_img, $rank_img_src);
// Assign specific vars
$template->assign_vars(array(
'L_NEW_POSTS' => $user->lang['SEARCH_NEW'] . '&nbsp;(' . $new_posts_count . ')',
'L_SELF_POSTS' => $user->lang['SEARCH_SELF'] . '&nbsp;(' . $user->data['user_posts'] . ')',
'L_UNREAD_POSTS'=> $user->lang['SEARCH_UNREAD'] . '&nbsp;(' . $unread_posts_count . ')',
'B3P_AVATAR_IMG' => $avatar_img,
'B3P_RANK_TITLE' => $rank_title,
'B3P_RANK_IMG' => $rank_img,
'RANK_IMG_SRC' => $rank_img_src,
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour),
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour),
'U_NEW_POSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'),
'U_SELF_POSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'),
'U_UNREAD_POSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'),
'U_UM_BOOKMARKS' => ($config['allow_bookmarks']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&amp;mode=bookmarks') : '',
'U_UM_MAIN_SUBSCRIBED' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&amp;mode=subscribed'),
'U_UM_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '',
'S_DISPLAY_SUBSCRIPTIONS' => ($config['allow_topic_notify'] || $config['allow_forum_notify']) ? true : false,
));
return 'user_menu_side.html';
}
else
{
// Assign specific vars
$template->assign_vars(array(
'U_PORTAL' => append_sid("{$phpbb_root_path}portal.$phpEx"),
'S_DISPLAY_FULL_LOGIN' => true,
'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false,
'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
'S_SHOW_REGISTER' => ($config['board3_user_menu_register_' . $module_id]) ? true : false,
));
return 'login_box_side.html';
}
}
public function get_template_acp($module_id)
{
return array(
'title' => 'USER_MENU',
'vars' => array(
'legend1' => 'USER_MENU_SETTINGS',
'board3_user_menu_register_' . $module_id => array('lang' => 'USER_MENU_REGISTER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_user_menu_register_' . $module_id, 1);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_user_menu_register_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}

View File

@@ -0,0 +1,217 @@
<?php
/**
*
* @package Board3 Portal v2 - Welcome
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Welcome
*/
class portal_welcome_module
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'PORTAL_WELCOME';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_welcome_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = 'acp_portal_welcome';
public function get_template_center($module_id)
{
global $config, $template, $portal_config, $phpEx;
// Generate text for display and assign template vars
$uid = $config['board3_welcome_message_uid_' . $module_id];
$bitfield = $config['board3_welcome_message_bitfield_' . $module_id];
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
$text = generate_text_for_display($portal_config['board3_welcome_message_' . $module_id], $uid, $bitfield, $bbcode_options);
$template->assign_vars(array(
'PORTAL_WELCOME_MSG' => $text,
));
return 'welcome_center.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_WELCOME_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_WELCOME_SETTINGS',
'board3_welcome_message_' . $module_id => array('lang' => 'PORTAL_WELCOME_INTRO', 'validate' => 'string', 'type' => 'custom', 'method' => 'manage_welcome', 'submit' => 'update_welcome', 'explain' => true),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_portal_config('board3_welcome_message_' . $module_id, 'Welcome to my Community!');
set_config('board3_welcome_message_' . $module_id, '');
set_config('board3_welcome_message_uid_' . $module_id, '');
set_config('board3_welcome_message_bitfield_' . $module_id, '');
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_welcome_message_' . $module_id,
);
$sql = 'DELETE FROM ' . PORTAL_CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
$check = $db->sql_query($sql);
$del_config = array(
'board3_welcome_intro_' . $module_id,
'board3_welcome_message_uid_' . $module_id,
'board3_welcome_message_bitfield_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return ((!$check) ? $check : $db->sql_query($sql)); // if something went wrong, make sure we are aware of the first query
}
public function manage_welcome($value, $key, $module_id)
{
global $db, $portal_config, $config, $template, $user, $phpEx, $phpbb_admin_path, $phpbb_root_path;
$action = (isset($_POST['reset'])) ? 'reset' : '';
$action = (isset($_POST['submit'])) ? 'save' : $action;
$action = (isset($_POST['preview'])) ? 'preview' : $action;
$portal_config = obtain_portal_config();
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id);
switch($action)
{
// Save changes
case 'save':
if (!check_form_key('acp_portal'))
{
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
}
$welcome_message = utf8_normalize_nfc(request_var('welcome_message', '', true));
$uid = $bitfield = $flags = '';
$options = 7;
generate_text_for_storage($welcome_message, $uid, $bitfield, $flags, true, true, true);
// first check for obvious errors, we don't want to waste server resources
if(empty($welcome_message))
{
trigger_error($user->lang['ACP_PORTAL_WELCOME_MESSAGE_SHORT']. adm_back_link($u_action), E_USER_WARNING);
}
add_log('admin', 'LOG_PORTAL_CONFIG', $user->lang['PORTAL_WELCOME']);
// set_portal_config will take care of escaping the welcome message
set_portal_config('board3_welcome_message_' . $module_id, $welcome_message);
set_config('board3_welcome_message_uid_' . $module_id, $uid);
set_config('board3_welcome_message_bitfield_' . $module_id, $bitfield);
break;
case 'preview':
$welcome_message = $text = utf8_normalize_nfc(request_var('welcome_message', '', true));
if (!class_exists('parse_message'))
{
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
}
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
$uid = (isset($config['board3_welcome_message_uid_' . $module_id])) ? $config['board3_welcome_message_uid_' . $module_id] : '';
$bitfield = (isset($config['board3_welcome_message_bitfield_' . $module_id])) ? $config['board3_welcome_message_bitfield_' . $module_id] : '';
$options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
$text = generate_text_for_display($text, $uid, $bitfield, $options);
$template->assign_vars(array(
'PREVIEW_TEXT' => $text,
'S_PREVIEW' => true,
));
// Edit or add menu item
case 'reset':
default:
if(!isset($welcome_message))
{
$welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $config['board3_welcome_message_uid_' . $module_id], '');
}
$template->assign_vars(array(
'WELCOME_MESSAGE' => (is_array($welcome_message)) ? $welcome_message['text'] : $welcome_message,
//'U_BACK' => $u_action,
'U_ACTION' => $u_action,
'S_EDIT' => true,
'S_LINKS_ALLOWED' => true,
'S_BBCODE_IMG' => true,
'S_BBCODE_FLASH' => true,
'S_BBCODE_QUOTE' => true,
'S_BBCODE_ALLOWED' => true,
'MAX_FONT_SIZE' => (int) $config['max_post_font_size'],
));
if(!function_exists('display_forums'))
{
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}
// Build custom bbcodes array
display_custom_bbcodes();
$user->add_lang('posting');
break;
}
}
public function update_welcome($key, $module_id)
{
$this->manage_welcome('', $key, $module_id);
}
}

View File

@@ -0,0 +1,137 @@
<?php
/**
*
* @package Board3 Portal v2 - Who is online
* @copyright (c) Board3 Group ( www.board3.de )
* @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
*/
public $columns = 31;
/**
* Default modulename
*/
public $name = 'PORTAL_WHOIS_ONLINE';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_friends.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_whois_online_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
public 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';
}
public function get_template_side($module_id)
{
global $config, $template, $user, $auth, $db, $phpbb_root_path, $phpEx;
// No legend on the side so just return the template file
return 'whois_online_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_WHOIS_ONLINE',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
}

View File

@@ -0,0 +1,7 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>