示例#1
0
/**
 * Checks if user has permission to comment on photo or edit tags.
 * User can comment photo or edit tags if he is friend with user that posted the tweet.
 * @return true if user has permission to comment photo or edit tag
 */
function checkPermissionToCommentPhotoAndEditTags()
{
    $photoid = getIdFromURL();
    $photo = \Repository\PhotoRepository::getPhotoByID($photoid);
    $activeUserID = \Repository\UserRepository::getIdByUsername($_SESSION['username']);
    $gallery = \Repository\GalleryRepository::getByID($photo['galleryid']);
    $galleryCreatorID = $gallery['userid'];
    if ($activeUserID != $galleryCreatorID) {
        if (\Repository\FriendRepository::isFriend($activeUserID, $galleryCreatorID) == null || \Repository\ResctrictionRepository::isBlocked($galleryCreatorID, $activeUserID) != null) {
            return false;
        }
    }
    return true;
}
示例#2
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);
 }
示例#3
0
 public function setUserBackground()
 {
     $id = getIdFromURL();
     checkUnauthorizedAccess();
     $photo = PhotoRepository::getPhotoByID($id);
     $galleryID = PhotoRepository::getGalleryID($id);
     $gallery = GalleryRepository::getByID($galleryID);
     $background = $gallery['title'] . '/' . $photo['image'];
     $userid = UserRepository::getIdByUsername($_SESSION['username']);
     try {
         UserRepository::setBackground($background, $userid);
         redirect(\route\Route::get("viewPhoto")->generate(array("id" => $photo['photoid'])));
     } catch (\PDOException $e) {
         $e->getMessage();
     }
 }
示例#4
0
 public function action()
 {
     $photoID = getParamFromURL("id");
     $filter = getParamFromURL("filter");
     $photo = PhotoRepository::getPhotoByID($photoID);
     $path = substr($photo['path'], 12);
     $im = null;
     $imageType = null;
     if (endsWith($photo['image'], ".jpeg") || endsWith($photo['image'], ".jpg")) {
         $im = imagecreatefromjpeg($path);
         $imageType = "jpeg";
     } else {
         if (endsWith($photo['image'], ".png")) {
             $im = imagecreatefrompng($path);
             $imageType = "png";
         }
     }
     if ($filter === "blackwhite") {
         BlackWhite::filter($im);
     } else {
         if ($filter === "brightness") {
             $brightness = post('number');
             Brightness::setBrightness($brightness);
             Brightness::filter($im);
         } else {
             if ($filter === "sepia") {
                 Sepia::filter($im);
             } else {
                 if ($filter === "blur") {
                     Blur::filter($im);
                 }
             }
         }
     }
     header('Content-Type: image/' . $imageType);
     if ($imageType === "jpeg") {
         imagejpeg($im);
         imagejpeg($im, $path);
     } else {
         imagepng($im);
     }
     imagedestroy($im);
     redirect(Route::get("viewPhoto")->generate(array("id" => $photo['photoid'])));
 }