fixing mcp bugs by introducing a new feature to check for loaded/accessible modules/modes. If the MCP module "logs" get disabled the quick mod tools on viewtopic still show a link to the logs, this will then lead to an error message. This is not fixable. The logs should be accessible to all moderators by default.

git-svn-id: file:///svn/phpbb/trunk@6920 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2007-01-22 17:05:23 +00:00
parent 41d0347eb4
commit 60d817416b
7 changed files with 262 additions and 191 deletions

View file

@ -21,6 +21,7 @@ class p_master
var $p_parent;
var $active_module = false;
var $active_module_row_id = false;
var $acl_forum_id = false;
var $module_ary = array();
@ -216,6 +217,50 @@ class p_master
unset($this->module_cache['modules'], $names);
}
/**
* Check if a certain main module is accessible/loaded
* By giving the module mode you are able to additionally check for only one mode within the main module
*
* @param string $module_basename The module base name, for example logs, reports, main (for the mcp).
* @param mixed $module_mode The module mode to check. If provided the mode will be checked in addition for presence.
*
* @return bool Returns true if module is loaded and accessible, else returns false
*/
function loaded($module_basename, $module_mode = false)
{
if (empty($this->loaded_cache))
{
$this->loaded_cache = array();
foreach ($this->module_ary as $row)
{
if (!$row['name'])
{
continue;
}
if (!isset($this->loaded_cache[$row['name']]))
{
$this->loaded_cache[$row['name']] = array();
}
if (!$row['mode'])
{
continue;
}
$this->loaded_cache[$row['name']][$row['mode']] = true;
}
}
if ($module_mode === false)
{
return (isset($this->loaded_cache[$module_basename])) ? true : false;
}
return (!empty($this->loaded_cache[$module_basename][$module_mode])) ? true : false;
}
/**
* Check module authorisation
*/
@ -319,6 +364,7 @@ class p_master
$this->module_cache['parents'] = $this->module_cache['parents'][$this->p_id];
$this->active_module = $item_ary['id'];
$this->active_module_row_id = $row_id;
break;
}
@ -374,6 +420,12 @@ class p_master
// We pre-define the action parameter we are using all over the place
if (defined('IN_ADMIN'))
{
// Is first module automatically enabled a duplicate and the category not passed yet?
if (!$icat && $this->module_ary[$this->active_module_row_id]['is_duplicate'])
{
$icat = $this->module_ary[$this->active_module_row_id]['parent'];
}
// Not being able to overwrite ;)
$this->module->u_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
}
@ -392,6 +444,12 @@ class p_master
$this->module->u_action = append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
}
// Add url_extra parameter to u_action url
if ($this->module_ary[$this->active_module_row_id]['url_extra'])
{
$this->module->u_action .= $this->module_ary[$this->active_module_row_id]['url_extra'];
}
// Assign the module path for re-usage
$this->module->module_path = $module_path . '/';

View file

@ -13,7 +13,7 @@
*/
function mcp_forum_view($id, $mode, $action, $forum_info)
{
global $template, $db, $user, $auth, $cache;
global $template, $db, $user, $auth, $cache, $module;
global $phpEx, $phpbb_root_path, $config;
$user->add_lang('viewtopic');
@ -85,7 +85,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id),
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
'U_VIEW_FORUM_LOGS' => ($auth->acl_gets('a_', 'm_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=forum_logs&f=' . $forum_id) : '',
'U_VIEW_FORUM_LOGS' => ($auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=forum_logs&f=' . $forum_id) : '',
'S_MCP_ACTION' => $url . "&i=$id&mode=$mode&start=$start" . (($action == 'merge_select') ? $selected_ids : ''),
@ -165,6 +165,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
{
$topic_row = array_merge($topic_row, array(
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_moved_id']}"),
'U_DELETE_TOPIC' => ($auth->acl_get('m_delete', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&topic_id_list[]={$row['topic_id']}&mode=forum_view&action=delete_topic") : '',
'S_MOVED_TOPIC' => true,
'TOPIC_ID' => $row['topic_moved_id'],
));

View file

@ -14,9 +14,11 @@
function mcp_front_view($id, $mode, $action)
{
global $phpEx, $phpbb_root_path, $config;
global $template, $db, $user, $auth;
global $template, $db, $user, $auth, $module;
// Latest 5 unapproved
if ($module->loaded('queue'))
{
$forum_list = get_forum_list('m_approve');
$post_list = array();
$forum_names = array();
@ -117,8 +119,11 @@ function mcp_front_view($id, $mode, $action)
);
}
}
}
// Latest 5 reported
if ($module->loaded('reports'))
{
$forum_list = get_forum_list('m_report');
$template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? true : false);
@ -210,8 +215,11 @@ function mcp_front_view($id, $mode, $action)
);
}
}
}
// Latest 5 logs
if ($module->loaded('logs'))
{
$forum_list = get_forum_list(array('m_', 'a_'));
if (!empty($forum_list))
@ -240,6 +248,7 @@ function mcp_front_view($id, $mode, $action)
'S_SHOW_LOGS' => (!empty($forum_list)) ? true : false,
'S_HAS_LOGS' => (!empty($log)) ? true : false)
);
}
$template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.$phpEx"));
make_jumpbox(append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view'), 0, false, 'm_');

View file

@ -317,7 +317,7 @@ function mcp_warn_post_view($id, $mode, $action)
*/
function mcp_warn_user_view($id, $mode, $action)
{
global $phpEx, $phpbb_root_path, $config;
global $phpEx, $phpbb_root_path, $config, $module;
global $template, $db, $user, $auth;
$user_id = request_var('u', 0);

View file

@ -64,6 +64,7 @@ $lang = array_merge($lang, array(
'DELETE_REPORT_CONFIRM' => 'Are you sure you want to delete the selected report?',
'DELETE_REPORTS' => 'Delete reports',
'DELETE_REPORTS_CONFIRM' => 'Are you sure you want to delete the selected reports?',
'DELETE_SHADOW_TOPIC' => 'Delete shadow topic',
'DELETE_TOPICS' => 'Delete selected topics',
'DELETE_TOPICS_CONFIRM' => 'Are you sure you want to delete these topics?',
'DELETE_TOPIC_CONFIRM' => 'Are you sure you want to delete this topic?',

View file

@ -223,7 +223,6 @@ $module->assign_tpl_vars(append_sid("{$phpbb_root_path}mcp.$phpEx"));
// Generate the page, do not display/query online list
$module->display($module->get_page_title(), false);
/**
* Functions used to generate additional URL paramters
*/

View file

@ -36,6 +36,9 @@
<!-- IF topicrow.S_TOPIC_REPORTED and topicrow.U_MCP_REPORT -->
<a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a>&nbsp;
<!-- ENDIF -->
<!-- IF topicrow.S_MOVED_TOPIC and S_CAN_DELETE -->
[ <a href="{topicrow.U_DELETE_TOPIC}">{L_DELETE_SHADOW_TOPIC}</a> ]&nbsp;
<!-- ENDIF -->
</p>
</td>
<td class="row1" width="50" align="center"><p class="topicdetails">{topicrow.REPLIES}</p></td>