Author: Xavier De Cock (xdecock@gmail.com)
Ejemplo n.º 1
0
 /**
  * Reset Email
  *
  * @param  Request $request
  * @return RedirectResponse
  */
 public function resetEmail(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'))) {
         throw new BadRequestHttpException($this->app->trans('Could not perform request, please contact an administrator.'));
     }
     $user = $this->getAuthenticatedUser();
     if (!$this->getPasswordEncoder()->isPasswordValid($user->getPassword(), $password, $user->getNonce())) {
         $this->app->addFlash('error', $this->app->trans('admin::compte-utilisateur:ftp: Le mot de passe est errone'));
         return $this->app->redirectPath('account_reset_email');
     }
     if (!\Swift_Validate::email($email)) {
         $this->app->addFlash('error', $this->app->trans('forms::l\'email semble invalide'));
         return $this->app->redirectPath('account_reset_email');
     }
     if ($email !== $emailConfirm) {
         $this->app->addFlash('error', $this->app->trans('forms::les emails ne correspondent pas'));
         return $this->app->redirectPath('account_reset_email');
     }
     $token = $this->getTokenManipulator()->createResetEmailToken($user, $email);
     $url = $this->app->url('account_reset_email', ['token' => $token->getValue()]);
     try {
         $receiver = Receiver::fromUser($user);
     } catch (InvalidArgumentException $e) {
         $this->app->addFlash('error', $this->app->trans('phraseanet::erreur: echec du serveur de mail'));
         return $this->app->redirectPath('account_reset_email');
     }
     $mail = MailRequestEmailUpdate::create($this->app, $receiver, null);
     $mail->setButtonUrl($url);
     $mail->setExpiration($token->getExpiration());
     $this->deliver($mail);
     $this->app->addFlash('info', $this->app->trans('admin::compte-utilisateur un email de confirmation vient de vous etre envoye. Veuillez suivre les instructions contenue pour continuer'));
     return $this->app->redirectPath('account');
 }
Ejemplo n.º 2
0
 /**
  * Checks if an email matches the current grammars
  * @param string $email
  */
 public static function email($email)
 {
     if (self::$grammar === null) {
         self::$grammar = Swift_DependencyContainer::getInstance()->lookup('mime.grammar');
     }
     return preg_match('/^' . self::$grammar->getDefinition('addr-spec') . '$/D', $email);
 }
Ejemplo n.º 3
0
 static function sendemail($to, $subject, $message2, $ar = array())
 {
     include WRA_Path . '/modules/swiftmailer/swift_required.php';
     WRA::debug($to);
     // die();
     if (!Swift_Validate::email($to)) {
         //if email is not valid
         //do something, skip them or log them
         WRA::debug("invalid email");
         WRA::debug($to);
         die;
     }
     $message = Swift_Message::newInstance()->setSubject($subject)->setFrom(WRA_CONF::$smtpfrom)->setTo(array($to))->setBody($message2, 'text/html', 'utf-8');
     for ($i = 0; $i < count($ar); $i++) {
     }
     $transporter = Swift_SmtpTransport::newInstance(WRA_CONF::$smtpserver, WRA_CONF::$smtpport, '')->setUsername(WRA_CONF::$smtpuser)->setPassword(WRA_CONF::$smtppassword);
     $mailer = Swift_Mailer::newInstance($transporter);
     try {
         $result = $mailer->send($message);
     } catch (Exception $e) {
         WRA::logit($e->getMessage(), 'message');
         // echo   $e->getMessage(), "\n";
     }
     return $result;
 }
Ejemplo n.º 4
0
 public function create_newuser()
 {
     $email = $this->request->get('value');
     if (!\Swift_Validate::email($email)) {
         throw new \Exception_InvalidArgument('Invalid mail address');
     }
     if (null === ($createdUser = $this->app['repo.users']->findByEmail($email))) {
         $sendCredentials = !!$this->request->get('send_credentials', false);
         $validateMail = !!$this->request->get('validate_mail', false);
         $createdUser = $this->app['manipulator.user']->createUser($email, $this->app['random.medium']->generateString(128), $email);
         $receiver = null;
         try {
             $receiver = Receiver::fromUser($createdUser);
         } catch (InvalidArgumentException $e) {
         }
         if ($sendCredentials && $receiver) {
             $urlToken = $this->app['manipulator.token']->createResetPasswordToken($createdUser);
             $url = $this->app->url('login_renew_password', ['token' => $urlToken->getValue()]);
             $mail = MailRequestPasswordSetup::create($this->app, $receiver, null, '', $url);
             $mail->setLogin($createdUser->getLogin());
             $this->app['notification.deliverer']->deliver($mail);
         }
         if ($validateMail && $receiver) {
             $createdUser->setMailLocked(true);
             $token = $this->app['manipulator.token']->createAccountUnlockToken($createdUser);
             $url = $this->app->url('login_register_confirm', ['code' => $token]);
             $mail = MailRequestEmailConfirmation::create($this->app, $receiver, null, '', $url, $token->getExpiration());
             $this->app['notification.deliverer']->deliver($mail);
         }
     }
     $this->usr_id = $createdUser->getId();
     return $createdUser;
 }
