public function importBoard($id, $newJournalId) { $settingsSql = "SELECT setting_value, locale FROM group_settings WHERE group_id = :id"; $settingsStatement = $this->dbalConnection->prepare($settingsSql); $settingsStatement->bindValue('id', $id); $settingsStatement->execute(); $results = $settingsStatement->fetchAll(); if (count($results) == 0) { return null; } $journal = $this->em->getReference('OjsJournalBundle:Journal', $newJournalId); $board = new Board(); $board->setJournal($journal); foreach ($results as $result) { $board->setCurrentLocale(mb_substr($result['locale'], 0, 2, 'UTF-8')); $board->setName($result['setting_value']); } return $board; }
/** * Deletes a Board entity. * * @param Request $request * @param Board $board * @return RedirectResponse */ public function deleteAction(Request $request, Board $entity) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); $eventDispatcher = $this->get('event_dispatcher'); if (!$this->isGranted('DELETE', $journal, 'boards')) { throw new AccessDeniedException("You not authorized for delete this journal's boards!"); } $em = $this->getDoctrine()->getManager(); $csrf = $this->get('security.csrf.token_manager'); $token = $csrf->getToken('ojs_journal_board' . $entity->getId()); if ($token != $request->get('_token')) { throw new TokenNotFoundException("Token Not Found!"); } $event = new JournalItemEvent($entity); $eventDispatcher->dispatch(BoardEvents::PRE_DELETE, $event); $em->remove($entity); $em->flush(); $event = new JournalEvent($journal); $eventDispatcher->dispatch(BoardEvents::POST_DELETE, $event); if ($event->getResponse()) { return $event->getResponse(); } $this->successFlashBag('successful.remove'); return $this->redirectToRoute('ojs_journal_board_index', ['journalId' => $journal->getId()]); }
/** * @return RedirectResponse */ public function otoGenerateAction(Request $request) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); if (!$this->isGranted('EDIT', $journal, 'boards')) { throw new AccessDeniedException("You not authorized for edit this journal's board!"); } $em = $this->getDoctrine()->getManager(); $translator = $this->get('translator'); $getEditorUsers = $em->getRepository(User::class)->findUsersByJournalRole(['ROLE_EDITOR', 'ROLE_CO_EDITOR', 'ROLE_SECTION_EDITOR']); usort($getEditorUsers, function ($a, $b) { return strcmp($a->getLastName(), $b->getLastName()); }); $board = new Board(); $board->setJournal($journal); foreach ($this->getParameter('locale_support') as $localeCode) { $board->setCurrentLocale($localeCode)->setName($translator->trans('board', [], null, $localeCode))->setDescription($translator->trans('board', [], null, $localeCode)); } $counter = 1; foreach ($getEditorUsers as $user) { $boardMember = new BoardMember(); $boardMember->setBoard($board)->setUser($user)->setSeq($counter); $counter = $counter + 1; $board->addBoardMember($boardMember); $em->persist($boardMember); } $em->persist($board); $em->flush(); $this->successFlashBag('successfully.created'); return $this->redirectToRoute('ojs_journal_board_index', ['journalId' => $journal->getId()]); }
/** * @param Board $board * @param User $user * @return RedirectResponse */ public function removeMemberAction(Board $board, User $user) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); if (!$this->isGranted('EDIT', $journal, 'boards')) { throw new AccessDeniedException("You not authorized for edit this journal's board!"); } $em = $this->getDoctrine()->getManager(); $boardMember = $em->getRepository('OjsJournalBundle:BoardMember')->findOneBy(array('user' => $user, 'board' => $board)); $this->throw404IfNotFound($boardMember); $em->remove($boardMember); $em->flush(); return $this->redirectToRoute('ojs_journal_board_show', ['id' => $board->getId(), 'journalId' => $journal->getId()]); }
/** * Deletes a Board entity. * * @param Request $request * @param Board $board * @return RedirectResponse */ public function deleteAction(Request $request, Board $board) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); if (!$this->isGranted('DELETE', $journal, 'boards')) { throw new AccessDeniedException("You not authorized for delete this journal's boards!"); } /** @var $dispatcher EventDispatcherInterface */ $dispatcher = $this->get('event_dispatcher'); $em = $this->getDoctrine()->getManager(); $csrf = $this->get('security.csrf.token_manager'); $token = $csrf->getToken('ojs_journal_board' . $board->getId()); if ($token != $request->get('_token')) { throw new TokenNotFoundException("Token Not Found!"); } $em->remove($board); $em->flush(); $this->successFlashBag('successful.remove'); $event = new JournalEvent($request, $journal, $this->getUser(), 'delete'); $dispatcher->dispatch(JournalEvents::JOURNAL_BOARD_CHANGE, $event); return $this->redirectToRoute('ojs_journal_board_index', ['journalId' => $journal->getId()]); }