public static function postComment($id, $type, $backPage) { if (empty($id) || empty($type) || empty($backPage)) { Watermelon::displayNoPageFoundError(); return; } if (!in_array($type, array('blogpost', 'page'))) { Watermelon::displayNoPageFoundError(); return; } //-- $model = new Comments_Model(); $backPage = base64_decode($backPage); $form = Form::validate('wmelon.comments.addComment', $backPage)->get(); // testing for spam and adding if (!Users::isLogged()) { // testing for spam $commentStatus = Sblam::test('content', 'name', 'email', 'website'); // remembering user's data $_SESSION['wmelon.comments.name'] = $form->name; $_SESSION['wmelon.comments.email'] = $form->email; $_SESSION['wmelon.comments.website'] = $form->website; // assigning "visibility token" (token user needs to have in session to see his own comments, even if not approved) if (isset($_SESSION['wmelon.comments.visibilityToken'])) { $visibilityToken = $_SESSION['wmelon.comments.visibilityToken']; } else { $visibilityToken = $form->name . $form->email . mt_rand(); $visibilityToken = md5($visibilityToken); $visibilityToken = substr($visibilityToken, 16); $_SESSION['wmelon.comments.visibilityToken'] = $visibilityToken; } // adding comment switch ($commentStatus) { case 0: case 1: case -1: $model->postComment($id, $type, $form->name, $form->email, $form->website, $form->content, false, $visibilityToken); Watermelon::displayNotice('Twój komentarz zostanie sprawdzony zanim zostanie publicznie pokazany'); break; case -2: $commentID = $model->postComment($id, $type, $form->name, $form->email, $form->website, $form->content, true, $visibilityToken); Watermelon::displaySuccessNotice('Dodano komentarz'); $backPage .= '#comment-' . $commentID; break; case 2: Watermelon::displayError('Filtr uznał twój komentarz za spam. ' . Sblam::reportLink()); break; } } else { $commentID = $model->postComment_logged($id, $type, $form->content); $backPage .= '#comment-' . $commentID; } SiteRedirect($backPage); }
public function deletePosts(array $ids) { DB::delete('blogposts', $ids); foreach ($ids as $id) { Comments_Model::deleteCommentsFor($id, 'blogpost'); } self::updateFeed(); }
public function deletePages(array $ids) { DB::delete('pages', $ids); foreach ($ids as $id) { Comments_Model::deleteCommentsFor($id, 'page'); } }