Ejemplo n.º 5
0
 public function __construct($name, $email)
 {
     if (!\Swift_Validate::email($email)) {
         throw new InvalidArgumentException(sprintf('Invalid e-mail address (%s)', $email));
     }
     $this->name = $name;
     $this->email = $email;
 }
 public function validate($value, Constraint $constraint)
 {
     if (!$constraint instanceof EmailEntity) {
         throw new \InvalidArgumentException('Given constraint must ne instance of EmailEntity class');
     }
     if ($value) {
         if (!\Swift_Validate::email($value)) {
             $this->context->addViolation($constraint->message, array('%string%' => $value));
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Prepare environment for test
  */
 protected function setUp()
 {
     $this->httpClient = static::createClient();
     $this->container = $this->httpClient->getContainer();
     if (!$this->storageApiToken) {
         $this->storageApiToken = TEST_ORCHESTRATOR_SAPI_TOKEN;
     }
     $this->setupStorageApi();
     $message = 'Testing token description must contains same email as TEST_ERROR_NOTIFICATION_EMAIL_1';
     if (!\Swift_Validate::email($this->token->getDescription())) {
         throw new \Exception($message);
     }
     if ($this->token->getDescription() !== TEST_ERROR_NOTIFICATION_EMAIL_1) {
         throw new \Exception($message);
     }
     $this->deleteTestEnvironments();
 }
Ejemplo n.º 8
0
 /**
  * Test a mail address
  *
  * @param  Application      $app
  * @param  Request          $request
  * @return RedirectResponse
  */
 public function sendMail(Application $app, Request $request)
 {
     if (null === ($mail = $request->request->get('email'))) {
         $app->abort(400, 'Bad request missing email parameter');
     }
     if (!\Swift_Validate::email($request->request->get('email'))) {
         $app->abort(400, 'Bad request missing email parameter');
     }
     try {
         $receiver = new Receiver(null, $mail);
     } catch (InvalidArgumentException $e) {
         return $app->redirectPath('admin_dashbord', ['email' => 'not-sent']);
     }
     $mail = MailTest::create($app, $receiver);
     $app['notification.deliverer']->deliver($mail);
     $app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']);
     return $app->redirectPath('admin_dashbord', ['email' => 'sent']);
 }
Ejemplo n.º 9
0
 /**
  * Test a mail address
  *
  * @param  Request $request
  * @return RedirectResponse
  */
 public function sendMail(Request $request)
 {
     if (null === ($mail = $request->request->get('email'))) {
         $this->app->abort(400, 'Bad request missing email parameter');
     }
     if (!\Swift_Validate::email($mail)) {
         $this->app->abort(400, 'Bad request missing email parameter');
     }
     try {
         $receiver = new Receiver(null, $mail);
     } catch (InvalidArgumentException $e) {
         return $this->app->redirectPath('admin_dashboard', ['email' => 'not-sent']);
     }
     $mail = MailTest::create($this->app, $receiver);
     $this->deliver($mail);
     /** @var \Swift_SpoolTransport $spoolTransport */
     $spoolTransport = $this->app['swiftmailer.spooltransport'];
     /** @var \Swift_Transport $transport */
     $transport = $this->app['swiftmailer.transport'];
     $spoolTransport->getSpool()->flushQueue($transport);
     return $this->app->redirectPath('admin_dashboard', ['email' => 'sent']);
 }
Ejemplo n.º 10
0
 public function action_signup()
 {
     if ($this->request->method != 'POST') {
         throw new HttpException('Method Not Allowed', 405, null, 'Method Not Allowed');
     }
     $email = $this->request->post('email');
     if (!$email || !\Swift_Validate::email($email)) {
         $this->jsonResponse(['error' => 1, 'message' => 'Пожалуйста укажите корректный адрес email.']);
         return;
     }
     /** @var NewsletterSignup $subscription */
     $subscription = $this->model->where('email', $email)->find();
     if (!$subscription->loaded()) {
         $subscription = $this->model->create($email);
     }
     if ($subscription->loaded()) {
         $this->sendSubscribeEmail($subscription);
         $this->jsonResponse(['success' => 1, 'message' => 'Благодарим за подписку!']);
     } else {
         $this->jsonResponse(['error' => 1, 'message' => 'Произошла ошибка.']);
     }
 }
Ejemplo n.º 11
0
 public function create_newuser()
 {
     $email = $this->request->get('value');
     if (!\Swift_Validate::email($email)) {
         throw new \Exception_InvalidArgument('Invalid mail address');
     }
     if (null === ($createdUser = $this->app['manipulator.user']->getRepository()->findByEmail($email))) {
         $sendCredentials = !!$this->request->get('send_credentials', false);
         $validateMail = !!$this->request->get('validate_mail', false);
         $createdUser = $this->app['manipulator.user']->createUser($email, \random::generatePassword(16), $email);
         $receiver = null;
         try {
             $receiver = Receiver::fromUser($createdUser);
         } catch (InvalidArgumentException $e) {
         }
         if ($sendCredentials) {
             $urlToken = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->getId());
             if ($receiver && false !== $urlToken) {
                 $url = $this->app->url('login_renew_password', ['token' => $urlToken]);
                 $mail = MailRequestPasswordSetup::create($this->app, $receiver, null, '', $url);
                 $mail->setLogin($createdUser->getLogin());
                 $this->app['notification.deliverer']->deliver($mail);
             }
         }
         if ($validateMail) {
             $createdUser->setMailLocked(true);
             if ($receiver) {
                 $expire = new \DateTime('+3 days');
                 $token = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->getId(), $expire, $createdUser->getEmail());
                 $url = $this->app->url('login_register_confirm', ['code' => $token]);
                 $mail = MailRequestEmailConfirmation::create($this->app, $receiver, null, '', $url, $expire);
                 $this->app['notification.deliverer']->deliver($mail);
             }
         }
     }
     $this->usr_id = $createdUser->getId();
     return $createdUser;
 }
Ejemplo n.º 12
0
 /**
  * Takes a comma-separated list of emails (or an array of email addresses)
  * and parses them all into a single array of validated emails.
  *
  * @param string|array $buffer
  *
  * @return array
  */
 public static function normalizeEmailAddresses($buffer)
 {
     if (!is_array($buffer)) {
         $buffer = explode(',', str_ireplace("\n", ',', $buffer));
     }
     $emails = [];
     foreach ($buffer as $key => $value) {
         $value = explode(',', str_ireplace("\n", ',', $value));
         foreach ($value as $possible_email) {
             $possible_email = trim($possible_email);
             if (empty($possible_email) || !filter_var($possible_email, FILTER_VALIDATE_EMAIL)) {
                 continue;
             }
             $emails[] = $possible_email;
         }
     }
     foreach ($emails as $key => $value) {
         if (!\Swift_Validate::email($value)) {
             unset($emails[$key]);
         }
     }
     return $emails;
 }
Ejemplo n.º 13
0
 /**
  * Sets email for a user.
  *
  * @param User   $user
  * @param string $email
  *
  * @throws InvalidArgumentException if email is not valid or already exists.
  * @throws RuntimeException         if email already exists.
  */
 private function doSetEmail(User $user, $email)
 {
     if (null !== $email && false === (bool) \Swift_Validate::email($email)) {
         throw new InvalidArgumentException(sprintf('Email %s is not legal.', $email));
     }
     if (null !== $this->getRepository()->findByEmail($email)) {
         throw new RuntimeException(sprintf('User with email %s already exists.', $email));
     }
     $user->setEmail($email);
 }
Ejemplo n.º 14
0
 /**
  * Checks if an e-mail address is valid
  *
  * @param string $email Email address to be validated
  * @return bool True if the mail address is valid, false otherwise
  */
 public function validateMailAddress($email)
 {
     return \Swift_Validate::email($this->convertEmail($email));
 }
Ejemplo n.º 15
0
 static function validateAddress($email)
 {
     require_once 'include/swiftmailer/swift_required.php';
     return Swift_Validate::email($email);
 }
Ejemplo n.º 16
0
 public function addUserAction(Request $request)
 {
     $result = ['success' => false, 'message' => '', 'user' => null];
     try {
         if (!$this->getAclForUser($this->getAuthenticatedUser())->has_right('manageusers')) {
             throw new ControllerException($this->app->trans('You are not allowed to add users'));
         }
         if (!$request->request->get('firstname')) {
             throw new ControllerException($this->app->trans('First name is required'));
         }
         if (!$request->request->get('lastname')) {
             throw new ControllerException($this->app->trans('Last name is required'));
         }
         if (!$request->request->get('email')) {
             throw new ControllerException($this->app->trans('Email is required'));
         }
         if (!\Swift_Validate::email($request->request->get('email'))) {
             throw new ControllerException($this->app->trans('Email is invalid'));
         }
     } catch (ControllerException $e) {
         $result['message'] = $e->getMessage();
         return $this->app->json($result);
     }
     $user = null;
     $email = $request->request->get('email');
     if (null !== ($user = $this->getUserRepository()->findByEmail($email))) {
         $result['message'] = $this->app->trans('User already exists');
         $result['success'] = true;
         $result['user'] = $this->formatUser($user);
         return $this->app->json($result);
     }
     try {
         $password = $this->getRandomGenerator()->generateString(128);
         $user = $this->getUserManipulator()->createUser($email, $password, $email);
         $user->setFirstName($request->request->get('firstname'))->setLastName($request->request->get('lastname'));
         if ($request->request->get('company')) {
             $user->setCompany($request->request->get('company'));
         }
         if ($request->request->get('job')) {
             $user->setCompany($request->request->get('job'));
         }
         if ($request->request->get('form_geonameid')) {
             $this->getUserManipulator()->setGeonameId($user, $request->request->get('form_geonameid'));
         }
         $result['message'] = $this->app->trans('User successfully created');
         $result['success'] = true;
         $result['user'] = $this->formatUser($user);
     } catch (\Exception $e) {
         $result['message'] = $this->app->trans('Error while creating user');
     }
     return $this->app->json($result);
 }
Ejemplo n.º 17
0
<?php

/**
 * 400-validate.php
 */
require_once '../vendor/autoload.php';
require_once './config.php';
$recipients = ['*****@*****.**', '*****@*****.**', '"ok."@example.com'];
foreach ($recipients as $recipient) {
    if (Swift_Validate::email($recipient)) {
        echo $recipient . " is OK\n";
    } else {
        echo $recipient . " is BAD\n";
    }
}
Ejemplo n.º 18
0
 /**
  * Comprueba la validez sintáctica de un email
  * Devuelve true o false
  *
  * @param string $email El correo electrónico
  * @return boolean
  */
 public function compruebaEmail($email)
 {
     $ok = Swift_Validate::email($email);
     if (!$ok) {
         $this->mensaje[] = "La direccion email indicada no es valida";
     }
     return count($this->mensaje) == 0;
 }
Ejemplo n.º 19
0
 public function connect(Application $app)
 {
     $app['controller.prod.push'] = $this;
     $controllers = $app['controllers_factory'];
     $app['firewall']->addMandatoryAuthentication($controllers);
     $controllers->before(function (Request $request) use($app) {
         $app['firewall']->requireRight('push');
     });
     $userFormatter = $this->getUserFormatter($app);
     $listFormatter = $this->getListFormatter($app);
     $userSelection = $this->getUsersInSelectionExtractor();
     $controllers->post('/sendform/', function (Application $app) use($userSelection) {
         $push = new RecordHelper\Push($app, $app['request']);
         $repository = $app['repo.usr-lists'];
         $RecommendedUsers = $userSelection($push->get_elements());
         $params = ['push' => $push, 'message' => '', 'lists' => $repository->findUserLists($app['authentication']->getUser()), 'context' => 'Push', 'RecommendedUsers' => $RecommendedUsers];
         return $app['twig']->render('prod/actions/Push.html.twig', $params);
     });
     $controllers->post('/validateform/', function (Application $app) use($userSelection) {
         $push = new RecordHelper\Push($app, $app['request']);
         $repository = $app['repo.usr-lists'];
         $RecommendedUsers = $userSelection($push->get_elements());
         $params = ['push' => $push, 'message' => '', 'lists' => $repository->findUserLists($app['authentication']->getUser()), 'context' => 'Feedback', 'RecommendedUsers' => $RecommendedUsers];
         return $app['twig']->render('prod/actions/Push.html.twig', $params);
     });
     $controllers->post('/send/', function (Application $app) {
         $request = $app['request'];
         $ret = ['success' => false, 'message' => $app->trans('Unable to send the documents')];
         try {
             $pusher = new RecordHelper\Push($app, $app['request']);
             $push_name = $request->request->get('name', $app->trans('Push from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName()]));
             $push_description = $request->request->get('push_description');
             $receivers = $request->request->get('participants');
             if (!is_array($receivers) || count($receivers) === 0) {
                 throw new ControllerException($app->trans('No receivers specified'));
             }
             if (!is_array($pusher->get_elements()) || count($pusher->get_elements()) === 0) {
                 throw new ControllerException($app->trans('No elements to push'));
             }
             foreach ($receivers as $receiver) {
                 try {
                     $user_receiver = $app['repo.users']->find($receiver['usr_id']);
                 } catch (\Exception $e) {
                     throw new ControllerException($app->trans('Unknown user %user_id%', ['%user_id%' => $receiver['usr_id']]));
                 }
                 $Basket = new Basket();
                 $Basket->setName($push_name);
                 $Basket->setDescription($push_description);
                 $Basket->setUser($user_receiver);
                 $Basket->setPusher($app['authentication']->getUser());
                 $Basket->setIsRead(false);
                 $app['EM']->persist($Basket);
                 foreach ($pusher->get_elements() as $element) {
                     $BasketElement = new BasketElement();
                     $BasketElement->setRecord($element);
                     $BasketElement->setBasket($Basket);
                     $app['EM']->persist($BasketElement);
                     $Basket->addElement($BasketElement);
                     if ($receiver['HD']) {
                         $app['acl']->get($user_receiver)->grant_hd_on($BasketElement->getRecord($app), $app['authentication']->getUser(), \ACL::GRANT_ACTION_PUSH);
                     } else {
                         $app['acl']->get($user_receiver)->grant_preview_on($BasketElement->getRecord($app), $app['authentication']->getUser(), \ACL::GRANT_ACTION_PUSH);
                     }
                 }
                 $app['EM']->flush();
                 $arguments = ['basket' => $Basket->getId()];
                 if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) {
                     $arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $user_receiver);
                 }
                 $url = $app->url('lightbox_compare', $arguments);
                 $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
                 $app['dispatcher']->dispatch(PhraseaEvents::BASKET_PUSH, new PushEvent($Basket, $request->request->get('message'), $url, $receipt));
             }
             $app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox())->log($BasketElement->getRecord($app), \Session_Logger::EVENT_VALIDATE, $user_receiver->getId(), '');
             $app['EM']->flush();
             $message = $app->trans('%quantity_records% records have been sent to %quantity_users% users', ['%quantity_records%' => count($pusher->get_elements()), '%quantity_users%' => count($receivers)]);
             $ret = ['success' => true, 'message' => $message];
         } catch (ControllerException $e) {
             $ret['message'] = $e->getMessage() . $e->getFile() . $e->getLine();
         }
         return $app->json($ret);
     })->bind('prod_push_send');
     $controllers->post('/validate/', function (Application $app) {
         $request = $app['request'];
         $ret = ['success' => false, 'message' => $app->trans('Unable to send the documents')];
         $app['EM']->beginTransaction();
         try {
             $pusher = new RecordHelper\Push($app, $app['request']);
             $validation_name = $request->request->get('name', $app->trans('Validation from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName()]));
             $validation_description = $request->request->get('validation_description');
             $participants = $request->request->get('participants');
             if (!is_array($participants) || count($participants) === 0) {
                 throw new ControllerException($app->trans('No participants specified'));
             }
             if (!is_array($pusher->get_elements()) || count($pusher->get_elements()) === 0) {
                 throw new ControllerException($app->trans('No elements to validate'));
             }
             if ($pusher->is_basket()) {
                 $Basket = $pusher->get_original_basket();
             } else {
                 $Basket = new Basket();
                 $Basket->setName($validation_name);
                 $Basket->setDescription($validation_description);
                 $Basket->setUser($app['authentication']->getUser());
                 $Basket->setIsRead(false);
                 $app['EM']->persist($Basket);
                 foreach ($pusher->get_elements() as $element) {
                     $BasketElement = new BasketElement();
                     $BasketElement->setRecord($element);
                     $BasketElement->setBasket($Basket);
                     $app['EM']->persist($BasketElement);
                     $Basket->addElement($BasketElement);
                 }
                 $app['EM']->flush();
             }
             $app['EM']->refresh($Basket);
             if (!$Basket->getValidation()) {
                 $Validation = new ValidationSession();
                 $Validation->setInitiator($app['authentication']->getUser());
                 $Validation->setBasket($Basket);
                 $duration = (int) $request->request->get('duration');
                 if ($duration > 0) {
                     $date = new \DateTime('+' . $duration . ' day' . ($duration > 1 ? 's' : ''));
                     $Validation->setExpires($date);
                 }
                 $Basket->setValidation($Validation);
                 $app['EM']->persist($Validation);
             } else {
                 $Validation = $Basket->getValidation();
             }
             $found = false;
             foreach ($participants as $participant) {
                 if ($participant['usr_id'] === $app['authentication']->getUser()->getId()) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $participants[] = ['see_others' => 1, 'usr_id' => $app['authentication']->getUser()->getId(), 'agree' => 0, 'HD' => 0];
             }
             foreach ($participants as $key => $participant) {
                 foreach (['see_others', 'usr_id', 'agree', 'HD'] as $mandatoryParam) {
                     if (!array_key_exists($mandatoryParam, $participant)) {
                         throw new ControllerException($app->trans('Missing mandatory parameter %parameter%', ['%parameter%' => $mandatoryParam]));
                     }
                 }
                 try {
                     $participantUser = $app['repo.users']->find($participant['usr_id']);
                 } catch (\Exception $e) {
                     throw new ControllerException($app->trans('Unknown user %usr_id%', ['%usr_id%' => $participant['usr_id']]));
                 }
                 try {
                     $Validation->getParticipant($participantUser);
                     continue;
                 } catch (NotFoundHttpException $e) {
                 }
                 $validationParticipant = new ValidationParticipant();
                 $validationParticipant->setUser($participantUser);
                 $validationParticipant->setSession($Validation);
                 $validationParticipant->setCanAgree($participant['agree']);
                 $validationParticipant->setCanSeeOthers($participant['see_others']);
                 $app['EM']->persist($validationParticipant);
                 foreach ($Basket->getElements() as $BasketElement) {
                     $ValidationData = new ValidationData();
                     $ValidationData->setParticipant($validationParticipant);
                     $ValidationData->setBasketElement($BasketElement);
                     $BasketElement->addValidationData($ValidationData);
                     if ($participant['HD']) {
                         $app['acl']->get($participantUser)->grant_hd_on($BasketElement->getRecord($app), $app['authentication']->getUser(), \ACL::GRANT_ACTION_VALIDATE);
                     } else {
                         $app['acl']->get($participantUser)->grant_preview_on($BasketElement->getRecord($app), $app['authentication']->getUser(), \ACL::GRANT_ACTION_VALIDATE);
                     }
                     $app['EM']->merge($BasketElement);
                     $app['EM']->persist($ValidationData);
                     $app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox())->log($BasketElement->getRecord($app), \Session_Logger::EVENT_PUSH, $participantUser->getId(), '');
                     $validationParticipant->addData($ValidationData);
                 }
                 $validationParticipant = $app['EM']->merge($validationParticipant);
                 $app['EM']->flush();
                 $arguments = ['basket' => $Basket->getId()];
                 if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) {
                     $arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $participantUser);
                 }
                 $url = $app->url('lightbox_validation', $arguments);
                 $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
                 $app['dispatcher']->dispatch(PhraseaEvents::VALIDATION_CREATE, new ValidationEvent($validationParticipant, $Basket, $url, $request->request->get('message'), $receipt, (int) $request->request->get('duration')));
             }
             $app['EM']->merge($Basket);
             $app['EM']->merge($Validation);
             $app['EM']->flush();
             $message = $app->trans('%quantity_records% records have been sent for validation to %quantity_users% users', ['%quantity_records%' => count($pusher->get_elements()), '%quantity_users%' => count($request->request->get('participants'))]);
             $ret = ['success' => true, 'message' => $message];
             $app['EM']->commit();
         } catch (ControllerException $e) {
             $ret['message'] = $e->getMessage();
             $app['EM']->rollback();
         }
         return $app->json($ret);
     })->bind('prod_push_validate');
     $controllers->get('/user/{usr_id}/', function (Application $app, $usr_id) use($userFormatter) {
         $datas = null;
         $request = $app['request'];
         $query = new $app['phraseanet.user-query']();
         $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']);
         $query->in([$usr_id]);
         $result = $query->include_phantoms()->limit(0, 1)->execute()->get_results();
         if ($result) {
             foreach ($result as $user) {
                 $datas = $userFormatter($user);
             }
         }
         return $app->json($datas);
     })->assert('usr_id', '\\d+');
     $controllers->get('/list/{list_id}/', function (Application $app, $list_id) use($listFormatter) {
         $datas = null;
         $repository = $app['repo.usr-lists'];
         $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
         if ($list) {
             $datas = $listFormatter($list);
         }
         return $app->json($datas);
     })->bind('prod_push_lists_list')->assert('list_id', '\\d+');
     $controllers->post('/add-user/', function (Application $app, Request $request) use($userFormatter) {
         $result = ['success' => false, 'message' => '', 'user' => null];
         try {
             if (!$app['acl']->get($app['authentication']->getUser())->has_right('manageusers')) {
                 throw new ControllerException($app->trans('You are not allowed to add users'));
             }
             if (!$request->request->get('firstname')) {
                 throw new ControllerException($app->trans('First name is required'));
             }
             if (!$request->request->get('lastname')) {
                 throw new ControllerException($app->trans('Last name is required'));
             }
             if (!$request->request->get('email')) {
                 throw new ControllerException($app->trans('Email is required'));
             }
             if (!\Swift_Validate::email($request->request->get('email'))) {
                 throw new ControllerException($app->trans('Email is invalid'));
             }
         } catch (ControllerException $e) {
             $result['message'] = $e->getMessage();
             return $app->json($result);
         }
         $user = null;
         $email = $request->request->get('email');
         try {
             $user = $app['repo.users']->findByEmail($email);
             $result['message'] = $app->trans('User already exists');
             $result['success'] = true;
             $result['user'] = $userFormatter($user);
         } catch (\Exception $e) {
         }
         if (!$user instanceof User) {
             try {
                 $password = $app['random.medium']->generateString(128);
                 $user = $app['manipulator.user']->createUser($email, $password, $email);
                 $user->setFirstName($request->request->get('firstname'))->setLastName($request->request->get('lastname'));
                 if ($request->request->get('company')) {
                     $user->setCompany($request->request->get('company'));
                 }
                 if ($request->request->get('job')) {
                     $user->setCompany($request->request->get('job'));
                 }
                 if ($request->request->get('form_geonameid')) {
                     $app['manipulator.user']->setGeonameId($user, $request->request->get('form_geonameid'));
                 }
                 $result['message'] = $app->trans('User successfully created');
                 $result['success'] = true;
                 $result['user'] = $userFormatter($user);
             } catch (\Exception $e) {
                 $result['message'] = $app->trans('Error while creating user');
             }
         }
         return $app->json($result);
     })->bind('prod_push_do_add_user');
     $controllers->get('/add-user/', function (Application $app, Request $request) {
         $params = ['callback' => $request->query->get('callback')];
         return $app['twig']->render('prod/User/Add.html.twig', $params);
     })->bind('prod_push_add_user');
     $controllers->get('/search-user/', function (Application $app) use($userFormatter, $listFormatter) {
         $request = $app['request'];
         $query = $app['phraseanet.user-query'];
         $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']);
         $query->like(\User_Query::LIKE_FIRSTNAME, $request->query->get('query'))->like(\User_Query::LIKE_LASTNAME, $request->query->get('query'))->like(\User_Query::LIKE_LOGIN, $request->query->get('query'))->like_match(\User_Query::LIKE_MATCH_OR);
         $result = $query->include_phantoms()->limit(0, 50)->execute()->get_results();
         $repository = $app['repo.usr-lists'];
         $lists = $repository->findUserListLike($app['authentication']->getUser(), $request->query->get('query'));
         $datas = [];
         if ($lists) {
             foreach ($lists as $list) {
                 $datas[] = $listFormatter($list);
             }
         }
         if ($result) {
             foreach ($result as $user) {
                 $datas[] = $userFormatter($user);
             }
         }
         return $app->json($datas);
     });
     $controllers->match('/edit-list/{list_id}/', function (Application $app, Request $request, $list_id) {
         $repository = $app['repo.usr-lists'];
         $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
         $query = $app['phraseanet.user-query'];
         $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']);
         if ($request->get('query')) {
             $query->like($request->get('like_field'), $request->get('query'))->like_match(\User_Query::LIKE_MATCH_OR);
         }
         if (is_array($request->get('Activity'))) {
             $query->haveActivities($request->get('Activity'));
         }
         if (is_array($request->get('Template'))) {
             $query->haveTemplate($request->get('Template'));
         }
         if (is_array($request->get('Company'))) {
             $query->inCompanies($request->get('Company'));
         }
         if (is_array($request->get('Country'))) {
             $query->inCountries($request->get('Country'));
         }
         if (is_array($request->get('Position'))) {
             $query->havePositions($request->get('Position'));
         }
         $sort = $request->get('srt', 'usr_creationdate');
         $ord = $request->get('ord', 'desc');
         $perPage = 10;
         $offset_start = Max(((int) $request->get('page') - 1) * $perPage, 0);
         $query->sort_by($sort, $ord);
         $results = $query->include_phantoms()->limit($offset_start, $perPage)->execute()->get_results();
         $params = ['query' => $query, 'results' => $results, 'list' => $list, 'sort' => $sort, 'ord' => $ord];
         if ($request->get('type') === 'fragment') {
             return new Response($app['twig']->render('prod/actions/Feedback/ResultTable.html.twig', $params));
         } else {
             return new Response($app['twig']->render('prod/actions/Feedback/list.html.twig', $params));
         }
     })->bind('prod_push_list_edit')->assert('list_id', '\\d+');
     return $controllers;
 }
