Update notifications

This commit is contained in:
Romain Neutron
2013-01-22 15:22:04 +01:00
parent b5980ab866
commit 9cce7ab8f9
51 changed files with 1188 additions and 893 deletions

View File

@@ -191,7 +191,7 @@ class Dashboard implements ControllerProviderInterface
return $app->redirect('/admin/dashboard/?email=sent');
} catch (\Exception $e) {
exit($e->getMessage());
}
return $app->redirect('/admin/dashboard/?email=error');

View File

@@ -547,7 +547,23 @@ class Users implements ControllerProviderInterface
}
}
if (($accept != '' || $deny != '')) {
\mail::register_confirm($app, $row['usr_mail'], $accept, $deny);
$message = '';
if ($accept != '') {
$message .= "\n" . _('login::register:email: Vous avez ete accepte sur les collections suivantes : ') . implode(', ', $accept). "\n";
}
if ($deny != '') {
$message .= "\n" . _('login::register:email: Vous avez ete refuse sur les collections suivantes : ') . implode(', ', $deny) . "\n";
}
$receiver = new Receiver(null, $row['usr_mail']);
$mail = MailSuccessEmailUpdate::create($this->app, $receiver, null, $message);
try {
$this->app['notification.deliverer']->deliver($mail);
} catch (\Exception $e) {
}
}
}
}

View File

@@ -13,6 +13,9 @@ namespace Alchemy\Phrasea\Controller\Prod;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailRecordsExport;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -279,24 +282,20 @@ class Export implements ControllerProviderInterface
$url = $app['phraseanet.registry']->get('GV_ServerName') . 'download/' . $token . '/prepare/?anonymous';
$from = array(
'name' => $app['phraseanet.user']->get_display_name(),
'email' => $app['phraseanet.user']->get_email()
);
$emitter = new Emitter($app['phraseanet.user']->get_display_name(), $app['phraseanet.user']->get_email());
//send mails
foreach ($destMails as $key => $mail) {
if (\mail::send_documents(
$app,
trim($mail),
$url,
$from,
$endDateObject,
$request->request->get('textmail'),
$request->request->get('reading_confirm') == '1' ? : false
)
) {
$receiver = new Receiver(null, trim($mail));
$mail = MailRecordsExport::create($app, $receiver, $emitter, $request->request->get('textmail'));
$mail->setUrl($url);
$mail->setEnddate($endDateObject);
try {
$app['notification.deliverer']->deliver($mail);
unset($remaingEmails[$key]);
} catch (\Exception $e) {
}
}

View File

@@ -13,6 +13,8 @@ namespace Alchemy\Phrasea\Controller\Root;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailRequestEmailUpdate;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -293,7 +295,18 @@ class Account implements ControllerProviderInterface
return $app->redirect('/account/reset-email/?notice=mail-match');
}
if (!\mail::reset_email($app, $email, $app['phraseanet.user']->get_id()) === true) {
try {
$date = new DateTime('1 day');
$token = random::getUrlToken($app, \random::TYPE_EMAIL, $app['phraseanet.user']->get_id(), $date, $app['phraseanet.user']->get_email());
$url = $app['phraseanet.registry']->get('GV_ServerName') . 'account/reset-email/?token=' . $token;
$receiver = Receiver::fromUser($app['phraseanet.user']);
$mail = MailRequestEmailUpdate::create($app, $receiver, null);
$mail->setUrl($url);
$mail->setExpiration($date);
$app['notification.deliverer']->deliver($mail);
} catch (\Exception $e) {
return $app->redirect('/account/reset-email/?notice=mail-server');
}

View File

@@ -14,6 +14,10 @@ namespace Alchemy\Phrasea\Controller\Root;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Core\Event\LogoutEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation;
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailConfirmationRegistered;
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailConfirmationUnregistered;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Cookie;
@@ -234,14 +238,22 @@ class Login implements ControllerProviderInterface
try {
$user = \User_Adapter::getInstance((int) $usrId, $app);
$email = $user->get_email();
if (true === \mail::mail_confirmation($app, $email, $usrId)) {
$expire = new \DateTime('+3 days');
$token = \random::getUrlToken($app, \random::TYPE_PASSWORD, $user->get_id(), $expire, $user->get_email());
$mail = MailRequestEmailConfirmation::create($app, Receiver::fromUser($user));
$mail->setButtonUrl($app['phraseanet.registry']->get('GV_ServerName') . "register-confirm/?code=" . $token);
$mail->setExpiration($expire);
$app['notification.deliverer']->deliver($mail);
return $app->redirect('/login/?notice=mail-sent');
}
} catch (\Exception $e) {
return $app->redirect('/login/?error=user-not-found');
}
return $app->redirect('/login/?error=user-not-found');
}
/**
@@ -277,29 +289,15 @@ class Login implements ControllerProviderInterface
if (\Swift_Validate::email($user->get_email())) {
if (count($user->ACL()->get_granted_base()) > 0) {
\mail::mail_confirm_registered($app, $user->get_email());
$mail = MailSuccessEmailConfirmationRegistered::create($app, Receiver::fromUser($user));
$app['notification.deliverer']->deliver($mail);
}
$user->set_mail_locked(false);
\random::removeToken($app, $code);
$appboxRegister = new \appbox_register($app['phraseanet.appbox']);
$list = $appboxRegister->get_collection_awaiting_for_user($app, $user);
if (count($list) > 0) {
$others = array();
foreach ($list as $collection) {
$others[] = $collection->get_name();
}
\mail::mail_confirm_unregistered($app, $user->get_email(), $others);
return $app->redirect('/login/?redirect=prod&notice=confirm-ok-wait');
}
return $app->redirect('/login/?redirect=prod&notice=confirm-ok');
$mail = MailSuccessEmailConfirmationUnregistered::create($app, Receiver::fromUser($user));
$app['notification.deliverer']->deliver($mail);
}
}
@@ -328,10 +326,14 @@ class Login implements ControllerProviderInterface
if ($token) {
$url = $app['url_generator']->generate('login_forgot_password', array('token' => $token), true);
if (\mail::forgot_passord($app, $mail, $user->get_login(), $url)) {
$mail = MailRequestEmailConfirmation::create($app, Receiver::fromUser($user));
$mail->setButtonUrl($url);
try {
$app['notification.deliverer']->deliver($mail);
return $app->redirect($app['url_generator']->generate('login_forgot_password', array('sent' => 'ok')));
} catch (\Exception $e) {
return $app->redirect($app['url_generator']->generate('login_forgot_password', array('sent' => 'ok')));
} else {
return $app->redirect($app['url_generator']->generate('login_forgot_password', array('error' => 'mailserver')));
}
}
}
@@ -686,9 +688,20 @@ class Login implements ControllerProviderInterface
$app['events-manager']->trigger('__REGISTER_APPROVAL__', $params);
$user->set_mail_locked(true);
if (true === \mail::mail_confirmation($app, $user->get_email(), $user->get_id())) {
try {
$expire = new \DateTime('+3 days');
$token = \random::getUrlToken($app, \random::TYPE_PASSWORD, $user->get_id(), $expire, $user->get_email());
$mail = MailRequestEmailConfirmation::create($app, Receiver::fromUser($user));
$mail->setButtonUrl($app['phraseanet.registry']->get('GV_ServerName') . "register-confirm/?code=" . $token);
$mail->setExpiration($expire);
$app['notification.deliverer']->deliver($mail);
return $app->redirect('/login/?notice=mail-sent');
} catch (\Exception $e) {
}
return $app->redirect(sprintf('/login/?usr=%d', $user->get_id()));

View File

@@ -12,6 +12,8 @@
namespace Alchemy\Phrasea\Helper\User;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate;
use Alchemy\Phrasea\Notification\Receiver;
use Symfony\Component\HttpFoundation\Request;
/**
@@ -537,7 +539,19 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
$new_email = $user->get_email();
if ($old_email != $new_email) {
\mail::change_mail_information($this->app, $user->get_display_name(), $old_email, $new_email);
$newReceiver = new Receiver(null, $new_email);
$oldReceiver = new Receiver(null, $old_email);
$mailOldAddress = MailSuccessEmailUpdate::create($this->app, $oldReceiver, null, sprintf(_('You will now receive notifications at %s'), $new_email));
$mailNewAddress = MailSuccessEmailUpdate::create($this->app, $newReceiver, null, sprintf(_('You will no longer receive notifications at %s'), $old_email));
try {
$this->app['notification.deliverer']->deliver($mailOldAddress);
$this->app['notification.deliverer']->deliver($mailNewAddress);
} catch (\Exception $e) {
}
}
return $this;

View File

@@ -12,6 +12,8 @@
namespace Alchemy\Phrasea\Helper\User;
use Alchemy\Phrasea\Helper\Helper;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailRequestPasswordSetup;
/**
*
@@ -165,15 +167,24 @@ class Manage extends Helper
/* @var $createdUser \User_Adapter */
if ($validateMail) {
$createdUser->set_mail_locked(true);
\mail::mail_confirmation($this->app, $email, $createdUser->get_id());
$expire = new \DateTime('+3 days');
$token = \random::getUrlToken($this->app, \random::TYPE_PASSWORD, $createdUser->get_id(), $expire, $createdUser->get_email());
$mail = MailRequestPasswordSetup::create($this->app, Receiver::fromUser($createdUser));
$mail->setButtonUrl($this->app['phraseanet.registry']->get('GV_ServerName') . "register-confirm/?code=" . $token);
$mail->setExpiration($expire);
$this->app['notification.deliverer']->deliver($mail);
}
if ($sendCredentials) {
$urlToken = \random::getUrlToken($this->app, \random::TYPE_PASSWORD, $createdUser->get_id());
if (false !== $urlToken) {
$url = $this->app['url_generator']->generate('login_forgot_password', array('token' => $urlToken), true);
\mail::send_credentials($this->app, $url, $createdUser->get_login(), $createdUser->get_email());
$mail = MailSuccessEmailConfirmationUnregistered::create($this->app, Receiver::fromUser($createdUser));
$mail->setUrl($this->app['url_generator']->generate('login_forgot_password', array('token' => $urlToken), true));
$this->app['notification.deliverer']->deliver($mail);
}
}

