Beispiel #1
0
function delete($id)
{
    /* Create a new blog interface object. */
    $blog = new Blog(createPDO());
    /* Attempt to delete the post and return the result. */
    return $blog->delete_post($id);
}
Beispiel #2
0
 public function testDeletePost()
 {
     $blog = new Blog($this->pdo);
     $blog->delete_post(1);
     $result = $this->getConnection()->createQueryTable("posts", "SELECT * FROM posts\n       WHERE id = 1");
     $this->assertEquals(0, $result->getRowCount());
 }
Beispiel #3
0
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'view_post') {
    $task_id = isset($_GET['task_id']) && is_numeric($_GET['task_id']) ? $_GET['task_id'] : 0;
    if (isset($_GET['do']) && $_GET['do'] == 'delete_comment') {
        if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) {
            Blog::delete_comment($blog_id, (int) $_GET['post_id'], (int) $_GET['comment_id']);
            $return_message = array('type' => 'confirmation', 'message' => get_lang('CommentDeleted'));
        } else {
            $error = true;
            $message = get_lang('ActionNotAllowed');
        }
    }
    if (isset($_GET['do']) && $_GET['do'] == 'delete_article') {
        if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) {
            Blog::delete_post($blog_id, (int) $_GET['article_id']);
            $current_page = '';
            // Article is gone, go to blog home
            $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogDeleted'));
        } else {
            $error = true;
            $message = get_lang('ActionNotAllowed');
        }
    }
    if (isset($_GET['do']) && $_GET['do'] == 'rate') {
        if (isset($_GET['type']) && $_GET['type'] == 'post') {
            if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) {
                Blog::add_rating('post', $blog_id, (int) $_GET['post_id'], (int) $_GET['rating']);
                $return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded'));
            }
        }