[feature/soft-delete] Fix deleting via post editing

PHPBB3-9567
This commit is contained in:
Joas Schilling 2012-11-03 22:53:54 +01:00
parent 6999d776d4
commit dfcfccf537
4 changed files with 32 additions and 20 deletions

View file

@ -85,7 +85,7 @@ $lang = array_merge($lang, array(
'DELETE_POSTS_PERMANENTLY_CONFIRM' => 'Are you sure you want to <strong>permanently</strong> delete these posts?', 'DELETE_POSTS_PERMANENTLY_CONFIRM' => 'Are you sure you want to <strong>permanently</strong> delete these posts?',
'DELETE_REASON' => 'Delete reason', 'DELETE_REASON' => 'Delete reason',
'DELETE_REASON_EXPLAIN' => 'The reason is only used when the post is not deleted permanently.', 'DELETE_REASON_EXPLAIN' => 'The reason is only used when the post is not deleted permanently.',
'DELETE_POST_WARN' => 'Once deleted the post cannot be recovered', 'DELETE_POST_WARN' => 'Deleted this post',
'DELETE_TOPIC_CONFIRM' => 'Are you sure you want to delete this topic?', 'DELETE_TOPIC_CONFIRM' => 'Are you sure you want to delete this topic?',
'DELETE_TOPIC_PERMANENTLY' => 'Permanently delete this topic so it can not be recovered', 'DELETE_TOPIC_PERMANENTLY' => 'Permanently delete this topic so it can not be recovered',
'DELETE_TOPIC_PERMANENTLY_CONFIRM' => 'Are you sure you want to <strong>permanently</strong> delete this topic?', 'DELETE_TOPIC_PERMANENTLY_CONFIRM' => 'Are you sure you want to <strong>permanently</strong> delete this topic?',

View file

@ -322,6 +322,12 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id))
// Handle delete mode... // Handle delete mode...
if ($mode == 'delete' || $mode == 'soft_delete') if ($mode == 'delete' || $mode == 'soft_delete')
{ {
if ($mode == 'soft_delete' && $post_data['post_visibility'] == ITEM_DELETED)
{
$user->setup('posting');
trigger_error('NO_POST');
}
$soft_delete_reason = ($mode == 'soft_delete' && $auth->acl_get('m_softdelete', $forum_id)) ? utf8_normalize_nfc(request_var('delete_reason', '', true)) : ''; $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); handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $soft_delete_reason);
return; return;
@ -1110,6 +1116,14 @@ if ($submit || $preview || $refresh)
$captcha->reset(); $captcha->reset();
} }
// Handle delete mode...
if ($request->is_set_post('delete') || $request->is_set_post('delete_permanent'))
{
$soft_delete_reason = (!$request->is_set_post('delete_permanent') && $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, !$request->is_set_post('delete_permanent'), $soft_delete_reason);
return;
}
// Check the permissions for post approval. Moderators are not affected. // Check the permissions for post approval. Moderators are not affected.
if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id']) && empty($data['force_approved_state'])) || (isset($data['force_approved_state']) && !$data['force_approved_state'])) if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id']) && empty($data['force_approved_state'])) || (isset($data['force_approved_state']) && !$data['force_approved_state']))
{ {
@ -1430,8 +1444,9 @@ $template->assign_vars(array(
'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '',
'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '',
'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', 'S_SOFTDELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '',
'S_SOFT_DELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, 'S_DELETE_REASON' => ($mode == 'edit' && $auth->acl_get('m_softdelete', $forum_id)) ? true : false,
'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false,
'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id), 'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id),
'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false,
'S_LINKS_ALLOWED' => $url_status, 'S_LINKS_ALLOWED' => $url_status,
@ -1584,10 +1599,11 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
} }
else else
{ {
global $template; global $template, $request;
$template->assign_vars(array( $template->assign_vars(array(
'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED,
'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '',
'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id) || $auth->acl_get('f_delete', $forum_id), '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_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), 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id),

View file

@ -15,7 +15,7 @@
<dt><label for="delete_permanent">{L_DELETE_PERMANENTLY}:</label></dt> <dt><label for="delete_permanent">{L_DELETE_PERMANENTLY}:</label></dt>
<dd> <dd>
<label for="delete_permanent"> <label for="delete_permanent">
<input id="delete_permanent" name="delete_permanent" type="checkbox" value="1" /> <input id="delete_permanent" name="delete_permanent" type="checkbox" value="1" {S_CHECKED_PERMANENT} />
<!-- IF S_TOPIC_MODE -->{L_DELETE_TOPIC_PERMANENTLY}<!-- ELSE -->{L_DELETE_POST_PERMANENTLY}<!-- ENDIF --> <!-- IF S_TOPIC_MODE -->{L_DELETE_TOPIC_PERMANENTLY}<!-- ELSE -->{L_DELETE_POST_PERMANENTLY}<!-- ENDIF -->
</label> </label>
</dd> </dd>

View file

@ -73,21 +73,6 @@
<!-- ENDIF --> <!-- ENDIF -->
<div class="clear"></div> <div class="clear"></div>
<!-- ENDIF -->
<!-- IF S_DELETE_ALLOWED -->
<dl>
<dt><label for="delete">{L_DELETE_POST}:</label></dt>
<dd><label for="delete"><input type="checkbox" name="delete" id="delete" /> {L_DELETE_POST_WARN}</label></dd>
</dl>
<!-- ENDIF -->
<!-- IF (S_SOFT_DELETE_ALLOWED and not S_IS_DELETED) or (S_RESTORE_ALLOWED and S_IS_DELETED) -->
<dl>
<dt><label for="soft_delete">{L_SOFT_DELETE_POST}:</label></dt>
<dd><label for="soft_delete"><input type="checkbox" name="soft_delete"{S_SOFT_DELETE_CHECKED} id="soft_delete" /> {L_SOFT_DELETE_POST_EXPLAIN}</label></dd>
</dl>
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF S_SHOW_TOPIC_ICONS or S_SHOW_PM_ICONS --> <!-- IF S_SHOW_TOPIC_ICONS or S_SHOW_PM_ICONS -->
@ -261,6 +246,17 @@
</dl> </dl>
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF S_SOFTDELETE_ALLOWED or S_DELETE_ALLOWED -->
<hr class="dashed" />
<dl>
<dt><label for="delete">{L_DELETE_POST}:</label></dt>
<dd><label for="delete"><input type="checkbox" name="delete" id="delete" {S_SOFTDELETE_CHECKED} /> {L_DELETE_POST_WARN}</label></dd>
<!-- IF S_DELETE_ALLOWED and S_SOFTDELETE_ALLOWED -->
<dd><label for="delete_permanent"><input type="checkbox" name="delete_permanent" id="delete_permanent" /> {L_DELETE_POST_PERMANENTLY}</label></dd>
<!-- ENDIF -->
</dl>
<!-- ENDIF -->
<!-- IF S_EDIT_REASON --> <!-- IF S_EDIT_REASON -->
<dl> <dl>
<dt><label for="edit_reason">{L_EDIT_REASON}:</label></dt> <dt><label for="edit_reason">{L_EDIT_REASON}:</label></dt>