1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-28 04:20:32 +02:00

Merge pull request #4804 from rxu/ticket/15186

[ticket/15186] Fully implement the force_delete_allowed feature
This commit is contained in:
Marc Alexander
2017-06-25 21:25:54 +02:00
2 changed files with 50 additions and 9 deletions

View File

@@ -2691,16 +2691,54 @@ function phpbb_upload_popup($forum_style = 0)
/**
* Do the various checks required for removing posts as well as removing it
*
* @param int $forum_id The id of the forum
* @param int $topic_id The id of the topic
* @param int $post_id The id of the post
* @param array $post_data Array with the post data
* @param bool $is_soft The flag indicating whether it is the soft delete mode
* @param string $delete_reason Description for the post deletion reason
*
* @return null
*/
function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $delete_reason = '')
{
global $user, $auth, $config, $request;
global $phpbb_root_path, $phpEx;
global $phpbb_root_path, $phpEx, $phpbb_dispatcher;
$force_delete_allowed = $force_softdelete_allowed = false;
$perm_check = ($is_soft) ? 'softdelete' : 'delete';
/**
* This event allows to modify the conditions for the post deletion
*
* @event core.handle_post_delete_conditions
* @var int forum_id The id of the forum
* @var int topic_id The id of the topic
* @var int post_id The id of the post
* @var array post_data Array with the post data
* @var bool is_soft The flag indicating whether it is the soft delete mode
* @var string delete_reason Description for the post deletion reason
* @var bool force_delete_allowed Allow the user to delete the post (all permissions and conditions are ignored)
* @var bool force_softdelete_allowed Allow the user to softdelete the post (all permissions and conditions are ignored)
* @var string perm_check The deletion mode softdelete|delete
* @since 3.1.11-RC1
*/
$vars = array(
'forum_id',
'topic_id',
'post_id',
'post_data',
'is_soft',
'delete_reason',
'force_delete_allowed',
'force_softdelete_allowed',
'perm_check',
);
extract($phpbb_dispatcher->trigger_event('core.handle_post_delete_conditions', compact($vars)));
// If moderator removing post or user itself removing post, present a confirmation screen
if ($auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])))
if ($force_delete_allowed || ($is_soft && $force_softdelete_allowed) || $auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])))
{
$s_hidden_fields = array(
'p' => $post_id,
@@ -2757,10 +2795,10 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $
}
else
{
global $user, $template, $request;
global $template;
$can_delete = $auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id));
$can_softdelete = $auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id));
$can_delete = $force_delete_allowed || ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id)));
$can_softdelete = $force_softdelete_allowed || ($auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id)));
$template->assign_vars(array(
'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED,