Replaced the notifications library with the new one (fixes #178).
This commit is contained in:
parent
f95dd31ad3
commit
15cfcf2e76
5 changed files with 76 additions and 58 deletions
|
@ -5,10 +5,10 @@
|
|||
// @link https://codeigniter.com/user_guide/libraries/email.html
|
||||
|
||||
$config['useragent'] = 'Easy!Appointments';
|
||||
$config['protocol'] = 'mail';
|
||||
$config['protocol'] = 'smtp';
|
||||
$config['mailtype'] = 'html';
|
||||
// $config['smtp_host'] = '';
|
||||
// $config['smtp_user'] = '';
|
||||
// $config['smtp_pass'] = '';
|
||||
// $config['smtp_crypto'] = 'ssl';
|
||||
// $config['smtp_port'] = 25;
|
||||
$config['smtp_host'] = 'smtp.gmail.com';
|
||||
$config['smtp_user'] = 'johndoe.atdev@gmail.com';
|
||||
$config['smtp_pass'] = 'aPCiALxAgrpwG9RgcqxN';
|
||||
$config['smtp_crypto'] = 'ssl';
|
||||
$config['smtp_port'] = 465;
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
* @since v1.0.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
use \EA\Engine\Types\String;
|
||||
use \EA\Engine\Types\Email;
|
||||
use \EA\Engine\Types\Url;
|
||||
|
||||
/**
|
||||
* Appointments Controller
|
||||
*
|
||||
|
@ -190,24 +194,25 @@ class Appointments extends CI_Controller {
|
|||
|
||||
// :: SEND NOTIFICATION EMAILS TO CUSTOMER AND PROVIDER
|
||||
try {
|
||||
$this->load->library('Notifications');
|
||||
$this->config->load('email');
|
||||
$email = new \EA\Engine\Notifications\Email($this, $this->config->config);
|
||||
|
||||
$send_provider = filter_var($this->providers_model
|
||||
->get_setting('notifications', $provider['id']), FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
if ($send_provider == TRUE) {
|
||||
$this->notifications->send_delete_appointment($appointment, $provider,
|
||||
$service, $customer, $company_settings, $provider['email'],
|
||||
$_POST['cancel_reason']);
|
||||
if ($send_provider === TRUE) {
|
||||
$email->sendDeleteAppointment($appointment, $provider,
|
||||
$service, $customer, $company_settings, new Email($provider['email']),
|
||||
new String($_POST['cancel_reason']));
|
||||
}
|
||||
|
||||
$send_customer = filter_var($this->settings_model->get_setting('customer_notifications'),
|
||||
FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
if ($send_customer === TRUE) {
|
||||
$this->notifications->send_delete_appointment($appointment, $provider,
|
||||
$service, $customer, $company_settings, $customer['email'],
|
||||
$_POST['cancel_reason']);
|
||||
$email->sendDeleteAppointment($appointment, $provider,
|
||||
$service, $customer, $company_settings, new Email($customer['email']),
|
||||
new String($_POST['cancel_reason']));
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
|
@ -412,40 +417,41 @@ class Appointments extends CI_Controller {
|
|||
|
||||
// :: SEND NOTIFICATION EMAILS TO BOTH CUSTOMER AND PROVIDER
|
||||
try {
|
||||
$this->load->library('Notifications');
|
||||
$this->config->load('email');
|
||||
$email = new \EA\Engine\Notifications\Email($this, $this->config->config);
|
||||
|
||||
if ($post_data['manage_mode'] == FALSE) {
|
||||
$customer_title = $this->lang->line('appointment_booked');
|
||||
$customer_message = $this->lang->line('thank_you_for_appointment');
|
||||
$provider_title = $this->lang->line('appointment_added_to_your_plan');
|
||||
$provider_message = $this->lang->line('appointment_link_description');
|
||||
$customer_title = new String($this->lang->line('appointment_booked'));
|
||||
$customer_message = new String($this->lang->line('thank_you_for_appointment'));
|
||||
$provider_title = new String($this->lang->line('appointment_added_to_your_plan'));
|
||||
$provider_message = new String($this->lang->line('appointment_link_description'));
|
||||
|
||||
} else {
|
||||
$customer_title = $this->lang->line('appointment_changes_saved');
|
||||
$customer_message = '';
|
||||
$provider_title = $this->lang->line('appointment_details_changed');
|
||||
$provider_message = '';
|
||||
$customer_title = new String($this->lang->line('appointment_changes_saved'));
|
||||
$customer_message = new String('');
|
||||
$provider_title = new String($this->lang->line('appointment_details_changed'));
|
||||
$provider_message = new String('');
|
||||
}
|
||||
|
||||
$customer_link = site_url('appointments/index/' . $appointment['hash']);
|
||||
$provider_link = site_url('backend/index/' . $appointment['hash']);
|
||||
$customer_link = new Url(site_url('appointments/index/' . $appointment['hash']));
|
||||
$provider_link = new Url(site_url('backend/index/' . $appointment['hash']));
|
||||
|
||||
$send_customer = filter_var($this->settings_model->get_setting('customer_notifications'),
|
||||
FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
if ($send_customer == TRUE) {
|
||||
$this->notifications->send_appointment_details($appointment, $provider,
|
||||
if ($send_customer === TRUE) {
|
||||
$email->sendAppointmentDetails($appointment, $provider,
|
||||
$service, $customer,$company_settings, $customer_title,
|
||||
$customer_message, $customer_link, $customer['email']);
|
||||
$customer_message, $customer_link, new Email($customer['email']));
|
||||
}
|
||||
|
||||
$send_provider = filter_var($this->providers_model ->get_setting('notifications', $provider['id']),
|
||||
FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
if ($send_provider == TRUE) {
|
||||
$this->notifications->send_appointment_details($appointment, $provider,
|
||||
if ($send_provider === TRUE) {
|
||||
$email->sendAppointmentDetails($appointment, $provider,
|
||||
$service, $customer, $company_settings, $provider_title,
|
||||
$provider_message, $provider_link, $provider['email']);
|
||||
$provider_message, $provider_link, new Email($provider['email']));
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
log_message('error', $exc->getMessage());
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
* @since v1.0.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
use \EA\Engine\Types\String;
|
||||
use \EA\Engine\Types\Email;
|
||||
use \EA\Engine\Types\Url;
|
||||
|
||||
/**
|
||||
* Backend API Controller
|
||||
*
|
||||
|
@ -206,38 +210,39 @@ class Backend_api extends CI_Controller {
|
|||
|
||||
// :: SEND EMAIL NOTIFICATIONS TO PROVIDER AND CUSTOMER
|
||||
try {
|
||||
$this->load->library('Notifications');
|
||||
$this->config->load('email');
|
||||
$email = new \EA\Engine\Notifications\Email($this, $this->config->config);
|
||||
|
||||
$send_provider = $this->providers_model
|
||||
->get_setting('notifications', $provider['id']);
|
||||
|
||||
if (!$manage_mode) {
|
||||
$customer_title = $this->lang->line('appointment_booked');
|
||||
$customer_message = $this->lang->line('thank_you_for_appointment');
|
||||
$provider_title = $this->lang->line('appointment_added_to_your_plan');
|
||||
$provider_message = $this->lang->line('appointment_link_description');
|
||||
$customer_title = new String($this->lang->line('appointment_booked'));
|
||||
$customer_message = new String($this->lang->line('thank_you_for_appointment'));
|
||||
$provider_title = new String($this->lang->line('appointment_added_to_your_plan'));
|
||||
$provider_message = new String($this->lang->line('appointment_link_description'));
|
||||
} else {
|
||||
$customer_title = $this->lang->line('appointment_changes_saved');
|
||||
$customer_message = '';
|
||||
$provider_title = $this->lang->line('appointment_details_changed');
|
||||
$provider_message = '';
|
||||
$customer_title = new String($this->lang->line('appointment_changes_saved'));
|
||||
$customer_message = new String('');
|
||||
$provider_title = new String($this->lang->line('appointment_details_changed'));
|
||||
$provider_message = new String('');
|
||||
}
|
||||
|
||||
$customer_link = site_url('appointments/index/' . $appointment['hash']);
|
||||
$provider_link = site_url('backend/index/' . $appointment['hash']);
|
||||
$customer_link = new Url(site_url('appointments/index/' . $appointment['hash']));
|
||||
$provider_link = new Url(site_url('backend/index/' . $appointment['hash']));
|
||||
|
||||
$send_customer = $this->settings_model->get_setting('customer_notifications');
|
||||
|
||||
if ((bool)$send_customer === TRUE) {
|
||||
$this->notifications->send_appointment_details($appointment, $provider,
|
||||
$email->sendAppointmentDetails($appointment, $provider,
|
||||
$service, $customer, $company_settings, $customer_title,
|
||||
$customer_message, $customer_link, $customer['email']);
|
||||
$customer_message, $customer_link, new Email($customer['email']));
|
||||
}
|
||||
|
||||
if ($send_provider == TRUE) {
|
||||
$this->notifications->send_appointment_details($appointment, $provider,
|
||||
$email->sendAppointmentDetails($appointment, $provider,
|
||||
$service, $customer, $company_settings, $provider_title,
|
||||
$provider_message, $provider_link, $provider['email']);
|
||||
$provider_message, $provider_link, new Email($provider['email']));
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
|
@ -318,23 +323,24 @@ class Backend_api extends CI_Controller {
|
|||
|
||||
// :: SEND NOTIFICATION EMAILS TO PROVIDER AND CUSTOMER
|
||||
try {
|
||||
$this->load->library('Notifications');
|
||||
$this->config->load('email');
|
||||
$email = new \EA\Engine\Notifications\Email($this, $this->config->config);
|
||||
|
||||
$send_provider = $this->providers_model
|
||||
->get_setting('notifications', $provider['id']);
|
||||
|
||||
if ($send_provider == TRUE) {
|
||||
$this->notifications->send_delete_appointment($appointment, $provider,
|
||||
$service, $customer, $company_settings, $provider['email'],
|
||||
$_POST['delete_reason']);
|
||||
if ((bool)$send_provider === TRUE) {
|
||||
$email->sendDeleteAppointment($appointment, $provider,
|
||||
$service, $customer, $company_settings, new Email($provider['email']),
|
||||
new String($_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']);
|
||||
$email->sendDeleteAppointment($appointment, $provider,
|
||||
$service, $customer, $company_settings, new Email($customer['email']),
|
||||
new String($_POST['delete_reason']));
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$warnings[] = exceptionToJavaScript($exc);
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
* @since v1.0.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
use \EA\Engine\Types\NonEmptyString;
|
||||
use \EA\Engine\Types\Email;
|
||||
|
||||
/**
|
||||
* User Controller
|
||||
*
|
||||
|
@ -148,13 +151,15 @@ class User extends CI_Controller {
|
|||
$new_password = $this->user_model->regenerate_password($_POST['username'], $_POST['email']);
|
||||
|
||||
if ($new_password != FALSE) {
|
||||
$this->load->library('notifications');
|
||||
$this->config->load('email');
|
||||
$email = new \EA\Engine\Notifications\Email($this, $this->config->config);
|
||||
$company_settings = array(
|
||||
'company_name' => $this->settings_model->get_setting('company_name'),
|
||||
'company_link' => $this->settings_model->get_setting('company_link'),
|
||||
'company_email' => $this->settings_model->get_setting('company_email')
|
||||
);
|
||||
$this->notifications->send_password($new_password, $_POST['email'], $company_settings);
|
||||
|
||||
$email->sendPassword(new NonEmptyString($new_password), new Email($_POST['email']), $company_settings);
|
||||
}
|
||||
|
||||
echo ($new_password != FALSE) ? json_encode(AJAX_SUCCESS) : json_encode(AJAX_FAILURE);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
namespace EA\Engine\Notifications;
|
||||
|
||||
use \EA\Engine\Types\String;
|
||||
use \EA\Engine\Types\NonEmptyString;
|
||||
use \EA\Engine\Types\Url;
|
||||
use \EA\Engine\Types\Email as EmailAddress;
|
||||
|
||||
|
@ -222,11 +223,11 @@ class Email {
|
|||
/**
|
||||
* This method sends an email with the new password of a user.
|
||||
*
|
||||
* @param \EA\Engine\Types\String $password Contains the new password.
|
||||
* @param \EA\Engine\Types\NonEmptyString $password Contains the new password.
|
||||
* @param \EA\Engine\Types\Email $email The receiver's email address.
|
||||
* @param array $company The company settings to be included in the email.
|
||||
*/
|
||||
public function sendPassword(String $password, EmailAddress $recipientEmail, array $company) {
|
||||
public function sendPassword(NonEmptyString $password, EmailAddress $recipientEmail, array $company) {
|
||||
$replaceArray = array(
|
||||
'$email_title' => $this->framework->lang->line('new_account_password'),
|
||||
'$email_message' => $this->framework->lang->line('new_password_is'),
|
||||
|
|
Loading…
Reference in a new issue