/** * Lists all new Article submissions entities. * @param bool $all * @return Response */ public function indexAction($all = false) { $translator = $this->get('translator'); /** @var Journal $currentJournal */ $currentJournal = $this->get('ojs.journal_service')->getSelectedJournal(); if ($all && !$this->isGranted('VIEW', $currentJournal, 'articles') || !$all && !$this->isGranted('CREATE', $currentJournal, 'articles')) { return $this->redirect($this->generateUrl('ojs_user_index')); } $user = $this->getUser(); $source1 = new Entity('OjsJournalBundle:Article', 'submission'); $source1TableAlias = $source1->getTableAlias(); $source2 = new Entity('OjsJournalBundle:ArticleSubmissionProgress'); $source2TableAlias = $source2->getTableAlias(); if ($all) { $source1->manipulateQuery(function (QueryBuilder $qb) use($source1TableAlias, $currentJournal) { $qb->where($source1TableAlias . '.status = 0'); $qb->andWhere($source1TableAlias . '.journalId = ' . $currentJournal->getId()); return $qb; }); $source2->manipulateQuery(function (QueryBuilder $qb) use($source2TableAlias, $currentJournal) { $qb->where($source2TableAlias . '.submitted = 0'); $qb->andWhere($source2TableAlias . '.journalId = ' . $currentJournal->getId()); return $qb; }); } else { $source1->manipulateQuery(function (QueryBuilder $qb) use($source1TableAlias, $user, $currentJournal) { $qb->where($qb->expr()->andX($qb->expr()->eq($source1TableAlias . '.submitterId', $user->getId()))); $qb->andWhere($source1TableAlias . '.journalId = ' . $currentJournal->getId()); return $qb; }); $source2->manipulateQuery(function (QueryBuilder $qb) use($source2TableAlias, $user, $currentJournal) { $qb->where($source2TableAlias . '.submitted = 0'); $qb->andWhere($source2TableAlias . '.journalId = ' . $currentJournal->getId()); $qb->andWhere($source2TableAlias . '.userId = ' . $user->getId()); return $qb; }); } $gridManager = $this->get('grid.manager'); $submissionsGrid = $gridManager->createGrid('submission'); $drafts = $gridManager->createGrid('drafts'); $source1->manipulateRow(function ($row) use($translator) { $row->setField('status', $translator->trans(ArticleParams::statusText($row->getField('status')))); return $row; }); $submissionsGrid->setSource($source1); $drafts->setSource($source2); /** @var GridAction $gridAction */ $gridAction = $this->get('grid_action'); $submissionsGrid->addRowAction($gridAction->showAction('ojs_journal_article_show', ['id', 'journalId' => $currentJournal->getId()])); $submissionsGrid->addRowAction($gridAction->editAction('ojs_journal_article_edit', ['id', 'journalId' => $currentJournal->getId()])); $submissionsGrid->addRowAction($gridAction->deleteAction('ojs_journal_article_delete', ['id', 'journalId' => $currentJournal->getId()])); $rowAction = []; $actionColumn = new ActionsColumn("actions", 'actions'); $rowAction[] = $gridAction->submissionResumeAction('article_submission_resume', 'id'); $rowAction[] = $gridAction->deleteAction('article_submission_cancel', 'id'); $actionColumn->setRowActions($rowAction); $drafts->addColumn($actionColumn); $data = ['page' => 'submission', 'submissions' => $submissionsGrid, 'drafts' => $drafts, 'all' => $all]; return $gridManager->getGridManagerResponse('OjsJournalBundle:ArticleSubmission:index.html.twig', $data); }
/** * * @return string */ public function getStatusText() { return ArticleParams::statusText($this->status); }