Exemplo n.º 1
0
 /**
  * @param  Request $request
  * @return RedirectResponse|Response
  */
 public function updateJournalAction(Request $request)
 {
     $eventDispatcher = $this->get('event_dispatcher');
     $em = $this->getDoctrine()->getManager();
     $entity = $this->get('ojs.journal_service')->getSelectedJournal(false);
     $this->throw404IfNotFound($entity);
     if (!$this->isGranted('EDIT', $entity)) {
         throw new AccessDeniedException("You are not authorized for this page!");
     }
     $editForm = $this->createJournalEditForm($entity);
     $editForm->handleRequest($request);
     if ($editForm->isValid()) {
         $entity->setLanguageCodeSet($entity->getLanguages());
         $entity->addLanguage($entity->getMandatoryLang());
         $event = new JournalEvent($entity);
         $eventDispatcher->dispatch(JournalEvents::PRE_UPDATE, $event);
         $em->persist($event->getJournal());
         $em->flush();
         $event = new JournalEvent($event->getJournal());
         $eventDispatcher->dispatch(JournalEvents::POST_UPDATE, $event);
         if ($event->getResponse()) {
             return $event->getResponse();
         }
         $this->successFlashBag('successful.update');
         return $this->redirectToRoute('ojs_journal_settings_index', ['journalId' => $entity->getId()]);
     }
     return $this->render('OjsJournalBundle:Manager:journal_settings.html.twig', array('entity' => $entity, 'edit_form' => $editForm->createView()));
 }
Exemplo n.º 2
0
 /**
  * @param JournalEvent $event
  */
 public function onJournalPostUpdate(JournalEvent $event)
 {
     $mailUsers = $this->em->getRepository('OjsUserBundle:User')->findUsersByJournalRole(['ROLE_JOURNAL_MANAGER', 'ROLE_EDITOR']);
     foreach ($mailUsers as $user) {
         $this->ojsMailer->sendToUser($user, 'Journal Event : Journal Changed :' . $event->getJournal()->getTitle(), 'Journal Event : Journal Changed by -> ' . $this->user->getUsername());
     }
 }
Exemplo n.º 3
0
 /**
  * @param JournalEvent $event
  */
 public function onJournalPostUpdate(JournalEvent $event)
 {
     $getMailEvent = $this->ojsMailer->getEventByName(JournalEvents::POST_UPDATE);
     if (!$getMailEvent) {
         return;
     }
     /** @var User $user */
     foreach ($this->ojsMailer->getJournalRelatedUsers() as $user) {
         $transformParams = ['journal' => (string) $event->getJournal(), 'done.by' => $this->ojsMailer->currentUser()->getUsername(), 'receiver.username' => $user->getUsername(), 'receiver.fullName' => $user->getFullName()];
         $template = $this->ojsMailer->transformTemplate($getMailEvent->getTemplate(), $transformParams);
         $this->ojsMailer->sendToUser($user, $getMailEvent->getSubject(), $template);
     }
 }
Exemplo n.º 4
0
 /**
  * @param JournalEvent $event
  */
 public function onJournalPageChange(JournalEvent $event)
 {
     $mailUsers = $this->getJournalRelationalUsers();
     /** @var User $user */
     foreach ($mailUsers as $user) {
         $this->sendMail($user, 'Journal Event : Journal Page Change -> ' . $event->getEventType(), 'Journal Event : Journal Page Change -> ' . $event->getEventType() . ' -> by ' . $event->getUser()->getUsername());
     }
 }