Exemplo n.º 1
0
 /**
  * Gets asccessible image QueryBuilder
  * @param Album $album
  * @param type $user
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function getAccessibleImagesBuilder(Album $album, $user = null)
 {
     $qb = $this->createQueryBuilder('i')->where('i.album = :album')->setParameter('album', $album->getId())->orderBy('i.takenAt', 'asc')->addOrderBy('i.uploadedAt', 'asc');
     if (!$user) {
         $qb->andWhere('i.private = false');
     }
     return $qb;
 }
Exemplo n.º 2
0
 /**
  * Gets Album images Tags using filters
  * @param integer $year
  * @param array $use_tags
  * @param UserInterface $user
  * @return array
  */
 public function getFilteredAlbumImagesTags(Album $album, $user, array $filters)
 {
     $qb = $this->createQueryBuilder('t')->select('t')->innerJoin('t.images', 'i')->groupBy('t.name')->orderBy('t.name');
     $qb->andWhere('i.album = :album')->setParameter('album', $album->getId());
     if (is_numeric($filters['year'])) {
         $qb->andWhere($qb->expr()->eq('i.year', $filters['year']));
     }
     if (!$user instanceof UserInterface) {
         $qb->andWhere('i.private = false');
     }
     return $qb->getQuery()->execute();
 }
Exemplo n.º 3
0
 /**
  * @Route("/{slug}/upload", name="album.upload")
  * @Template
  * @Secure(roles="ROLE_USER")
  *
  * @param Album $album
  *
  * @throws AccessDeniedException
  * @return array|\Symfony\Component\HttpFoundation\Response
  */
 public function uploadAction(Album $album)
 {
     if (!$album->getUser()->equals($this->getUser())) {
         throw new AccessDeniedException();
     }
     $image = new Image();
     $image->setAlbum($album);
     $image->setUser($this->getUser());
     $form = $this->createForm(new Forms\ImageType(), $image);
     if ($this->getRequest()->isMethod('POST')) {
         $form->submit($this->getRequest());
         if ($form->isValid()) {
             /** @var UploadManager $manager */
             $manager = $this->get('gallery.upload_manager');
             return $manager->save($image);
         }
         return new Response('', 500);
     }
     return array('form' => $form->createView(), 'album' => $album);
 }
 protected function addResult(Album $album, $dir)
 {
     $new_dirname = preg_replace("#\\/" . $album->getSlug() . "\$#", "/" . $album->getId(), $dir->getRealpath());
     $this->result[] = array('old' => $dir->getRealpath(), 'new' => $new_dirname);
 }