From 53b22b4c57641889e309096335f9ae0d025fa689 Mon Sep 17 00:00:00 2001 From: noud Date: Wed, 5 Sep 2012 09:08:44 +0200 Subject: [PATCH] Sync. On publish and no configured GnuPG, do tell event is published but no email sent. --- app/Controller/EventsController.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index d5bad4a98..678ad0668 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -533,12 +533,19 @@ class EventsController extends AppController { // only allow form submit CSRF protection. if ($this->request->is('post') || $this->request->is('put')) { // send out the email - if ($this->_sendAlertEmail($id)) { + $emailResult = $this->_sendAlertEmail($id); + if (is_bool($emailResult) && $emailResult = true) { // Performs all the actions required to publish an event $this->_publish($id); // redirect to the view event page $this->Session->setFlash(__('Email sent to all participants.', true)); + } elseif (!is_bool($emailResult)) { + // Performs all the actions required to publish an event + $this->_publish($id); + + // redirect to the view event page + $this->Session->setFlash(__('Published but no email sent given GnuPG is not configured.', true)); } else { $this->Session->setFlash('Sending of email failed', 'default', array(), 'error'); } @@ -656,6 +663,7 @@ class EventsController extends AppController { } catch (Exception $e){ // catch errors like expired PGP keys $this->log($e->getMessage()); + return $e->getMessage(); } // If you wish to send multiple emails using a loop, you'll need // to reset the email fields using the reset method of the Email component. @@ -664,6 +672,7 @@ class EventsController extends AppController { } catch (Exception $e){ // catch errors like expired PGP keys $this->log($e->getMessage()); + return $e->getMessage(); } // LATER check if sending email succeeded and return appropriate result