Skip to content
Snippets Groups Projects

Hotline 6.54

Merged Patrick Barroca requested to merge hotline_6.54 into master
Compare and
+ 113
40
Preferences
Compare changes
Files
@@ -269,6 +269,7 @@ class Admin_CmsController extends ZendAfi_Controller_Action {
$post[$content_field] = Class_CmsUrlTransformer::forSaving($post['ckeditor_'.$content_field]);
unset($post['ckeditor_'.$content_field]);
}
return $article
->updateAttributes($post)
->save();
@@ -285,13 +286,22 @@ class Admin_CmsController extends ZendAfi_Controller_Action {
protected function _notifyArticleChanged($article) {
$this->_sendMailWhenUpdatedStatusToValidationPending($article);
$this->_sendMailWhenUpdatedStatusToRefused($article);
$this->_sendMailWhenUpdatedStatusToValidated($article);
}
protected function _sendMailWhenUpdatedStatusToRefused($article) {
if ($article->old_status != Class_Article::STATUS_REFUSED &&
$article->getStatus() == Class_Article::STATUS_REFUSED) {
$this->_sendMailToAuteur($article);
$this->_sendRefusedMailToAuteur($article);
}
}
protected function _sendMailWhenUpdatedStatusToValidated($article) {
if ($article->old_status != Class_Article::STATUS_VALIDATED &&
$article->getStatus() == Class_Article::STATUS_VALIDATED) {
$this->_sendValidatedMailToAuteur($article);
}
}
@@ -304,8 +314,8 @@ class Admin_CmsController extends ZendAfi_Controller_Action {
}
protected function _sendMailToAuteur($article) {
$mail = new ZendAfi_Mail('utf8');
protected function prepareMailForAuteur($article) {
$mail = new ZendAfi_Mail('utf8');
if(!$article->getAuteur()) {
$this->_helper->notify('Mail non envoyé: article sans auteur');
return;
@@ -315,22 +325,42 @@ class Admin_CmsController extends ZendAfi_Controller_Action {
return;
}
$body = $article->getRefusMessage();
$body = str_replace('TITRE_ARTICLE',
$article->getTitre(),
$body);
$body = str_replace('URL_ARTICLE',
$this->view->absoluteUrl($article->getUrl(), null, true),
$body);
$mail->setFrom('no-reply@no-reply-afi.fr')
->addTo($mail_address);
return $mail;
}
protected function prepareBodyMail($article, $message) {
$message = str_replace('TITRE_ARTICLE', $article->getTitre(), $message);
$message = str_replace('URL_ARTICLE', $this->view->absoluteUrl($article->getUrl(), null, true), $message);
return $message;
}
protected function _sendRefusedMailToAuteur($article) {
if(!$mail = $this->prepareMailForAuteur($article))
return;
$body = $this->prepareBodyMail($article, $article->getRefusMessage());
$this->sendPreparedMail($mail, '[Bokeh] Refus de l\'article '.$article->getTitre(), $body);
}
protected function sendPreparedMail($mail, $subject, $body) {
$mail->setSubject(quoted_printable_decode($subject))
->setBodyText($body,'utf-8',Zend_Mime::ENCODING_8BIT);
$mail
->setFrom('no-reply@no-reply-afi.fr')
->addTo($mail_address)
->setSubject(quoted_printable_decode('[Bokeh] Refus de l\'article '.$article->getTitre()))
->setBodyText($body,'utf-8',Zend_Mime::ENCODING_8BIT);
if($this->_sendMail($mail))
$this->_helper->notify('Mail envoyé à: '.$mail_address);
$this->_helper->notify('Mail envoyé à: '.$mail->getRecipients()[0]);
}
protected function _sendValidatedMailToAuteur($article) {
if(!$mail = $this->prepareMailForAuteur($article))
return;
$body = $this->prepareBodyMail($article, $article->getValideMessage());
$this->sendPreparedMail($mail, '[Bokeh] Validation de l\'article '.$article->getTitre(), $body);
}