Esempio n. 1
0
 /**
  * Elimina la collection dal sistema.
  *
  * @param post: la collection da eliminare.
  * @return: la collection eliminata.
  */
 static function deleteCollection($collection)
 {
     return PostManager::deletePost($collection);
 }
Esempio n. 2
0
 /**
  * Elimina la collection dal sistema.
  *
  * @param post: la collection da eliminare.
  * @return: la collection eliminata.
  */
 static function deleteCollection($collection)
 {
     require_once "post/PostManager.php";
     return PostManager::deletePost($collection);
 }
Esempio n. 3
0
 private static function doPostAction($request)
 {
     require_once 'post/PostManager.php';
     if (isset(self::$currentID) && self::$currentID != null) {
         self::$currentObject = PostManager::loadPostByPermalink(self::$currentID);
     }
     //echo "<p>" . $request["action"] . "</p>"; //DEBUG
     switch (self::$requestedAction) {
         //modifica, vota, commenta, elimina, subscribe o aggiungi a una collezione il post
         case "Read":
             //echo "<p><font color='green'>" . $request["permalink"] . "</font></p>"; //DEBUG
             require_once "post/PostPage.php";
             PostPage::showPost(self::$currentObject, self::$post_options);
             break;
         case "Edit":
             //echo "<p><font color='green'>REQUEST TO LOAD " . $request["script"] . " by: " . $author->getNickname() . ", with the title of: " . $request["posttitle"] . ", created the day: " . date("d/m/Y", $request["postday"]) . "</font></p>"; //DEBUG
             require_once "post/PostPage.php";
             PostPage::showEditPostForm(self::$currentObject);
             break;
         case "Vote":
             //echo "<p><font color='green'>REQUEST TO LOAD " . $request["script"] . " by: " . $author->getNickname() . ", with the title of: " . $request["posttitle"] . ", created the day: " . date("d/m/Y", $request["postday"]) . "</font></p>"; //DEBUG
             require_once "post/PostPage.php";
             //controllo su vote.
             if (isset($_GET["vote"])) {
                 if ($_GET["vote"] == "y" || $_GET["vote"] == "yes") {
                     $vote = true;
                 }
                 if ($_GET["vote"] == "n" || $_GET["vote"] == "no") {
                     $vote = false;
                 }
                 if (!isset($_GET["vote"])) {
                     header("location: " . FileManager::appendToRootPath("error.php?error=Oops, il voto da te inserito non &egrave; valido."));
                 }
                 PostManager::votePost(self::$user->getID(), self::$currentObject, $vote);
             }
             PostPage::showPost(self::$currentObject, self::$post_options);
             break;
         case "Comment":
             //echo "<p><font color='green'>REQUEST TO LOAD " . $request["script"] . " by: " . $author->getNickname() . ", with the title of: " . $request["posttitle"] . ", created the day: " . date("d/m/Y", $request["postday"]) . "</font></p>"; //DEBUG
             require_once "post/PostPage.php";
             PostPage::showComments(self::$currentObject);
             break;
         case "Delete":
             //echo "<p><font color='green'>REQUEST TO LOAD " . $request["script"] . " by: " . $author->getNickname() . ", with the title of: " . $request["posttitle"] . ", created the day: " . date("d/m/Y", $request["postday"]) . "</font></p>"; //DEBUG
             require_once "post/PostPage.php";
             PostManager::deletePost(self::$currentObject);
             header("location: " . FileManager::getServerPath());
             break;
         case "Subscribe":
             //echo "<p><font color='green'>REQUEST TO LOAD " . $request["script"] . " by: " . $author->getNickname() . ", with the title of: " . $request["posttitle"] . ", created the day: " . date("d/m/Y", $request["postday"]) . "</font></p>"; //DEBUG
             require_once "post/PostPage.php";
             PostPage::showContestForm(self::$currentObject);
             break;
         case "AddToCollection":
             //echo "<p><font color='green'>REQUEST TO LOAD " . $request["script"] . " by: " . $author->getNickname() . ", with the title of: " . $request["posttitle"] . ", created the day: " . date("d/m/Y", $request["postday"]) . "</font></p>"; //DEBUG
             require_once "post/PostPage.php";
             PostPage::showCollectionForm(self::$currentObject);
             break;
         case "New":
             require_once "post/PostPage.php";
             PostPage::showNewPostForm();
             break;
         case "Search":
         default:
             require_once "search/SearchPage.php";
             SearchPage::showPostSearchForm();
             break;
     }
 }
Esempio n. 4
0
 /**
  * Crea un post;
  * Associa al post un voto ed un commento (li crea);
  * Cancella il post (di conseguenza anche il voto e il commento, per CASCADE);
  */
 function testDeletePost()
 {
     $data = $this->post_data_all;
     $p = PostManager::createPost($data);
     $p1 = PostManager::votePost($this->author_id, $p, $this->vote_value);
     $p1 = PostManager::commentPost($p, $this->author_id, $this->comment_text);
     if (count($p1->getComments()) == 0) {
         return "<br />Post deleting test NOT PASSED: not added";
     }
     $comm = $p1->getComments();
     $votes = $p1->getVotes();
     $com = PostManager::loadComment($comm[0]->getId());
     $vote = PostManager::loadVote($votes[0]->getAuthor(), $votes[0]->getPost());
     $post = PostManager::loadPost($p1->getId());
     //echo "<p>" . $post . "</p><p>" . $com . "</p><p>" . $vote . "</p>"; //DEBUG
     if ($com !== false && $post !== false && $vote !== false) {
         $post = PostManager::deletePost($post);
         $post = PostManager::loadPost($post->getID());
         $com = PostManager::loadComment($com->getID());
         $vote = PostManager::loadVote($vote->getAuthor(), $vote->getPost());
         //echo "<p>" . $post . "</p><p>" . $com . "</p><p>" . $vote . "</p>"; //DEBUG
         if ($post === false && $com === false && $vote === false) {
             return "<br />Post deleting test passed";
         }
     }
     return "<br />Post deleting test NOT PASSED: not deleted";
 }