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

@@ -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,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 = "<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) {
return false;
$this->app['notification.deliverer']->deliver($mail);
return true;
} catch (\Exception $e) {
}
$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 false;
}
/**

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);
}
}