diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php
index 529325ef0f..ea80c442cc 100644
--- a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php
+++ b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php
@@ -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');
diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php
index bc6c32173a..70a7736a58 100644
--- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php
+++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php
@@ -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) {
+
+ }
}
}
}
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php
index 5f563e7202..779666f9f2 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Export.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Export.php
@@ -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) {
+
}
}
diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php
index 25a1a9609a..91556f7f69 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Account.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php
@@ -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');
}
diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php
index 25a5cbe3f1..f28fdbfb19 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Login.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php
@@ -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)) {
- return $app->redirect('/login/?notice=mail-sent');
- }
+ $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¬ice=confirm-ok-wait');
- }
-
- return $app->redirect('/login/?redirect=prod¬ice=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()));
diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php
index 74902ee440..8b0f26047a 100644
--- a/lib/Alchemy/Phrasea/Helper/User/Edit.php
+++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php
@@ -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;
diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php
index 5cd0032aad..9d402ffb0d 100644
--- a/lib/Alchemy/Phrasea/Helper/User/Manage.php
+++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php
@@ -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);
}
}
diff --git a/lib/Alchemy/Phrasea/Notification/Deliverer.php b/lib/Alchemy/Phrasea/Notification/Deliverer.php
index 9fa8fba811..454997f988 100644
--- a/lib/Alchemy/Phrasea/Notification/Deliverer.php
+++ b/lib/Alchemy/Phrasea/Notification/Deliverer.php
@@ -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);
}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php
index a4e5621935..6db3ef631a 100644
--- a/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php
+++ b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php
@@ -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);
}
}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/AbstractMailWithLink.php b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMailWithLink.php
new file mode 100644
index 0000000000..83bfd3cead
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMailWithLink.php
@@ -0,0 +1,19 @@
+url = $url;
+ }
+
+ public function setExpiration(\DateTime $expiration = null)
+ {
+ $this->expiration = $expiration;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php
new file mode 100644
index 0000000000..a15bae1a97
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoBridgeUploadFailed.php
@@ -0,0 +1,39 @@
+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()
+ {
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php
new file mode 100644
index 0000000000..d3e77e8858
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php
@@ -0,0 +1,36 @@
+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'));
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php
new file mode 100644
index 0000000000..b2eb8ed1c7
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php
@@ -0,0 +1,39 @@
+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;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php
new file mode 100644
index 0000000000..b12e6a1974
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php
@@ -0,0 +1,43 @@
+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'));
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php
new file mode 100644
index 0000000000..6017b5c093
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php
@@ -0,0 +1,50 @@
+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()
+ );
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php
new file mode 100644
index 0000000000..88ba10c799
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php
@@ -0,0 +1,41 @@
+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;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php
new file mode 100644
index 0000000000..62e260a136
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoRecordQuarantined.php
@@ -0,0 +1,26 @@
+app['phraseanet.registry']->get('GV_ServerName'));
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php
new file mode 100644
index 0000000000..0d6294d7ea
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php
@@ -0,0 +1,29 @@
+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';
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php
new file mode 100644
index 0000000000..5e832b8ebb
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php
@@ -0,0 +1,37 @@
+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'));
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php
new file mode 100644
index 0000000000..15e863a613
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php
@@ -0,0 +1,40 @@
+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;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php
new file mode 100644
index 0000000000..3d0278a43e
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationReminder.php
@@ -0,0 +1,36 @@
+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;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php
new file mode 100644
index 0000000000..0edc373580
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php
@@ -0,0 +1,33 @@
+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;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php
new file mode 100644
index 0000000000..4fdf3f01fc
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRecordsExport.php
@@ -0,0 +1,35 @@
+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;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php
new file mode 100644
index 0000000000..f50407843d
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailConfirmation.php
@@ -0,0 +1,35 @@
+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;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php
new file mode 100644
index 0000000000..308c8cd8b6
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestEmailUpdate.php
@@ -0,0 +1,26 @@
+url;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php
new file mode 100644
index 0000000000..44822dbaa0
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordSetup.php
@@ -0,0 +1,35 @@
+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;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php
new file mode 100644
index 0000000000..75d23f692e
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailRequestPasswordUpdate.php
@@ -0,0 +1,28 @@
+url;
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccessRequest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccessRequest.php
new file mode 100644
index 0000000000..b5f6eb200e
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessAccessRequest.php
@@ -0,0 +1,29 @@
+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');
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php
new file mode 100644
index 0000000000..00f652a150
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationRegistered.php
@@ -0,0 +1,26 @@
+app['phraseanet.registry']->get('GV_homeTile'));
+ }
+
+ public function buttonURL()
+ {
+ return $this->app['phraseanet.registry']->get('GV_ServerName');
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php
new file mode 100644
index 0000000000..e051468ae9
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailConfirmationUnregistered.php
@@ -0,0 +1,29 @@
+app['url_generator']->generate('account_access');
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php
new file mode 100644
index 0000000000..056b908da2
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessEmailUpdate.php
@@ -0,0 +1,30 @@
+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');
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessFTP.php b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessFTP.php
new file mode 100644
index 0000000000..0a9a7de410
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailSuccessFTP.php
@@ -0,0 +1,34 @@
+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()
+ {
+ }
+}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailTest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailTest.php
index 24bb39bec6..4929b8698f 100644
--- a/lib/Alchemy/Phrasea/Notification/Mail/MailTest.php
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailTest.php
@@ -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()
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailWithLinkInterface.php b/lib/Alchemy/Phrasea/Notification/Mail/MailWithLinkInterface.php
new file mode 100644
index 0000000000..d3d65f7a2d
--- /dev/null
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailWithLinkInterface.php
@@ -0,0 +1,9 @@
+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,64 +189,25 @@ 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 = "
" . _('admin::register: un utilisateur s\'est inscrit')
- . "
\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) {
- return false;
+ $this->app['notification.deliverer']->deliver($mail);
+
+ return true;
+ } catch (\Exception $e) {
}
- $body .= "
\nLogin : " . $registered_user->get_login() . "
\n";
- $body .= "" . _('admin::compte-utilisateur nom')
- . " : " . $registered_user->get_firstname() . "
\n";
- $body .= "" . _('admin::compte-utilisateur prenom')
- . " : " . $registered_user->get_lastname() . "
\n";
- $body .= "" . _('admin::compte-utilisateur email')
- . " : " . $registered_user->get_email() . "
\n";
- $body .= "" . _('admin::compte-utilisateur adresse')
- . " : " . $registered_user->get_address() . "
\n";
- $body .= "" . $registered_user->get_city() . " "
- . $registered_user->get_zipcode() . "
\n";
- $body .= "" . _('admin::compte-utilisateur telephone')
- . " : " . $registered_user->get_tel() . "
\n";
- $body .= "" . _('admin::compte-utilisateur fax')
- . " : " . $registered_user->get_fax() . "
\n";
- $body .= "" . _('admin::compte-utilisateur poste')
- . "/" . _('admin::compte-utilisateur societe') . " "
- . $registered_user->get_job() . " " . $registered_user->get_company()
- . "
\n";
-
- $base_ids = $sx->base_ids;
-
- $body .= "
\n"
- . _('admin::register: l\'utilisateur s\'est inscrit sur les bases suivantes')
- . "
\n";
- $body .= "\n";
-
- foreach ($base_ids->base_id as $base_id) {
- $body .= "- "
- . phrasea::sbas_names(phrasea::sbasFromBas($this->app, (string) $base_id), $this->app)
- . ' - ' . phrasea::bas_names((string) $base_id, $this->app) . "
\n";
- }
-
- $body .= "
\n";
-
- $body .= "
\n\n";
-
- return mail::send_mail($this->app, $subject, $body, $to, $from);
+ return false;
}
/**
diff --git a/lib/classes/eventsmanager/notify/bridgeuploadfail.php b/lib/classes/eventsmanager/notify/bridgeuploadfail.php
index c67029d7ba..020fc9cfd9 100644
--- a/lib/classes/eventsmanager/notify/bridgeuploadfail.php
+++ b/lib/classes/eventsmanager/notify/bridgeuploadfail.php
@@ -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
diff --git a/lib/classes/eventsmanager/notify/downloadmailfail.php b/lib/classes/eventsmanager/notify/downloadmailfail.php
index a893769a4a..b10124bf84 100644
--- a/lib/classes/eventsmanager/notify/downloadmailfail.php
+++ b/lib/classes/eventsmanager/notify/downloadmailfail.php
@@ -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();
diff --git a/lib/classes/eventsmanager/notify/feed.php b/lib/classes/eventsmanager/notify/feed.php
index 06626bbcca..17afd36e65 100644
--- a/lib/classes/eventsmanager/notify/feed.php
+++ b/lib/classes/eventsmanager/notify/feed.php
@@ -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 = ""
- . sprintf('%s vient de publier %s', $entry->get_author_name(), $entry->get_title())
- . _('Connectez vous a l\'adresse suivante pour la consulter')
- . "
\n";
-
- $body .= '\n";
-
- $body .= "
";
-
- $body .= "
\n
\n
\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());
- }
}
diff --git a/lib/classes/eventsmanager/notify/order.php b/lib/classes/eventsmanager/notify/order.php
index d78e7e7afb..978364c9b2 100644
--- a/lib/classes/eventsmanager/notify/order.php
+++ b/lib/classes/eventsmanager/notify/order.php
@@ -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 = ""
- . _('admin::register: un utilisateur a commande des documents')
- . "
\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 .= "
\nLogin : "
- . $registered_user->get_login() . "
\n";
- $body .= "" . _('admin::compte-utilisateur nom')
- . " : " . $registered_user->get_firstname() . "
\n";
- $body .= "" . _('admin::compte-utilisateur prenom')
- . " : " . $registered_user->get_lastname() . "
\n";
- $body .= "" . _('admin::compte-utilisateur email')
- . " : " . $registered_user->get_email() . "
\n";
- $body .= "" . _('admin::compte-utilisateur adresse')
- . " : " . $registered_user->get_address() . "
\n";
- $body .= "" . $registered_user->get_city()
- . " " . $registered_user->get_zipcode() . "
\n";
- $body .= "" . _('admin::compte-utilisateur telephone')
- . " : " . $registered_user->get_tel() . "
\n";
- $body .= "" . _('admin::compte-utilisateur fax')
- . " : " . $registered_user->get_fax() . "
\n";
- $body .= "" . _('admin::compte-utilisateur poste')
- . "/" . _('admin::compte-utilisateur societe')
- . " " . $registered_user->get_job()
- . " " . $registered_user->get_company() . "
\n";
-
- $base_ids = $sx->base_ids;
-
- $body .= "
\n"
- . _('Retrouvez son bon de commande dans l\'interface')
- . "
\n";
-
- return mail::send_mail($this->app, $subject, $body, $to, $from);
- }
-
/**
*
* @return boolean
diff --git a/lib/classes/eventsmanager/notify/orderdeliver.php b/lib/classes/eventsmanager/notify/orderdeliver.php
index c9208556e2..1d4a524fd0 100644
--- a/lib/classes/eventsmanager/notify/orderdeliver.php
+++ b/lib/classes/eventsmanager/notify/orderdeliver.php
@@ -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 = ""
- . sprintf(
- _('%s vous a delivre votre commande, consultez la en ligne a l\'adresse suivante'), $from['name']
- ) . "
\n";
-
- $body .= "
\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
diff --git a/lib/classes/eventsmanager/notify/ordernotdelivered.php b/lib/classes/eventsmanager/notify/ordernotdelivered.php
index 72e51539b3..ce98074f3e 100644
--- a/lib/classes/eventsmanager/notify/ordernotdelivered.php
+++ b/lib/classes/eventsmanager/notify/ordernotdelivered.php
@@ -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 = ""
- . sprintf(
- _('%s a refuse %d elements de votre commande'), $from['name'], $n
- ) . "
\n";
-
- return mail::send_mail($this->app, $subject, $body, $to, $from, array());
- }
-
/**
*
* @return boolean
diff --git a/lib/classes/eventsmanager/notify/push.php b/lib/classes/eventsmanager/notify/push.php
index 3fbd4dcddd..ecdf02eb66 100644
--- a/lib/classes/eventsmanager/notify/push.php
+++ b/lib/classes/eventsmanager/notify/push.php
@@ -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 = ""
- . _('push::Vous pouvez vous connecter a l\'adresse suivante afin de retrouver votre panier, voir les previews, les descriptions, le telecharger, etc.')
- . "
\n";
-
- $body .= '\n";
-
- $body .= "
";
-
- $body .= $message;
-
- $body .= "
\n
\n
\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);
- }
}
diff --git a/lib/classes/eventsmanager/notify/register.php b/lib/classes/eventsmanager/notify/register.php
index b2e9cdf902..d69e8839a2 100644
--- a/lib/classes/eventsmanager/notify/register.php
+++ b/lib/classes/eventsmanager/notify/register.php
@@ -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 = ""
- . _('admin::register: un utilisateur a fait une demande d\'inscription')
- . "
\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 .= "
\nLogin : "
- . $registered_user->get_login() . "
\n";
- $body .= "" . _('admin::compte-utilisateur nom')
- . " : " . $registered_user->get_firstname() . "
\n";
- $body .= "" . _('admin::compte-utilisateur prenom')
- . " : " . $registered_user->get_lastname() . "
\n";
- $body .= "" . _('admin::compte-utilisateur email')
- . " : " . $registered_user->get_email() . "
\n";
- $body .= "" . _('admin::compte-utilisateur adresse')
- . " : " . $registered_user->get_address() . "
\n";
- $body .= "" . $registered_user->get_city()
- . " " . $registered_user->get_zipcode() . "
\n";
- $body .= "" . _('admin::compte-utilisateur telephone')
- . " : " . $registered_user->get_tel() . "
\n";
- $body .= "" . _('admin::compte-utilisateur fax')
- . " : " . $registered_user->get_fax() . "
\n";
- $body .= "" . _('admin::compte-utilisateur poste')
- . "/" . _('admin::compte-utilisateur societe')
- . " " . $registered_user->get_job()
- . " " . $registered_user->get_company() . "
\n";
-
- $base_ids = $sx->base_ids;
-
- $body .= "
\n"
- . _('admin::register: les demandes de l\'utilisateur portent sur les bases suivantes')
- . "
\n";
- $body .= "\n";
-
- foreach ($base_ids->base_id as $base_id) {
- $body .= "- "
- . phrasea::sbas_names(phrasea::sbasFromBas($this->app, (string) $base_id), $this->app)
- . ' - '
- . phrasea::bas_names((string) $base_id, $this->app) . "
\n";
- }
-
- $body .= "
\n";
-
- $body .= "
\n\n";
-
- return mail::send_mail($this->app, $subject, $body, $to, $from);
- }
-
/**
*
* @return boolean
diff --git a/lib/classes/eventsmanager/notify/uploadquarantine.php b/lib/classes/eventsmanager/notify/uploadquarantine.php
index 1f624f235f..86142721cd 100644
--- a/lib/classes/eventsmanager/notify/uploadquarantine.php
+++ b/lib/classes/eventsmanager/notify/uploadquarantine.php
@@ -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
diff --git a/lib/classes/eventsmanager/notify/validate.php b/lib/classes/eventsmanager/notify/validate.php
index 2febe3436e..815a6f3b27 100644
--- a/lib/classes/eventsmanager/notify/validate.php
+++ b/lib/classes/eventsmanager/notify/validate.php
@@ -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 = '' . sprintf(
- _('Le lien suivant vous propose de valider une selection faite par %s'), $from['name']
- )
- . "
\n";
-
- $body .= "
\n";
- $body .= '\n" . $message;
-
- $body .= "
\n
\n
\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
diff --git a/lib/classes/eventsmanager/notify/validationdone.php b/lib/classes/eventsmanager/notify/validationdone.php
index a11b841b8e..a58c23f493 100644
--- a/lib/classes/eventsmanager/notify/validationdone.php
+++ b/lib/classes/eventsmanager/notify/validationdone.php
@@ -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 = "" . sprintf(
- _('%s a rendu son rapport, consulter le en ligne a l\'adresse suivante'), $from['name']
- ) . "
\n";
-
- $body .= "
\n" . $url;
-
- return mail::send_mail($this->app, $subject, $body, $to, $from, array());
- }
-
/**
*
* @return boolean
diff --git a/lib/classes/eventsmanager/notify/validationreminder.php b/lib/classes/eventsmanager/notify/validationreminder.php
index 6f60a4bb86..4d31f9faa5 100644
--- a/lib/classes/eventsmanager/notify/validationreminder.php
+++ b/lib/classes/eventsmanager/notify/validationreminder.php
@@ -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 = ""
- . sprintf(
- _('Il ne vous reste plus que %d jours pour terminer votre validation'), $this->app['phraseanet.registry']->get('GV_validation_reminder'))
- . "
\n";
-
- if (trim($url) != '') {
- $body = ''
- . sprintf(
- _('Le lien suivant vous propose de valider une selection faite par %s'), $from['name']
- ) . "
\n";
-
- $body .= "
\n";
-
- $body .= '\n";
- }
-
- $body .= "
\n
\n
\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
diff --git a/lib/classes/eventsmanager/notifyAbstract.php b/lib/classes/eventsmanager/notifyAbstract.php
index 92ef6ca0ac..88e6c497eb 100644
--- a/lib/classes/eventsmanager/notifyAbstract.php
+++ b/lib/classes/eventsmanager/notifyAbstract.php
@@ -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);
+ }
}
diff --git a/lib/classes/mail.php b/lib/classes/mail.php
index 549f1c95a7..f1598b076b 100644
--- a/lib/classes/mail.php
+++ b/lib/classes/mail.php
@@ -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 = '' . _('Vous avez recu des documents, vous pourrez les telecharger a ladresse suivante ') . "
\n";
- $body .= "" . $url . "\n";
-
- $body .= '
' .
- sprintf(
- _('Attention, ce lien lien est valable jusqu\'au %s'), $app['date-formatter']->getDate($endate_obj) . ' ' . $app['date-formatter']->getTime($endate_obj)
- )
- . '
';
-
- if ($message != '') {
- $body .= "---------------------------------------------------
\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 = "" . _('login:: Quelqu\'un a demande a reinitialiser le mode passe correspondant au login suivant : ') . "
\n\n" . $login . "
\n\n";
- $body .= "" . _('login:: Visitez le lien suivant et suivez les instructions pour continuer, sinon ignorez cet email et il ne se passera rien') . "
\n\n";
- $body .= "\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 = '' . _('login::register:email: Voici un compte rendu du traitement de vos demandes d\'acces :') . "
\n";
-
- if ($accept != '') {
- $body .= "
\n" . _('login::register:email: Vous avez ete accepte sur les collections suivantes : ') . "
\n\n";
- }
- if ($deny != '') {
- $body .= "
\n" . _('login::register:email: Vous avez ete refuse sur les collections suivantes : ') . "
\n\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 = "" . _('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.') . "
\n";
- $body .= "\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 = "" . sprintf(_('Dear %s,'), $display_name) . "
\n
\n";
- $body .= "" . _('Your contact email address has been updated') . "
\n
\n";
-
- if ($old_email) {
- $body .= "" . sprintf(_('You will no longer receive notifications at %s'), sprintf('%s', $old_email)) . "
\n";
- }
-
- if ($new_email) {
- $body .= "" . sprintf(_('You will now receive notifications at %s'), sprintf('%s', $new_email)) . "
\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 = "" . sprintf(_('Your account with the login %s as been created'), $login) . "
\n\n";
- $body .= "" . _('Please follow this url to setup your password') . "
\n";
- $body .= "\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 = "" . _('login::register: merci d\'avoir confirme votre adresse email') . "
\n";
- $body .= "
" . _('login::register: vous pouvez maintenant vous connecter a l\'adresse suivante : ') . "
\n";
- $body .= "\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 = "" . _('login::register: merci d\'avoir confirme votre adresse email') . "
\n";
- $body .= "
\n" . _('login::register: vous devez attendre la confirmation d\'un administrateur ; vos demandes sur les collections suivantes sont toujours en attente : ') . "
\n";
- $body .= "";
- foreach ($others as $other) {
- $body .= sprintf("- %s
", $other);
- }
- $body .= "
\n";
- $body .= "
\n" . _('login::register : vous serez avertis par email lorsque vos demandes seront traitees') . "
\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 = "" . _('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.') . "
\n";
- $body .= "
\n\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 .= "
\n\n\n\n";
- $body .= '' . _('si cet email contient des liens non cliquables copiez/collez ces liens dans votre navigateur.') . '
';
- $body .= "
\n";
- $body .= '' . _('phraseanet::signature automatique des notifications par mail, infos a l\'url suivante') . "
\n";
- $body .= '\n";
- $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, '
'));
-
- 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();
- }
- }
}
diff --git a/lib/classes/task/period/ftp.php b/lib/classes/task/period/ftp.php
index f45840c6f6..5b6c845893 100644
--- a/lib/classes/task/period/ftp.php
+++ b/lib/classes/task/period/ftp.php
@@ -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
----------------------------------------
\n";
- $message = "" . $connection_status . "
\n";
- $message .= "" . $transfert_status . "
\n";
- $message .= "" . _("task::ftp:Details des fichiers") . "
\n";
+ $message = "\n\n----------------------------------------\n\n";
+ $message = $connection_status . "\n";
+ $message .= $transfert_status . "\n";
+ $message .= _("task::ftp:Details des fichiers") . "\n\n";
- $message .= "";
$message .= implode("\n", $transferts);
- $message .= "
";
$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)
diff --git a/templates/web/email-template.html.twig b/templates/web/email-template.html.twig
index 90df00e672..2214197196 100644
--- a/templates/web/email-template.html.twig
+++ b/templates/web/email-template.html.twig
@@ -53,6 +53,13 @@
+ {% if expirationMessage is defined %}
+
+
+ Le lien suivant est valable jusque {{ expirationMessage | app['date-formater']->getDate() }} {{ expirationMessage | app['date-formater']->getTime() }}
+ |
+
+ {% endif %}
{% if buttonText is defined and buttonUrl is defined %}
|