Example #1
0
 public function photoCommentsRss()
 {
     checkUnauthorizedAccess();
     $photoID = getIdFromURL();
     checkIntValueOfId($photoID);
     $photo = PhotoRepository::getPhotoByID($photoID);
     if ($photo == null) {
         redirect(\route\Route::get("errorPage")->generate());
     }
     $photoComments = PhotoCommentRepository::getPhotoComments($photoID);
     $title = "Tweet";
     $link = "http://localhost:8080/TwitterApp/tweet/" . $photoID;
     $description = "List of all comments for selected tweet.";
     generateCommentsRss($title, $link, $description, $photoComments);
 }
Example #2
0
 public function postPhotoComment()
 {
     checkUnauthorizedAccess();
     $id = getIdFromURL();
     checkIntValueOfId($id);
     if (post('comment')) {
         $photoID = $id;
         $username = $_SESSION['username'];
         $userid = UserRepository::getIdByUsername($_SESSION['username']);
         $content = htmlentities(trim(post('comment')));
         $comment = new PhotoComment();
         $comment->setPhotoid($photoID);
         $comment->setUserid($userid);
         $comment->setContent($content);
         try {
             PhotoCommentRepository::postComment($comment);
             echo json_encode(['comment' => parseText($comment->getContent()), 'user' => $username]);
         } catch (\PDOException $e) {
             $e->getMessage();
         }
     }
 }