mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-05 15:16:16 +02:00
[feature/soft-delete] Correctly manage softdeleting via posting.php
PHPBB3-9567
This commit is contained in:
parent
bed82bf2bd
commit
63e3baf0eb
@ -537,12 +537,12 @@ class phpbb_content_visibility
|
|||||||
*/
|
*/
|
||||||
static public function remove_post_from_statistic($data, &$sql_data)
|
static public function remove_post_from_statistic($data, &$sql_data)
|
||||||
{
|
{
|
||||||
$sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts = topic_posts - 1';
|
$sql_data[TOPICS_TABLE] = ((!empty($sql_data[TOPICS_TABLE])) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts = topic_posts - 1';
|
||||||
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts = forum_posts - 1';
|
$sql_data[FORUMS_TABLE] = ((!empty($sql_data[FORUMS_TABLE])) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts = forum_posts - 1';
|
||||||
|
|
||||||
if ($data['post_postcount'])
|
if ($data['post_postcount'])
|
||||||
{
|
{
|
||||||
$sql_data[USERS_TABLE] = (($sql_data[USERS_TABLE]) ? $sql_data[USERS_TABLE] . ', ' : '') . 'user_posts = user_posts - 1';
|
$sql_data[USERS_TABLE] = ((!empty($sql_data[USERS_TABLE])) ? $sql_data[USERS_TABLE] . ', ' : '') . 'user_posts = user_posts - 1';
|
||||||
}
|
}
|
||||||
|
|
||||||
set_config_count('num_posts', -1, true);
|
set_config_count('num_posts', -1, true);
|
||||||
|
@ -881,7 +881,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
|
|||||||
sync('forum', 'forum_id', $forum_ids, true, true);
|
sync('forum', 'forum_id', $forum_ids, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($approved_posts)
|
if ($approved_posts && $post_count_sync)
|
||||||
{
|
{
|
||||||
set_config_count('num_posts', $approved_posts * (-1), true);
|
set_config_count('num_posts', $approved_posts * (-1), true);
|
||||||
}
|
}
|
||||||
|
@ -1467,7 +1467,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
|
|||||||
}
|
}
|
||||||
else if (!$is_soft)
|
else if (!$is_soft)
|
||||||
{
|
{
|
||||||
if (!delete_posts('post_id', array($post_id), false, false))
|
if (!delete_posts('post_id', array($post_id), false, false, false))
|
||||||
{
|
{
|
||||||
// Try to delete topic, we may had an previous error causing inconsistency
|
// Try to delete topic, we may had an previous error causing inconsistency
|
||||||
if ($post_mode == 'delete_topic')
|
if ($post_mode == 'delete_topic')
|
||||||
@ -1625,8 +1625,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
|
|||||||
}
|
}
|
||||||
else if ($data['post_visibility'] == ITEM_DELETED)
|
else if ($data['post_visibility'] == ITEM_DELETED)
|
||||||
{
|
{
|
||||||
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_deleted = forum_posts_deleted - 1';
|
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_softdeleted = forum_posts_softdeleted - 1';
|
||||||
$sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_deleted = topic_posts_deleted - 1';
|
$sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_softdeleted = topic_posts_softdeleted - 1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2030,7 +2030,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
|||||||
'topic_last_post_id' => $data['post_id'],
|
'topic_last_post_id' => $data['post_id'],
|
||||||
'topic_last_post_time' => $current_time,
|
'topic_last_post_time' => $current_time,
|
||||||
'topic_last_poster_id' => $sql_data[POSTS_TABLE]['sql']['poster_id'],
|
'topic_last_poster_id' => $sql_data[POSTS_TABLE]['sql']['poster_id'],
|
||||||
'topic_last_poster_name' => $sql_data[POSTS_TABLE]['sql']['post_username'],
|
'topic_last_poster_name' => ($user->data['user_id'] == ANONYMOUS) ? $sql_data[POSTS_TABLE]['sql']['post_username'] : $user->data['username'],
|
||||||
'topic_last_poster_colour' => $user->data['user_colour'],
|
'topic_last_poster_colour' => $user->data['user_colour'],
|
||||||
'topic_last_post_subject' => (string) $subject,
|
'topic_last_post_subject' => (string) $subject,
|
||||||
);
|
);
|
||||||
|
@ -35,14 +35,14 @@ $submit = (isset($_POST['post'])) ? true : false;
|
|||||||
$preview = (isset($_POST['preview'])) ? true : false;
|
$preview = (isset($_POST['preview'])) ? true : false;
|
||||||
$save = (isset($_POST['save'])) ? true : false;
|
$save = (isset($_POST['save'])) ? true : false;
|
||||||
$load = (isset($_POST['load'])) ? true : false;
|
$load = (isset($_POST['load'])) ? true : false;
|
||||||
$delete = (isset($_POST['delete'])) ? true : false;
|
$confirm = (isset($_POST['confirm'])) ? true : false;
|
||||||
$cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false;
|
$cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false;
|
||||||
|
|
||||||
$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview);
|
$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview);
|
||||||
$mode = request_var('mode', '');
|
$mode = request_var('mode', '');
|
||||||
|
|
||||||
// If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here.
|
// If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here.
|
||||||
if ($mode == 'delete' && (($auth->acl_get('m_softdelete', $forum_id) && $request->is_set_post('soft_delete')) || !$auth->acl_get('m_delete', $forum_id)))
|
if ($mode == 'delete' && (($confirm && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id)))
|
||||||
{
|
{
|
||||||
$mode = 'soft_delete';
|
$mode = 'soft_delete';
|
||||||
}
|
}
|
||||||
@ -1537,11 +1537,11 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
|
|||||||
// If moderator removing post or user itself removing post, present a confirmation screen
|
// 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 ($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 = build_hidden_fields(array(
|
$s_hidden_fields = array(
|
||||||
'p' => $post_id,
|
'p' => $post_id,
|
||||||
'f' => $forum_id,
|
'f' => $forum_id,
|
||||||
'mode' => ($is_soft) ? 'soft_delete' : 'delete',
|
'mode' => ($is_soft) ? 'soft_delete' : 'delete',
|
||||||
));
|
);
|
||||||
|
|
||||||
if (confirm_box(true))
|
if (confirm_box(true))
|
||||||
{
|
{
|
||||||
@ -1593,9 +1593,18 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
|
|||||||
'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id),
|
'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id),
|
||||||
));
|
));
|
||||||
|
|
||||||
$l_confirm = 'DELETE_POST' . (($post_data['post_visibility'] == ITEM_DELETED) ? '_PERMANENTLY' : '');
|
$l_confirm = 'DELETE_POST';
|
||||||
|
if ($post_data['post_visibility'] == ITEM_DELETED)
|
||||||
|
{
|
||||||
|
$l_confirm .= '_PERMANENTLY';
|
||||||
|
$s_hidden_fields['delete_permanent'] = '1';
|
||||||
|
}
|
||||||
|
else if (!$auth->acl_get('m_softdelete', $forum_id) && !$auth->acl_get('f_softdelete', $forum_id))
|
||||||
|
{
|
||||||
|
$s_hidden_fields['delete_permanent'] = '1';
|
||||||
|
}
|
||||||
|
|
||||||
confirm_box(false, $l_confirm, $s_hidden_fields, 'confirm_delete_body.html');
|
confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user