Blog notification

This commit is contained in:
fredtempez 2021-01-08 10:49:31 +01:00
parent beff8b1012
commit f22eda7e6d
1 changed files with 16 additions and 10 deletions

View File

@ -81,13 +81,13 @@ class blog extends common {
public static $articleConsent = [ public static $articleConsent = [
self::EDIT_ALL => 'Tous les groupes', self::EDIT_ALL => 'Tous les groupes',
self::EDIT_GROUP => 'Groupe du propriétaire', self::EDIT_GROUP => 'Groupe du propriétaire',
self::EDIT_OWNER => 'Propiétaire' self::EDIT_OWNER => 'Propriétaire'
]; ];
public static $users = []; public static $users = [];
const BLOG_VERSION = '4.1'; const BLOG_VERSION = '4.2';
/** /**
* Flux RSS * Flux RSS
@ -627,22 +627,28 @@ class blog extends common {
foreach($this->getData(['user']) as $userId => $user) { foreach($this->getData(['user']) as $userId => $user) {
if ($user['group'] >= $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentGroupNotification']) ) { if ($user['group'] >= $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentGroupNotification']) ) {
$to[] = $user['mail']; $to[] = $user['mail'];
$firstname[] = $user['firstname'];
$lastname[] = $user['lastname'];
} }
} }
// Envoi du mail $sent code d'erreur ou de réussite // Envoi du mail $sent code d'erreur ou de réussite
$notification = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentApproved']) === true ? 'Commentaire déposé en attente d\'approbation': 'Commentaire déposé'; $notification = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentApproved']) === true ? 'Commentaire déposé en attente d\'approbation': 'Commentaire déposé';
if ($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentNotification']) === true) { if ($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentNotification']) === true) {
$sent = $this->sendMail( $error = 0;
$to, foreach($to as $key => $adress){
'Nouveau commentaire déposé', $sent = $this->sendMail(
'Bonjour<br><br>' . $adress,
'L\'article <a href="' . helper::baseUrl() . $this->getUrl(0) . '/ ' . $this->getUrl(1) . '">' . $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'title']) . '</a> a reçu un nouveau commentaire.<br><br>', 'Nouveau commentaire déposé',
'' 'Bonjour' . ' <strong>' . $firstname[$key] . ' ' . $lastname[$key] . '</strong>,<br><br>' .
); 'L\'article <a href="' . helper::baseUrl() . $this->getUrl(0) . '/ ' . $this->getUrl(1) . '">' . $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'title']) . '</a> a reçu un nouveau commentaire.<br><br>',
''
);
if( $sent === false) $error++;
}
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl() . '#comment', 'redirect' => helper::baseUrl() . $this->getUrl() . '#comment',
'notification' => ($sent === true ? $notification . '<br/>Une notification a été envoyée.' : $notification . '<br/> Erreur de notification : ' . $sent), 'notification' => ($error === 0 ? $notification . '<br/>Une notification a été envoyée.' : $notification . '<br/> Erreur de notification : ' . $sent),
'state' => ($sent === true ? true : null) 'state' => ($sent === true ? true : null)
]); ]);