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