Permalink
Browse files

Merge branch '3.2.x'

2 parents 848cc8c + aef138d commit 5e24508280e1fc3393966487d72f01932d92afbc @marc1706 marc1706 committed Jun 25, 2017
Showing with 50 additions and 9 deletions.
  1. +43 −5 phpBB/includes/functions_posting.php
  2. +7 −4 phpBB/viewtopic.php
@@ -2543,16 +2543,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, $phpbb_log;
+ global $phpbb_root_path, $phpEx, $phpbb_log, $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,
@@ -2622,10 +2660,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,
View
@@ -1817,7 +1817,7 @@
$s_first_unread = $first_unread = true;
}
- $force_edit_allowed = $force_delete_allowed = false;
+ $force_edit_allowed = $force_delete_allowed = $force_softdelete_allowed = false;
$s_cannot_edit = !$auth->acl_get('f_edit', $forum_id) || $user->data['user_id'] != $poster_id;
$s_cannot_edit_time = $config['edit_time'] && $row['post_time'] <= time() - ($config['edit_time'] * 60);
@@ -1847,7 +1847,9 @@
* @var bool s_cannot_delete_lastpost User can not delete the post because it's not the last post of the topic
* @var bool s_cannot_delete_locked User can not delete the post because it's locked
* @var bool s_cannot_delete_time User can not delete the post because edit_time has passed
+ * @var bool force_softdelete_allowed Allow the user to ыoftdelete the post (all permissions and conditions are ignored)
* @since 3.1.0-b4
+ * @changed 3.1.11-RC1 Added force_softdelete_allowed var
*/
$vars = array(
'row',
@@ -1861,6 +1863,7 @@
's_cannot_delete_lastpost',
's_cannot_delete_locked',
's_cannot_delete_time',
+ 'force_softdelete_allowed',
);
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_action_conditions', compact($vars)));
@@ -1882,10 +1885,10 @@
(!$s_cannot_delete && !$s_cannot_delete_lastpost && !$s_cannot_delete_time && !$s_cannot_delete_locked)
));
- $softdelete_allowed = ($auth->acl_get('m_softdelete', $forum_id) ||
- ($auth->acl_get('f_softdelete', $forum_id) && $user->data['user_id'] == $poster_id)) && ($row['post_visibility'] != ITEM_DELETED);
+ $softdelete_allowed = $force_softdelete_allowed || (($auth->acl_get('m_softdelete', $forum_id) ||
+ ($auth->acl_get('f_softdelete', $forum_id) && $user->data['user_id'] == $poster_id)) && ($row['post_visibility'] != ITEM_DELETED));
- $permanent_delete_allowed = ($auth->acl_get('m_delete', $forum_id) ||
+ $permanent_delete_allowed = $force_delete_allowed || ($auth->acl_get('m_delete', $forum_id) ||
($auth->acl_get('f_delete', $forum_id) && $user->data['user_id'] == $poster_id));
// Can this user receive a Private Message?

0 comments on commit 5e24508

Please sign in to comment.