コード例 #1
0
ファイル: UserSubscriber.php プロジェクト: necatikartal/ojs
 public function onPasswordChange(UserEvent $event)
 {
     $message = $this->mailer->createMessage()->setSubject(ojs . change_password)->setFrom($this->systemEmail)->setTo($event->getUser()->getEmail())->setBody($this->twig->render('OjsUserBundle:Mails:User/password_changed.html.twig', ['user' => $event->getUser()]))->setContentType('text/html');
     $this->mailer->send($message);
     try {
         //log as eventlog
         $eventLog = new EventLog();
         $eventLog->setEventInfo(UserEventLogParams::$PASSWORD_CHANGE);
         $eventLog->setIp($this->request->getCurrentRequest()->getClientIp());
         $eventLog->setUserId($event->getUser()->getId());
         $this->em->persist($eventLog);
         $this->em->flush();
     } catch (\Exception $e) {
     }
 }
コード例 #2
0
ファイル: LogoutListener.php プロジェクト: necatikartal/ojs
 /**
  * Creates a Response object to send upon a successful logout.
  *
  * @param Request $request
  *
  * @return Response never null
  */
 public function onLogoutSuccess(Request $request)
 {
     if ($this->tokenStorage->getToken()) {
         /* @var $user User */
         $user = $this->tokenStorage->getToken()->getUser();
         //log as eventlog
         $event = new EventLog();
         $event->setEventInfo(UserEventLogParams::$USER_LOGOUT);
         $event->setIp($request->getClientIp());
         $event->setUserId($user->getId());
         $this->em->persist($event);
         $this->em->flush();
     }
     $response = new RedirectResponse($this->router->generate('login'));
     return $response;
 }
コード例 #3
0
ファイル: UserListener.php プロジェクト: necatikartal/ojs
 /**
  * Every new user log to event log
  * @param  LifecycleEventArgs|RequestStack $args
  * @link http://docs.doctrine-project.org/en/latest/reference/events.html#postupdate-postremove-postpersist
  * @return Response                        never null
  */
 public function postPersist(LifecycleEventArgs $args)
 {
     if (php_sapi_name() != 'cli') {
         $entity = $args->getEntity();
         $entityManager = $args->getEntityManager();
         // perhaps you only want to act on some "User" entity
         if ($entity instanceof User) {
             //log as eventlog
             $event = new EventLog();
             $event->setEventInfo(UserEventLogParams::$USER_ADD);
             $event->setIp($this->request->getCurrentRequest()->getClientIp());
             $event->setUserId($entity->getId());
             $entityManager->persist($event);
             $entityManager->flush();
         }
     }
 }
コード例 #4
0
ファイル: LoginListener.php プロジェクト: necatikartal/ojs
 /**
  *
  * @param  InteractiveLoginEvent $event
  * @return void
  */
 public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
 {
     $request = $event->getRequest();
     $token = $event->getAuthenticationToken();
     if ($token && $token->getUser() instanceof User) {
         /* @var $user User */
         // save last login
         $user = $token->getUser();
         $user->setLastlogin(new \DateTime());
         $this->em->persist($user);
         //log as eventlog
         $event = new EventLog();
         $event->setEventInfo(UserEventLogParams::$USER_LOGIN);
         $event->setIp($request->getClientIp());
         $event->setUserId($user->getId());
         $this->em->persist($event);
         $this->em->flush();
     }
 }
コード例 #5
0
ファイル: ProxyListener.php プロジェクト: necatikartal/ojs
 /**
  * Proxy drop event event log function.
  * @param  LifecycleEventArgs $args
  * @return null
  */
 public function preRemove(LifecycleEventArgs $args)
 {
     if (php_sapi_name() != 'cli') {
         $entity = $args->getEntity();
         $entityManager = $args->getEntityManager();
         /**
          * perhaps you only want to act on some "Proxy" entity
          * @link http://docs.doctrine-project.org/en/latest/reference/events.html#listening-and-subscribing-to-lifecycle-events
          */
         if ($entity instanceof Proxy) {
             //log as eventlog
             $event = new EventLog();
             $event->setEventInfo(ProxyEventLogParams::$PROXY_DROP);
             $event->setIp($this->request->getCurrentRequest()->getClientIp());
             $event->setAffectedUserId($entity->getProxyUserId());
             $event->setUserId($entity->getClientUserId());
             $entityManager->persist($event);
             $entityManager->flush();
         }
     }
 }
コード例 #6
0
ファイル: ArticleListener.php プロジェクト: necatikartal/ojs
 /**
  * Article remove event event log function.
  * @param  LifecycleEventArgs $args
  * @return null
  */
 public function preRemove(LifecycleEventArgs $args)
 {
     if (php_sapi_name() != 'cli') {
         $entity = $args->getEntity();
         $entityManager = $args->getEntityManager();
         /* @var $user User */
         $user = $this->tokenStorage->getToken()->getUser();
         /**
          * perhaps you only want to act on some "Article" entity
          * @link http://docs.doctrine-project.org/en/latest/reference/events.html#listening-and-subscribing-to-lifecycle-events
          */
         if ($entity instanceof Article) {
             //log as eventlog
             $event = new EventLog();
             $event->setEventInfo(ArticleEventLogParams::$ARTICLE_REMOVE);
             $event->setIp($this->request->getCurrentRequest()->getClientIp());
             $event->setUserId($user->getId());
             $event->setAffectedUserId($entity->getSubmitterId());
             $entityManager->persist($event);
             $entityManager->flush();
         }
     }
 }