View File

@@ -23,7 +23,7 @@ class Deliverer
$this->registry = $registry;
}
public function deliver(MailInterface $mail)
public function deliver(MailInterface $mail, $readReceipt = false)
{
if (!$mail->receiver()) {
throw new \LogicException('You should provide a receiver for a mail notification');
@@ -41,6 +41,9 @@ class Deliverer
$message->setReplyTo($mail->emitter()->email(), $mail->emitter()->name());
}
if ($readReceipt) {
$message->setReadReceiptTo($readReceipt);
}
$this->mailer->send($message);
}

View File

@@ -8,16 +8,16 @@ use Alchemy\Phrasea\Notification\Receiver;
abstract class AbstractMail implements MailInterface
{
private $twig;
protected $registry;
private $emitter;
private $receiver;
private $message;
protected $app;
/** @var Emitter */
protected $emitter;
/** @var Receiver */
protected $receiver;
protected $message;
public function __construct(\Twig_Environment $twig, \registry $registry, Receiver $receiver, Emitter $emitter = null, $message = null)
public function __construct(Application $app, Receiver $receiver, Emitter $emitter = null, $message = null)
{
$this->twig = $twig;
$this->registry = $registry;
$this->app = $app;
$this->emitter = $emitter;
$this->receiver = $receiver;
$this->message = $message;
@@ -25,7 +25,7 @@ abstract class AbstractMail implements MailInterface
public function renderHTML()
{
return $this->twig->render('email-template.html.twig', array(
return $this->app['twig']->render('email-template.html.twig', array(
'phraseanetURL' => $this->phraseanetURL(),
'logoUrl' => $this->logoUrl(),
'logoText' => $this->logoText(),
@@ -33,6 +33,7 @@ abstract class AbstractMail implements MailInterface
'senderName' => $this->emitter() ? $this->emitter()->getName() : null,
'senderMail' => $this->emitter() ? $this->emitter()->getEmail() : null,
'messageText' => $this->message(),
'expirationMessage' => $this->getExpirationMessage(),
'buttonUrl' => $this->buttonURL(),
'buttonText' => $this->buttonText(),
));
@@ -40,7 +41,7 @@ abstract class AbstractMail implements MailInterface
public function phraseanetURL()
{
return $this->registry->get('GV_ServerName');
return $this->app['phraseanet.registry']->get('GV_ServerName');
}
public function logoUrl()
@@ -50,7 +51,7 @@ abstract class AbstractMail implements MailInterface
public function logoText()
{
return $this->registry->get('GV_homeTitle');
return $this->app['phraseanet.registry']->get('GV_homeTitle');
}
public function emitter()
@@ -63,6 +64,11 @@ abstract class AbstractMail implements MailInterface
return $this->receiver;
}
public function getExpirationMessage()
{
return null;
}
abstract public function subject();
abstract public function message();
@@ -73,6 +79,6 @@ abstract class AbstractMail implements MailInterface
public static function create(Application $app, Receiver $receiver, Emitter $emitter = null, $message = null)
{
return new static($app['twig'], $app['phraseanet.registry'], $receiver, $emitter, $message);
return new static($app['twig'], $receiver, $emitter, $message);
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
abstract class AbstractMailWithLink extends AbstractMail implements MailWithLinkInterface
{
protected $url;
protected $expiration;
public function setButtonUrl($url)
{
$this->url = $url;
}
public function setExpiration(\DateTime $expiration = null)
{
$this->expiration = $expiration;
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoBridgeUploadFailed extends AbstractMailWithLink
{
private $adapter;
private $reason;
public function setAdapter($adapter)
{
$this->adapter = $adapter;
}
public function setReason($reason)
{
$this->reason = $reason;
}
public function subject()
{
return sprintf(
_('Upload failed on %s'),
$this->app['phraseanet.registry']->get('GV_homeTitle')
);
}
public function message()
{
return _('An upload on %s failed, the resaon is : %s', $this->adapter, $this->reason);
}
public function buttonText()
{
}
public function buttonURL()
{
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoNewOrder extends AbstractMail
{
private $user;
public function setUser(\User_Adapter $user)
{
$this->user = $user;
}
public function subject()
{
return sprintf(
_('admin::register: Nouvelle commande sur %s'),
$this->app['phraseanet.registry']->get('GV_homeTitle')
);
}
public function message()
{
return sprintf(_('%s has ordered documents'),$this->user->get_display_name());
}
public function buttonText()
{
return sprintf(_('See order on %s'), $this->app['phraseanet.registry']->get('GV_homeTitle'));
}
public function buttonURL()
{
return sprintf('%sprod', $this->app['phraseanet.registry']->get('GV_ServerName'));
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoNewPublication extends AbstractMailWithLink
{
private $author;
private $title;
public function setTitle($title)
{
$this->title = $title;
}
public function setAuthor($author)
{
$this->author = $author;
}
public function subject()
{
return sprintf(_('Nouvelle publication : %s'), $this->title);
}
public function message()
{
return sprintf('%s vient de publier %s', $this->author, $this->title);
}
public function buttonText()
{
return sprintf(_('View on %s'), $this->app['phraseanet.registry']->get('GV_homeTitle'));
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoOrderCancelled extends AbstractMail
{
private $deliverer;
private $quantity;
public function setQuantity($quantity)
{
$this->quantity = $quantity;
}
public function setDeliverer(\User_Adapter $deliverer)
{
$this->deliverer = $deliverer;
}
public function subject()
{
return _('push::mail:: Refus d\'elements de votre commande');
}
public function message()
{
return sprintf(
_('%s a refuse %d elements de votre commande'),
$this->deliverer->get_display_name(),
$this->quantity
);
}
public function buttonText()
{
return _('See my order');
}
public function buttonURL()
{
return sprintf('%sprod/', $this->app['phraseanet.registry']->get('GV_ServerName'));
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
use Entities\Basket;
class MailInfoOrderDelivered extends AbstractMail
{
private $basket;
private $deliverer;
public function setBasket(Basket $basket)
{
$this->basket = $basket;
}
public function setDeliverer(\User_Adapter $deliverer)
{
$this->deliverer = $deliverer;
}
public function subject()
{
return sprintf(
_('push::mail:: Reception de votre commande %s'), $this->basket->getName()
);
}
public function message()
{
return sprintf(
_('%s vous a delivre votre commande, consultez la en ligne a l\'adresse suivante'),
$this->deliverer->get_display_name()
);
}
public function buttonText()
{
return _('See my order');
}
public function buttonURL()
{
return sprintf(
'%slightbox/compare/%s/',
$this->app['phraseanet.registry']->get('GV_ServerName'),
$this->basket->getId()
);
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoPushReceived extends AbstractMailWithLink
{
private $basket;
private $pusher;
public function setBasket(Basket $basket)
{
$this->basket = $basket;
}
public function setPusher(\User_Adapter $pusher)
{
$this->pusher = $pusher;
}
public function subject()
{
return sprintf(_('Reception of %s'), $this->basket->getName());
}
public function message()
{
return
sprintf(_('You just received a push containing %s documents from %s'), $this->pusher->get_display_name())
. "\n" . $this->message;
}
public function buttonText()
{
return _('Watch it online');
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoRecordQuarantined extends AbstractMail
{
public function subject()
{
return _('A document has been quarantined');
}
public function message()
{
return _('A file has been thrown to the quarantine.');
}
public function buttonText()
{
return _('Access quarantine');
}
public function buttonURL()
{
return sprintf('%sprod/', $this->app['phraseanet.registry']->get('GV_ServerName'));
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoSomebodyAutoregistered extends AbstractMailWithLink
{
public function subject()
{
return sprintf(
_('admin::register: Inscription automatique sur %s'),
$this->app['phraseanet.registry']->get('GV_homeTitle')
);
}
public function message()
{
return _('admin::register: un utilisateur s\'est inscrit')."\n\n".$this->message;
}
public function buttonText()
{
return _('Update the account');
}
public function buttonURL()
{
return $this->app['phraseanet.registry']->get('GV_ServerName') . 'admin/?section=users';
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoUserRegistered extends AbstractMail
{
private $registeredUser;
public function setRegisteredUser($registeredUser)
{
$this->registeredUser = $registeredUser;
}
public function subject()
{
return sprintf(
_('admin::register: demande d\'inscription sur %s'), $this->app['phraseanet.registry']->get('GV_homeTitle')
);
}
public function message()
{
return _('admin::register: un utilisateur a fait une demande d\'inscription')
. "\n\n" . sprintf('%s %s',$this->registeredUser->get_firstname(), $this->registeredUser->get_lastname())
. "\n\n" . sprintf('%s %s',$this->registeredUser->get_job(), $this->registeredUser->get_company());
}
public function buttonText()
{
return _('Process the registration');
}
public function buttonURL()
{
return sprintf('%sadmin/?section=registrations', $this->app['phraseanet.registry']->get('GV_ServerName'));
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoValidationDone extends AbstractMailWithLink
{
private $title;
public function setTitle($title)
{
$this->title = $title;
}
public function subject()
{
return sprintf(
_('push::mail:: Rapport de validation de %1$s pour %2$s'),
$this->emitter->name(),
$this->title
);
}
public function message()
{
return sprintf(
_('%s has just sent its validation report, you can now see it'),
$this->emitter->name()
);
}
public function buttonText()
{
return _('See validation results');
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoValidationReminder extends AbstractMailWithLink
{
private $title;
public function setTitle($title)
{
$this->title = $title;
}
public function subject()
{
return sprintf(_("Reminder : validate '%s'"), $this->title);
}
public function message()
{
return sprintf(
_('Il ne vous reste plus que %d jours pour terminer votre validation'),
$this->app['phraseanet.registry']->get('GV_validation_reminder')
);
}
public function buttonText()
{
return _('Validate');
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailInfoValidationRequest extends AbstractMailWithLink
{
private $title;
public function setTitle($title)
{
$this->title = $title;
}
public function subject()
{
return sprintf(_("Validation request from %s : '%s'", $this->emitter->name(), $this->title));
}
public function message()
{
return $this->message;
}
public function buttonText()
{
return _('Validate');
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailRecordsExport extends AbstractMailWithLink
{
public function subject()
{
return _('Vous avez recu des documents');
}
public function message()
{
return $this->message;
}
public function getExpirationMessage()
{
return sprintf(
_('Attention, ce lien lien est valable jusqu\'au %s %s'),
$this->app['date-formatter']->getDate($this->expiration),
$this->app['date-formatter']->getTime($this->expiration)
);
}
public function buttonText()
{
return _('Download');
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailRequestEmailConfirmation extends AbstractMailWithLink
{
public function subject()
{
return _('login::register: sujet email : confirmation de votre adresse email');
}
public function message()
{
_('login::register: email confirmation email Pour valider votre inscription a la base de donnees, merci de confirmer votre e-mail en suivant le lien ci-dessous.');
}
public function getExpirationMessage()
{
return sprintf(
_('Attention, ce lien lien est valable jusqu\'au %s %s'),
$this->app['date-formatter']->getDate($this->expiration),
$this->app['date-formatter']->getTime($this->expiration)
);
}
public function buttonText()
{
return _('Validate e-mail address');
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailRequestEmailUpdate extends AbstractMailWithLink
{
public function subject()
{
return _('login::register: sujet email : confirmation de votre adresse email');
}
public function message()
{
return _('admin::compte-utilisateur: email changement de mot d\'email Bonjour, nous avons bien recu votre demande de changement d\'adresse e-mail. Pour la confirmer, veuillez suivre le lien qui suit. SI vous recevez ce mail sans l\'avoir sollicite, merci de le detruire et de l\'ignorer.');
}
public function buttonText()
{
return _('Confirm new email address');
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailRequestPasswordSetup extends AbstractMailWithLink
{
private $login;
public function subject()
{
return sprintf(_('Your account on %s'), $this->app['phraseanet.registry']->get('GV_homeTitle'));
}
public function setLogin($login)
{
$this->login = $login;
}
public function message()
{
return sprintf(_('Your account with the login %s as been created'), $this->login)
. "\n"
. _('You now have to set up your pasword');
}
public function buttonText()
{
return _('Setup my password');
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailRequestPasswordUpdate extends AbstractMailWithLink
{
public function subject()
{
return _('login:: Forgot your password');
}
public function message()
{
return _('login:: Quelqu\'un a demande a reinitialiser le mode passe correspondant au login suivant : ')
. "\n"
. _('login:: Visitez le lien suivant et suivez les instructions pour continuer, sinon ignorez cet email et il ne se passera rien');
}
public function buttonText()
{
return _('Renew password');
}
public function buttonURL()
{
return $this->url;
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailSuccessAccessRequest extends AbstractMailWithLink
{
public function subject()
{
return sprintf(_('login::register:email: Votre compte %s'), $this->app['phraseanet.registry']->get('GV_homeTitle'));
}
public function message()
{
return _('login::register:email: Voici un compte rendu du traitement de vos demandes d\'acces :')
. "\n"
. $this->message;
}
public function buttonText()
{
return _('Watch my access requests status');
}
public function buttonURL()
{
return $this->app['url_generator']->generate('account_access');
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailSuccessEmailConfirmationRegistered extends AbstractMailWithLink
{
public function subject()
{
return _('Email successfully confirmed');
}
public function message()
{
return _('login::register: merci d\'avoir confirme votre adresse email');
}
public function buttonText()
{
return sprintf(_('Access %'), $this->app['phraseanet.registry']->get('GV_homeTile'));
}
public function buttonURL()
{
return $this->app['phraseanet.registry']->get('GV_ServerName');
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailSuccessEmailConfirmationUnregistered extends AbstractMailWithLink
{
public function subject()
{
return _('Email successfully confirmed');
}
public function message()
{
return _('login::register: merci d\'avoir confirme votre adresse email')
. "\n"
. _("You have to wait for an administrator approval for your access request");
}
public function buttonText()
{
return _('Watch my access requests status');
}
public function buttonURL()
{
return $this->app['url_generator']->generate('account_access');
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailSuccessEmailUpdate extends AbstractMail
{
public function subject()
{
return sprintf(_('Update of your email address on %s'), $this->app['phraseanet.registry']->get('GV_homeTitle'));
}
public function message()
{
return sprintf("%s\n%s\n%s",
sprintf(_('Dear %s,'), $this->receiver->name()),
_('Your contact email address has been updated'),
$this->message
);
}
public function buttonText()
{
return $this->app['phraseanet.registry']->get('GV_homeTitle');
}
public function buttonURL()
{
return $this->registry->get('GV_ServerName');
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
class MailSuccessFTPSender extends AbstractMail
{
private $server;
public function setServer($server)
{
$this->server = $server;
}
public function subject()
{
return sprintf(
_('task::ftp:Status about your FTP transfert from %1$s to %2$s'),
$this->app['phraseanet.registry']->get('GV_homeTitle'), $this->server
);
}
public function message()
{
return $this->message;
}
public function buttonText()
{
}
public function buttonURL()
{
}
}

View File

@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\Notification\Mail;
class MailTest extends AbstractMail
{
public function subject()
{
return _('mail:: test d\'envoi d\'email');
@@ -12,14 +11,15 @@ class MailTest extends AbstractMail
public function message()
{
return sprintf(
_('Ce mail est un test d\'envoi de mail depuis %s'), $this->registry->get('GV_ServerName')
);
return sprintf("%s\n%s", sprintf(
_('Ce mail est un test d\'envoi de mail depuis %s'),
$this->registry->get('GV_ServerName')
), $this->message);
}
public function buttonText()
{
return _('Return to Phraseanet');
return $this->app['phraseanet.registry']->get('GV_homeTitle');
}
public function buttonURL()

View File

@@ -0,0 +1,9 @@
<?php
namespace Alchemy\Phrasea\Notification\Mail;
interface MailWithLinkInterface
{
public function setButtonUrl($url);
public function setExpiration(\DateTime $expiration);
}

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoSomebodyAutoregistered;
/**
*
*
@@ -105,31 +108,24 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
$datas = $dom_xml->saveXml();
try {
$registered_user = User_Adapter::getInstance($params['usr_id'], $this->app);
} catch (Exception $e) {
return;
}
foreach ($mailColl as $usr_id => $base_ids) {
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $usr_id) != '0');
if ($send_notif) {
if ($this->shouldSendNotificationFor($usr_id)) {
try {
$admin_user = User_Adapter::getInstance($usr_id, $this->app);
} catch (Exception $e) {
continue;
}
$dest = $admin_user->get_email();
if (trim($admin_user->get_firstname() . ' ' . $admin_user->get_lastname()) != '')
$dest = $admin_user->get_firstname() . ' ' . $admin_user->get_lastname();
$to = array('email' => $admin_user->get_email(), 'name' => $dest);
$from = array(
'email' => $this->app['phraseanet.registry']->get('GV_defaulmailsenderaddr'),
'name' => $this->app['phraseanet.registry']->get('GV_homeTitle')
);
if (self::mail($to, $from, $datas))
if (self::mail($admin_user, $registered_user))
$mailed = true;
}
@@ -193,66 +189,27 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
* @param Array $datas
* @return boolean
*/
public function mail($to, $from, $datas)
public function mail(\User_Adapter $to, \User_Adapter $registeredUser)
{
$subject = sprintf(_('admin::register: Inscription automatique sur %s')
, $this->app['phraseanet.registry']->get('GV_homeTitle'));
$body .= sprintf("Login : %s\n", $registeredUser->get_login());
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur nom'), $registeredUser->get_firstname());
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur prenom'), $registeredUser->get_lastname());
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur email'), $registeredUser->get_email());
$body .= sprintf("%s/%s\n", $registeredUser->get_job(), $registeredUser->get_company());
$body = "<div>" . _('admin::register: un utilisateur s\'est inscrit')
. "</div>\n";
$sx = simplexml_load_string($datas);
$usr_id = (string) $sx->usr_id;
$receiver = Receiver::fromUser($to);
$mail = MailInfoSomebodyAutoregistered::create($this->app, $receiver, $body);
try {
$registered_user = User_Adapter::getInstance($usr_id, $this->app);
} catch (Exception $e) {
$this->app['notification.deliverer']->deliver($mail);
return true;
} catch (\Exception $e) {
}
return false;
}
$body .= "<br/>\n<div>Login : " . $registered_user->get_login() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur nom')
. " : " . $registered_user->get_firstname() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur prenom')
. " : " . $registered_user->get_lastname() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur email')
. " : " . $registered_user->get_email() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur adresse')
. " : " . $registered_user->get_address() . "</div>\n";
$body .= "<div>" . $registered_user->get_city() . " "
. $registered_user->get_zipcode() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur telephone')
. " : " . $registered_user->get_tel() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur fax')
. " : " . $registered_user->get_fax() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur poste')
. "/" . _('admin::compte-utilisateur societe') . " "
. $registered_user->get_job() . " " . $registered_user->get_company()
. "</div>\n";
$base_ids = $sx->base_ids;
$body .= "<br/>\n<div>"
. _('admin::register: l\'utilisateur s\'est inscrit sur les bases suivantes')
. "</div>\n";
$body .= "<ul>\n";
foreach ($base_ids->base_id as $base_id) {
$body .= "<li>"
. phrasea::sbas_names(phrasea::sbasFromBas($this->app, (string) $base_id), $this->app)
. ' - ' . phrasea::bas_names((string) $base_id, $this->app) . "</li>\n";
}
$body .= "</ul>\n";
$body .= "<br/>\n<div><a href='/login/?redirect=admin' target='_blank'>"
. _('admin::register: vous pourrez consulter son compte en ligne via l\'interface d\'administration')
. "</a></div>\n";
return mail::send_mail($this->app, $subject, $body, $to, $from);
}
/**
*
* @return boolean

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoBridgeUploadFailed;
/**
*
*
@@ -78,21 +81,21 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $params['usr_id']) != '0');
if ($send_notif) {
if ($this->shouldSendNotificationFor($params['usr_id'])) {
$user = User_Adapter::getInstance($params['usr_id'], $this->app);
$name = $user->get_display_name();
$to = array('email' => $user->get_email(), 'name' => $name);
try {
$account = Bridge_Account::load_account($this->app, $params['account_id']);
$from = array(
'email' => $this->app['phraseanet.registry']->get('GV_defaulmailsenderaddr'),
'name' => $this->app['phraseanet.registry']->get('GV_homeTitle')
);
if (self::mail($to, $from, $datas))
$receiver = Receiver::fromUser($user);
$mail = MailInfoBridgeUploadFailed::create($this->app, $receiver);
$mail->setAdapter($account->get_api()->get_connector()->get_name());
$mail->setReason($params['reason']);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
} catch (\Exception $e) {
}
}
$this->broker->notify($params['usr_id'], __CLASS__, $datas, $mailed);
@@ -150,26 +153,6 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract
. ' upload echoue sur un bridge');
}
/**
*
* @param Array $to
* @param Array $from
* @param Array $datas
* @return boolean
*/
public function mail($to, $from, $datas)
{
$subject = sprintf('Echec upload sur %s'
, $this->app['phraseanet.registry']->get('GV_homeTitle'));
$sx = simplexml_load_string($datas);
$reason = (string) $sx->reason;
$body = "reason : " . $reason;
return mail::send_mail($this->app, $subject, $body, $to, $from);
}
/**
*
* @return boolean

View File

@@ -81,9 +81,7 @@ class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $params['usr_id']) != '0');
if ($send_notif) {
if ($this->shouldSendNotificationFor($params['usr_id'])) {
$user = User_Adapter::getInstance($params['usr_id'], $this->app);
$name = $user->get_display_name();

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication;
/**
*
*
@@ -85,12 +88,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
/* @var $user_to_notif \User_Adapter */
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $user_to_notif->get_id()) != '0');
if ($send_notif) {
$email = array(
'email' => $user_to_notif->get_email(),
'name' => $user_to_notif->get_display_name()
);
if ($this->shouldSendNotificationFor($user_to_notif->get_id())) {
$token = \random::getUrlToken(
$this->app,
@@ -102,8 +100,16 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
$url = $this->app['phraseanet.registry']->get('GV_ServerName') . 'lightbox/index.php?LOG=' . $token;
if (self::mail($email, $from, $url, $entry))
try {
$receiver = Receiver::fromUser($user_to_notif);
$mail = MailInfoNewPublication::create($this->app, $receiver);
$mail->setUrl($url);
$mail->setAuthor($entry->get_author_name());
$mail->setTitle($entry->get_title());
$mailed = true;
} catch (\Exception $e) {
}
}
$this->broker->notify($user_to_notif->get_id(), __CLASS__, $datas, $mailed);
@@ -168,32 +174,4 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
{
return true;
}
/**
*
* @param Array $to
* @param Array $from
* @param string $message
* @param string $url
* @param boolean $accuse
* @return boolean
*/
public function mail($to, $from, $url, \Feed_Entry_Adapter $entry)
{
$subject = sprintf(_('Nouvelle publication : %s'), $entry->get_title());
$body = "<div>"
. sprintf('%s vient de publier %s', $entry->get_author_name(), $entry->get_title())
. _('Connectez vous a l\'adresse suivante pour la consulter')
. "</div>\n";
$body .= '<div><a href="' . $url . '">' . $url . "</a></div>\n";
$body .= " <br/> ";
$body .= "<br/>\n<br/>\n<br/>\n"
. _('push::atention: ce lien est unique et son contenu confidentiel, ne divulguez pas');
return mail::send_mail($this->app, $subject, $body, $to, $from, array());
}
}

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoNewOrder;
/**
*
*
@@ -98,26 +101,29 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
$datas = $dom_xml->saveXml();
try {
$orderInitiator = User_Adapter::getInstance($params['usr_id'], $this->app);
} catch (\Exception $e) {
return;
}
foreach ($users as $user) {
$usr_id = $user->get_id();
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $usr_id) != '0');
if ($send_notif) {
$dest = User_Adapter::getInstance($usr_id, $this->app)->get_display_name();
if ($this->shouldSendNotificationFor($user->get_id())) {
try {
$receiver = Receiver::fromUser($user);
$mail = MailInfoNewOrder::create($this->app, $receiver);
$mail->setUser($orderInitiator);
$to = array('email' => $user->get_email(), 'name' => $dest);
$from = array(
'email' => $this->app['phraseanet.registry']->get('GV_defaulmailsenderaddr'),
'name' => $this->app['phraseanet.registry']->get('GV_homeTitle')
);
if (self::mail($to, $from, $datas)) {
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
} catch (\Exception $e) {
}
}
$this->broker->notify($usr_id, __CLASS__, $datas, $mailed);
$this->broker->notify($user->get_id(), __CLASS__, $datas, $mailed);
}
return;
@@ -173,62 +179,6 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
return _('Recevoir des notifications lorsqu\'un utilisateur commande des documents');
}
/**
*
* @param Array $to
* @param Array $from
* @param Array $datas
* @return boolean
*/
public function mail($to, $from, $datas)
{
$subject = sprintf(_('admin::register: Nouvelle commande sur %s')
, $this->app['phraseanet.registry']->get('GV_homeTitle'));
$body = "<div>"
. _('admin::register: un utilisateur a commande des documents')
. "</div>\n";
$sx = simplexml_load_string($datas);
$usr_id = (string) $sx->usr_id;
try {
$registered_user = User_Adapter::getInstance($usr_id, $this->app);
} catch (Exception $e) {
return false;
}
$body .= "<br/>\n<div>Login : "
. $registered_user->get_login() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur nom')
. " : " . $registered_user->get_firstname() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur prenom')
. " : " . $registered_user->get_lastname() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur email')
. " : " . $registered_user->get_email() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur adresse')
. " : " . $registered_user->get_address() . "</div>\n";
$body .= "<div>" . $registered_user->get_city()
. " " . $registered_user->get_zipcode() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur telephone')
. " : " . $registered_user->get_tel() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur fax')
. " : " . $registered_user->get_fax() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur poste')
. "/" . _('admin::compte-utilisateur societe')
. " " . $registered_user->get_job()
. " " . $registered_user->get_company() . "</div>\n";
$base_ids = $sx->base_ids;
$body .= "<br/>\n<div>"
. _('Retrouvez son bon de commande dans l\'interface')
. "</div>\n";
return mail::send_mail($this->app, $subject, $body, $to, $from);
}
/**
*
* @return boolean

View File

@@ -10,6 +10,9 @@
*/
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoOrderDelivered;
/**
*
@@ -92,8 +95,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $params['to']) != '0');
if ($send_notif) {
if ($this->shouldSendNotificationFor($params['to'])) {
try {
$user_from = User_Adapter::getInstance($params['from'], $this->app);
$user_to = User_Adapter::getInstance($params['to'], $this->app);
@@ -101,17 +103,24 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
return false;
}
$to = array(
'email' => $user_to->get_email(),
'name' => $user_to->get_display_name()
);
$from = array(
'email' => $user_from->get_email(),
'name' => $user_from->get_display_name()
);
try {
$repository = $this->app['EM']->getRepository('\Entities\Basket');
if (self::mail($to, $from, $params['ssel_id'], $params['n']))
$basket = $repository->find($params['ssel_id']);
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$mail = MailInfoOrderDelivered::create($this->app, $receiver, $emitter);
$mail->setBasket($basket);
$mail->setDeliverer($user_from);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
} catch (Exception $e) {
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
@@ -176,40 +185,6 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
return _('Reception d\'une commande');
}
/**
*
* @param Array $to
* @param Array $from
* @param int $ssel_id
* @return boolean
*/
public function mail($to, $from, $ssel_id)
{
try {
$repository = $this->app['EM']->getRepository('\Entities\Basket');
$basket = $repository->findOneBy(array(
'id' => $ssel_id
, 'pusher_id' => $this->app['phraseanet.user']->get_id()
)
);
} catch (Exception $e) {
return false;
}
$subject = sprintf(
_('push::mail:: Reception de votre commande %s'), $basket->getName()
);
$body = "<div>"
. sprintf(
_('%s vous a delivre votre commande, consultez la en ligne a l\'adresse suivante'), $from['name']
) . "</div>\n";
$body .= "<br/>\n" . $this->app['phraseanet.registry']->get('GV_ServerName') . 'lightbox/validate/' . $ssel_id;
return mail::send_mail($this->app, $subject, $body, $to, $from, array());
}
/**
*
* @return boolean

View File

@@ -10,6 +10,9 @@
*/
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Mail\MailInfoOrderCancelled;
/**
*
@@ -72,8 +75,7 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $params['to']) != '0');
if ($send_notif) {
if ($this->shouldSendNotificationFor($params['to'])) {
try {
$user_from = User_Adapter::getInstance($params['from'], $this->app);
$user_to = User_Adapter::getInstance($params['to'], $this->app);
@@ -81,17 +83,20 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
return false;
}
$to = array(
'email' => $user_to->get_email(),
'name' => $user_to->get_display_name()
);
$from = array(
'email' => $user_from->get_email(),
'name' => $user_from->get_display_name()
);
try {
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$mail = MailInfoOrderCancelled::create($this->app, $receiver, $emitter);
$mail->setQuantity($params['n']);
$mail->setDeliverer($user_from);
$this->app['notification.deliverer']->deliver($mail);
if (self::mail($to, $from, $params['n']))
$mailed = true;
} catch (\Exception $e) {
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
@@ -132,18 +137,6 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
return _('Refus d\'elements de commande');
}
public function mail($to, $from, $n)
{
$subject = sprintf(_('push::mail:: Refus d\'elements de votre commande'));
$body = "<div>"
. sprintf(
_('%s a refuse %d elements de votre commande'), $from['name'], $n
) . "</div>\n";
return mail::send_mail($this->app, $subject, $body, $to, $from, array());
}
/**
*
* @return boolean

View File

@@ -9,6 +9,10 @@
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoPushReceived;
/**
*
*
@@ -78,22 +82,27 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $params['to']) != '0');
if ($send_notif) {
$email = array(
'email' => $params['to_email'],
'name' => $params['to_name']
);
$from = array(
'email' => $params['from_email'],
'name' => $params['from_email']
);
$message = $params['message'];
$url = $params['url'];
$accuse = $params['accuse'];
if ($this->shouldSendNotificationFor($params['to'])) {
try {
$repository = $this->app['EM']->getRepository('\Entities\Basket');
$basket = $repository->find($params['ssel_id']);
$user_from = User_Adapter::getInstance($params['from'], $this->app);
$user_to = User_Adapter::getInstance($params['to'], $this->app);
$receiver = Receiver::fromUser($user_from);
$emitter = Emitter::fromUser($user_to);
$mail = MailInfoPushReceived::create($this->app, $receiver, $emitter, $params['message']);
$mail->setBasket($basket);
$mail->setPusher($user_from);
$this->app['notification.deliverer']->deliver($mail, $params['accuse']);
if (self::mail($email, $from, $message, $url, $accuse))
$mailed = true;
} catch (Exception $e) {
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
@@ -156,32 +165,4 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
return true;
}
/**
*
* @param Array $to
* @param Array $from
* @param string $message
* @param string $url
* @param boolean $accuse
* @return boolean
*/
public function mail($to, $from, $message, $url, $accuse)
{
$subject = _('push::mail:: Reception de documents');
$body = "<div>"
. _('push::Vous pouvez vous connecter a l\'adresse suivante afin de retrouver votre panier, voir les previews, les descriptions, le telecharger, etc.')
. "</div>\n";
$body .= '<div><a href="' . $url . '">' . $url . "</a></div>\n";
$body .= " <br/> ";
$body .= $message;
$body .= "<br/>\n<br/>\n<br/>\n"
. _('push::atention: ce lien est unique et son contenu confidentiel, ne divulguez pas');
return mail::send_mail($this->app, $subject, $body, $to, $from, array(), $accuse);
}
}

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered;
/**
*
*
@@ -106,29 +109,29 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$datas = $dom_xml->saveXml();
try {
$registeredUser = \User_Adapter::getInstance($params['usr_id'], $this->app);
} catch (\Exception $e) {
return;
}
foreach ($mailColl as $usr_id => $base_ids) {
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $usr_id) != '0');
if ($send_notif) {
if ($this->shouldSendNotificationFor($usr_id)) {
try {
$admin_user = User_Adapter::getInstance($usr_id, $this->app);
$receiver = Receiver::fromUser($admin_user);
$mail = MailInfoUserRegistered::create($this->app, $receiver);
$mail->setRegisteredUser($registeredUser);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
} catch (Exception $e) {
continue;
}
$dest = $admin_user->get_email();
$dest = $admin_user->get_display_name();
$to = array('email' => $admin_user->get_email(), 'name' => $dest);
$from = array(
'email' => $this->app['phraseanet.registry']->get('GV_defaulmailsenderaddr'),
'name' => $this->app['phraseanet.registry']->get('GV_homeTitle')
);
if (self::mail($to, $from, $datas))
$mailed = true;
}
$this->broker->notify($usr_id, __CLASS__, $datas, $mailed);
@@ -185,78 +188,6 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
return _('Recevoir des notifications lorsqu\'un utilisateur demande une inscription necessitant mon approbation');
}
/**
*
* @param Array $to
* @param Array $from
* @param string $datas
* @return boolean
*/
public function mail($to, $from, $datas)
{
$subject = sprintf(
_('admin::register: demande d\'inscription sur %s'), $this->app['phraseanet.registry']->get('GV_homeTitle')
);
$body = "<div>"
. _('admin::register: un utilisateur a fait une demande d\'inscription')
. "</div>\n";
$sx = simplexml_load_string($datas);
$usr_id = (string) $sx->usr_id;
try {
$registered_user = User_Adapter::getInstance($usr_id, $this->app);
} catch (Exception $e) {
return false;
}
$body .= "<br/>\n<div>Login : "
. $registered_user->get_login() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur nom')
. " : " . $registered_user->get_firstname() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur prenom')
. " : " . $registered_user->get_lastname() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur email')
. " : " . $registered_user->get_email() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur adresse')
. " : " . $registered_user->get_address() . "</div>\n";
$body .= "<div>" . $registered_user->get_city()
. " " . $registered_user->get_zipcode() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur telephone')
. " : " . $registered_user->get_tel() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur fax')
. " : " . $registered_user->get_fax() . "</div>\n";
$body .= "<div>" . _('admin::compte-utilisateur poste')
. "/" . _('admin::compte-utilisateur societe')
. " " . $registered_user->get_job()
. " " . $registered_user->get_company() . "</div>\n";
$base_ids = $sx->base_ids;
$body .= "<br/>\n<div>"
. _('admin::register: les demandes de l\'utilisateur portent sur les bases suivantes')
. "</div>\n";
$body .= "<ul>\n";
foreach ($base_ids->base_id as $base_id) {
$body .= "<li>"
. phrasea::sbas_names(phrasea::sbasFromBas($this->app, (string) $base_id), $this->app)
. ' - '
. phrasea::bas_names((string) $base_id, $this->app) . "</li>\n";
}
$body .= "</ul>\n";
$body .= "<br/>\n<div><a href='" . $this->app['phraseanet.registry']->get('GV_ServerName')
. "login/?redirect=admin' target='_blank'>"
. _('admin::register: vous pourrez traiter ses demandes en ligne via l\'interface d\'administration')
. "</a></div>\n";
return mail::send_mail($this->app, $subject, $body, $to, $from);
}
/**
*
* @return boolean

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoRecordQuarantined;
/**
*
*
@@ -106,16 +109,14 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
{
$mailed = false;
if ( ! ! (int) $this->get_prefs(__CLASS__, $user->get_id())) {
$to = array('email' => $user->get_email(), 'name' => $user->get_display_name());
$from = array(
'email' => $this->app['phraseanet.registry']->get('GV_defaulmailsenderaddr'),
'name' => $this->app['phraseanet.registry']->get('GV_homeTitle')
);
if (self::mail($to, $from, $datas)) {
if ($this->shouldSendNotificationFor($user->get_id())) {
try {
$receiver = Receiver::fromUser($user);
$mail = MailInfoRecordQuarantined::create($this->app, $receiver);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
} catch (\Exception $e) {
}
}
@@ -173,20 +174,6 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
return _('be notified when a document is placed in quarantine');
}
/**
* @return boolean
*/
public function mail($to, $from, $datas)
{
$subject = _('A document has been quarantined');
$datas = $this->datas($datas, false);
$body = $datas['text'];
return \mail::send_mail($this->app, $subject, $body, $to, $from);
}
/**
*
* @return boolean

View File

@@ -11,12 +11,8 @@
use Alchemy\Phrasea\Application;
/**
*
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationRequest;
class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
{
/**
@@ -92,22 +88,36 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $params['to']) != '0');
if ($send_notif) {
$to = array(
'email' => $params['to_email'],
'name' => $params['to_name']
);
$from = array(
'email' => $params['from_email'],
'name' => $params['from_email']
);
$message = $params['message'];
$url = $params['url'];
$accuse = $params['accuse'];
if ($this->shouldSendNotificationFor($params['to'])) {
try {
$user_from = User_Adapter::getInstance($params['from'], $this->app);
$user_to = User_Adapter::getInstance($params['to'], $this->app);
} catch (Exception $e) {
return false;
}
if (self::mail($to, $from, $message, $url, $accuse))
try {
$basket = $this->app['EM']
->getRepository('\Entities\Basket')
->find($params['ssel_id']);
$title = $basket->getName();
} catch (\Exception $e) {
$title = '';
}
$receiver = Receiver::fromUser($user_to);
$emitter = Receiver::fromUser($user_from);
try {
$mail = MailInfoValidationRequest::create($this->app, $receiver, $emitter, $params['message']);
$mail->setUrl($params['url']);
$mail->setTitle($title);
$this->app['notification.deliverer']->deliver($mail, $params['accuse']);
$mailed = true;
} catch (\Exception $e) {
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
@@ -178,34 +188,6 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
return _('Recevoir des notifications lorsqu\'on me demande une validation');
}
/**
*
* @param Array $to
* @param Array $from
* @param string $message
* @param string $url
* @param boolean $accuse
* @return boolean
*/
public function mail($to, $from, $message, $url, $accuse)
{
$subject = _('push::mail:: Demande de validation de documents');
$body = '<div>' . sprintf(
_('Le lien suivant vous propose de valider une selection faite par %s'), $from['name']
)
. "</div>\n";
$body .= "<br/>\n";
$body .= '<div><a href="' . $url
. '" target="_blank">' . $url . "</a></div>\n" . $message;
$body .= "<br/>\n<br/>\n<br/>\n"
. _('push::atention: ce lien est unique et son contenu confidentiel, ne divulguez pas');
return mail::send_mail($this->app, $subject, $body, $to, $from, array(), $accuse);
}
/**
*
* @return boolean

View File

@@ -11,12 +11,8 @@
use Alchemy\Phrasea\Application;
/**
*
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationDone;
class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
{
/**
@@ -88,9 +84,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$mailed = false;
$send_notif = ($this->get_prefs(__CLASS__, $params['to']) != '0');
if ($send_notif) {
if ($this->shouldSendNotificationFor($params['to'])) {
try {
$user_from = User_Adapter::getInstance($params['from'], $this->app);
$user_to = User_Adapter::getInstance($params['to'], $this->app);
@@ -98,17 +92,28 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
return false;
}
$to = array(
'email' => $user_to->get_email(),
'name' => $user_to->get_display_name()
);
$from = array(
'email' => $user_from->get_email(),
'name' => $user_from->get_display_name()
);
try {
$basket = $this->app['EM']
->getRepository('\Entities\Basket')
->find($params['ssel_id']);
$title = $basket->getName();
} catch (\Exception $e) {
$title = '';
}
if (self::mail($to, $from, $params['ssel_id'], $params['url']))
$receiver = Receiver::fromUser($user_to);
$emitter = Receiver::fromUser($user_from);
try {
$mail = MailInfoValidationDone::create($this->app, $receiver, $emitter);
$mail->setUrl($params['url']);
$mail->setTitle($title);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
} catch (\Exception $e) {
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
@@ -173,36 +178,6 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
return _('Reception d\'un rapport de validation');
}
/**
*
* @param Array $to
* @param Array $from
* @param int $ssel_id
* @return boolean
*/
public function mail($to, $from, $ssel_id, $url)
{
try {
$repository = $this->app['EM']->getRepository('\Entities\Basket');
$basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['phraseanet.user'], false);
} catch (Exception $e) {
return false;
}
$subject = sprintf(
_('push::mail:: Rapport de validation de %1$s pour %2$s'), $from['name'], $basket->getName()
);
$body = "<div>" . sprintf(
_('%s a rendu son rapport, consulter le en ligne a l\'adresse suivante'), $from['name']
) . "</div>\n";
$body .= "<br/>\n" . $url;
return mail::send_mail($this->app, $subject, $body, $to, $from, array());
}
/**
*
* @return boolean

View File

@@ -10,13 +10,9 @@
*/
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationReminder;
use Alchemy\Phrasea\Notification\Receiver;
/**
*
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstract
{
/**
@@ -96,20 +92,30 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
return false;
}
$send_notif = ($this->get_prefs(__CLASS__, $params['to']) != '0');
if ($send_notif) {
$to = array(
'email' => $user_to->get_email(),
'name' => $user_to->get_display_name()
);
$from = array(
'email' => $user_from->get_email(),
'name' => $user_from->get_display_name()
);
$url = $params['url'];
if ($this->shouldSendNotificationFor($params['to'])) {
if (self::mail($to, $from, $url))
try {
$basket = $this->app['EM']
->getRepository('\Entities\Basket')
->find($params['ssel_id']);
$title = $basket->getName();
} catch (\Exception $e) {
$title = '';
}
$receiver = Receiver::fromUser($user_to);
$emitter = Receiver::fromUser($user_from);
try {
$mail = MailInfoValidationReminder::create($this->app, $receiver, $emitter);
$mail->setUrl($params['url']);
$mail->setTitle($title);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
} catch (\Exception $e) {
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
@@ -178,40 +184,6 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
return _('Rappel pour une demande de validation');
}
/**
*
* @param Array $to
* @param Array $from
* @param string $url
* @return boolean
*/
public function mail($to, $from, $url)
{
$subject = _('push::mail:: Rappel de demande de validation de documents');
$body = "<div>"
. sprintf(
_('Il ne vous reste plus que %d jours pour terminer votre validation'), $this->app['phraseanet.registry']->get('GV_validation_reminder'))
. "</div>\n";
if (trim($url) != '') {
$body = '<div>'
. sprintf(
_('Le lien suivant vous propose de valider une selection faite par %s'), $from['name']
) . "</div>\n";
$body .= "<br/>\n";
$body .= '<div><a href="' . $url
. '" target="_blank">' . $url . "</a></div>\n";
}
$body .= "<br/>\n<br/>\n<br/>\n"
. _('push::atention: ce lien est unique et son contenu confidentiel, ne divulguez pas');
return mail::send_mail($this->app, $subject, $body, $to, $from, array());
}
/**
*
* @return string

View File

@@ -29,4 +29,9 @@ abstract class eventsmanager_notifyAbstract extends eventsmanager_eventAbstract
return $user->getPrefs('notification_' . $class);
}
protected function shouldSendNotificationFor($usr_id)
{
return 0 !== (int) $this->get_prefs(get_class($this), $usr_id);
}
}

View File

@@ -4,20 +4,6 @@ use Alchemy\Phrasea\Application;
class mail
{
public static function mail_test(Application $app, $email)
{
$from = array('email' => $app['phraseanet.registry']->get('GV_defaulmailsenderaddr'), 'name' => $app['phraseanet.registry']->get('GV_defaulmailsenderaddr'));
$subject = _('mail:: test d\'envoi d\'email');
$message = sprintf(_('Ce mail est un test d\'envoi de mail depuis %s'), $app['phraseanet.registry']->get('GV_ServerName'));
$to = array('email' => $email, 'name' => $email);
return self::send_mail($app, $subject, $message, $to, $from);
}
public static function ftp_sent(Application $app, $email, $subject, $body)
{
$to = array('email' => $email, 'name' => $email);
@@ -34,227 +20,4 @@ class mail
return self::send_mail($app, $subject, $body, $to);
}
public static function send_documents(Application $app, $email, $url, $from, $endate_obj, $message = '', $accuse)
{
$subject = _('export::vous avez recu des documents');
$body = '<div>' . _('Vous avez recu des documents, vous pourrez les telecharger a ladresse suivante ') . "</div>\n";
$body .= "<a title='' href='" . $url . "'>" . $url . "</a>\n";
$body .= '<br><div>' .
sprintf(
_('Attention, ce lien lien est valable jusqu\'au %s'), $app['date-formatter']->getDate($endate_obj) . ' ' . $app['date-formatter']->getTime($endate_obj)
)
. '</div>';
if ($message != '') {
$body .= "<div>---------------------------------------------------</div>\n" . $message;
}
$to = array('email' => $email, 'name' => $email);
return self::send_mail($app, $subject, $body, $to, $from, array(), $accuse);
}
public static function forgot_passord(Application $app, $email, $login, $url)
{
$subject = _('login:: Forgot your password'); // Registration order on .
$body = "<div>" . _('login:: Quelqu\'un a demande a reinitialiser le mode passe correspondant au login suivant : ') . "</div><div>\n\n" . $login . "</div>\n\n";
$body .= "<div>" . _('login:: Visitez le lien suivant et suivez les instructions pour continuer, sinon ignorez cet email et il ne se passera rien') . "</div>\n\n";
$body .= "<div>" . '<a href="' . $url . '">' . $url . '</a>' . "</div>\n";
$to = array('email' => $email, 'name' => $email);
return self::send_mail($app, $subject, $body, $to);
}
public static function register_confirm(Application $app, $email, $accept, $deny)
{
$subject = sprintf(_('login::register:email: Votre compte %s'), $app['phraseanet.registry']->get('GV_homeTitle'));
$body = '<div>' . _('login::register:email: Voici un compte rendu du traitement de vos demandes d\'acces :') . "</div>\n";
if ($accept != '') {
$body .= "<br/>\n<div>" . _('login::register:email: Vous avez ete accepte sur les collections suivantes : ') . "</div>\n<ul>" . $accept . "</ul>\n";
}
if ($deny != '') {
$body .= "<br/>\n<div>" . _('login::register:email: Vous avez ete refuse sur les collections suivantes : ') . "</div>\n<ul>" . $deny . "</ul>\n";
}
$to = array('email' => $email, 'name' => $email);
return self::send_mail($app, $subject, $body, $to);
}
public static function reset_email(Application $app, $email, $usr_id)
{
$date = new DateTime('1 day');
$token = random::getUrlToken($app, \random::TYPE_EMAIL, $usr_id, $date, $email);
$url = $app['phraseanet.registry']->get('GV_ServerName') . 'account/reset-email/?token=' . $token;
$subject = _('login::register: sujet email : confirmation de votre adresse email');
$body = "<div>" . _('admin::compte-utilisateur: email changement de mot d\'email Bonjour, nous avons bien recu votre demande de changement d\'adresse e-mail. Pour la confirmer, veuillez suivre le lien qui suit. SI vous recevez ce mail sans l\'avoir sollicite, merci de le detruire et de l\'ignorer.') . "</div>\n";
$body .= "<div><a href='" . $url . "'>" . $url . "</a></div>\n";
$to = array('email' => $email, 'name' => $email);
return self::send_mail($app, $subject, $body, $to);
}
public static function change_mail_information(Application $app, $display_name, $old_email, $new_email)
{
$subject = sprintf(_('Update of your email address on %s'), $app['phraseanet.registry']->get('GV_homeTitle'));
$body = "<div>" . sprintf(_('Dear %s,'), $display_name) . "</div>\n<br/>\n";
$body .= "<div>" . _('Your contact email address has been updated') . "</div>\n<br/>\n";
if ($old_email) {
$body .= "<div>" . sprintf(_('You will no longer receive notifications at %s'), sprintf('<b>%s</b>', $old_email)) . "</div>\n";
}
if ($new_email) {
$body .= "<div>" . sprintf(_('You will now receive notifications at %s'), sprintf('<b>%s</b>', $new_email)) . "</div>\n";
}
$to_old = array('email' => $old_email, 'name' => $display_name);
$to_new = array('email' => $new_email, 'name' => $display_name);
$res_old = $old_email ? self::send_mail($app, $subject, $body, $to_old) : true;
$res_new = $new_email ? self::send_mail($app, $subject, $body, $to_new) : true;
return $res_old && $res_new;
}
public static function send_credentials(Application $app, $url, $login, $email)
{
$subject = sprintf(_('Your account on %s'), $app['phraseanet.registry']->get('GV_homeTitle'));
$body = "<div>" . sprintf(_('Your account with the login %s as been created'), $login) . "</div><br/>\n\n";
$body .= "<div>" . _('Please follow this url to setup your password') . "</div>\n";
$body .= "<div><a href=\"" . $url . "\">" . $url . "</a></div>\n";
$to = array('email' => $email, 'name' => $email);
return self::send_mail($app, $subject, $body, $to);
}
public static function mail_confirm_registered(Application $app, $email)
{
$subject = _('login::register: sujet email : confirmation de votre adresse email');
$body = "<div>" . _('login::register: merci d\'avoir confirme votre adresse email') . "</div>\n";
$body .= "<br/><div>" . _('login::register: vous pouvez maintenant vous connecter a l\'adresse suivante : ') . "</div>\n";
$body .= "<div><a href='" . $app['phraseanet.registry']->get('GV_ServerName') . "' target='_blank'>" . $app['phraseanet.registry']->get('GV_ServerName') . "</a></div>\n";
$to = array('email' => $email, 'name' => $email);
return self::send_mail($app, $subject, $body, $to);
}
public static function mail_confirm_unregistered(Application $app, $email, array $others)
{
$subject = _('login::register: sujet email : confirmation de votre adresse email');
$body = "<div>" . _('login::register: merci d\'avoir confirme votre adresse email') . "</div>\n";
$body .= "<br/>\n<div>" . _('login::register: vous devez attendre la confirmation d\'un administrateur ; vos demandes sur les collections suivantes sont toujours en attente : ') . "</div>\n";
$body .= "<ul>";
foreach ($others as $other) {
$body .= sprintf("<li>%s</li>", $other);
}
$body .= "</ul>\n";
$body .= "<br/>\n<div>" . _('login::register : vous serez avertis par email lorsque vos demandes seront traitees') . "</div>\n";
$to = array('email' => $email, 'name' => $email);
return self::send_mail($app, $subject, $body, $to);
}
public static function mail_confirmation(Application $app, $email, $usr_id)
{
$expire = new DateTime('+3 days');
$token = random::getUrlToken($app, \random::TYPE_PASSWORD, $usr_id, $expire, $email);
$subject = _('login::register: sujet email : confirmation de votre adresse email');
$body = "<div>" . _('login::register: email confirmation email Pour valider votre inscription a la base de donnees, merci de confirmer votre e-mail en suivant le lien ci-dessous.') . "</div>\n";
$body .= "<br/>\n<div><a href='" . $app['phraseanet.registry']->get('GV_ServerName') . "register-confirm/?code=" . $token . "' target='_blank'>" . $app['phraseanet.registry']->get('GV_ServerName') . "register-confirm/code=" . $token . "</a></div>\n";
$to = array('email' => $email, 'name' => $email);
return self::send_mail($app, $subject, $body, $to);
}
public static function send_mail(Application $app, $subject, $body, $to, $from = false, $files = array(), $reading_confirm_to = false)
{
if ( ! isset($to['email']) || !\Swift_Validate::email($to['email'])) {
return false;
}
$mail = new PHPMailer();
$body .= "<br/><br/><br/><br/>\n\n\n\n";
$body .= '<div style="font-style:italic;">' . _('si cet email contient des liens non cliquables copiez/collez ces liens dans votre navigateur.') . '</div>';
$body .= "<br/>\n";
$body .= '<div style="font-style:italic;">' . _('phraseanet::signature automatique des notifications par mail, infos a l\'url suivante') . "</div>\n";
$body .= '<div><a href="' . $app['phraseanet.registry']->get('GV_ServerName') . '">' . $app['phraseanet.registry']->get('GV_ServerName') . "</a></div>\n";
$body = '<body>' . $body . '</body>';
try {
$mail->CharSet = 'utf-8';
$mail->Encoding = 'base64'; //'quoted-printable';
if ($app['phraseanet.registry']->get('GV_smtp')) {
$mail->IsSMTP();
if ($app['phraseanet.registry']->get('GV_smtp_host') != '')
$mail->Host = $app['phraseanet.registry']->get('GV_smtp_host');
if ($app['phraseanet.registry']->get('GV_smtp_auth')) {
$mail->SMTPAuth = true;
if ($app['phraseanet.registry']->get('GV_smtp_secure') === true) {
$mail->SMTPSecure = "ssl";
}
$mail->Host = $app['phraseanet.registry']->get('GV_smtp_host');
$mail->Port = $app['phraseanet.registry']->get('GV_smtp_port');
$mail->Username = $app['phraseanet.registry']->get('GV_smtp_user');
$mail->Password = $app['phraseanet.registry']->get('GV_smtp_password');
}
}
if ($from && trim($from['email']) != '')
$mail->AddReplyTo($from['email'], $from['name']);
$mail->AddAddress($to['email'], $to['name']);
$mail->SetFrom($app['phraseanet.registry']->get('GV_defaulmailsenderaddr'), $app['phraseanet.registry']->get('GV_homeTitle'));
$mail->Subject = $subject;
$mail->AltBody = html_entity_decode(strip_tags($body), ENT_QUOTES, 'UTF-8');
if ($reading_confirm_to) {
$mail->ConfirmReadingTo = $reading_confirm_to;
}
$mail->MsgHTML(strip_tags($body, '<div><br><ul><li><em><strong><span><br><a>'));
foreach ($files as $f) {
$mail->AddAttachment($f); // attachment
}
if ($app->getEnvironment() !== 'test') {
$mail->Send();
}
return true;
} catch (phpmailerException $e) {
return $e->errorMessage();
} catch (Exception $e) {
return $e->getMessage();
}
}
}

View File

@@ -8,11 +8,9 @@
* file that was distributed with this source code.
*/
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Alchemy\Phrasea\Notification\Mail\MailSuccessFTP;
use Alchemy\Phrasea\Notification\Receiver;
class task_period_ftp extends task_appboxAbstract
{
protected $proxy;
@@ -650,26 +648,27 @@ class task_period_ftp extends task_appboxAbstract
$ftp_server = $row['addr'];
}
$message = "\n<br/>----------------------------------------<br/>\n";
$message = "<div>" . $connection_status . "</div>\n";
$message .= "<div>" . $transfert_status . "</div>\n";
$message .= "<div>" . _("task::ftp:Details des fichiers") . "</div>\n";
$message = "\n\n----------------------------------------\n\n";
$message = $connection_status . "\n";
$message .= $transfert_status . "\n";
$message .= _("task::ftp:Details des fichiers") . "\n\n";
$message .= "<ul>";
$message .= implode("\n", $transferts);
$message .= "</ul>";
$sender_message = $text_mail_sender . $message;
$receiver_message = $text_mail_receiver . $message;
$subject = sprintf(
_('task::ftp:Status about your FTP transfert from %1$s to %2$s')
, $this->dependencyContainer['phraseanet.registry']->get('GV_homeTitle'), $ftp_server
);
$receiver = new Receiver(null, $sendermail);
$mail = MailSuccessFTP::create($this->dependencyContainer, $receiver, null, $sender_message);
$mail->setServer($ftp_server);
mail::ftp_sent($this->dependencyContainer, $sendermail, $subject, $sender_message);
$this->dependencyContainer['notification.deliverer']->deliver($mail);
mail::ftp_receive($this->dependencyContainer, $mail, $receiver_message);
$receiver = new Receiver(null, $mail);
$mail = MailSuccessFTP::create($this->dependencyContainer, $receiver, null, $receiver_message);
$mail->setServer($ftp_server);
$this->dependencyContainer['notification.deliverer']->deliver($mail);
}
public function logexport(record_adapter $record, $obj, $ftpLog)

View File

@@ -53,6 +53,13 @@
<!-- End of message table -->
</td>
</tr>
{% if expirationMessage is defined %}
<tr>
<td colspan="2" width="720" height="60" valign="center" align="center" style="font-family:sans-serif,'Lucida Console'; font-size:15px; font-weight:bold; text-transform:uppercase; color:#494949;">
Le lien suivant est valable jusque {{ expirationMessage | app['date-formater']->getDate() }} {{ expirationMessage | app['date-formater']->getTime() }}
</td>
</tr>
{% endif %}
{% if buttonText is defined and buttonUrl is defined %}
<tr>
<td colspan="2" width="720" height="70" valign="center" align="center" style="">