Ejemplo n.º 20
0
 private function getCredentials(InputInterface $input, OutputInterface $output, DialogHelper $dialog)
 {
     $email = $password = null;
     if (!$input->getOption('email') && !$input->getOption('password')) {
         $output->writeln("\n<info>--- Account Informations ---</info>\n");
         do {
             $email = $dialog->ask($output, 'Please provide a valid e-mail address : ');
         } while (!\Swift_Validate::email($email));
         do {
             $password = $dialog->askHiddenResponse($output, 'Please provide a password (hidden, 6 character min) : ');
         } while (strlen($password) < 6);
         $output->writeln("\n\t<info>Email / Password successfully set</info>\n");
     } elseif ($input->getOption('email') && $input->getOption('password')) {
         if (!\Swift_Validate::email($input->getOption('email'))) {
             throw new \RuntimeException('Invalid email addess');
         }
         $email = $input->getOption('email');
         $password = $input->getOption('password');
     } else {
         throw new \RuntimeException('You have to provide both email and password');
     }
     return [$email, $password];
 }
Ejemplo n.º 21
0
function popola($file, $id_associazione)
{
    $data = new Spreadsheet_Excel_Reader();
    //$data->setOutputEncoding('CP1251'); //UTF-8
    $data->setOutputEncoding('UTF-8');
    $data->read($file);
    error_reporting(E_ALL ^ E_NOTICE);
    $counter = 0;
    $counterP = 0;
    $log_error = new log();
    for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
        $counterP++;
        echo $counterP . " ";
        if ($counterP % 100 == 0) {
            echo "\n  Processati: " . $counterP . "\n";
        }
        ob_flush();
        flush();
        $query = "INSERT into soci (nome,mail) values ";
        $query .= "(";
        echo $data->sheets[0]['cells'][$i][1] . "   ... \n";
        $actual_element = trim($data->sheets[0]['cells'][$i][1], " \t\n\r\v,;");
        echo $actual_element;
        $actual_element = mysql_real_escape_string($actual_element);
        $actual_element2 = trim($data->sheets[0]['cells'][$i][2], " \t\n\r\v,;");
        $mail = mysql_real_escape_string($actual_element2);
        $query .= "'" . $actual_element . "','" . $mail . "'";
        // Aggiungi user e password
        //$query.="'".(($email=="") ? getUniqueCode(10) : $email)."','".getUniqueCode(10)."',$id_associazione";
        $query .= ")";
        //validate email
        if (!Swift_Validate::email($actual_element2)) {
            //validate email, log error
            $log_error->scrivi_popola($actual_element . "\t" . $mail);
        } else {
            //insert into DB
            $result = mysql_query("SELECT id FROM soci WHERE mail='" . $mail . "'");
            if ($riga = mysql_fetch_assoc($result)) {
                //if the mail is  already in the database
                $int_id = $riga['id'];
            } else {
                if (!mysql_query($query)) {
                    //insert new record
                    echo "ti è andata male   ";
                    echo $query;
                    return false;
                }
                $int_id = mysql_insert_id();
                $counter++;
            }
            if ($id_associazione > 0) {
                mysql_query("INSERT into interessi_soci (id_socio,id_interesse) values ('{$int_id}','{$id_associazione}')");
            }
        }
    }
    $log_error->close_popola();
    //return $data->sheets[0]['numRows']-1;
    return "<BR>Letti " . $counterP . " e inseriti (non duplicati) " . $counter;
}
 private function handlePostJobs($orchestrationId, Request $request, $async = false)
 {
     $orchestration = $this->dbOrchestrationManager->findOrchestrationById($orchestrationId, $this->token, true);
     if (!$orchestration) {
         $exception = new OrchestratorException(404, sprintf('Orchestration %s not found', $orchestrationId));
         $exception->setExceptionCode('ORCHESTRATION_NOT_FOUND');
         throw $exception;
     }
     // waiting jobs limit
     $jobsStats = $this->jobEsManager->getWaitingStats();
     // skip waiting
     if (array_key_exists($orchestration->getId(), $jobsStats) && $jobsStats[$orchestration->getId()] >= AppConfiguration::MAX_WAITING_JOBS_COUNT) {
         $count = $jobsStats[$orchestration->getId()];
         if ($count > 1) {
             $exception = new OrchestratorException(409, sprintf('Orchestration %s has %d waiting jobs. Current limit is %d.', $orchestrationId, $count, AppConfiguration::MAX_WAITING_JOBS_COUNT));
         } else {
             $exception = new OrchestratorException(409, sprintf('Orchestration %s has %d waiting job. Current limit is %d.', $orchestrationId, $count, AppConfiguration::MAX_WAITING_JOBS_COUNT));
         }
         $exception->setExceptionCode('ORCHESTRATION_VALIDATION');
         throw $exception;
     }
     // skip jobs depth
     $jobsDepth = $this->jobEsManager->getDepthFromRunId($this->storageApi->getRunId());
     if ($jobsDepth >= AppConfiguration::MAX_ORCHESTRATION_RUN_DEPTH) {
         $this->logger->info('scheduler.orchestration.skipped', array('depth' => $jobsDepth, 'limit' => AppConfiguration::MAX_ORCHESTRATION_RUN_DEPTH, 'orchestrationId' => $orchestration->getId(), 'orchestrationName' => $orchestration->getName(), 'projectId' => $this->token->getProjectId(), 'projectName' => $this->token->getOwnerName()));
         $exception = new OrchestratorException(409, sprintf('Orchestrations can be started only %d times for current id.', AppConfiguration::MAX_ORCHESTRATION_RUN_DEPTH));
         $exception->setExceptionCode('RUNTIME_VALIDATION');
         throw $exception;
     }
     try {
         $form = $this->createForm(new OrchestrationRunType($this->storageApi, $this->dbOrchestrationManager, $this->token, $orchestration));
         $handler = $this->createRunFormHandler($form, $request, $orchestration);
         if ($handler->process()) {
             if ($handler->getTaskList()) {
                 $tasks = array_map(function ($task) {
                     /** @var StorageApi\OrchestrationTask $task */
                     $task->setId($this->storageApi->generateId());
                     return $task->toApiArray();
                 }, $handler->getTaskList());
             } else {
                 $tasks = array_map(function ($task) {
                     /**
                      * @var StorageApi\OrchestrationTask $task
                      */
                     return $task->toApiArray();
                 }, $orchestration->getTasks());
             }
         }
     } catch (HttpException $e) {
         $exception = new OrchestratorException($e->getStatusCode(), $e->getMessage());
         $exception->setExceptionCode('JOB_VALIDATION');
         throw $exception;
     }
     $form = $this->createForm(new ScheduleJobType($this->storageApi, $this->dbOrchestrationManager, $this->token));
     $handler = parent::createFormHandler($form, $request);
     try {
         $notificationsEmails = array();
         if ($handler->process()) {
             $notificationsEmails = $handler->getPost('notificationsEmails', array());
         }
         if (!$notificationsEmails && \Swift_Validate::email($this->token->getDescription())) {
             $notificationsEmails = array($this->token->getDescription());
         }
     } catch (HttpException $e) {
         $exception = new OrchestratorException(400, $e->getMessage());
         $exception->setExceptionCode('JOB_VALIDATION');
         throw $exception;
     }
     $this->initSqsQueue();
     $job = new Elasticsearch\Job();
     $job->setOrchestrationId($orchestration->getId())->setConfig($orchestration->getId())->setOrchestrationName($orchestration->getName())->setToken($orchestration->getToken())->setTokenId($orchestration->getTokenId())->setTokenDesc($orchestration->getTokenDesc())->setTokenOwnerName($this->token->getOwnerName())->setProjectId($this->token->getProjectId())->setInitializedBy('manually')->setTaks($tasks)->setInitiatorTokenId($this->token->getId())->setInitiatorTokenDesc($this->token->getDescription())->setInitiatorUserAgent($this->getRequestUserAgent($request))->setNotificationsEmails($notificationsEmails);
     $job = $this->jobEsManager->saveJob($job, new StorageApi\UniqueManager($this->storageApi));
     $this->queue->enqueue($job->getId(), array('jobId' => $job->getId(), 'component' => KeboolaOrchestratorBundle::SYRUP_COMPONENT_NAME));
     // log event
     $this->logger->info(sprintf('Orchestration job %s created manually', $job->getId()));
     if ($async) {
         return $this->createJsonResponse($job->toApiArray(), 202);
     } else {
         $this->logger->debug(sprintf('Orchestration job %s created manually - sync', $job->getId()), array('orchestrationId' => $orchestration->getId(), 'orchestration' => $orchestration->getName(), 'projectId' => $this->token->getProjectId(), 'projectName' => $this->token->getOwnerName(), 'tokenId' => $this->token->getId(), 'token' => $this->token->getDescription()));
         return $this->createJsonResponse($job->toOldApiArray(), 201);
     }
 }
