[feature/soft-delete] Update docs of can_soft_delete and remove can_restore

PHPBB3-9567
This commit is contained in:
Joas Schilling 2012-10-05 14:42:11 +02:00
parent 526721c7db
commit 05f2366755
2 changed files with 10 additions and 29 deletions

View file

@ -293,9 +293,10 @@ class phpbb_content_visibility
/** /**
* Can the current logged-in user soft-delete posts? * Can the current logged-in user soft-delete posts?
* @param $forum_id - int - the forum ID whose permissions to check *
* @param $poster_id - int - the poster ID of the post in question * @param $forum_id int Forum ID whose permissions to check
* @param $post_locked - bool - is the post locked? * @param $poster_id int Poster ID of the post in question
* @param $post_locked bool Is the post locked?
* @return bool * @return bool
*/ */
static function can_soft_delete($forum_id, $poster_id, $post_locked) static function can_soft_delete($forum_id, $poster_id, $post_locked)
@ -310,28 +311,7 @@ class phpbb_content_visibility
{ {
return true; return true;
} }
return false;
}
/**
* Can the current logged-in user restore soft-deleted posts?
* @param $forum_id - int - the forum ID whose permissions to check
* @param $poster_id - int - the poster ID of the post in question
* @param $post_locked - bool - is the post locked?
* @return bool
*/
public function can_restore($forum_id, $poster_id, $post_locked)
{
global $auth, $user;
if ($auth->acl_get('m_restore', $forum_id))
{
return true;
}
else if ($auth->acl_get('f_restore', $forum_id) && $poster_id == $user->data['user_id'] && !$post_locked)
{
return true;
}
return false; return false;
} }

View file

@ -884,8 +884,9 @@ if ($submit || $preview || $refresh)
$error[] = $user->lang['FORM_INVALID']; $error[] = $user->lang['FORM_INVALID'];
} }
if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && $auth->acl_get('m_approve', $forum_id))
{ {
//@todo: REMOVE the magic!
// if this is the first post of the topic, restore the whole topic // if this is the first post of the topic, restore the whole topic
if ($post_id == $post_data['topic_first_post_id']) if ($post_id == $post_data['topic_first_post_id'])
{ {
@ -1471,10 +1472,10 @@ $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_SOFT_DELETE_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_SOFT_DELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false,
'S_RESTORE_ALLOWED' => (phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, '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,
'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '',
'S_TYPE_TOGGLE' => $topic_type_toggle, 'S_TYPE_TOGGLE' => $topic_type_toggle,