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);
}
}
?>