Added forumlist module

This commit is contained in:
Marc Alexander
2011-01-05 11:28:13 +00:00
parent 30271517b8
commit d72f0f80f2
6 changed files with 191 additions and 431 deletions

View File

@@ -1,172 +0,0 @@
<?php
/**
*
* @package Board3 Portal v2
* @version $Id$
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
// COULD BE DELETED
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class acp_portal_config
{
var $u_action;
var $new_config = array();
function main($id, $mode)
{
global $db, $user, $cache, $template;
global $config, $portal_config, $phpbb_root_path, $portal_root_path, $phpbb_admin_path, $phpEx;
$portal_root_path = PORTAL_ROOT_PATH;
if (!function_exists('obtain_portal_config'))
{
include($phpbb_root_path . $portal_root_path . 'includes/functions.' . $phpEx);
}
$portal_config = obtain_portal_config();
if (!function_exists('mod_version_check'))
{
include($phpbb_root_path . $portal_root_path . 'includes/functions_version_check.' . $phpEx);
}
mod_version_check();
$user->add_lang('mods/portal');
$submit = (isset($_POST['submit'])) ? true : false;
$form_key = 'acp_time';
add_form_key($form_key);
/**
* Validation types are:
* string, int, bool,
* script_path (absolute path in url - beginning with / and no trailing slash),
* rpath (relative), rwpath (realtive, writeable), path (relative path, but able to escape the root), wpath (writeable)
*/
switch ($mode)
{
case 'config':
$display_vars = array(
'title' => 'ACP_PORTAL_GENERAL_TITLE',
'vars' => array(
'legend1' => 'ACP_PORTAL_GENERAL_INFO',
'portal_enable' => array('lang' => 'PORTAL_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_left_column_width' => array('lang' => 'PORTAL_LEFT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_right_column_width' => array('lang' => 'PORTAL_RIGHT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
)
);
break;
default:
trigger_error('NO_MODE', E_USER_ERROR);
break;
}
$this->new_config = $config;
$cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
$error = array();
// We validate the complete config if whished
validate_config_vars($display_vars['vars'], $cfg_array, $error);
if ($submit && !check_form_key($form_key))
{
$error[] = $user->lang['FORM_INVALID'];
}
// Do not write values if there is an error
if (sizeof($error))
{
$submit = false;
}
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $config_name => $null)
{
if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
{
continue;
}
$this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
if ($submit)
{
set_portal_config($config_name, $config_value);
}
}
if ($submit)
{
$cache->destroy('sql', PORTAL_CONFIG_TABLE);
add_log('admin', 'LOG_PORTAL_CONFIG', $user->lang['ACP_PORTAL_' . strtoupper($mode) . '_INFO']);
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
$this->tpl_name = 'acp_portal_config';
$this->page_title = $display_vars['title'];
$template->assign_vars(array(
'L_TITLE' => $user->lang[$display_vars['title']],
'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'],
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => implode('<br />', $error),
'U_ACTION' => $this->u_action)
);
// Output relevant page
foreach ($display_vars['vars'] as $config_key => $vars)
{
if (!is_array($vars) && strpos($config_key, 'legend') === false)
{
continue;
}
if (strpos($config_key, 'legend') !== false)
{
$template->assign_block_vars('options', array(
'S_LEGEND' => true,
'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars)
);
continue;
}
$this->new_config[$config_key] = $portal_config[$config_key];
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'])
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXP'])) ? $user->lang[$vars['lang'] . '_EXP'] : '';
}
$content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
if (empty($content))
{
continue;
}
$template->assign_block_vars('options', array(
'KEY' => $config_key,
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => $content,
));
unset($display_vars['vars'][$config_key]);
}
}
}
?>

View File

