Merge pull request #3781 from Elsensee/ticket/8708-2

[ticket/8708] Add extra permission for posting global announcements

* Elsensee/ticket/8708-2:
  [ticket/8708] Apply permission 'f_announce_global'
  [ticket/8708] Add f_announce_global permission
This commit is contained in:
Tristan Darricau 2015-07-22 11:30:50 +02:00
commit e1cbe73538
13 changed files with 69 additions and 25 deletions

View file

@ -64,6 +64,7 @@ $f_permissions = array(
'f_vote' => array(1, 0), 'f_vote' => array(1, 0),
'f_votechg' => array(1, 0), 'f_votechg' => array(1, 0),
'f_announce'=> array(1, 0), 'f_announce'=> array(1, 0),
'f_announce_global' => array(1, 0),
'f_sticky' => array(1, 0), 'f_sticky' => array(1, 0),
'f_attach' => array(1, 0), 'f_attach' => array(1, 0),
'f_download'=> array(1, 0), 'f_download'=> array(1, 0),

View file

@ -339,16 +339,13 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
$topic_types = array( $topic_types = array(
'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'), 'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'),
'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'), 'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'),
'global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL') 'announce_global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL')
); );
$topic_type_array = array(); $topic_type_array = array();
foreach ($topic_types as $auth_key => $topic_value) foreach ($topic_types as $auth_key => $topic_value)
{ {
// We do not have a special post global announcement permission
$auth_key = ($auth_key == 'global') ? 'announce' : $auth_key;
if ($auth->acl_get('f_' . $auth_key, $forum_id)) if ($auth->acl_get('f_' . $auth_key, $forum_id))
{ {
$toggle = true; $toggle = true;
@ -378,8 +375,8 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
$template->assign_vars(array( $template->assign_vars(array(
'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)), 'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)),
'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_get('f_announce', $forum_id))) 'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_gets('f_announce', 'f_announce_global', $forum_id)),
); ));
} }
return $toggle; return $toggle;

View file

@ -131,9 +131,10 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id), 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id),
'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id),
'S_MERGE_SELECT' => ($merge_select) ? true : false, 'S_MERGE_SELECT' => ($merge_select) ? true : false,
'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', $forum_id), 'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id),
'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id), 'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id),
'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id), 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id),
'S_CAN_MAKE_ANNOUNCE_GLOBAL' => $auth->acl_get('f_announce_global', $forum_id),
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $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) && $module->loaded('logs')) ? 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) : '',

View file

@ -362,7 +362,7 @@ function change_topic_type($action, $topic_ids)
case 'make_global': case 'make_global':
$new_topic_type = POST_GLOBAL; $new_topic_type = POST_GLOBAL;
$check_acl = 'f_announce'; $check_acl = 'f_announce_global';
$l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_GLOBAL' : 'MCP_MAKE_GLOBALS'; $l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_GLOBAL' : 'MCP_MAKE_GLOBALS';
break; break;

View file

@ -661,7 +661,7 @@ function phpbb_convert_authentication($mode)
'auth_delete' => 'f_delete', 'auth_delete' => 'f_delete',
'auth_pollcreate' => 'f_poll', 'auth_pollcreate' => 'f_poll',
'auth_vote' => 'f_vote', 'auth_vote' => 'f_vote',
'auth_announce' => 'f_announce', 'auth_announce' => array('f_announce', 'f_announce_global'),
'auth_sticky' => 'f_sticky', 'auth_sticky' => 'f_sticky',
'auth_attachments' => array('f_attach', 'f_download'), 'auth_attachments' => array('f_attach', 'f_download'),
'auth_download' => 'f_download', 'auth_download' => 'f_download',
@ -990,7 +990,7 @@ function phpbb_convert_authentication($mode)
// We make sure that they have at least standard access to the forums they moderate in addition to the moderating permissions // We make sure that they have at least standard access to the forums they moderate in addition to the moderating permissions
$mod_post_map = array( $mod_post_map = array(
'auth_announce' => 'f_announce', 'auth_announce' => array('f_announce', 'f_announce_global'),
'auth_sticky' => 'f_sticky' 'auth_sticky' => 'f_sticky'
); );

View file

