aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCallum Macrae <callum@lynxphp.com>2012-03-09 07:34:52 +0000
committerCallum Macrae <callum@lynxphp.com>2012-03-17 18:06:45 +0000
commit4f59990d900b699cdd2cfe4b43e6972bf99d977b (patch)
tree91a1b3b20426ff967da3b2a0fa6d7ba2c8652996
parentc52e99fdbb4854f57ab8e4c6ad1fe06c4944a492 (diff)
downloadforums-4f59990d900b699cdd2cfe4b43e6972bf99d977b.tar
forums-4f59990d900b699cdd2cfe4b43e6972bf99d977b.tar.gz
forums-4f59990d900b699cdd2cfe4b43e6972bf99d977b.tar.bz2
forums-4f59990d900b699cdd2cfe4b43e6972bf99d977b.tar.xz
forums-4f59990d900b699cdd2cfe4b43e6972bf99d977b.zip
[ticket/10510] Added phpbb_add_quickmod_option and moved existing to it.
PHPBB3-10510
-rw-r--r--phpBB/includes/functions_content.php19
-rw-r--r--phpBB/viewtopic.php110
2 files changed, 38 insertions, 91 deletions
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 3a0124934e..b9ab2d8a7a 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -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 = '')
@@ -1259,6 +1259,21 @@ function get_username_string($mode, $user_id, $username, $username_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
*/
class bitfield
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 12a611ce6f..717e1515a8 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -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']
- ));
-}
-
-if ($auth->acl_get('m_delete', $forum_id))
-{
- $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']
- ));
-}
+$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_', $forum_id))
+foreach($quickmod_array as $option => $qm_ary)
{
- $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.