Ejemplo n.º 23
0
 /**
  * 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');
 }
Ejemplo n.º 24
0
 public function apply_infos()
 {
     if (count($this->users) != 1) {
         return $this;
     }
     $users = $this->users;
     $user = $this->app['repo.users']->find(array_pop($users));
     if ($user->isTemplate() || $user->isSpecial()) {
         return $this;
     }
     $infos = ['gender', 'first_name', 'last_name', 'email', 'address', 'zip', 'geonameid', 'function', 'company', 'activite', 'telephone', 'fax'];
     $parm = $this->unserializedRequestData($this->request, $infos, 'user_infos');
     if ($parm['email'] && !\Swift_Validate::email($parm['email'])) {
         throw new \Exception_InvalidArgument('Email addess is not valid');
     }
     $old_email = $user->getEmail();
     $user->setFirstName($parm['first_name'])->setLastName($parm['last_name'])->setGender((int) $parm['gender'])->setEmail($parm['email'])->setAddress($parm['address'])->setZipCode($parm['zip'])->setActivity($parm['function'])->setJob($parm['activite'])->setCompany($parm['company'])->setPhone($parm['telephone'])->setFax($parm['fax']);
     $this->app['manipulator.user']->setGeonameId($user, $parm['geonameid']);
     $new_email = $user->getEmail();
     if ($old_email != $new_email) {
         $oldReceiver = $newReceiver = null;
         try {
             $oldReceiver = new Receiver(null, $old_email);
         } catch (InvalidArgumentException $e) {
         }
         if ($oldReceiver) {
             $mailOldAddress = MailSuccessEmailUpdate::create($this->app, $oldReceiver, null, $this->app->trans('You will now receive notifications at %new_email%', ['%new_email%' => $new_email]));
             $this->deliver($mailOldAddress);
         }
         try {
             $newReceiver = new Receiver(null, $new_email);
         } catch (InvalidArgumentException $e) {
         }
         if ($newReceiver) {
             $mailNewAddress = MailSuccessEmailUpdate::create($this->app, $newReceiver, null, $this->app->trans('You will no longer receive notifications at %old_email%', ['%old_email%' => $old_email]));
             $this->deliver($mailNewAddress);
         }
     }
     return $this;
 }
Ejemplo n.º 25
0
        //set encoder
        $msg->setEncoder(Swift_Encoding::get7BitEncoding());
        $search = array(';', ',,', ',');
        $replace = array('', '', '');
        $msgok = 0;
        while ($row = mysqli_fetch_assoc($result)) {
            //per ogni riga sul db
            if ($row['mail'] != '') {
                $destinatari_raw = $row['mail'];
                //prendo l'id utente
                $id_utente = $row['id'];
                //pulitura indirizzi sostituisco gli spazi e i ";" con le ","
                //$destinatari = str_replace($search, $replace, $destinatari_raw);
                $destinatari = trim($destinatari_raw);
                //https://github.com/swiftmailer/swiftmailer/blob/master/lib/classes/Swift/Validate.php
                if (!Swift_Validate::email($destinatari)) {
                    //validate email
                    //do something, skip them
                    $log_error->scrivi_errore_invio($destinatari);
                    continue;
                }
                $msg->setTo(array($destinatari));
                //invio del messaggio
                try {
                    $ret = $mailer->send($msg);
                    if ($ret > 0) {
                        //log email correttamente inviata esito = true
                        $qry_log_mail = 'INSERT INTO tmpmail(id,indirizzo,id_utente,ora_invio,oggetto_mail,esito)
	    				VALUES (NULL,"' . $destinatari . '",' . $id_utente . ',NULL,"' . $subject . '",true)';
                        $result_log_mail_ok = mysqli_query($db, $qry_log_mail);
                        $msgok++;
Ejemplo n.º 26
0
 /**
  * @param Elasticsearch\Job $job
  * @param Orchestration $orchestration
  * @param Elasticsearch\JobManager $jobManager
  * @param KbcComponentsList $components
  */
 public function sendJobWarningMessage(Elasticsearch\Job $job, Orchestration $orchestration, Elasticsearch\JobManager $jobManager, KbcComponentsList $components)
 {
     /**
      * @var Notification[] $notifications
      */
     $notifications = array_filter($orchestration->getNotifications(), function ($row) {
         /**
          * @var Notification $row
          */
         if (!\Swift_Validate::email($row->getEmail())) {
             return false;
         }
         return $row->getChannel() === Job::STATUS_WARNING;
     });
     $notificationsEmails = $jobManager->getWarningNotificationsEmails($job);
     if (!$notificationsEmails) {
         $notificationsEmails = array();
     }
     // validating emails
     foreach ($notificationsEmails as $key => $notificationsEmail) {
         if (!\Swift_Validate::email($notificationsEmail)) {
             unset($notificationsEmails[$key]);
         }
     }
     if (!count($notifications) && !count($notificationsEmails)) {
         return;
     }
     $message = \Swift_Message::newInstance();
     $message->setSubject(sprintf("[KBC] %s orchestrator %s warning", $job->getTokenOwnerName(), $job->getOrchestrationName()));
     $message->setFrom(self::MAIL_SENDER);
     foreach ($notificationsEmails as $notificationsEmail) {
         $message->addTo($notificationsEmail);
     }
     foreach ($notifications as $notification) {
         if ($job->getInitializedBy() !== 'manually') {
             if (!in_array($notification->getEmail(), $notificationsEmails)) {
                 $message->addTo($notification->getEmail());
             }
         }
     }
     $schedule = null;
     try {
         $cronSchedule = CronSchedule::fromCronString($orchestration->getCrontabRecord(), 'en');
         $schedule = $cronSchedule->asNaturalLanguage();
     } catch (\Exception $e) {
     }
     $tasks = $job->getResults();
     if (empty($tasks->tasks)) {
         $tasks = array();
     } else {
         $tasks = $tasks->tasks;
     }
     $jobUrl = $components->getJobUriTemplate(KeboolaOrchestratorBundle::SYRUP_COMPONENT_NAME);
     $jobUrl = str_replace('&&projectId&&', $job->getProjectId(), $jobUrl);
     $jobUrl = str_replace('&&orchestrationId&&', $job->getOrchestrationId(), $jobUrl);
     $jobUrl = str_replace('&&jobId&&', $job->getId(), $jobUrl);
     $message->setBody($this->templating->render('KeboolaOrchestratorBundle:Email:jobWarning.email.html.twig', array('schedule' => $schedule, 'tasks' => $tasks, 'componentsIcons' => $components->getComponentsIcons(), 'componentsNames' => $components->getComponentsNames(), 'componentsTypes' => $this->filterComponentsTypes($components->getComponentsTypes()), 'job' => $job, 'jobUrl' => $jobUrl)), 'text/html');
     $this->mailer->send($message);
     /**
      * @var \Swift_Spool $spool
      */
     $spool = $this->mailer->getTransport()->getSpool();
     $spool->flushQueue($this->mailerTransport);
 }
Ejemplo n.º 27
0
 /**
  * Validate email address
  *
  * @param string $emailAddress
  *
  * @return bool
  */
 public static function validationEmail($emailAddress)
 {
     return \Swift_Validate::email($emailAddress);
 }