/** * article view event log * @param Request $request * @param $article */ private function articleViewLog(Request $request, Article $article) { $entity = new ArticleEventLog(); $em = $this->getDoctrine()->getManager(); $entity->setArticleId($article->getId()); $entity->setEventInfo(ArticleEventLogParams::$ARTICLE_VIEW); $entity->setIp($request->getClientIp()); $em->persist($entity); $em->flush(); }
/** * Creates a form to edit a ArticleFile entity. * @param ArticleFile $entity The entity * @param Journal $journal * @param Article $article * @return Form The form */ private function createEditForm(ArticleFile $entity, Journal $journal, Article $article) { $form = $this->createForm(new ArticleFileType(), $entity, ['action' => $this->generateUrl('ojs_journal_article_file_update', ['id' => $entity->getId(), 'journalId' => $journal->getId(), 'articleId' => $article->getId()]), 'method' => 'PUT']); return $form; }
/** * @param Article $article * @return ArticleFile[] */ public function getFullTextFiles(Article $article) { /** @var ArticleFileRepository $repo */ $repo = $this->em->getRepository('OjsJournalBundle:ArticleFile'); $files = $repo->getArticleFullTextFiles($article->getId()); return $files; }
/** * Deletes a ArticleFile entity. * * @param Request $request * @param ArticleFile $articleFile * @param Article $article * @return RedirectResponse */ public function deleteAction(Request $request, ArticleFile $articleFile, Article $article) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); $em = $this->getDoctrine()->getManager(); if (!$this->isGranted('EDIT', $journal, 'articles')) { throw new AccessDeniedException("You not authorized for this page!"); } if ($articleFile->getArticle() !== $article) { $this->throw404IfNotFound($articleFile); } $csrf = $this->get('security.csrf.token_manager'); $token = $csrf->getToken('ojs_journal_article_file' . $articleFile->getId()); if ($token != $request->get('_token')) { throw new TokenNotFoundException("Token Not Found!"); } $em->remove($articleFile); $em->flush(); $this->successFlashBag('successful.remove'); return $this->redirectToRoute('ojs_journal_article_file_index', ['articleId' => $article->getId(), 'journalId' => $journal->getId()]); }
public function articleIdAction(Article $article) { return $this->redirectToRoute('ojs_article_page', ['slug' => $article->getJournal()->getSlug(), 'article_id' => $article->getId(), 'issue_id' => $article->getIssue()->getId()]); }
/** * Deletes an article entity * * @param Request $request * @param Article $article * @return RedirectResponse */ public function deleteAction(Request $request, Article $article) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); $em = $this->getDoctrine()->getManager(); if (!$this->isGranted('EDIT', $journal, 'articles')) { throw new AccessDeniedException("You not authorized for this page!"); } /** @var $dispatcher EventDispatcherInterface */ $dispatcher = $this->get('event_dispatcher'); $csrf = $this->get('security.csrf.token_manager'); $token = $csrf->getToken('ojs_journal_article' . $article->getId()); if ($token != $request->get('_token')) { throw new TokenNotFoundException("Token Not Found!"); } $event = new JournalItemEvent($article); $dispatcher->dispatch(ArticleEvents::PRE_DELETE, $event); /** @var Article $article */ $article = $event->getItem(); $article->getCitations()->clear(); $article->getLanguages()->clear(); $this->get('ojs_core.delete.service')->check($event->getItem()); $em->remove($event->getItem()); $em->flush(); $this->successFlashBag('successful.remove'); $event = new JournalEvent($journal); $dispatcher->dispatch(ArticleEvents::POST_DELETE, $event); if ($event->getResponse()) { return $event->getResponse(); } return $this->redirectToRoute('ojs_journal_article_index', ['journalId' => $journal->getId()]); }
/** * * @return integer */ public function getArticleId() { return $this->article ? $this->article->getId() : false; }
/** * Deletes an article entity * * @param Request $request * @param Article $article * @return RedirectResponse */ public function deleteAction(Request $request, Article $article) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); $em = $this->getDoctrine()->getManager(); if (!$this->isGranted('EDIT', $journal, 'articles')) { throw new AccessDeniedException("You not authorized for this page!"); } /** @var $dispatcher EventDispatcherInterface */ $dispatcher = $this->get('event_dispatcher'); $csrf = $this->get('security.csrf.token_manager'); $token = $csrf->getToken('ojs_journal_article' . $article->getId()); if ($token != $request->get('_token')) { throw new TokenNotFoundException("Token Not Found!"); } $em->remove($article); $em->flush(); $this->successFlashBag('successful.remove'); $event = new JournalEvent($request, $journal, $this->getUser(), 'delete'); $dispatcher->dispatch(JournalMailEvents::JOURNAL_ARTICLE_CHANGE, $event); return $this->redirect($this->generateUrl('ojs_journal_article_index', ['journalId' => $journal->getId()])); }