public static function ActionDeletePost($id)
 {
     if (ModeratorModel::isModerator()) {
         PostModel::deletePost($id);
     }
     header('Location: ' . $_SERVER['HTTP_REFERER']);
 }
Ejemplo n.º 2
0
 public function deletePost()
 {
     $postid = htmlspecialchars($_GET['id']);
     $session = new SessionHelper();
     $user = new User();
     $post = new Post($postid);
     $postmodel = new PostModel();
     $categorymodel = new CategoryModel();
     $category = new Category($post->category_id);
     // Only an admin or the moderator of this category may delete a post
     if ($user->role == 1 || $user->id == $category->moderator_id) {
         if ($postmodel->deletePost($postid)) {
             $session->setMessage('Post removed', 4);
             redirectTo('index.php?c=user&a=viewdashboard');
         } else {
             $session->setMessage('Post not removed', 3);
             redirectTo('index.php?c=user&a=viewdashboard');
         }
     } else {
         $session->setMessage('You are not an admin or you are not the moderator of this category', 2);
         redirectTo('index.php?c=user&a=viewdashboard');
     }
 }