/** * {@inheritdoc} */ public function getPhraseanetURL() { return $this->app->url('root'); }
public function testGenerateUrl() { $generator = $this->getMockBuilder('Symfony\\Component\\Routing\\Generator\\UrlGenerator')->disableOriginalConstructor()->getMock(); $app = new Application(Application::ENV_TEST); $app['url_generator'] = $generator; $ret = 'retval-' . mt_rand(); $route = 'route'; $generator->expects($this->once())->method('generate')->with($this->equalTo($route), $this->equalTo([]), $this->equalTo(UrlGenerator::ABSOLUTE_URL))->will($this->returnValue($ret)); $this->assertEquals($ret, $app->url($route)); }
public function postAuthProcess(PhraseaApplication $app, User $user) { $date = new \DateTime('+' . (int) $app['conf']->get(['registry', 'actions', 'validation-reminder-days']) . ' days'); foreach ($app['EM']->getRepository('Phraseanet:ValidationParticipant')->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) { /* @var $participant ValidationParticipant */ $validationSession = $participant->getSession(); $participantId = $participant->getUser()->getId(); $basketId = $validationSession->getBasket()->getId(); try { $token = $app['tokens']->getValidationToken($participantId, $basketId); } catch (NotFoundHttpException $e) { continue; } $app['events-manager']->trigger('__VALIDATION_REMINDER__', ['to' => $participantId, 'ssel_id' => $basketId, 'from' => $validationSession->getInitiator()->getId(), 'validate_id' => $validationSession->getId(), 'url' => $app->url('lightbox_validation', ['basket' => $basketId, 'LOG' => $token])]); $participant->setReminded(new \DateTime('now')); $app['EM']->persist($participant); } $app['EM']->flush(); $session = $app['authentication']->openAccount($user); if ($user->getLocale() != $app['locale']) { $user->setLocale($app['locale']); } $width = $height = null; if ($app['request']->cookies->has('screen')) { $data = explode('x', $app['request']->cookies->get('screen')); $width = $data[0]; $height = $data[1]; } $session->setIpAddress($app['request']->getClientIp())->setScreenHeight($height)->setScreenWidth($width); $app['EM']->persist($session); $app['EM']->flush(); return $session; }
/** * @return string */ public function get_page() { return $this->app->url('permalinks_permaview', ['sbas_id' => $this->media_subdef->get_sbas_id(), 'record_id' => $this->media_subdef->get_record_id(), 'subdef' => $this->media_subdef->get_name(), 'token' => $this->get_token()]); }
/** * Reset Email * * @param Application $app * @param Request $request * @return RedirectResponse */ public function resetEmail(PhraseaApplication $app, Request $request) { if (null === ($password = $request->request->get('form_password')) || null === ($email = $request->request->get('form_email')) || null === ($emailConfirm = $request->request->get('form_email_confirm'))) { $app->abort(400, $app->trans('Could not perform request, please contact an administrator.')); } $user = $app['authentication']->getUser(); if (!$app['auth.password-encoder']->isPasswordValid($user->getPassword(), $password, $user->getNonce())) { $app->addFlash('error', $app->trans('admin::compte-utilisateur:ftp: Le mot de passe est errone')); return $app->redirectPath('account_reset_email'); } if (!\Swift_Validate::email($email)) { $app->addFlash('error', $app->trans('forms::l\'email semble invalide')); return $app->redirectPath('account_reset_email'); } if ($email !== $emailConfirm) { $app->addFlash('error', $app->trans('forms::les emails ne correspondent pas')); return $app->redirectPath('account_reset_email'); } $date = new \DateTime('1 day'); $token = $app['tokens']->getUrlToken(\random::TYPE_EMAIL, $app['authentication']->getUser()->getId(), $date, $app['authentication']->getUser()->getEmail()); $url = $app->url('account_reset_email', ['token' => $token]); try { $receiver = Receiver::fromUser($app['authentication']->getUser()); } catch (InvalidArgumentException $e) { $app->addFlash('error', $app->trans('phraseanet::erreur: echec du serveur de mail')); return $app->redirectPath('account_reset_email'); } $mail = MailRequestEmailUpdate::create($app, $receiver, null); $mail->setButtonUrl($url); $mail->setExpiration($date); $app['notification.deliverer']->deliver($mail); $app->addFlash('info', $app->trans('admin::compte-utilisateur un email de confirmation vient de vous etre envoye. Veuillez suivre les instructions contenue pour continuer')); return $app->redirectPath('account'); }
public function postAuthProcess(PhraseaApplication $app, User $user) { $date = new \DateTime('+' . (int) $app['conf']->get(['registry', 'actions', 'validation-reminder-days']) . ' days'); foreach ($app['repo.validation-participants']->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) { /* @var $participant ValidationParticipant */ $validationSession = $participant->getSession(); $basket = $validationSession->getBasket(); if (null === ($token = $app['repo.tokens']->findValidationToken($basket, $participant->getUser()))) { continue; } $url = $app->url('lightbox_validation', ['basket' => $basket->getId(), 'LOG' => $token->getValue()]); $app['dispatcher']->dispatch(PhraseaEvents::VALIDATION_REMINDER, new ValidationEvent($participant, $basket, $url)); $participant->setReminded(new \DateTime('now')); $app['EM']->persist($participant); } $app['EM']->flush(); $session = $app['authentication']->openAccount($user); if ($user->getLocale() != $app['locale']) { $user->setLocale($app['locale']); } $width = $height = null; if ($app['request']->cookies->has('screen')) { $data = explode('x', $app['request']->cookies->get('screen')); $width = $data[0]; $height = $data[1]; } $session->setIpAddress($app['request']->getClientIp())->setScreenHeight($height)->setScreenWidth($width); $app['EM']->persist($session); $app['EM']->flush(); return $session; }