/** * Execute the job. * * @return void */ public function handle() { // Delete the notice from database $this->notice->delete(); // Fire Event and Listeners event(new DeletedNotice($this->notice)); }
function delete($id = null) { if (!$id) { $this->flash(__('Invalid Post', true), array('action' => 'index')); } if ($this->Post->delete($id)) { $this->flash(__('Post deleted', true), array('action' => 'index')); } else { $this->flash(__('Post deleted Fail', true), array('action' => 'index')); } }
/** * Verifies that main cache key resets every time post is edited. * * @return void * @since 0.1.0 */ public function testCacheInvalidation() { $value = \Yii::app()->cacheHelper->getPostsCacheTokenValue(); $post = new \Post(); $attrs = array('name' => 'just a name', 'slug' => 'just-a-name', 'content' => 'Dummy content', 'created' => '2010-05-05 12:12:12', 'user_id' => 1, 'category_id' => 1); $post->setAttributes($attrs, false); $post->save(); $this->assertNotSame($value, $value = \Yii::app()->cacheHelper->getPostsCacheTokenValue()); $post->delete(); $this->assertNotSame($value, $value = \Yii::app()->cacheHelper->getPostsCacheTokenValue()); }
public function delete($id) { if (!self::owner($id)) { throw new NotAuthorized(); } if ((string) (int) $id != $id) { throw new InvalidInput('Post id provided was not an integer: "' . $id . '" given'); } Post::delete($id); echo 'Post deleted successfully.'; }
public function controlerJob($maincont) { if ($maincont->isLoggued()) { if (isset($_GET["id"])) { $p = new Post($_GET["id"]); $p->delete(); } $maincont->goModule("post", "admin"); } else { $maincont->goModule("home", "display"); } }
public function delete($where = null) { if ($where === null) { $where = array(); foreach ($this->getPrimaryColumns() as $col) { $where[$col] = $this->{$col}; } $this->clear(); } $rows = $this->get($where); if ($rows) { foreach ($rows as $row) { $this->unlink('image', (array) $row); } } return parent::delete($where); }
/** * @inheritdoc */ public function saveAfter(Post $previous) { // If the previous post is another 'discussion renamed' post, and it's // by the same user, then we can merge this post into it. If we find // that we've in fact reverted the title, delete it. Otherwise, update // its content. if ($previous instanceof static && $this->user_id === $previous->user_id) { if ($previous->content[0] == $this->content[1]) { $previous->delete(); } else { $previous->content = static::buildContent($previous->content[0], $this->content[1]); $previous->save(); } return $previous; } $this->save(); return $this; }
break; case 'destroy': //各条件 $cont->destroy(10); break; case 'view': //各条件 $modl->view(10); break; case 'update': //各条件 $modl->update(10); break; case 'delete': //各条件 $modl->delete(10); break; default: echo 'It is error'; break; } //controller class class PostController { //property private $resouce = ''; private $action = ''; private $view_options = ''; //construct public function __construct() {
get('/user/:username', function ($app) { get_user_profile($app); $app->render('user/profile'); }); get('/user/:username/:skip', function ($app) { get_user_profile($app); $app->render('user/_posts', false); }); post('/post', function ($app) { if (User::is_authenticated()) { $post = new Post(); $post->content = $app->form('content'); $post->create(); $app->redirect('/user/' . User::current_user()); } else { $app->set('error', 'You must be logged in to do that.'); $app->render('user/login'); } }); delete('/post/delete/:id/:rev', function ($app) { $post = new Post(); $post->_id = $app->request('id'); $post->_rev = $app->request('rev'); $post->delete(); $app->redirect('/user/' . User::current_user()); }); get('/say/:message', function ($app) { $app->set('message', $app->request('message')); $app->render('home'); }); resolve();
$default_file = FEATHERS_DIR . "/" . $post->feather . "/fields.php"; $options = array(); Trigger::current()->filter($options, array("edit_post_options", "post_options"), $post); $main->display("forms/post/edit", array("post" => $post, "feather" => Feathers::$instances[$post->feather], "options" => $options, "groups" => Group::find(array("order" => "id ASC")))); break; case "delete_post": $post = new Post($_POST['id'], array("drafts" => true)); if ($post->no_results) { header("HTTP/1.1 404 Not Found"); $trigger->call("not_found"); exit; } if (!$post->deletable()) { show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this post.")); } Post::delete($_POST['id']); break; case "view_post": fallback($_POST['offset'], 0); fallback($_POST['context']); $reason = isset($_POST['reason']) ? $_POST['reason'] : ""; if (isset($_POST['id'])) { $post = new Post($_POST['id'], array("drafts" => true)); } if ($post->no_results) { header("HTTP/1.1 404 Not Found"); $trigger->call("not_found"); exit; } $main->display("feathers/" . $post->feather, array("post" => $post, "ajax_reason" => $reason)); break;
$posts->show(1); break; case 'edit': $posts->edit(1); break; case 'destroy': $posts->destroy(1); break; case 'view': $post->view(1); break; case 'update': $post->update(1); break; case 'delete': $post->delete(1); default: # code... break; } function changesingular($value) { //複数形から単数形へ変換 if ($value == 'posts') { return 'post'; } } /** * Controllerのクラス */ class PostsController
{ $query = "SELECT * FROM posts WHERE active=1 AND id > " . $lastId; $result = $this->db->query($query); while ($row = $result->fetch_object()) { $out[] = $row; } if (empty($out)) { $out[] = ''; } return $out; } } if (isset($_POST['findNew'])) { $post = new Post(); $out = $post->findNew($_POST['findNew']); if (!empty($out)) { echo json_encode($out); } else { header('HTTP/1.1 500 F**k'); exit; } } if (isset($_POST['deleteId'])) { $post = new Post(); $post->delete($_POST['deleteId']); } if (isset($_POST['body'])) { $post = new Post(); $post->setBody($_POST['body']); $post->add(); }
private function delPost() { $post = new Post($_GET["id"]); $post->delete(); header("Location: home.php"); }
/** * Delete post */ function deletePost() { $pid = intval($this->params['pid']); if ($pid > 0) { Doo::loadModel('Post'); $p = new Post(); $p->id = $pid; $p->delete(); //clear the sidebar cache Doo::cache('front')->flushAllParts(); $data['rootUrl'] = Doo::conf()->APP_URL; $data['title'] = 'Post Deleted!'; $data['content'] = "<p>Post with ID {$pid} is deleted successfully!</p>"; $this->render('admin_msg', $data); } }
} } $j = ["post_id" => $p->getID(), "liked" => false, "tapped_into" => false, "likes_count" => 0, "comments_count" => 0, "taps_count" => 0, "text" => $p->getText(), "time" => $p->getTime(), "category" => $p->getCategory()->getName(), "user" => $user, "images" => $ijson, "comments" => []]; echo json_encode($j); } else { echo json_encode(["status" => false]); } }); $app->get('/posts', function () use($app) { $posts = App::getPosts(["limit" => 25, "user_id" => 13]); echo json_encode(Utility::formatActivitiesToPosts($posts, $app)); }); $app->delete('/posts/:id', function ($id) use($app) { $p = new Post($id); if ($p->getID() && $app->environment()['testify.user_id'] == $p->getAuthor()->getID()) { $p->delete(); if ($p) { echo json_encode(['status' => true]); } } }); $app->post('/posts/:id/favorites', function ($id) use($app) { if ($uid = $app->environment['testify.user_id']) { $post = new Post($id); if ($post) { $u = new User($uid); $u->favoritePost($post, true); echo json_encode(array("favorites" => $post->countFavorites(), "status" => true)); } } });
public function deletePost(Post $post) { $post->delete(); return Redirect::route('post.list')->with('success', 'Post is deleted!'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $token = Input::get('token', ''); $u_id = Input::get('u_id', 0); $title = Input::get('title'); $title = urldecode($title); $longitude = Input::get('longitude'); $latitude = Input::get('latitude'); $address = Input::get('address'); $imgToken = Input::get('img_token', ''); $site_id = 1; $post = new Post(); $post->p_title = $title; $post->s_id = $site_id; $post->p_longitude = $longitude; $post->p_latitude = $latitude; $post->p_address = $address; try { $this->_user = User::chkUserByToken($token, $u_id); $post->u_id = $this->_user->u_id; $post->addPost($imgToken); $re = ['result' => 2000, 'data' => [], 'info' => '添加成功']; } catch (Exception $e) { $re = ['result' => 2001, 'data' => [], 'info' => $e->getMessage()]; if ($e->getCode() == 2) { $post->delete(); } } return Response::json($re); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Post $post) { /*$post = Post::findOrFail($id)->delete();*/ $post->delete(); return Redirect::route('posts.index')->withMessage("L'article a été supprimé"); }
<?php //删除一个帖子 require_once "Post.class.php"; $postid = $_GET["postid"]; $post = new Post(); $post->delete($postid); $post->closeDB(); echo "1";
/** * @expectedException \Exception * @expectedExceptionMessage cant delete without id */ public function testDeleteFail() { $post = new Post(); $post->delete(); }
public function blogger_deletePost($args) { $this->auth($args[2], $args[3], 'delete'); global $user; $post = new Post($args[1], array('filter' => false)); if ($post->no_results) { return new IXR_Error(500, __("Post not found.")); } else { if (!$post->deletable($user)) { return new IXR_Error(500, __("You don't have permission to delete this post.")); } } Post::delete($args[1]); return true; }
// check if question exists $question = $QNA->get_question(); if (!is_object($question)) { die(json_encode(['status' => false, 'err' => 'Question was not found.'])); } $save = QNA::remove_saved($PostID); if ($save === true) { die(json_encode(['status' => true])); } else { die(json_encode(['status' => false, 'err' => $save])); } break; case 'post_delete': $PostID = sanitize_id($data['id']); $post = new Post(); // check if post exists $post = $post->get_post($PostID, true); if (!is_array($post)) { die(json_encode(['status' => false, 'err' => 'Post was not found.'])); } if (USER_ID !== $post['user_id'] && USER_ID !== $post['poster_id']) { die(json_encode(['status' => false, 'id' => $PostID, 'err' => 'Authentication error.'])); } $post = new Post(); $post->PostID = $PostID; $delete = $post->delete(); if ($delete === true) { die(json_encode(['status' => true])); } break; }
function delete_posts($aggregate_name) { $sql = SQL::current(); $attrs = $sql->select("post_attributes", "post_id", array("name" => "aggregate", "value" => $aggregate_name))->fetchAll(); foreach ($attrs as $attr) { Post::delete($attr["post_id"]); } }
require_once '../model/paths.php'; $session = new Session(); if (!$session->isLogin) { redirect("../login.php"); } $user = new User(); $database = new Database(); $post = new Post(); $media = new Media(); if (isset($_POST['postList']) && $_POST['postList'] != null) { foreach ($_POST['postList'] as $postId) { // DELETE CATEGORIES OF A POST $post->setPostId($postId); $post->deleteCategories($database); // DELETE MEDIA OF A POST $media->setPostId($postId); $media->deleteMediaOfAPost($database); // DELTE POST ITSELF $post->delete($database); $path = "../logs"; $dateTime = strftime("%Y-%m-%d %H:%M:%S"); $text = "Deleted post with id:" . $postId; $content = $dateTime . " " . $_SESSION['USNM'] . ": " . $text; $user->setId($_SESSION['USID']); $user->storeLog($content, $path); echo "true"; } } else { echo "false"; }
/** * Function: destroy_user * Destroys a user. */ public function destroy_user() { if (!Visitor::current()->group->can("delete_user")) { show_403(__("Access Denied"), __("You do not have sufficient privileges to delete users.")); } if (empty($_POST['id'])) { error(__("No ID Specified"), __("An ID is required to delete a user.")); } if ($_POST['destroy'] == "bollocks") { redirect("/admin/?action=manage_users"); } if (!isset($_POST['hash']) or $_POST['hash'] != Config::current()->secure_hashkey) { show_403(__("Access Denied"), __("Invalid security key.")); } $sql = SQL::current(); $user = new User($_POST['id']); if (isset($_POST['posts'])) { if ($_POST['posts'] == "delete") { foreach ($user->post as $post) { Post::delete($post->id); } } elseif ($_POST['posts'] == "move") { $sql->update("posts", array("user_id" => $user->id), array("user_id" => $_POST['move_posts'])); } } if (isset($_POST['pages'])) { if ($_POST['pages'] == "delete") { foreach ($user->page as $page) { Page::delete($page->id); } } elseif ($_POST['pages'] == "move") { $sql->update("pages", array("user_id" => $user->id), array("user_id" => $_POST['move_pages'])); } } User::delete($_POST['id']); Flash::notice(__("User deleted."), "/admin/?action=manage_users"); }
/** * Deletes a single record or multiple records, ignoring relationships * * @param boolean $soft Make delete as soft or hard. Default hard [Optional] * @return Post */ public function delete($soft = FALSE) { $this->where($this->_object_name . '.type', '=', $this->_post_type); return parent::delete($soft); }
/** * Delete post * * @param type $cid */ public function delete_action($post_id) { $post = new Post(); $post->id = $post_id; if ($post->find() && access('Post.delete.all')) { if ($post->delete()) { $message = t('Пост удалён'); if (Ajax::is()) { $data['success'] = TRUE; $data['messages'] = array(array('type' => 'success', 'body' => $message)); $data['redirect'] = server('referer'); $ajax = new Ajax(); $ajax->json($data); } $post = new Post(); $post->id = $post->post_id; flash_success($message); back(-2); } } }
/** * Deletes a single record or multiple records, ignoring relationships * * @param integer $id Row ID. The search criteria [Optional] * @return Post */ public function delete($id = NULL) { $this->where($this->_object_name . '.type', '=', $this->_post_type); return parent::delete($id); }