protected function common_delete($post_id, $undelete = false) { $this->user->add_lang('posting'); // Load the stuff we need $post = $this->load_post($post_id); // Check permissions if (!$undelete && !$post->acl_get('delete') || $undelete && !$post->acl_get('undelete')) { return $this->controller_helper->needs_auth(); } if (confirm_box(true)) { if (!$undelete) { // Delete the post if ($this->request->is_set_post('hard_delete') || $post->post_deleted) { if (!$this->auth->acl_get('u_titania_post_hard_delete')) { return $this->controller_helper->needs_auth(); } $post->hard_delete(); // Try to redirect to the next or previous post $redirect_post_id = \posts_overlord::next_prev_post_id($post->topic_id, $post->post_id); if ($redirect_post_id) { return new RedirectResponse($post->topic->get_url(false, array('p' => $redirect_post_id, '#' => "p{$redirect_post_id}"))); } return new RedirectResponse($post->topic->get_parent_url()); } else { $post->soft_delete(); if ($this->auth->acl_get('u_titania_mod_post_mod')) { // They can see the post, redirect back to it return new RedirectResponse($post->get_url()); } else { // They cannot see the post, try to redirect to the next or previous post $redirect_post_id = \posts_overlord::next_prev_post_id($post->topic_id, $post->post_id); if ($redirect_post_id) { return new RedirectResponse($post->topic->get_url(false, array('p' => $redirect_post_id, '#' => "p{$redirect_post_id}"))); } } } return new RedirectResponse($post->topic->get_url()); } else { $post->undelete(); return new RedirectResponse($post->get_url()); } } else { $s_hard_delete = !$undelete && !$post->post_deleted && $this->auth->acl_get('u_titania_post_hard_delete'); $this->template->assign_var('S_HARD_DELETE', $s_hard_delete); confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', 'posting/delete_confirm.html'); } return new RedirectResponse($post->get_url()); }
private function common_delete($post_id, $undelete = false) { titania::add_lang('posting'); phpbb::$user->add_lang('posting'); // Load the stuff we need $post_object = $this->load_post($post_id); // Check permissions if (!$undelete && !$post_object->acl_get('delete') || $undelete && !$post_object->acl_get('undelete')) { titania::needs_auth(); } if (titania::confirm_box(true)) { if (!$undelete) { $redirect_post_id = false; // Delete the post if (isset($_POST['hard_delete']) || $post_object->post_deleted) { if (!phpbb::$auth->acl_get('u_titania_post_hard_delete')) { titania::needs_auth(); } $post_object->hard_delete(); // Try to redirect to the next or previous post $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id); if ($redirect_post_id) { redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id))); } redirect(titania_url::build_url($post_object->topic->topic_url)); } else { $post_object->soft_delete(); if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) { // They can see the post, redirect back to it redirect($post_object->get_url()); } else { // They cannot see the post, try to redirect to the next or previous post $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id); if ($redirect_post_id) { redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id))); } } } redirect($post_object->topic->get_url()); } else { $post_object->undelete(); redirect($post_object->get_url()); } } else { phpbb::$template->assign_var('S_HARD_DELETE', !$undelete && !$post_object->post_deleted && phpbb::$auth->acl_get('u_titania_post_hard_delete') ? true : false); titania::confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', array(), 'posting/delete_confirm.html'); } redirect($post_object->get_url()); }