Start B3P v2 :-D
This commit is contained in:
497
root/includes/acp/acp_portal_blocks.php
Normal file
497
root/includes/acp/acp_portal_blocks.php
Normal file
@@ -0,0 +1,497 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package acp
|
||||
*/
|
||||
class acp_portal_blocks
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $db, $user, $template, $cache, $portal_config;
|
||||
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
||||
|
||||
$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;
|
||||
$block_id = request_var('id', 0);
|
||||
|
||||
$this->tpl_name = 'acp_portal_blocks';
|
||||
$this->page_title = 'ACP_PORTAL_BLOCKS';
|
||||
|
||||
$form_name = 'acp_portal_blocks';
|
||||
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);
|
||||
}
|
||||
|
||||
$block_title = utf8_normalize_nfc(request_var('block_title', '', true));
|
||||
$block_birthday = request_var('block_birthday', '');
|
||||
$block_online_friends = request_var('block_online_friends', '');
|
||||
$block_donation = request_var('block_donation', '');
|
||||
$block_latest_members = request_var('block_latest_members', '');
|
||||
$block_latest_bots = request_var('block_latest_bots', '');
|
||||
$block_type = request_var('block_type', '');
|
||||
$block_position = request_var('block_position', 0);
|
||||
$block_groups = request_var('block_groups', 0);
|
||||
$block_icon = request_var('block_icon', '');
|
||||
$block_text = ($block_type == 'custom') ? utf8_normalize_nfc(request_var('block_text', '', true)) : '';
|
||||
|
||||
if ($block_icon != '' && !preg_match('#(\.gif|\.png|\.jpg|\.jpeg)$#i', $block_icon))
|
||||
{
|
||||
$block_icon = '';
|
||||
}
|
||||
if (!$block_title)
|
||||
{
|
||||
trigger_error($user->lang['NO_BLOCK_TITLE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
||||
}
|
||||
|
||||
if ($block_type == 'custom' && $block_text == '')
|
||||
{
|
||||
trigger_error($user->lang['NO_BLOCK_TEXT'] . adm_back_link($this->u_action), E_USER_WARNING);
|
||||
}
|
||||
|
||||
set_portal_config('portal_birthdays_ahead', $block_birthday);
|
||||
set_portal_config('portal_max_online_friends', $block_online_friends);
|
||||
set_portal_config('portal_pay_acc', $block_donation);
|
||||
set_portal_config('portal_max_last_member', $block_latest_members);
|
||||
set_portal_config('portal_last_visited_bots_number', $block_latest_bots);
|
||||
|
||||
$sql_ary = array(
|
||||
'block_title' => $block_title,
|
||||
'block_type' => $block_type,
|
||||
'block_position' => $block_position,
|
||||
'block_groups' => $block_groups,
|
||||
'block_icon' => htmlspecialchars_decode($block_icon),
|
||||
'block_text' => ($block_type == 'custom') ? $block_text : '',
|
||||
'block_text_uid' => '',
|
||||
'block_text_options' => 7,
|
||||
'block_text_bitfield' => '',
|
||||
);
|
||||
|
||||
$order_ary = array(
|
||||
'block_order' => $portal_config['num_blocks'] + 1,
|
||||
);
|
||||
|
||||
// Get data for block text if specified
|
||||
if ($sql_ary['block_text'])
|
||||
{
|
||||
generate_text_for_storage($sql_ary['block_text'], $sql_ary['block_text_uid'], $sql_ary['block_text_bitfield'], $sql_ary['block_text_options'], request_var('text_parse_bbcode', false), request_var('text_parse_urls', false), request_var('text_parse_smilies', false));
|
||||
}
|
||||
|
||||
if ($block_id)
|
||||
{
|
||||
$sql = 'UPDATE ' . PORTAL_BLOCKS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE block_id = $block_id";
|
||||
$message = $user->lang['BLOCK_UPDATED'];
|
||||
|
||||
add_log('admin', 'LOG_BLOCK_UPDATED', (!empty($user->lang[strtoupper($block_title)])) ? $user->lang[strtoupper($block_title)] : $block_title);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'INSERT INTO ' . PORTAL_BLOCKS_TABLE . ' ' . $db->sql_build_array('INSERT', array_merge($sql_ary, $order_ary));
|
||||
$message = $user->lang['BLOCK_ADDED'];
|
||||
|
||||
set_portal_config('num_blocks', $portal_config['num_blocks'] + 1, true);
|
||||
add_log('admin', 'LOG_BLOCK_ADDED', (!empty($user->lang[strtoupper($block_title)])) ? $user->lang[strtoupper($block_title)] : $block_title);
|
||||
}
|
||||
$db->sql_query($sql);
|
||||
|
||||
$cache->destroy('_blocks');
|
||||
|
||||
trigger_error($message . adm_back_link($this->u_action));
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
|
||||
if (!$block_id)
|
||||
{
|
||||
trigger_error($user->lang['MUST_SELECT_BLOCK'] . adm_back_link($this->u_action), E_USER_WARNING);
|
||||
}
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$sql = 'SELECT block_title, block_order
|
||||
FROM ' . PORTAL_BLOCKS_TABLE . "
|
||||
WHERE block_id = $block_id";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
$row['block_title'] = (string) $row['block_title'];
|
||||
$row['block_order'] = (int) $row['block_order'];
|
||||
}
|
||||
|
||||
$sql = 'DELETE FROM ' . PORTAL_BLOCKS_TABLE . " WHERE block_id = $block_id";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . PORTAL_BLOCKS_TABLE . ' SET block_order = block_order - 1 WHERE block_order > ' . $row['block_order'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
$cache->destroy('_blocks');
|
||||
|
||||
set_portal_config('num_blocks', $portal_config['num_blocks'] - 1, true);
|
||||
add_log('admin', 'LOG_BLOCK_REMOVED', (!empty($user->lang[strtoupper($row['block_title'])])) ? $user->lang[strtoupper($row['block_title'])] : $row['block_title']);
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
|
||||
'i' => $id,
|
||||
'mode' => $mode,
|
||||
'block_id' => $block_id,
|
||||
'action' => 'delete',
|
||||
)));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'disable':
|
||||
|
||||
if (!$block_id)
|
||||
{
|
||||
trigger_error($user->lang['MUST_SELECT_BLOCK'] . adm_back_link($this->u_action), E_USER_WARNING);
|
||||
}
|
||||
|
||||
$sql = 'SELECT block_title
|
||||
FROM ' . PORTAL_BLOCKS_TABLE . "
|
||||
WHERE block_id = $block_id";
|
||||
$result = $db->sql_query($sql);
|
||||
$disabled_block = $db->sql_fetchfield('block_title');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = 'UPDATE ' . PORTAL_BLOCKS_TABLE . " SET block_position = 0 WHERE block_id = $block_id";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$cache->destroy('_blocks');
|
||||
|
||||
add_log('admin', 'LOG_BLOCK_DISABLED', (!empty($user->lang[strtoupper($disabled_block)])) ? $user->lang[strtoupper($disabled_block)] : $disabled_block);
|
||||
|
||||
break;
|
||||
|
||||
case 'move_up':
|
||||
case 'move_down':
|
||||
|
||||
if (!$block_id)
|
||||
{
|
||||
trigger_error($user->lang['MUST_SELECT_BLOCK'] . adm_back_link($this->u_action), E_USER_WARNING);
|
||||
}
|
||||
|
||||
// Get current order id...
|
||||
$sql = 'SELECT block_order AS current_order
|
||||
FROM ' . PORTAL_BLOCKS_TABLE . "
|
||||
WHERE block_id = $block_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;
|
||||
}
|
||||
$switch_order_id = ($action == 'move_down') ? $current_order + 1 : $current_order - 1;
|
||||
|
||||
$sql = 'UPDATE ' . PORTAL_BLOCKS_TABLE . "
|
||||
SET block_order = $current_order
|
||||
WHERE block_order = $switch_order_id
|
||||
AND block_id <> $block_id";
|
||||
$db->sql_query($sql);
|
||||
|
||||
if ($db->sql_affectedrows())
|
||||
{
|
||||
$sql = 'UPDATE ' . PORTAL_BLOCKS_TABLE . "
|
||||
SET block_order = $switch_order_id
|
||||
WHERE block_order = $current_order
|
||||
AND block_id = $block_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$cache->destroy('_blocks');
|
||||
|
||||
break;
|
||||
|
||||
case 'edit':
|
||||
case 'add':
|
||||
|
||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
|
||||
$user->add_lang('posting');
|
||||
|
||||
// Assigning custom bbcodes
|
||||
display_custom_bbcodes();
|
||||
|
||||
$blocks = $existing_icons = array();
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . PORTAL_BLOCKS_TABLE . '
|
||||
ORDER BY block_order';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$existing_icons[] = $row['block_icon'];
|
||||
|
||||
if ($action == 'edit' && $block_id == $row['block_id'])
|
||||
{
|
||||
$blocks = $row;
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Select the block icon
|
||||
$icon_list = filelist($phpbb_root_path . $portal_icons_path);
|
||||
$edit_icon = $icon_filename_list = '';
|
||||
|
||||
foreach ($icon_list as $path => $icon_ary)
|
||||
{
|
||||
sort($icon_ary);
|
||||
|
||||
foreach ($icon_ary as $icon)
|
||||
{
|
||||
$icon = $path . $icon;
|
||||
|
||||
if (!in_array($icon, $existing_icons) || $action == 'edit')
|
||||
{
|
||||
if ($blocks && $icon == $blocks['block_icon'])
|
||||
{
|
||||
$selected = ' selected="selected"';
|
||||
$edit_icon = $icon;
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
if (strlen($icon) > 255)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$icon_filename_list .= '<option value="' . htmlspecialchars($icon) . '"' . $selected . '>' . $icon . '</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$icon_filename_list = '<option value=""' . (($edit_icon == '') ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_BLOCK_ICON'] . '</option>' . $icon_filename_list;
|
||||
unset($existing_icons, $icon_list);
|
||||
|
||||
$block_groups = '';
|
||||
$sql = 'SELECT g.*
|
||||
FROM ' . GROUPS_TABLE . ' g
|
||||
ORDER BY g.group_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$block_groups = '<option value="0"' . ((0 <> isset($blocks['block_groups'])) ? '' : ' selected="selected"') . '>' . "Alle" . '</option>';
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$block_groups .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] <> isset($blocks['block_groups'])) ? '' : ' selected="selected"') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Select the display position for block
|
||||
$position_list = array(
|
||||
'none' => array($user->lang['BLOCK_POSITION_NONE'], BLOCK_NONE),
|
||||
'left' => array($user->lang['BLOCK_POSITION_LEFT'], BLOCK_LEFT),
|
||||
'right' => array($user->lang['BLOCK_POSITION_RIGHT'], BLOCK_RIGHT),
|
||||
'top' => array($user->lang['BLOCK_POSITION_TOP'], BLOCK_TOP),
|
||||
'bottom' => array($user->lang['BLOCK_POSITION_BOTTOM'], BLOCK_BOTTOM),
|
||||
'middle_top' => array($user->lang['BLOCK_POSITION_MIDDLE_TOP'], BLOCK_MIDDLE_TOP),
|
||||
'middle_bottom' => array($user->lang['BLOCK_POSITION_MIDDLE_BOTTOM'], BLOCK_MIDDLE_BOTTOM),
|
||||
);
|
||||
|
||||
$s_position_options = '<option value=""' . ((!isset($blocks['block_position'])) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_BLOCK_POSITION'] . '</option>';
|
||||
|
||||
foreach ($position_list as $position_var => $position_ary)
|
||||
{
|
||||
$selected = (isset($blocks['block_position']) && $position_ary[1] == $blocks['block_position']) ? ' selected="selected"' : '';
|
||||
$s_position_options .= '<option value="' . $position_ary[1] . '" ' . $selected . '>' . $position_ary[0] . '</option>';
|
||||
}
|
||||
|
||||
// Select the block type
|
||||
$type_list = array(
|
||||
0 => array($user->lang['BLOCK_CUSTOM'], 'custom'),
|
||||
1 => array($user->lang['BLOCK_BIRTHDAY'], 'birthday'),
|
||||
2 => array($user->lang['BLOCK_ONLINE'], 'online'),
|
||||
3 => array($user->lang['BLOCK_SEARCH'], 'search'),
|
||||
4 => array($user->lang['BLOCK_CLOCK'], 'clock'),
|
||||
5 => array($user->lang['BLOCK_USER_MENU'], 'user_menu'),
|
||||
6 => array($user->lang['BLOCK_CHANGE_STYLE'], 'change_style'),
|
||||
7 => array($user->lang['BLOCK_DONATION'], 'donation'),
|
||||
8 => array($user->lang['BLOCK_LINKS'], 'links'),
|
||||
9 => array($user->lang['BLOCK_LATEST_BOTS'], 'latest_bots'),
|
||||
10 => array($user->lang['BLOCK_LATEST_MEMBERS'], 'latest_members'),
|
||||
11 => array($user->lang['BLOCK_MINI_CALENDAR'], 'mini_calendar'),
|
||||
12 => array($user->lang['BLOCK_ONLINE_FRIENDS'], 'online_friends'),
|
||||
13 => array($user->lang['BLOCK_STATISTICS'], 'statistics'),
|
||||
14 => array($user->lang['BLOCK_TOP_POSTER'], 'top_poster'),
|
||||
//15 => array($user->lang['BLOCK_'], ''),// Add your blocks here...
|
||||
);
|
||||
|
||||
|
||||
|
||||
$s_type_options = '<option value=""' . ((!isset($blocks['block_type'])) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_BLOCK_TYPE'] . '</option>';
|
||||
|
||||
foreach ($type_list as $type_var => $type_ary)
|
||||
{
|
||||
$selected = (isset($blocks['block_type']) && $type_ary[1] == $blocks['block_type']) ? ' selected="selected"' : '';
|
||||
$s_type_options .= '<option value="' . $type_ary[1] . '" ' . $selected . '>' . $type_ary[0] . '</option>';
|
||||
}
|
||||
|
||||
$block_text_data = array(
|
||||
'text' => (isset($blocks['block_text'])) ? $blocks['block_text'] : '',
|
||||
'allow_bbcode' => true,
|
||||
'allow_smilies' => true,
|
||||
'allow_urls' => true
|
||||
);
|
||||
|
||||
$block_text_preview = '';
|
||||
|
||||
if (isset($blocks['block_text']))
|
||||
{
|
||||
if (!isset($blocks['block_text_uid']))
|
||||
{
|
||||
$blocks['block_text_uid'] = '';
|
||||
$blocks['block_text_bitfield'] = '';
|
||||
$blocks['block_text_options'] = 0;
|
||||
|
||||
generate_text_for_storage($blocks['block_text'], $blocks['block_text_uid'], $blocks['block_text_bitfield'], $blocks['block_text_options'], request_var('text_allow_bbcode', false), request_var('text_allow_urls', false), request_var('text_allow_smilies', false));
|
||||
}
|
||||
$block_text_preview = generate_text_for_display($blocks['block_text'], $blocks['block_text_uid'], $blocks['block_text_bitfield'], $blocks['block_text_options']);
|
||||
$block_text_data = generate_text_for_edit($blocks['block_text'], $blocks['block_text_uid'], $blocks['block_text_options']);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'TYPE' => (isset($blocks['block_type'])) ? $blocks['block_type'] : '',
|
||||
'ICONS_PATH' => $phpbb_root_path . $portal_icons_path,
|
||||
|
||||
'BLOCK_TITLE' => (isset($blocks['block_title'])) ? $blocks['block_title'] : '',
|
||||
'BLOCK_PAYPAL' => (isset($portal_config['portal_pay_acc'])) ? $portal_config['portal_pay_acc'] : '',
|
||||
'BLOCK_BIRTHDAY' => (isset($portal_config['portal_birthdays_ahead'])) ? $portal_config['portal_birthdays_ahead'] : '',
|
||||
'BLOCK_LATEST_MEMBERS' => (isset($portal_config['portal_max_last_member'])) ? $portal_config['portal_max_last_member'] : '',
|
||||
'BLOCK_ONLINE_FRIENDS' => (isset($portal_config['portal_max_online_friends'])) ? $portal_config['portal_max_online_friends'] : '',
|
||||
'BLOCK_LATEST_BOTS' => (isset($portal_config['portal_last_visited_bots_number'])) ? $portal_config['portal_last_visited_bots_number'] : '',
|
||||
'BLOCK_GROUPS' => (isset($blocks['block_groups'])) ? $blocks['block_groups'] : 0,
|
||||
'BLOCK_POSITION' => (isset($blocks['block_position'])) ? $blocks['block_position'] : 0,
|
||||
'BLOCK_ICON' => ($edit_icon) ? $phpbb_root_path . $portal_icons_path . '/' . $edit_icon : $phpbb_admin_path . 'images/spacer.gif',
|
||||
'BLOCK_TEXT' => $block_text_data['text'],
|
||||
'BLOCK_TEXT_PREVIEW' => $block_text_preview,
|
||||
|
||||
'U_BACK' => $this->u_action,
|
||||
'U_ACTION' => $this->u_action . '&id=' . $block_id,
|
||||
|
||||
'S_EDIT' => true,
|
||||
'S_ICON_FILENAME_LIST' => $icon_filename_list,
|
||||
'S_POSITION_OPTIONS' => $s_position_options,
|
||||
'S_BLOCK_GROUPS' => $block_groups,
|
||||
'S_TYPE_OPTIONS' => $s_type_options,
|
||||
'S_SELECT_BLOCK' => (!isset($blocks['block_type']) || $blocks['block_type'] != 'custom') ? true : false,
|
||||
'S_SELECT_BIRTHDAY' => (!isset($blocks['block_type']) || $blocks['block_type'] != 'birthday') ? true : false,
|
||||
'S_SELECT_ONLINE_FRIENDS' => (!isset($blocks['block_type']) || $blocks['block_type'] != 'online_friends') ? true : false,
|
||||
'S_SELECT_PAYPAL' => (!isset($blocks['block_type']) || $blocks['block_type'] != 'donation') ? true : false,
|
||||
'S_SELECT_LATEST_MEMBERS' => (!isset($blocks['block_type']) || $blocks['block_type'] != 'latest_members') ? true : false,
|
||||
'S_SELECT_LATEST_BOTS' => (!isset($blocks['block_type']) || $blocks['block_type'] != 'latest_bots') ? true : false,
|
||||
'S_TEXT_BBCODE_CHECKED' => ($block_text_data['allow_bbcode']) ? true : false,
|
||||
'S_TEXT_SMILIES_CHECKED' => ($block_text_data['allow_smilies']) ? true : false,
|
||||
'S_TEXT_URLS_CHECKED' => ($block_text_data['allow_urls']) ? true : false,
|
||||
));
|
||||
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_ACTION' => $this->u_action,
|
||||
));
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . PORTAL_BLOCKS_TABLE . '
|
||||
ORDER BY block_order';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
switch ($row['block_position'])
|
||||
{
|
||||
case BLOCK_LEFT:
|
||||
$position = $user->lang['BLOCK_POSITION_LEFT'];
|
||||
break;
|
||||
|
||||
case BLOCK_RIGHT:
|
||||
$position = $user->lang['BLOCK_POSITION_RIGHT'];
|
||||
break;
|
||||
|
||||
case BLOCK_TOP:
|
||||
$position = $user->lang['BLOCK_POSITION_TOP'];
|
||||
break;
|
||||
|
||||
case BLOCK_BOTTOM:
|
||||
$position = $user->lang['BLOCK_POSITION_BOTTOM'];
|
||||
break;
|
||||
|
||||
case BLOCK_MIDDLE_TOP:
|
||||
$position = $user->lang['BLOCK_POSITION_MIDDLE_TOP'];
|
||||
break;
|
||||
|
||||
case BLOCK_MIDDLE_BOTTOM:
|
||||
$position = $user->lang['BLOCK_POSITION_MIDDLE_BOTTOM'];
|
||||
break;
|
||||
|
||||
case BLOCK_NONE:
|
||||
default:
|
||||
$position = $user->lang['BLOCK_POSITION_NONE'];
|
||||
break;
|
||||
}
|
||||
|
||||
$template->assign_block_vars('blocks', array(
|
||||
'BLOCK_TITLE' => (!empty($user->lang[strtoupper($row['block_title'])])) ? $user->lang[strtoupper($row['block_title'])] : $row['block_title'],
|
||||
'BLOCK_POSITION' => $position,
|
||||
//'BLOCK_GROUP' => $groups,
|
||||
'BLOCK_TYPE' => $user->lang['BLOCK_' . strtoupper($row['block_type'])],
|
||||
'BLOCK_ICON' => $phpbb_root_path . $portal_icons_path . '/' . $row['block_icon'],
|
||||
|
||||
'U_DISABLE' => $this->u_action . '&action=disable&id=' . $row['block_id'],
|
||||
'U_EDIT' => $this->u_action . '&action=edit&id=' . $row['block_id'],
|
||||
'U_DELETE' => $this->u_action . '&action=delete&id=' . $row['block_id'],
|
||||
'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row['block_id'],
|
||||
'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row['block_id'],
|
||||
|
||||
'S_BLOCK_ICON' => ($row['block_icon']) ? true : false,
|
||||
'S_BLOCK_DISABLED' => ($row['block_position'] == BLOCK_NONE) ? true : false,
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
170
root/includes/acp/acp_portal_config.php
Normal file
170
root/includes/acp/acp_portal_config.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
257
root/includes/acp/acp_portal_links.php
Normal file
257
root/includes/acp/acp_portal_links.php
Normal file
@@ -0,0 +1,257 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 . '&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 . '&action=edit&id=' . $row['link_id'],
|
||||
'U_DELETE' => $this->u_action . '&action=delete&id=' . $row['link_id'],
|
||||
'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row['link_id'],
|
||||
'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row['link_id'],
|
||||
|
||||
'S_LINK_IS_CAT' => ($row['link_is_cat']) ? true : false,
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
42
root/includes/acp/info/acp_portal_blocks.php
Normal file
42
root/includes/acp/info/acp_portal_blocks.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package module_install
|
||||
*/
|
||||
class acp_portal_blocks_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'acp_portal_blocks',
|
||||
'title' => 'ACP_PORTAL_BLOCKS',
|
||||
'version' => '2.0.0',
|
||||
'modes' => array(
|
||||
'blocks' => array('title' => 'ACP_PORTAL_MANAGE_BLOCKS', 'auth' => 'acl_a_portal', 'cat' => array('ACP_PORTAL')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
42
root/includes/acp/info/acp_portal_config.php
Normal file
42
root/includes/acp/info/acp_portal_config.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package module_install
|
||||
*/
|
||||
class acp_portal_config_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'acp_portal_config',
|
||||
'title' => 'ACP_PORTAL_INFO',
|
||||
'version' => '2.0.0',
|
||||
'modes' => array(
|
||||
'config' => array('title' => 'ACP_PORTAL_GENERAL_INFO', 'auth' => 'acl_a_portal', 'cat' => array('ACP_PORTAL')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
42
root/includes/acp/info/acp_portal_links.php
Normal file
42
root/includes/acp/info/acp_portal_links.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package module_install
|
||||
*/
|
||||
class acp_portal_links_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'acp_portal_links',
|
||||
'title' => 'ACP_PORTAL_LINKS',
|
||||
'version' => '2.0.0',
|
||||
'modes' => array(
|
||||
'links' => array('title' => 'ACP_PORTAL_MANAGE_LINKS', 'auth' => 'acl_a_portal', 'cat' => array('ACP_PORTAL')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user