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)); }
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); }
/** * Assign submission(s) to the specified folder Id. * * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface * @throws \FA\Exception */ public function assignfolderAction() { $submissions = $this->_initBulkAction(); // Verify that folder ID is owned by user and valid. $folder_id = (int) $this->getParam('folder_id'); $folder = Folder::getRepository()->findOneBy(array('id' => $folder_id, 'user_id' => $this->user->id)); if (!$folder instanceof Folder) { throw new \FA\Exception('Folder not found!'); } foreach ($submissions as $sub) { $record = UploadFolder::getRepository()->findOneBy(array('folder_id' => $folder_id, 'upload_id' => $sub->id)); if (!$record instanceof UploadFolder) { $record = new UploadFolder(); $record->upload = $sub; $record->folder = $folder; $this->em->persist($record); } } $this->em->flush(); $this->alert('<b>Submissions assigned to folder!</b>', 'green'); return $this->redirectFromHere(array('action' => 'index', 'ids' => NULL)); }