1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-06 15:45:34 +02:00

[ticket/10510] Added phpbb_add_quickmod_option and moved existing to it.

PHPBB3-10510
This commit is contained in:
Callum Macrae 2012-03-09 07:34:52 +00:00
parent c52e99fdbb
commit 4f59990d90
2 changed files with 38 additions and 91 deletions

View File

@ -1103,8 +1103,8 @@ function extension_allowed($forum_id, $extension, &$extensions)
* @param string $string The text to truncate to the given length. String is specialchared.
* @param int $max_length Maximum length of string (multibyte character count as 1 char / Html entity count as 1 char)
* @param int $max_store_length Maximum character length of string (multibyte character count as 1 char / Html entity count as entity chars).
* @param bool $allow_reply Allow Re: in front of string
* NOTE: This parameter can cause undesired behavior (returning strings longer than $max_store_length) and is deprecated.
* @param bool $allow_reply Allow Re: in front of string
* NOTE: This parameter can cause undesired behavior (returning strings longer than $max_store_length) and is deprecated.
* @param string $append String to be appended
*/
function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = false, $append = '')
@ -1258,6 +1258,21 @@ function get_username_string($mode, $user_id, $username, $username_colour = '',
return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']);
}
/**
* Add an option to the quick-mod tools.
*
* @param string $option The value of the option.
* @param string $lang_string The language string to use.
*/
function phpbb_add_quickmod_option($option, $lang_string, $condition = true)
{
global $template;
$template->assign_block_vars('quickmod', array(
'VALUE' => $option,
'TITLE' => $lang_string,
));
}
/**
* @package phpBB3
*/

View File

@ -517,97 +517,29 @@ gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']);
// Quick mod tools
$allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false;
if ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))
{
$template->assign_block_vars('quickmod', array(
'VALUE' => (($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'lock' : 'unlock'),
'TITLE' => $user->lang[(($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'LOCK' : 'UNLOCK') . '_TOPIC']
));
}
$quickmod_array = array(
'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))),
'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))),
'delete_topic' => array('DELETE_TOPIC', $auth->acl_get('m_delete', $forum_id)),
'move' => array('MOVE_TOPIC', $auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED),
'split' => array('SPLIT_TOPIC', $auth->acl_get('m_split', $forum_id)),
'merge' => array('MERGE_POSTS', $auth->acl_get('m_merge', $forum_id)),
'merge_topic' => array('MERGE_TOPIC', $auth->acl_get('m_merge', $forum_id)),
'fork' => array('FORK_TOPIC', $auth->acl_get('m_move', $forum_id)),
'make_normal' => array('MAKE_NORMAL', ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL)),
'make_sticky' => array('MAKE_STICKY', ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY)),
'make_announce' => array('MAKE_ANNOUNCE', ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE)),
'make_global' => array('MAKE_GLOBAL', ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL)),
'topic_logs' => array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)),
);
if ($auth->acl_get('m_delete', $forum_id))
foreach($quickmod_array as $option => $qm_ary)
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'delete_topic',
'TITLE' => $user->lang['DELETE_TOPIC']
));
}
if ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED)
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'move',
'TITLE' => $user->lang['MOVE_TOPIC']
));
}
if ($auth->acl_get('m_split', $forum_id))
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'split',
'TITLE' => $user->lang['SPLIT_TOPIC']
));
}
if ($auth->acl_get('m_merge', $forum_id))
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'merge',
'TITLE' => $user->lang['MERGE_POSTS']
));
$template->assign_block_vars('quickmod', array(
'VALUE' => 'merge_topic',
'TITLE' => $user->lang['MERGE_TOPIC']
));
}
if ($auth->acl_get('m_move', $forum_id))
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'fork',
'TITLE' => $user->lang['FORK_TOPIC']
));
}
if ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL)
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'make_normal',
'TITLE' => $user->lang['MAKE_NORMAL']
));
}
if ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY)
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'make_sticky',
'TITLE' => $user->lang['MAKE_STICKY']
));
}
if ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE)
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'make_announce',
'TITLE' => $user->lang['MAKE_ANNOUNCE']
));
}
if ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL)
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'make_global',
'TITLE' => $user->lang['MAKE_GLOBAL']
));
}
if ($auth->acl_get('m_', $forum_id))
{
$template->assign_block_vars('quickmod', array(
'VALUE' => 'topic_logs',
'TITLE' => $user->lang['VIEW_TOPIC_LOGS']
));
$lang_string = $user->lang[$qm_ary[0]];
if ((isset($qm_ary[1])) ? $qm_ary[1] : true)
{
phpbb_add_quickmod_option($option, $lang_string);
}
}
// If we've got a hightlight set pass it on to pagination.