From f178c06b4fb53c232ee52f2683c777ba7f4aada9 Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 19 Apr 2017 21:18:14 +0700 Subject: [ticket/15186] Fully implement the force_delete_allowed feature PHPBB3-15186 --- phpBB/includes/functions_posting.php | 48 ++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index ba367e5eeb..71c89a0e62 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2663,16 +2663,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, @@ -2729,10 +2767,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, -- cgit v1.2.1