@@ -1,259 +0,0 @@
<?php
/**
*
* @package Board3 Portal v2
* @version $Id$
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
// COULD BE DELETED
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package acp
*/
class acp_portal_links
{
var $u_action;
function main($id, $mode)
{
global $db, $user, $template, $cache, $portal_config;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('mods/portal');
$portal_root_path = PORTAL_ROOT_PATH;
$portal_icons_path = PORTAL_ICONS_PATH;
include($phpbb_root_path . $portal_root_path . 'includes/functions.' . $phpEx);
$portal_config = obtain_portal_config();
// Set up general vars
$action = request_var('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action;
$action = (isset($_POST['save'])) ? 'save' : $action;
$link_id = request_var('id', 0);
$this->tpl_name = 'acp_portal_links';
$this->page_title = 'ACP_PORTAL_LINKS';
$form_name = 'acp_portal_links';
add_form_key($form_name);
switch ($action)
{
case 'save':
if (!check_form_key($form_name))
{
trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
}
$link_title = utf8_normalize_nfc(request_var('link_title', '', true));
$link_is_cat = request_var('link_is_cat', 0);
$link_url = ($link_is_cat) ? '' : request_var('link_url', '');
if (!$link_title)
{
trigger_error($user->lang['NO_LINK_TITLE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!$link_is_cat && !$link_url)
{
trigger_error($user->lang['NO_LINK_URL'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$sql_ary = array(
'link_title' => $link_title,
'link_is_cat' => $link_is_cat,
'link_url' => htmlspecialchars_decode($link_url),
);
$order_ary = array(
'link_order' => $portal_config['num_links'] + 1,
);
if ($link_id)
{
$sql = 'UPDATE ' . PORTAL_LINKS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE link_id = $link_id";
$message = $user->lang['LINK_UPDATED'];
add_log('admin', 'LOG_PORTAL_LINK_UPDATED', $link_title);
}
else
{
$sql = 'INSERT INTO ' . PORTAL_LINKS_TABLE . ' ' . $db->sql_build_array('INSERT', array_merge($sql_ary, $order_ary));
$message = $user->lang['LINK_ADDED'];
set_portal_config('num_links', $portal_config['num_links'] + 1, true);
add_log('admin', 'LOG_PORTAL_LINK_ADDED', $link_title);
}
$db->sql_query($sql);
$cache->destroy('_links');
trigger_error($message . adm_back_link($this->u_action));
break;
case 'delete':
if (!$link_id)
{
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (confirm_box(true))
{
$sql = 'SELECT link_title, link_order
FROM ' . PORTAL_LINKS_TABLE . "
WHERE link_id = $link_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$row['link_title'] = (string) $row['link_title'];
$row['link_order'] = (int) $row['link_order'];
}
$sql = 'DELETE FROM ' . PORTAL_LINKS_TABLE . " WHERE link_id = $link_id";
$db->sql_query($sql);
// Reset link order...
$sql = 'UPDATE ' . PORTAL_LINKS_TABLE . ' SET link_order = link_order - 1 WHERE link_order > ' . $row['link_order'];
$db->sql_query($sql);
$cache->destroy('_links');
set_portal_config('num_links', $portal_config['num_links'] - 1, true);
add_log('admin', 'LOG_PORTAL_LINK_REMOVED', $row['link_title']);
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'i' => $id,
'mode' => $mode,
'link_id' => $link_id,
'action' => 'delete',
)));
}
break;
case 'move_up':
case 'move_down':
if (!$link_id)
{
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Get current order id...
$sql = 'SELECT link_order AS current_order
FROM ' . PORTAL_LINKS_TABLE . "
WHERE link_id = $link_id";
$result = $db->sql_query($sql);
$current_order = (int) $db->sql_fetchfield('current_order');
$db->sql_freeresult($result);
if ($current_order == 0 && $action == 'move_up')
{
break;
}
// on move_down, switch position with next order_id...
// on move_up, switch position with previous order_id...
$switch_order_id = ($action == 'move_down') ? $current_order + 1 : $current_order - 1;
// Update order values
$sql = 'UPDATE ' . PORTAL_LINKS_TABLE . "
SET link_order = $current_order
WHERE link_order = $switch_order_id
AND link_id <> $link_id";
$db->sql_query($sql);
// Only update the other entry too if the previous entry got updated
if ($db->sql_affectedrows())
{
$sql = 'UPDATE ' . PORTAL_LINKS_TABLE . "
SET link_order = $switch_order_id
WHERE link_order = $current_order
AND link_id = $link_id";
$db->sql_query($sql);
}
break;
case 'edit':
case 'add':
$links = array();
$sql = 'SELECT *
FROM ' . PORTAL_LINKS_TABLE . '
ORDER BY link_order';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if ($action == 'edit' && $link_id == $row['link_id'])
{
$links = $row;
}
}
$db->sql_freeresult($result);
$template->assign_vars(array(
'LINK_TITLE' => (isset($links['link_title'])) ? $links['link_title'] : '',
'LINK_URL' => (isset($links['link_url']) && !$links['link_is_cat']) ? $links['link_url'] : '',
'U_BACK' => $this->u_action,
'U_ACTION' => $this->u_action . '&amp;id=' . $link_id,
'S_EDIT' => true,
'S_LINK_IS_CAT' => (!isset($links['link_is_cat']) || $links['link_is_cat']) ? true : false,
));
return;
break;
}
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
));
$sql = 'SELECT *
FROM ' . PORTAL_LINKS_TABLE . '
ORDER BY link_order';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('links', array(
'LINK_TITLE' => $row['link_title'],
'LINK_URL' => $row['link_url'],
'U_EDIT' => $this->u_action . '&amp;action=edit&amp;id=' . $row['link_id'],
'U_DELETE' => $this->u_action . '&amp;action=delete&amp;id=' . $row['link_id'],
'U_MOVE_UP' => $this->u_action . '&amp;action=move_up&amp;id=' . $row['link_id'],
'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;id=' . $row['link_id'],
'S_LINK_IS_CAT' => ($row['link_is_cat']) ? true : false,
));
}
$db->sql_freeresult($result);
}
}
?>

View File

@@ -0,0 +1,37 @@
<?php
/**
* @package Portal - Forumlist
* @version $Id$
* @copyright (c) 2009, 2010 Board3 Portal Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
'PORTAL_FORUMLIST' => 'Forumliste',
));
?>

View File

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

View File

@@ -0,0 +1,106 @@
<?php
/**
* @package Portal - Forumlist
* @version $Id$
* @copyright (c) 2009, 2010 Board3 Portal Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package 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
*/
var $columns = 4;
/**
* Default modulename
*/
var $name = 'PORTAL_FORUMLIST';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
var $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
var $language = 'portal_forumlist_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
var $custom_acp_tpl = '';
function get_template_center($module_id)
{
global $config, $template, $user, $auth, $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'),
'S_DISPLAY_PORTAL_FORUM_INDEX' => true,
'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';
}
function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_FORUMLIST',
'vars' => array(),
);
}
/**
* API functions
*/
function install($module_id)
{
set_config('portal_' . $module_id . '_configname', 'Hello World!');
set_config('portal_' . $module_id . '_configname2', 1337);
return true;
}
function uninstall($module_id)
{
global $db;
$del_config = array(
'portal_' . $module_id . '_configname',
'portal_' . $module_id . '_configname2',
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
}
?>

View File

@@ -0,0 +1,11 @@
<!--version $Id$ //-->
<!-- IF S_DISPLAY_SEARCH or (S_USER_LOGGED_IN and not S_IS_BOT) -->
<ul class="linklist">
<!-- IF S_DISPLAY_SEARCH -->
<li><a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a><!-- IF S_USER_LOGGED_IN --> &bull; <a href="{U_SEARCH_UNREAD}">{L_SEARCH_UNREAD}</a> &bull; <a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a><!-- ENDIF --> &bull; <a href="{U_SEARCH_ACTIVE_TOPICS}">{L_SEARCH_ACTIVE_TOPICS}</a></li>
<!-- ENDIF -->
<!-- IF not S_IS_BOT and U_MARK_FORUMS --><li class="rightside"><a href="{U_MARK_FORUMS}" accesskey="m">{L_MARK_FORUMS_READ}</a></li><!-- ENDIF -->
</ul>
<!-- ENDIF -->
<!-- INCLUDE forumlist_body.html -->
<br />