@ -310,6 +310,7 @@ INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin
# -- Forum related auth options # -- Forum related auth options
INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_', 1);
INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_announce', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_announce', 1);
INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_announce_global', 1);
INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_attach', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_attach', 1);
INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_bbcode', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_bbcode', 1);
INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_bump', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_bump', 1);
@ -552,7 +553,7 @@ INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 14, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%'; INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 14, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%';
# Standard Access (f_) # Standard Access (f_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 15, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_flash', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 15, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_announce_global', 'f_flash', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock');
# No Access (f_) # No Access (f_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 16, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option = 'f_'; INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 16, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option = 'f_';
@ -561,20 +562,20 @@ INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 17, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_', 'f_download', 'f_list', 'f_read', 'f_search', 'f_subscribe', 'f_print'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 17, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_', 'f_download', 'f_list', 'f_read', 'f_search', 'f_subscribe', 'f_print');
# Limited Access (f_) # Limited Access (f_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 18, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 18, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_announce_global', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg');
# Bot Access (f_) # Bot Access (f_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 19, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_', 'f_download', 'f_list', 'f_read', 'f_print'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 19, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_', 'f_download', 'f_list', 'f_read', 'f_print');
# On Moderation Queue (f_) # On Moderation Queue (f_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 20, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg', 'f_noapprove'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 20, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_announce_global', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg', 'f_noapprove');
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 20, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 20, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove');
# Standard Access + Polls (f_) # Standard Access + Polls (f_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 21, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_flash', 'f_ignoreflood', 'f_sticky', 'f_user_lock'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 21, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_announce_global', 'f_flash', 'f_ignoreflood', 'f_sticky', 'f_user_lock');
# Limited Access + Polls (f_) # Limited Access + Polls (f_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 22, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_sticky', 'f_user_lock', 'f_votechg'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 22, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_announce_global', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_sticky', 'f_user_lock', 'f_votechg');
# New Member (u_) # New Member (u_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 23, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group', 'u_chgprofileinfo'); INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 23, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group', 'u_chgprofileinfo');

View file

@ -120,6 +120,7 @@ $lang = array_merge($lang, array(
'ACL_F_POST' => 'Can start new topics', 'ACL_F_POST' => 'Can start new topics',
'ACL_F_STICKY' => 'Can post stickies', 'ACL_F_STICKY' => 'Can post stickies',
'ACL_F_ANNOUNCE' => 'Can post announcements', 'ACL_F_ANNOUNCE' => 'Can post announcements',
'ACL_F_ANNOUNCE_GLOBAL' => 'Can post global announcements',
'ACL_F_REPLY' => 'Can reply to topics', 'ACL_F_REPLY' => 'Can reply to topics',
'ACL_F_EDIT' => 'Can edit own posts', 'ACL_F_EDIT' => 'Can edit own posts',
'ACL_F_DELETE' => 'Can permanently delete own posts', 'ACL_F_DELETE' => 'Can permanently delete own posts',

View file

@ -111,8 +111,8 @@ if (!$auth->acl_getf_global('m_'))
'lock' => 'f_user_lock', 'lock' => 'f_user_lock',
'make_sticky' => 'f_sticky', 'make_sticky' => 'f_sticky',
'make_announce' => 'f_announce', 'make_announce' => 'f_announce',
'make_global' => 'f_announce', 'make_global' => 'f_announce_global',
'make_normal' => array('f_announce', 'f_sticky') 'make_normal' => array('f_announce', 'f_announce_global', 'f_sticky')
); );
$allow_user = false; $allow_user = false;

View file

@ -0,0 +1,41 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\migration\data\v320;
class announce_global_permission extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
$sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option = 'f_announce_global'";
$result = $this->db->sql_query($sql);
$auth_option_id = $this->db->sql_fetchfield('auth_option_id');
$this->db->sql_freeresult($result);
return $auth_option_id !== false;
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\rc2');
}
public function update_data()
{
return array(
array('permission.add', array('f_announce_global', false, 'f_announce')),
);
}
}

View file

