Esempio n. 1
0
 /**
  * Aggiunge un commento ad una Collection.
  * 
  * @param author: l'autore del commento.
  * @param collection: la collezione in cui aggiungere il voto.
  * @param comment: il testo del commento.
  * @return: la collezione aggiornata.
  */
 static function commentCollection($author, $collection, $comment)
 {
     return PostManager::commentPost($collection, $author, $comment);
 }
Esempio n. 2
0
 /**
  * Aggiunge un commento ad una Collection.
  * 
  * @param author: l'autore del commento.
  * @param collection: la collezione in cui aggiungere il voto.
  * @param comment: il testo del commento.
  * @return: la collezione aggiornata.
  */
 static function commentCollection($author, $collection, $comment)
 {
     require_once "post/PostManager.php";
     return PostManager::commentPost($collection, $author, $comment);
 }
Esempio n. 3
0
    static function showCommentForm($user, $post, $error = null)
    {
        if ($user == Session::getUser($user)) {
            //controllo se l'untente è loggato
            if ($error == null && count($_POST) > 0) {
                if (isset($_POST["comment"])) {
                    $comment = $_POST["comment"];
                } else {
                    $error = "devi inserire un commento!";
                }
                if (isset($error)) {
                    self::showCommentForm($error);
                } else {
                    PostManager::commentPost($post, $user->getID(), $comment);
                }
            } else {
                $POST_data = count($_POST) > 0;
                if ($error != null) {
                    foreach ($error as $valore) {
                        echo "{$valore}<br>";
                    }
                }
                ?>
				<form name="addComment" action="" method="post">
					<textarea name="comment">
					<?php 
                if ($POST_data) {
                    echo $_POST["comment"];
                }
                ?>
					</textarea>
					<input type="submit" value="comment">
				</form>
				<?php 
            }
        } else {
            /*user not loggedIn show error*/
            ?>
 <a href="">login</a> o <a href="">registrati</a> per commentare  <!-- TODO: link alla form di login e di registrazione --> <?php 
        }
    }
Esempio n. 4
0
 /**
  * Crea un post;
  * Associa al post un commento (lo crea);
  * Cancella il commento dal database;
  * Carica il post e cerca di caricare il commento;
  * Controlla che il post non abbia quel commento e di non essere riuscito a caricare il commento;
  */
 function testDeleteComment()
 {
     $data = $this->post_data_all;
     $p = PostManager::createPost($data);
     $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();
     $com = PostManager::loadComment($comm[0]->getId());
     $post = PostManager::loadPost($p1->getId());
     if ($com !== false && $post !== false) {
         $com = PostManager::removeComment($com);
         $post = PostManager::loadPost($post->getID());
         $com = PostManager::loadComment($com->getID());
         if ($post !== false && $com === false) {
             if (count($post->getComments()) == 0) {
                 return "<br />Comment deleting test passed";
             }
         }
     }
     return "<br />Comment deleting test NOT PASSED: not deleted";
 }