diff options
author | Marc Alexander <admin@m-a-styles.de> | 2017-06-25 21:26:43 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2017-06-25 21:26:43 +0200 |
commit | aef138d8bc2cc2c74bc9951d136c7bc1e0cf3ad7 (patch) | |
tree | ca0c91011c04b22e1e580d58a2a6e29398329d93 /phpBB | |
parent | 4f81c94a95b0ccaff2886980e4af458d92922a01 (diff) | |
parent | dc49a8a199df28d985e951474dc08d23cd46097c (diff) | |
download | forums-aef138d8bc2cc2c74bc9951d136c7bc1e0cf3ad7.tar forums-aef138d8bc2cc2c74bc9951d136c7bc1e0cf3ad7.tar.gz forums-aef138d8bc2cc2c74bc9951d136c7bc1e0cf3ad7.tar.bz2 forums-aef138d8bc2cc2c74bc9951d136c7bc1e0cf3ad7.tar.xz forums-aef138d8bc2cc2c74bc9951d136c7bc1e0cf3ad7.zip |
Merge branch '3.1.x' into 3.2.x
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/functions_posting.php | 48 | ||||
-rw-r--r-- | phpBB/viewtopic.php | 11 |
2 files changed, 50 insertions, 9 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 92679f8503..afa4bb56c4 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2571,16 +2571,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, @@ -2650,10 +2688,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, diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 72603e9fe1..d4bf5b2490 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1817,7 +1817,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $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 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) * @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 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) '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 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) (!$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? |