mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Update notifications
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user