From 8fd024d34ddac21f63bf7d54607129c655782196 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 24 Nov 2015 23:12:37 +0100 Subject: [PATCH] Added check before sending the notification. --- src/application/controllers/appointments.php | 21 ++++++++++++----- src/application/controllers/backend_api.php | 21 ++++++++++++----- src/application/libraries/notifications.php | 24 -------------------- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index 0ec72250..fdca4bbf 100755 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -192,9 +192,14 @@ class Appointments extends CI_Controller { $_POST['cancel_reason']); } - $this->notifications->send_delete_appointment($appointment, $provider, - $service, $customer, $company_settings, $customer['email'], - $_POST['cancel_reason']); + $send_customer = $this->settings_model->get_setting('customer_notifications'); + + if ((bool)$send_customer === TRUE) { + $this->notifications->send_delete_appointment($appointment, $provider, + $service, $customer, $company_settings, $customer['email'], + $_POST['cancel_reason']); + } + } catch(Exception $exc) { $exceptions[] = $exc; } @@ -458,9 +463,13 @@ class Appointments extends CI_Controller { . $appointment['hash']; } - $this->notifications->send_appointment_details($appointment, $provider, - $service, $customer,$company_settings, $customer_title, - $customer_message, $customer_link, $customer['email']); + $send_customer = $this->settings_model->get_setting('customer_notifications'); + + if ((bool)$send_customer === TRUE) { + $this->notifications->send_appointment_details($appointment, $provider, + $service, $customer,$company_settings, $customer_title, + $customer_message, $customer_link, $customer['email']); + } if ($send_provider == TRUE) { $this->notifications->send_appointment_details($appointment, $provider, diff --git a/src/application/controllers/backend_api.php b/src/application/controllers/backend_api.php index ad7268a1..0ece9d4c 100644 --- a/src/application/controllers/backend_api.php +++ b/src/application/controllers/backend_api.php @@ -230,9 +230,14 @@ class Backend_api extends CI_Controller { . $appointment['hash']; } - $this->notifications->send_appointment_details($appointment, $provider, - $service, $customer, $company_settings, $customer_title, - $customer_message, $customer_link, $customer['email']); + + $send_customer = $this->settings_model->get_setting('customer_notifications'); + + if ((bool)$send_customer === TRUE) { + $this->notifications->send_appointment_details($appointment, $provider, + $service, $customer, $company_settings, $customer_title, + $customer_message, $customer_link, $customer['email']); + } if ($send_provider == TRUE) { $this->notifications->send_appointment_details($appointment, $provider, @@ -329,9 +334,13 @@ class Backend_api extends CI_Controller { $_POST['delete_reason']); } - $this->notifications->send_delete_appointment($appointment, $provider, - $service, $customer, $company_settings, $customer['email'], - $_POST['delete_reason']); + $send_customer = $this->settings_model->get_setting('customer_notifications'); + + if ((bool)$send_customer === TRUE) { + $this->notifications->send_delete_appointment($appointment, $provider, + $service, $customer, $company_settings, $customer['email'], + $_POST['delete_reason']); + } } catch(Exception $exc) { $warnings[] = exceptionToJavaScript($exc); } diff --git a/src/application/libraries/notifications.php b/src/application/libraries/notifications.php index 60c75235..87a59d0c 100644 --- a/src/application/libraries/notifications.php +++ b/src/application/libraries/notifications.php @@ -240,30 +240,6 @@ class Notifications { return TRUE; } - - /** - * Sends a simple email to notify for a new installation. - * - * This method will be only used for tracking the number of installations. No personal - * data will be retrieved for any other cause. - * - * @returns bool Returns the "send()" method result. - */ - public function send_new_installation($company_name, $company_email, $company_link) { - $mail = new PHPMailer(); - $mail->From = $company_email; - $mail->FromName = 'New Installation: ' . $company_name ; - $mail->AddAddress('info@easyappointments.org'); - $mail->IsHTML(true); - $mail->CharSet = 'UTF-8'; - $mail->Subject = 'New Easy!Appointments Installation'; - $mail->Body = 'Base URL: ' . $this->ci->config->item('base_url') . '
' - . 'E!A Version: ' . $this->ci->config->item('ea_version') . '
' - . 'Company Name: ' . $company_name . '
' - . 'Company Email: ' . $company_email . '
' - . 'Company Link: ' . $company_link . '
'; - return $mail->Send(); - } } /* End of file notifications.php */