public function newComment(UserInterface $user, PictureInterface $picture) { $scheme = $this->isHTTPS() ? 'https' : 'http'; $message = ' <html> <head> <title>Camagru new comment</title> </head> <body> <p> Hello ' . $user->getUsername() . ' !<br /><br /> Someone posted a comment on one of your picture, to view it, click on the following link:<br /> <a href="' . $scheme . '://' . $_SERVER['HTTP_HOST'] . '/show?id=' . $picture->getId() . '"> ' . $scheme . '://' . $_SERVER['HTTP_HOST'] . '/show?id=' . $picture->getId() . '</a> <br /><br /> If you did not post a picture on Camagru, ignore this email.<br /><br /> Camagru webmaster. </p> </body> </html> '; $this->send($message, 'new comment', $user); }
public function get(PictureInterface $picture, $limit = self::LIMIT, $offset = 0) { $req = $this->db->prepare(' SELECT * FROM `camagru_comment` as c, `camagru_user` as u WHERE c.userId = u.id AND c.pictureId = :pictureId ORDER BY c.id DESC LIMIT :offset, :limit '); $pictureId = $picture->getId(); $req->bindParam(':pictureId', $pictureId, \PDO::PARAM_INT); $req->bindParam(':limit', $limit, \PDO::PARAM_INT); $req->bindParam(':offset', $offset, \PDO::PARAM_INT); $req->execute(); return $this->fromArray($req->fetchAll(\PDO::FETCH_ASSOC)); }
public function delete(PictureInterface $picture) { $req = $this->db->prepare(' DELETE FROM `camagru_picture` WHERE id = ? '); $req->execute([$picture->getId()]); unlink($picture->getRealPath); }