@ -251,6 +251,7 @@ class permissions
'f_post' => array('lang' => 'ACL_F_POST', 'cat' => 'post'), 'f_post' => array('lang' => 'ACL_F_POST', 'cat' => 'post'),
'f_sticky' => array('lang' => 'ACL_F_STICKY', 'cat' => 'post'), 'f_sticky' => array('lang' => 'ACL_F_STICKY', 'cat' => 'post'),
'f_announce' => array('lang' => 'ACL_F_ANNOUNCE', 'cat' => 'post'), 'f_announce' => array('lang' => 'ACL_F_ANNOUNCE', 'cat' => 'post'),
'f_announce_global' => array('lang' => 'ACL_F_ANNOUNCE_GLOBAL', 'cat' => 'post'),
'f_reply' => array('lang' => 'ACL_F_REPLY', 'cat' => 'post'), 'f_reply' => array('lang' => 'ACL_F_REPLY', 'cat' => 'post'),
'f_edit' => array('lang' => 'ACL_F_EDIT', 'cat' => 'post'), 'f_edit' => array('lang' => 'ACL_F_EDIT', 'cat' => 'post'),
'f_delete' => array('lang' => 'ACL_F_DELETE', 'cat' => 'post'), 'f_delete' => array('lang' => 'ACL_F_DELETE', 'cat' => 'post'),

View file

@ -1202,6 +1202,9 @@ if ($submit || $preview || $refresh)
switch ($post_data['topic_type']) switch ($post_data['topic_type'])
{ {
case POST_GLOBAL: case POST_GLOBAL:
$auth_option = 'f_announce_global';
break;
case POST_ANNOUNCE: case POST_ANNOUNCE:
$auth_option = 'f_announce'; $auth_option = 'f_announce';
break; break;

View file

@ -131,10 +131,8 @@
<!-- IF S_CAN_SYNC --><option value="resync">{L_RESYNC}</option><!-- ENDIF --> <!-- IF S_CAN_SYNC --><option value="resync">{L_RESYNC}</option><!-- ENDIF -->
<!-- IF S_CAN_MAKE_NORMAL --><option value="make_normal">{L_MAKE_NORMAL}</option><!-- ENDIF --> <!-- IF S_CAN_MAKE_NORMAL --><option value="make_normal">{L_MAKE_NORMAL}</option><!-- ENDIF -->
<!-- IF S_CAN_MAKE_STICKY --><option value="make_sticky">{L_MAKE_STICKY}</option><!-- ENDIF --> <!-- IF S_CAN_MAKE_STICKY --><option value="make_sticky">{L_MAKE_STICKY}</option><!-- ENDIF -->
<!-- IF S_CAN_MAKE_ANNOUNCE --> <!-- IF S_CAN_MAKE_ANNOUNCE --><option value="make_announce">{L_MAKE_ANNOUNCE}</option><!-- ENDIF -->
<option value="make_announce">{L_MAKE_ANNOUNCE}</option> <!-- IF S_CAN_MAKE_ANNOUNCE_GLOBAL --><option value="make_global">{L_MAKE_GLOBAL}</option><!-- ENDIF -->
<option value="make_global">{L_MAKE_GLOBAL}</option>
<!-- ENDIF -->
</select> </select>
<input class="button2" type="submit" value="{L_SUBMIT}" /> <input class="button2" type="submit" value="{L_SUBMIT}" />
<div><a href="#" onclick="marklist('mcp', 'topic_id_list', true); return false;">{L_MARK_ALL}</a> :: <a href="#" onclick="marklist('mcp', 'topic_id_list', false); return false;">{L_UNMARK_ALL}</a></div> <div><a href="#" onclick="marklist('mcp', 'topic_id_list', true); return false;">{L_MARK_ALL}</a> :: <a href="#" onclick="marklist('mcp', 'topic_id_list', false); return false;">{L_UNMARK_ALL}</a></div>

View file

@ -583,10 +583,10 @@ $quickmod_array = array(
'merge' => array('MERGE_POSTS', $auth->acl_get('m_merge', $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)), 'merge_topic' => array('MERGE_TOPIC', $auth->acl_get('m_merge', $forum_id)),
'fork' => array('FORK_TOPIC', $auth->acl_get('m_move', $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_normal' => array('MAKE_NORMAL', ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $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_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_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)), 'make_global' => array('MAKE_GLOBAL', ($allow_change_type && $auth->acl_get('f_announce_global', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL)),
'topic_logs' => array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)), 'topic_logs' => array('VIEW_TOPIC_LOGS', $auth->acl_get('m_', $forum_id)),
); );