aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_posting.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2017-06-25 21:25:54 +0200
committerMarc Alexander <admin@m-a-styles.de>2017-06-25 21:25:54 +0200
commitdc49a8a199df28d985e951474dc08d23cd46097c (patch)
treec5fe54e3a2846b7d81956bb3137fcf4c23db86ea /phpBB/includes/functions_posting.php
parent71f9c6ebe53648b4d9883e725bde3d836de8303d (diff)
parentf178c06b4fb53c232ee52f2683c777ba7f4aada9 (diff)
downloadforums-dc49a8a199df28d985e951474dc08d23cd46097c.tar
forums-dc49a8a199df28d985e951474dc08d23cd46097c.tar.gz
forums-dc49a8a199df28d985e951474dc08d23cd46097c.tar.bz2
forums-dc49a8a199df28d985e951474dc08d23cd46097c.tar.xz
forums-dc49a8a199df28d985e951474dc08d23cd46097c.zip
Merge pull request #4804 from rxu/ticket/15186
[ticket/15186] Fully implement the force_delete_allowed feature
Diffstat (limited to 'phpBB/includes/functions_posting.php')
-rw-r--r--phpBB/includes/functions_posting.php48
1 files changed, 43 insertions, 5 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 32b0149701..9712b6e922 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -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,