상속: implements Gedmo\Translatable\Translatable, use trait Ojs\CoreBundle\Entity\GenericEntityTrait
 public function importBoardMember($oldUserId, $seq, $newBoardId)
 {
     $user = $this->ui->importUser($oldUserId);
     $board = $this->em->getReference('OjsJournalBundle:Board', $newBoardId);
     $member = new BoardMember();
     $member->setUser($user)->setBoard($board)->setSeq($seq);
     return $member;
 }
예제 #2
0
 /**
  *  add posted user id  as board member with given board id
  * @param  Request          $req
  * @param  int              $boardId
  * @return RedirectResponse
  */
 public function addMemberAction(Request $req, $boardId)
 {
     $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!");
     }
     $userId = $req->get('userid');
     $em = $this->getDoctrine()->getManager();
     $user = $em->getRepository('OjsUserBundle:User')->find($userId);
     $this->throw404IfNotFound($user);
     /** @var Board $board */
     $board = $em->getRepository('OjsJournalBundle:Board')->findOneBy(array('id' => $boardId, 'journal' => $journal));
     $seq = (int) $req->get('seq');
     $boardMember = new BoardMember();
     $boardMember->setBoard($board);
     $boardMember->setUser($user);
     $boardMember->setSeq($seq);
     $em->persist($boardMember);
     $em->flush();
     return $this->redirectToRoute('ojs_journal_board_show', ['id' => $boardId, 'journalId' => $journal->getId()]);
 }
예제 #3
0
파일: BoardController.php 프로젝트: ojs/ojs
 /**
  * @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()]);
 }