Added portal_config table for large data that needs to inserted into the database (adds 1 query but we won't have to tamper with phpBB3's config table);
Added serialize and unserialize to the main menu block for a better way of working with the links;
This commit is contained in:
1 parent
73681a4b43
commit
1731999649
6 files changed
+139
-124
No files matched your search
@@ -36,6 +36,11 @@ class acp_portal
|
|||||||
include($phpbb_root_path . $portal_root_path . 'includes/functions_version_check.' . $phpEx);
|
include($phpbb_root_path . $portal_root_path . 'includes/functions_version_check.' . $phpEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!function_exists('obtain_portal_config'))
|
||||||
|
{
|
||||||
|
include($phpbb_root_path . $portal_root_path . 'includes/functions.' . $phpEx);
|
||||||
|
}
|
||||||
|
|
||||||
$user->add_lang('mods/portal');
|
$user->add_lang('mods/portal');
|
||||||
$submit = (isset($_POST['submit'])) ? true : false;
|
$submit = (isset($_POST['submit'])) ? true : false;
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,14 @@ $versions = array(
|
|||||||
|
|
||||||
'PRIMARY_KEY' => 'module_id',
|
'PRIMARY_KEY' => 'module_id',
|
||||||
)),
|
)),
|
||||||
|
array(phpbb_portal_config, array(
|
||||||
|
'COLUMNS' => array(
|
||||||
|
'config_name' => array('VCHAR:255', ''),
|
||||||
|
'config_value'=> array('MTEXT', ''),
|
||||||
|
),
|
||||||
|
|
||||||
|
'PRIMARY_KEY' => 'config_name',
|
||||||
|
));
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ if (!$config['board3_enable'])
|
|||||||
redirect(reapply_sid($phpbb_root_path . 'index.' . $phpEx));
|
redirect(reapply_sid($phpbb_root_path . 'index.' . $phpEx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$portal_config = obtain_portal_config();
|
||||||
|
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . PORTAL_MODULES_TABLE . '
|
FROM ' . PORTAL_MODULES_TABLE . '
|
||||||
ORDER BY module_order ASC';
|
ORDER BY module_order ASC';
|
||||||
|
|||||||
@@ -21,5 +21,6 @@ define('B3_LINKS_EXT', 2);
|
|||||||
// Tables and paths
|
// Tables and paths
|
||||||
define('PORTAL_ROOT_PATH', 'portal/');
|
define('PORTAL_ROOT_PATH', 'portal/');
|
||||||
define('PORTAL_MODULES_TABLE', $table_prefix . 'portal_modules');
|
define('PORTAL_MODULES_TABLE', $table_prefix . 'portal_modules');
|
||||||
|
define('PORTAL_CONFIG_TABLE', $table_prefix . 'portal_config');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -17,24 +17,27 @@ if (!defined('IN_PHPBB'))
|
|||||||
// Get portal config
|
// Get portal config
|
||||||
function obtain_portal_config()
|
function obtain_portal_config()
|
||||||
{
|
{
|
||||||
global $db;
|
global $db, $portal_config;
|
||||||
|
|
||||||
|
if(sizeof($portal_config) < 1)
|
||||||
|
{
|
||||||
$sql = 'SELECT config_name, config_value
|
$sql = 'SELECT config_name, config_value
|
||||||
FROM ' . PORTAL_CONFIG_TABLE;
|
FROM ' . PORTAL_CONFIG_TABLE;
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$cached_portal_config[$row['config_name']] = $row['config_value'];
|
|
||||||
$portal_config[$row['config_name']] = $row['config_value'];
|
$portal_config[$row['config_name']] = $row['config_value'];
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
|
||||||
return $portal_config;
|
return $portal_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set config value. Creates missing config entry.
|
* 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)
|
function set_portal_config($config_name, $config_value)
|
||||||
{
|
{
|
||||||
@@ -124,16 +127,16 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
|
|||||||
case "news":
|
case "news":
|
||||||
$topic_type = 't.topic_type = ' . POST_NORMAL;
|
$topic_type = 't.topic_type = ' . POST_NORMAL;
|
||||||
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
|
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
|
||||||
$user_link = ($portal_config['portal_news_style']) ? 't.topic_poster = u.user_id' : (($portal_config['portal_news_show_last']) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
|
$user_link = ($config['board3_news_style']) ? 't.topic_poster = u.user_id' : (($config['board3_news_show_last']) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
|
||||||
$post_link = ($portal_config['portal_news_style']) ? 't.topic_first_post_id = p.post_id' : (($portal_config['portal_news_show_last']) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
|
$post_link = ($config['board3_news_style']) ? 't.topic_first_post_id = p.post_id' : (($config['board3_news_show_last']) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
|
||||||
$topic_order = ($portal_config['portal_news_show_last']) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
|
$topic_order = ($config['board3_news_show_last']) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
|
||||||
break;
|
break;
|
||||||
case "news_all":
|
case "news_all":
|
||||||
$topic_type = '(t.topic_type <> ' . POST_ANNOUNCE . ') AND (t.topic_type <> ' . POST_GLOBAL . ')';
|
$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)) . ')' : '';
|
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
|
||||||
$user_link = ($portal_config['portal_news_style']) ? 't.topic_poster = u.user_id' : (($portal_config['portal_news_show_last']) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
|
$user_link = ($config['board3_news_style']) ? 't.topic_poster = u.user_id' : (($config['board3_news_show_last']) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
|
||||||
$post_link = ($portal_config['portal_news_style']) ? 't.topic_first_post_id = p.post_id' : (($portal_config['portal_news_show_last']) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
|
$post_link = ($config['board3_news_style']) ? 't.topic_first_post_id = p.post_id' : (($config['board3_news_show_last']) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
|
||||||
$topic_order = ($portal_config['portal_news_show_last']) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
|
$topic_order = ($config['board3_news_show_last']) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,17 +56,15 @@ class portal_main_menu_module
|
|||||||
{
|
{
|
||||||
global $config, $template, $phpEx, $phpbb_root_path, $user, $db;
|
global $config, $template, $phpEx, $phpbb_root_path, $user, $db;
|
||||||
|
|
||||||
$links_urls = $links_options = $links_titles = $groups_ary = array();
|
$links = array();
|
||||||
|
$portal_config = obtain_portal_config();
|
||||||
|
|
||||||
$links_urls = explode(';', $config['board3_links_urls_' . $module_id]);
|
$links = $this->utf_unserialize($portal_config['board3_menu_array_' . $module_id]);
|
||||||
$links_options = explode(';', $config['board3_links_options_' . $module_id]);
|
|
||||||
$links_titles = explode(';', $config['board3_links_titles_' . $module_id]);
|
|
||||||
$links_permissions = explode(';', $config['board3_links_permissions_' . $module_id]);
|
|
||||||
|
|
||||||
// get user's groups
|
// get user's groups
|
||||||
$sql = 'SELECT group_id
|
$sql = 'SELECT group_id
|
||||||
FROM ' . USER_GROUP_TABLE . '
|
FROM ' . USER_GROUP_TABLE . '
|
||||||
WHERE user_id = ' . $user->data['user_id'] . '
|
WHERE user_id = ' . (int) $user->data['user_id'] . '
|
||||||
ORDER BY group_id ASC';
|
ORDER BY group_id ASC';
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
while($row = $db->sql_fetchrow($result))
|
while($row = $db->sql_fetchrow($result))
|
||||||
@@ -76,33 +74,33 @@ class portal_main_menu_module
|
|||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
|
||||||
for ($i = 0; $i < sizeof($links_urls); $i++)
|
for ($i = 0; $i < sizeof($links); $i++)
|
||||||
{
|
{
|
||||||
if($links_options[$i] == B3_LINKS_CAT)
|
if($links[$i]['type'] == B3_LINKS_CAT)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars('portalmenu', array(
|
$template->assign_block_vars('portalmenu', array(
|
||||||
'CAT_TITLE' => (isset($user->lang[$links_titles[$i]])) ? $user->lang[$links_titles[$i]] : $links_titles[$i],
|
'CAT_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($links_options[$i] == B3_LINKS_INT)
|
if($links[$i]['type'] == B3_LINKS_INT)
|
||||||
{
|
{
|
||||||
$links_urls[$i] = str_replace('&', '&', $links_urls[$i]); // we need to do this in order to prevent XHTML validation errors
|
$links[$i]['url'] = str_replace('&', '&', $links[$i]['url']); // we need to do this in order to prevent XHTML validation errors
|
||||||
$cur_url = append_sid($phpbb_root_path . $links_urls[$i]); // the user should know what kind of file it is
|
$cur_url = append_sid($phpbb_root_path . $links[$i]['url']); // the user should know what kind of file it is
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$cur_url = $links_urls[$i];
|
$cur_url = $links[$i]['url'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$cur_permissions = explode(',', $links_permissions[$i]);
|
$cur_permissions = explode(',', $links[$i]['permission']);
|
||||||
$permission_check = array_intersect($groups_ary, $cur_permissions);
|
$permission_check = array_intersect($groups_ary, $cur_permissions);
|
||||||
|
|
||||||
if(!empty($permission_check) || $links_permissions[$i] == '')
|
if(!empty($permission_check) || $links[$i]['permission'] == '')
|
||||||
{
|
{
|
||||||
$template->assign_block_vars('portalmenu.links', array(
|
$template->assign_block_vars('portalmenu.links', array(
|
||||||
'LINK_TITLE' => (isset($user->lang[$links_titles[$i]])) ? $user->lang[$links_titles[$i]] : $links_titles[$i],
|
'LINK_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'],
|
||||||
'LINK_URL' => $cur_url,
|
'LINK_URL' => $cur_url,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -119,7 +117,7 @@ class portal_main_menu_module
|
|||||||
'title' => 'ACP_PORTAL_MENU',
|
'title' => 'ACP_PORTAL_MENU',
|
||||||
'vars' => array(
|
'vars' => array(
|
||||||
'legend1' => 'ACP_PORTAL_MENU',
|
'legend1' => 'ACP_PORTAL_MENU',
|
||||||
'board3_links_urls_' . $module_id => array('lang' => 'ACP_PORTAL_MENU_MANAGE', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'manage_links', 'submit' => 'update_links'),
|
'board3_menu_' . $module_id => array('lang' => 'ACP_PORTAL_MENU_MANAGE', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'manage_links', 'submit' => 'update_links'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -141,6 +139,8 @@ class portal_main_menu_module
|
|||||||
$groups_ary[$row['group_name']] = $row['group_id'];
|
$groups_ary[$row['group_name']] = $row['group_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$links = array();
|
||||||
|
|
||||||
$links_titles = array(
|
$links_titles = array(
|
||||||
'M_CONTENT',
|
'M_CONTENT',
|
||||||
'INDEX',
|
'INDEX',
|
||||||
@@ -155,7 +155,7 @@ class portal_main_menu_module
|
|||||||
'M_PRV',
|
'M_PRV',
|
||||||
);
|
);
|
||||||
|
|
||||||
$links_options = array(
|
$links_types = array(
|
||||||
B3_LINKS_CAT,
|
B3_LINKS_CAT,
|
||||||
B3_LINKS_INT,
|
B3_LINKS_INT,
|
||||||
B3_LINKS_INT,
|
B3_LINKS_INT,
|
||||||
@@ -197,10 +197,20 @@ class portal_main_menu_module
|
|||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
|
|
||||||
set_config('board3_links_urls_' . $module_id, implode(';', $links_urls));
|
foreach($links_urls as $i => $url)
|
||||||
set_config('board3_links_options_' . $module_id, implode(';', $links_options));
|
{
|
||||||
set_config('board3_links_titles_' . $module_id, implode(';', $links_titles));
|
$links[] = array(
|
||||||
set_config('board3_links_permissions_' . $module_id, implode(';', $links_permissions));
|
'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, '');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,16 +219,20 @@ class portal_main_menu_module
|
|||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$del_config = array(
|
$del_config = array(
|
||||||
'board3_links_urls_' . $module_id,
|
'board3_menu_array_' . $module_id,
|
||||||
'board3_links_options_' . $module_id,
|
);
|
||||||
'board3_links_titles_' . $module_id,
|
$sql = 'DELETE FROM ' . PORTAL_CONFIG_TABLE . '
|
||||||
'board3_links_permissions_' . $module_id,
|
WHERE ' . $db->sql_in_set('config_name', $del_config);
|
||||||
|
|
||||||
|
$del_config = array(
|
||||||
|
'board3_menu_' . $module_id,
|
||||||
);
|
);
|
||||||
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
|
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
|
||||||
WHERE ' . $db->sql_in_set('config_name', $del_config);
|
WHERE ' . $db->sql_in_set('config_name', $del_config);
|
||||||
return $db->sql_query($sql);
|
return $db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Manage the menu links
|
||||||
function manage_links($value, $key, $module_id)
|
function manage_links($value, $key, $module_id)
|
||||||
{
|
{
|
||||||
global $config, $phpbb_admin_path, $user, $phpEx, $db, $template;
|
global $config, $phpbb_admin_path, $user, $phpEx, $db, $template;
|
||||||
@@ -227,18 +241,16 @@ class portal_main_menu_module
|
|||||||
$action = (isset($_POST['add'])) ? 'add' : $action;
|
$action = (isset($_POST['add'])) ? 'add' : $action;
|
||||||
$action = (isset($_POST['save'])) ? 'save' : $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
|
$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();
|
||||||
|
|
||||||
$sql = 'SELECT module_id FROM ' . PORTAL_MODULES_TABLE . " WHERE module_classname = 'main_menu'";
|
$sql = 'SELECT module_id FROM ' . PORTAL_MODULES_TABLE . " WHERE module_classname = 'main_menu'";
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
$module_id = $db->sql_fetchfield('module_id');
|
$module_id = $db->sql_fetchfield('module_id');
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
$links_urls = $links_options = $links_titles = array();
|
$links = array();
|
||||||
|
|
||||||
$links_urls = explode(';', $config['board3_links_urls_' . $module_id]);
|
$links = $this->utf_unserialize($portal_config['board3_menu_array_' . $module_id]);
|
||||||
$links_options = explode(';', $config['board3_links_options_' . $module_id]);
|
|
||||||
$links_titles = explode(';', $config['board3_links_titles_' . $module_id]);
|
|
||||||
$links_permissions = explode(';', $config['board3_links_permissions_' . $module_id]);
|
|
||||||
|
|
||||||
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&mode=config&module_id=' . $module_id);
|
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&mode=config&module_id=' . $module_id);
|
||||||
|
|
||||||
@@ -273,6 +285,7 @@ class portal_main_menu_module
|
|||||||
$link_permissions = array_intersect($link_permission, $groups_ary);
|
$link_permissions = array_intersect($link_permission, $groups_ary);
|
||||||
$link_permissions = implode(',', $link_permissions);
|
$link_permissions = implode(',', $link_permissions);
|
||||||
|
|
||||||
|
// Check for errors
|
||||||
if (!$link_title)
|
if (!$link_title)
|
||||||
{
|
{
|
||||||
trigger_error($user->lang['NO_LINK_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
|
trigger_error($user->lang['NO_LINK_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
|
||||||
@@ -283,26 +296,17 @@ class portal_main_menu_module
|
|||||||
trigger_error($user->lang['NO_LINK_URL'] . adm_back_link($u_action), E_USER_WARNING);
|
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_urls
|
// 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_urls))
|
if (isset($link_id) && $link_id < sizeof($links))
|
||||||
{
|
{
|
||||||
$message = $user->lang['LINK_UPDATED'];
|
$message = $user->lang['LINK_UPDATED'];
|
||||||
|
|
||||||
// always check if the links already exist
|
$links[$link_id] = array(
|
||||||
if(isset($links_titles[$link_id]) && isset($links_options[$link_id]) && ($link_is_cat || isset($links_urls[$link_id])))
|
'title' => $link_title,
|
||||||
{
|
'url' => htmlspecialchars_decode($link_url),
|
||||||
$links_titles[$link_id] = $link_title;
|
'type' => $link_type,
|
||||||
$links_urls[$link_id] = htmlspecialchars_decode($link_url);
|
'permission' => $link_permissions,
|
||||||
$links_options[$link_id] = $link_type;
|
);
|
||||||
$links_permissions[$link_id] = $link_permissions;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$links_titles[] = $link_title;
|
|
||||||
$links_urls[] = $link_url;
|
|
||||||
$links_options[] = $link_type;
|
|
||||||
$links_permissions[$link_id] = $link_permissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_log('admin', 'LOG_PORTAL_LINK_UPDATED', $link_title);
|
add_log('admin', 'LOG_PORTAL_LINK_UPDATED', $link_title);
|
||||||
}
|
}
|
||||||
@@ -310,35 +314,21 @@ class portal_main_menu_module
|
|||||||
{
|
{
|
||||||
$message = $user->lang['LINK_ADDED'];
|
$message = $user->lang['LINK_ADDED'];
|
||||||
|
|
||||||
if($links_titles[0] == '')
|
if($link_type != B3_LINKS_CAT && sizeof($links) < 1)
|
||||||
{
|
|
||||||
if($link_type != B3_LINKS_CAT && sizeof($links_titles) < 1)
|
|
||||||
{
|
{
|
||||||
trigger_error($user->lang['ACP_PORTAL_MENU_CREATE_CAT'] . adm_back_link($u_action), E_USER_WARNING);
|
trigger_error($user->lang['ACP_PORTAL_MENU_CREATE_CAT'] . adm_back_link($u_action), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
$links_titles[0] = $link_title;
|
$links[] = array(
|
||||||
$links_urls[0] = $link_url;
|
'title' => $link_title,
|
||||||
$links_options[0] = $link_type;
|
'url' => htmlspecialchars_decode($link_url),
|
||||||
$links_permissions[0] = $link_permissions;
|
'type' => $link_type,
|
||||||
}
|
'permission' => $link_permissions,
|
||||||
else
|
);
|
||||||
{
|
|
||||||
if($link_type != B3_LINKS_CAT && sizeof($links_titles) < 1)
|
|
||||||
{
|
|
||||||
trigger_error($user->lang['ACP_PORTAL_MENU_CREATE_CAT'] . adm_back_link($u_action), E_USER_WARNING);
|
|
||||||
}
|
|
||||||
$links_titles[] = $link_title;
|
|
||||||
$links_urls[] = $link_url;
|
|
||||||
$links_options[] = $link_type;
|
|
||||||
$links_permissions[] = $link_permissions;
|
|
||||||
}
|
|
||||||
add_log('admin', 'LOG_PORTAL_LINK_ADDED', $link_title);
|
add_log('admin', 'LOG_PORTAL_LINK_ADDED', $link_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_config('board3_links_urls_' . $module_id, implode(';', $links_urls));
|
$board3_menu_array = serialize($links);
|
||||||
set_config('board3_links_options_' . $module_id, implode(';', $links_options));
|
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
|
||||||
set_config('board3_links_titles_' . $module_id, implode(';', $links_titles));
|
|
||||||
set_config('board3_links_permissions_' . $module_id, implode(';', $links_permissions));
|
|
||||||
|
|
||||||
trigger_error($message . adm_back_link($u_action));
|
trigger_error($message . adm_back_link($u_action));
|
||||||
|
|
||||||
@@ -347,7 +337,7 @@ class portal_main_menu_module
|
|||||||
// Delete link
|
// Delete link
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
|
||||||
if (!isset($link_id) && $link_id >= sizeof($links_urls))
|
if (!isset($link_id) && $link_id >= sizeof($links))
|
||||||
{
|
{
|
||||||
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
|
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
@@ -355,25 +345,25 @@ class portal_main_menu_module
|
|||||||
if (confirm_box(true))
|
if (confirm_box(true))
|
||||||
{
|
{
|
||||||
$cur_link_title = $links_titles[$link_id];
|
$cur_link_title = $links_titles[$link_id];
|
||||||
// make sure we don't delete links that weren't supposed to be deleted
|
// make sure we don't delete links that weren't supposed to be deleted, i.e. duplicate links
|
||||||
$title_ary = array('{remove_link}');
|
$del_ary = array(
|
||||||
$links_titles[$link_id] = '{remove_link}';
|
'title' => '{remove_link}',
|
||||||
$option_ary = array('{remove_link}');
|
'url' => '{remove_link}',
|
||||||
$links_options[$link_id] = '{remove_link}';
|
'type' => '{remove_link}',
|
||||||
$url_ary = array('{remove_link}');
|
'permission' => '{remove_link}',
|
||||||
$links_urls[$link_id] = '{remove_link}';
|
);
|
||||||
$permission_ary = array('{remove_link}');
|
|
||||||
$links_permissions[$link_id] = '{remove_link}';
|
|
||||||
|
|
||||||
$links_titles = array_diff($links_titles, $title_ary);
|
$links[$link_id] = array(
|
||||||
$links_urls = array_diff($links_urls, $url_ary);
|
'title' => '{remove_link}',
|
||||||
$links_options = array_diff($links_options, $url_ary);
|
'url' => '{remove_link}',
|
||||||
$links_permissions = array_diff($links_permissions, $permission_ary);
|
'type' => '{remove_link}',
|
||||||
|
'permission' => '{remove_link}',
|
||||||
|
);
|
||||||
|
|
||||||
set_config('board3_links_urls_' . $module_id, implode(';', $links_urls));
|
$links = array_diff($links, $del_ary);
|
||||||
set_config('board3_links_options_' . $module_id, implode(';', $links_options));
|
|
||||||
set_config('board3_links_titles_' . $module_id, implode(';', $links_titles));
|
$board3_menu_array = serialize($links);
|
||||||
set_config('board3_links_permissions_' . $module_id, implode(';', $links_permissions));
|
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
|
||||||
|
|
||||||
add_log('admin', 'LOG_PORTAL_LINK_REMOVED', $cur_link_title);
|
add_log('admin', 'LOG_PORTAL_LINK_REMOVED', $cur_link_title);
|
||||||
}
|
}
|
||||||
@@ -391,13 +381,13 @@ class portal_main_menu_module
|
|||||||
case 'move_up':
|
case 'move_up':
|
||||||
case 'move_down':
|
case 'move_down':
|
||||||
|
|
||||||
if (!isset($link_id) && $link_id >= sizeof($links_urls))
|
if (!isset($link_id) && $link_id >= sizeof($links))
|
||||||
{
|
{
|
||||||
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
|
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
|
// 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_urls) - 1) && $action == 'move_down'))
|
if (($link_id == 0 && $action == 'move_up') || ($link_id == (sizeof($links) - 1) && $action == 'move_down'))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -410,27 +400,26 @@ class portal_main_menu_module
|
|||||||
$switch_order_id = ($action == 'move_down') ? $link_id + 1 : $link_id - 1;
|
$switch_order_id = ($action == 'move_down') ? $link_id + 1 : $link_id - 1;
|
||||||
|
|
||||||
// back up the info of the link we want to move
|
// back up the info of the link we want to move
|
||||||
$cur_url = $links_urls[$link_id];
|
$cur_link = array(
|
||||||
$cur_title = $links_titles[$link_id];
|
'title' => $links[$link_id]['title'],
|
||||||
$cur_option = $links_options[$link_id];
|
'url' => $links[$link_id]['url'],
|
||||||
$cur_permission = $links_permissions[$link_id];
|
'type' => $links[$link_id]['type'],
|
||||||
|
'permission' => $links[$link_id]['permission'],
|
||||||
|
);
|
||||||
|
|
||||||
// move the info of the links we replace in the order
|
// move the info of the links we replace in the order
|
||||||
$links_urls[$link_id] = $links_urls[$switch_order_id];
|
$links[$link_id] = array(
|
||||||
$links_titles[$link_id] = $links_titles[$switch_order_id];
|
'title' => $links[$switch_order_id]['title'],
|
||||||
$links_options[$link_id] = $links_options[$switch_order_id];
|
'url' => $links[$switch_order_id]['url'],
|
||||||
$links_permissions[$link_id] = $links_permissions[$switch_order_id];
|
'type' => $links[$switch_order_id]['type'],
|
||||||
|
'permission' => $links[$switch_order_id]['permission'],
|
||||||
|
);
|
||||||
|
|
||||||
// insert the info of the moved link
|
// insert the info of the moved link
|
||||||
$links_urls[$switch_order_id] = $cur_url;
|
$links[$switch_order_id] = $cur_link;
|
||||||
$links_titles[$switch_order_id] = $cur_title;
|
|
||||||
$links_options[$switch_order_id] = $cur_option;
|
|
||||||
$links_permissions[$switch_order_id] = $cur_permission;
|
|
||||||
|
|
||||||
set_config('board3_links_urls_' . $module_id, implode(';', $links_urls));
|
$board3_menu_array = serialize($links);
|
||||||
set_config('board3_links_options_' . $module_id, implode(';', $links_options));
|
set_portal_config('board3_menu_array_' . $module_id, $board3_menu_array);
|
||||||
set_config('board3_links_titles_' . $module_id, implode(';', $links_titles));
|
|
||||||
set_config('board3_links_permissions_' . $module_id, implode(';', $links_permissions));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -438,18 +427,18 @@ class portal_main_menu_module
|
|||||||
case 'edit':
|
case 'edit':
|
||||||
case 'add':
|
case 'add':
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'LINK_TITLE' => (isset($links_titles[$link_id]) && $action != 'add') ? $links_titles[$link_id] : '',
|
'LINK_TITLE' => (isset($links[$link_id]['title']) && $action != 'add') ? $links[$link_id]['title'] : '',
|
||||||
'LINK_URL' => (isset($links_urls[$link_id]) && $links_options[$link_id] != B3_LINKS_CAT && $action != 'add') ? str_replace('&', '&', $links_urls[$link_id]) : '',
|
'LINK_URL' => (isset($links[$link_id]['url']) && $links[$link_id]['type'] != B3_LINKS_CAT && $action != 'add') ? str_replace('&', '&', $links[$link_id]['url']) : '',
|
||||||
|
|
||||||
//'U_BACK' => $u_action,
|
//'U_BACK' => $u_action,
|
||||||
'U_ACTION' => $u_action . '&id=' . $link_id,
|
'U_ACTION' => $u_action . '&id=' . $link_id,
|
||||||
|
|
||||||
'S_EDIT' => true,
|
'S_EDIT' => true,
|
||||||
'S_LINK_IS_CAT' => (!isset($links_options[$link_id]) || $links_options[$link_id] == B3_LINKS_CAT) ? true : false,
|
'S_LINK_IS_CAT' => (!isset($links[$link_id]['type']) || $links[$link_id]['type'] == B3_LINKS_CAT) ? true : false,
|
||||||
'S_LINK_IS_INT' => (isset($links_options[$link_id]) && $links_options[$link_id] == B3_LINKS_INT) ? true : false,
|
'S_LINK_IS_INT' => (isset($links[$link_id]['type']) && $links[$link_id]['type'] == B3_LINKS_INT) ? true : false,
|
||||||
));
|
));
|
||||||
|
|
||||||
$groups_ary = explode(',', $links_permissions[$link_id]);
|
$groups_ary = (isset($links[$link_id]['permission'])) ? explode(',', $links[$link_id]['permission']) : array();
|
||||||
|
|
||||||
// get group info from database and assign the block vars
|
// get group info from database and assign the block vars
|
||||||
$sql = 'SELECT group_id, group_name
|
$sql = 'SELECT group_id, group_name
|
||||||
@@ -471,18 +460,18 @@ class portal_main_menu_module
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < sizeof($links_urls); $i++)
|
for ($i = 0; $i < sizeof($links); $i++)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars('links', array(
|
$template->assign_block_vars('links', array(
|
||||||
'LINK_TITLE' => ($action != 'add') ? $links_titles[$i] : '',
|
'LINK_TITLE' => ($action != 'add') ? $links[$i]['title'] : '',
|
||||||
'LINK_URL' => ($action != 'add') ? str_replace('&', '&', $links_urls[$i]) : '',
|
'LINK_URL' => ($action != 'add') ? str_replace('&', '&', $links[$i]['url']) : '',
|
||||||
|
|
||||||
'U_EDIT' => $u_action . '&action=edit&id=' . $i,
|
'U_EDIT' => $u_action . '&action=edit&id=' . $i,
|
||||||
'U_DELETE' => $u_action . '&action=delete&id=' . $i,
|
'U_DELETE' => $u_action . '&action=delete&id=' . $i,
|
||||||
'U_MOVE_UP' => $u_action . '&action=move_up&id=' . $i,
|
'U_MOVE_UP' => $u_action . '&action=move_up&id=' . $i,
|
||||||
'U_MOVE_DOWN' => $u_action . '&action=move_down&id=' . $i,
|
'U_MOVE_DOWN' => $u_action . '&action=move_down&id=' . $i,
|
||||||
|
|
||||||
'S_LINK_IS_CAT' => ($links_options[$i] == B3_LINKS_CAT) ? true : false,
|
'S_LINK_IS_CAT' => ($links[$i]['type'] == B3_LINKS_CAT) ? true : false,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -491,6 +480,13 @@ class portal_main_menu_module
|
|||||||
{
|
{
|
||||||
$this->manage_links('', $key, $module_id);
|
$this->manage_links('', $key, $module_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unserialize links array
|
||||||
|
function utf_unserialize($serial_str)
|
||||||
|
{
|
||||||
|
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
|
||||||
|
return unserialize($out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in new issue
Block a user