Ejemplo n.º 1
0
 public function movefolderAction()
 {
     $this->fa->readOnly();
     // Trigger a manual folder re-sort before selecting the record.
     $this->_reSort();
     $id = (int) $this->getParam('id');
     $record = Folder::getRepository()->findOneBy(array('id' => $id, 'user_id' => $this->user->id));
     if (!$record instanceof Folder) {
         throw new \FA\Exception('Folder ID not found!');
     }
     $this->_moveEntity($record, $this->getParam('direction'));
     $this->alert('<b>Folder moved!</b>', 'green');
     return $this->redirectFromHere(array('action' => 'index', 'id' => NULL, 'direction' => NULL));
 }
Ejemplo n.º 2
0
 public function indexAction()
 {
     $this->view->scraps_mode = $this->scraps_mode;
     $rating_query = '(true = true)';
     $rating_cache = '';
     if ($this->fa->canSeeArt('adult')) {
         $rating_cache = 'gma';
     } elseif ($this->fa->canSeeArt('mature')) {
         $rating_query = '(up.rating = ' . Upload::RATING_GENERAL . ' OR up.rating = ' . Upload::RATING_MATURE . ')';
         $rating_cache = 'gm-';
     } else {
         $rating_query = '(up.rating = ' . Upload::RATING_GENERAL . ')';
         $rating_cache = 'g--';
     }
     $folder_id = (int) $this->getParam('folder');
     if ($folder_id) {
         $folder = Folder::getRepository()->findOneBy(array('user_id' => $this->owner->id, 'id' => $folder_id));
         if (!$folder instanceof Folder) {
             throw new \FA\Exception('Folder not found!');
         }
         $this->view->folder = $folder;
         $query = $this->em->createQuery('SELECT up FROM Entity\\Upload up WHERE up.user_id = :user_id AND ' . $rating_query . ' AND up.id IN (SELECT uf.upload_id FROM Entity\\UploadFolder uf WHERE uf.folder_id = :folder_id) ORDER BY up.id DESC')->setParameter('user_id', $this->owner->id)->setParameter('folder_id', $folder_id);
     } else {
         $query = $this->em->createQuery('SELECT up FROM Entity\\Upload up WHERE up.user_id = :user_id AND ' . $rating_query . ' AND up.is_scrap = :is_scrap ORDER BY up.id DESC')->setParameter('user_id', $this->owner->id)->setParameter('is_scrap', $this->scraps_mode);
     }
     $perpage = $this->user->getVariable('perpage');
     $pager = new \FA\Paginator\Doctrine($query, $this->getParam('page', 1), $perpage);
     if (count($pager) > 0) {
         foreach ($pager as $row) {
             if ($row->rating == Upload::RATING_ADULT) {
                 $this->fa->setPageHasMatureContent();
             }
         }
     }
     $this->view->pager = $pager;
     // Folder List
     $this->view->folder_list = Folder::fetchSelectWithGroups($this->owner->id, FALSE);
 }
Ejemplo n.º 3
0
 /**
  * Assign submission(s) to a newly created folder.
  *
  * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
  * @throws \FA\Exception
  */
 public function createfolderAction()
 {
     $submissions = $this->_initBulkAction();
     $folder_name = trim($this->getParam('new_folder_name'));
     if (empty($folder_name)) {
         throw new \FA\Exception('No folder name provided!');
     }
     $folder = new Folder();
     $folder->user = $this->user;
     $folder->name = $folder_name;
     $folder->save();
     foreach ($submissions as $submission) {
         $subfolder = new UploadFolder();
         $subfolder->upload = $submission;
         $subfolder->folder = $folder;
         $this->em->persist($subfolder);
     }
     $this->em->flush();
     $this->alert('<b>Submissions added to a newly created folder!</b>', 'green');
     return $this->redirectFromHere(array('action' => 'index', 'ids' => NULL));
 }