Esempio n. 1
0
 /**
  * Aggiunge un voto ad una Collection.
  * 
  * @param author: l'autore del commento.
  * @param collection: la collezione in cui aggiungere il voto.
  * @param vote: il voto (boolean).
  * @return: la collezione aggiornata.
  */
 static function voteCollection($author, $collection, $vote)
 {
     return PostManager::votePost($author, $collection, $vote);
 }
Esempio n. 2
0
 /**
  * Aggiunge un voto ad una Collection.
  * 
  * @param author: l'autore del commento.
  * @param collection: la collezione in cui aggiungere il voto.
  * @param vote: il voto (boolean).
  * @return: la collezione aggiornata.
  */
 static function voteCollection($author, $collection, $vote)
 {
     require_once "post/PostManager.php";
     return PostManager::votePost($author, $collection, $vote);
 }
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 (lo crea);
  * Cancella il voto dal database;
  * Carica il post e cerca di caricare il voto;
  * Controlla che il post non abbia quel voto e di non essere riuscito a caricare il voto;
  */
 function testDeleteVote()
 {
     $data = $this->post_data_all;
     $p = PostManager::createPost($data);
     $p1 = PostManager::votePost($this->author_id, $p, $this->vote_value);
     if (count($p1->getVotes()) == 0) {
         return "<br />Vote deleting test NOT PASSED: not added";
     }
     $votes = $p1->getVotes();
     $vote = PostManager::loadVote($votes[0]->getAuthor(), $votes[0]->getPost());
     $post = PostManager::loadPost($p1->getId());
     if ($vote !== false && $post !== false) {
         $vote = PostManager::removeVote($vote);
         $post = PostManager::loadPost($post->getID());
         $vote = PostManager::loadVote($vote->getAuthor(), $vote->getPost());
         if ($post !== false && $vote === false) {
             if (count($post->getVotes()) == 0) {
                 return "<br />Vote deleting test passed";
             }
         }
     }
     return "<br />Vote deleting test NOT PASSED: not deleted";
 }