mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[feature/soft-delete] Handle soft deleting via Delete Icon
PHPBB3-9567
This commit is contained in:
parent
3d56261621
commit
f21fd469bc
4 changed files with 61 additions and 16 deletions
|
@ -225,6 +225,7 @@ class phpbb_content_visibility
|
|||
{
|
||||
$where_sql .= ' AND post_visibility = ' . (int) $limit_visibility;
|
||||
}
|
||||
|
||||
if ($limit_delete_time !== false)
|
||||
{
|
||||
$where_sql .= ' AND post_delete_time = ' . (int) $limit_delete_time;
|
||||
|
|
|
@ -78,6 +78,9 @@ $lang = array_merge($lang, array(
|
|||
'DELETE_MESSAGE_CONFIRM' => 'Are you sure you want to delete this message?',
|
||||
'DELETE_OWN_POSTS' => 'Sorry but you can only delete your own posts.',
|
||||
'DELETE_POST_CONFIRM' => 'Are you sure you want to delete this post?',
|
||||
'DELETE_POST_SOFT' => 'Soft delete post',
|
||||
'DELETE_POST_SOFT_EXP' => 'Soft deleted posts can be recovered by a moderator',
|
||||
'DELETE_POST_REASON' => 'Soft delete reason',
|
||||
'DELETE_POST_WARN' => 'Once deleted the post cannot be recovered',
|
||||
'DISABLE_BBCODE' => 'Disable BBCode',
|
||||
'DISABLE_MAGIC_URL' => 'Do not automatically parse URLs',
|
||||
|
|
|
@ -41,16 +41,10 @@ $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);
|
||||
$mode = request_var('mode', '');
|
||||
|
||||
if ($submit && !$refresh)
|
||||
// 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 (isset($_POST['soft_delete']))
|
||||
{
|
||||
$mode = 'soft_delete';
|
||||
}
|
||||
else if (isset($_POST['delete']))
|
||||
{
|
||||
$mode = 'delete';
|
||||
}
|
||||
$mode = 'soft_delete';
|
||||
}
|
||||
|
||||
$error = $post_data = array();
|
||||
|
@ -328,7 +322,8 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id))
|
|||
// Handle delete mode...
|
||||
if ($mode == 'delete' || $mode == 'soft_delete')
|
||||
{
|
||||
handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'));
|
||||
$soft_delete_reason = ($mode == 'soft_delete' && $auth->acl_get('m_softdelete', $forum_id)) ? utf8_normalize_nfc(request_var('delete_reason', '', true)) : '';
|
||||
handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $soft_delete_reason);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1532,7 +1527,7 @@ function upload_popup($forum_style = 0)
|
|||
/**
|
||||
* Do the various checks required for removing posts as well as removing it
|
||||
*/
|
||||
function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft)
|
||||
function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $soft_delete_reason = '')
|
||||
{
|
||||
global $user, $db, $auth, $config;
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
@ -1553,9 +1548,9 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
|
|||
$data = array(
|
||||
'topic_first_post_id' => $post_data['topic_first_post_id'],
|
||||
'topic_last_post_id' => $post_data['topic_last_post_id'],
|
||||
'topic_posts' => $post_data['topic_posts'];
|
||||
'topic_posts_unapproved' => $post_data['topic_posts_unapproved'];
|
||||
'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted'];
|
||||
'topic_posts' => $post_data['topic_posts'],
|
||||
'topic_posts_unapproved' => $post_data['topic_posts_unapproved'],
|
||||
'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted'],
|
||||
'topic_visibility' => $post_data['topic_visibility'],
|
||||
'topic_type' => $post_data['topic_type'],
|
||||
'post_visibility' => $post_data['post_visibility'],
|
||||
|
@ -1565,7 +1560,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
|
|||
'post_postcount' => $post_data['post_postcount'],
|
||||
);
|
||||
|
||||
$next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft);//@todo: $reason);
|
||||
$next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $soft_delete_reason);
|
||||
$post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username'];
|
||||
|
||||
if ($next_post_id === false)
|
||||
|
@ -1589,7 +1584,15 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
|
|||
}
|
||||
else
|
||||
{
|
||||
confirm_box(false, 'DELETE_POST', $s_hidden_fields);
|
||||
global $template;
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id) || $auth->acl_get('f_delete', $forum_id),
|
||||
'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id) || $auth->acl_get('f_softdelete', $forum_id),
|
||||
'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id),
|
||||
));
|
||||
|
||||
confirm_box(false, 'DELETE_POST', $s_hidden_fields, 'posting_delete_post_body.html');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<!-- INCLUDE overall_header.html -->
|
||||
|
||||
<form id="confirm" action="{S_CONFIRM_ACTION}" method="post">
|
||||
<div class="panel">
|
||||
<div class="inner">
|
||||
|
||||
<h2>{MESSAGE_TITLE}</h2>
|
||||
<p>{MESSAGE_TEXT}</p>
|
||||
|
||||
<!-- IF S_DELETE_REASON or (S_ALLOWED_DELETE and S_ALLOWED_SOFTDELETE) -->
|
||||
<fieldset class="fields1">
|
||||
<!-- IF S_ALLOWED_DELETE and S_ALLOWED_SOFTDELETE -->
|
||||
<dl>
|
||||
<dt><label for="soft_delete">{L_DELETE_POST_SOFT}:</label></dt>
|
||||
<dd><label for="soft_delete"><input id="soft_delete" name="soft_delete" type="checkbox" checked="checked" value="1" /> {L_DELETE_POST_SOFT_EXP}</label></dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF S_DELETE_REASON -->
|
||||
<dl>
|
||||
<dt><label for="delete_reason">{L_DELETE_POST_REASON}:</label></dt>
|
||||
<dd><input type="text" name="delete_reason" id="delete_reason" value="" class="inputbox autowidth" maxlength="120" size="45" /></dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
</fieldset>
|
||||
<!-- ENDIF -->
|
||||
|
||||
<fieldset class="submit-buttons">
|
||||
{S_HIDDEN_FIELDS}
|
||||
<input type="submit" name="confirm" value="{L_YES}" class="button1" />
|
||||
<input type="submit" name="cancel" value="{L_NO}" class="button2" />
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- INCLUDE overall_footer.html -->
|
Loading…
Add table
Reference in a new issue