/** * Retrieve a page give its title * * @param string $title Page title * * @return object on success or null on failure */ public function getPageByTitle($title) { $param = ['type = "pages" AND title =?0', 'bind' => [$title]]; $post = Posts::findFirst($param); if (!$post) { return null; } return $post; }
/** * Delete spam posts */ public function deleteAction($id) { $auth = $this->auth->getAuth(); if (!$auth) { $this->flashSession->error('You must be logged first'); return $this->indexRedirect(); } $parameters = ["id = ?0 AND (usersId = ?1 OR 'Y' = ?2 OR 'Y' = ?3)", "bind" => [$id, $auth['id'], $auth['moderator'], $auth['admin']]]; if (!($object = Posts::findFirst($parameters))) { $this->flashSession->error(t('Post doesn\'t exist.')); return $this->indexRedirect(); } if (!$object->delete()) { $this->saveLoger($object->getMessages()); } $this->flashSession->success(t('Data was successfully deleted do late')); return $this->indexRedirect(); }