diff --git a/application/controllers/User.php b/application/controllers/User.php index 20a0c9ea..d01378ff 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -96,14 +96,14 @@ class User extends EA_Controller { if (empty($username)) { - throw new InvalidArgumentException('Empty username provided.'); + throw new InvalidArgumentException('No username value provided.'); } $password = request('password'); if (empty($password)) { - throw new InvalidArgumentException('Empty password provided.'); + throw new InvalidArgumentException('No password value provided.'); } $user_data = $this->accounts->check_login($username, $password); @@ -153,15 +153,13 @@ class User extends EA_Controller { if ($new_password) { - $email = new EmailClient($this, $this->config->config); - $settings = [ 'company_name' => setting('company_name'), 'company_link' => setting('company_link'), 'company_email' => setting('company_email') ]; - $email->send_password(new NonEmptyText($new_password), new Email(request('email')), $settings); + $this->email_messages->send_password($new_password, $email, $settings); } json_response([ diff --git a/application/libraries/Notifications.php b/application/libraries/Notifications.php index 5933519a..e69819ec 100644 --- a/application/libraries/Notifications.php +++ b/application/libraries/Notifications.php @@ -11,16 +11,11 @@ * @since v1.4.0 * ---------------------------------------------------------------------------- */ -use EA\Engine\Notifications\Email as EmailClient; -use EA\Engine\Types\Email; -use EA\Engine\Types\Text; -use EA\Engine\Types\Url; - /** * Notifications library * * Handles the notifications related functionality. - * + * * @package Libraries */ class Notifications { @@ -43,6 +38,7 @@ class Notifications { $this->CI->load->model('secretaries_model'); $this->CI->load->model('settings_model'); + $this->CI->load->library('email_messages'); $this->CI->load->library('ics_file'); $this->CI->load->library('timezones'); } @@ -61,25 +57,30 @@ class Notifications { { try { - $email = new EmailClient($this->CI, $this->CI->config->config); - if ($manage_mode) { - $customer_title = new Text(lang('appointment_changes_saved')); - $customer_message = new Text(''); - $provider_title = new Text(lang('appointment_details_changed')); - $provider_message = new Text(''); + $customer_subject = lang('appointment_changes_saved'); + + $customer_message = ''; + + $provider_subject = lang('appointment_details_changed'); + + $provider_message = ''; } else { - $customer_title = new Text(lang('appointment_booked')); - $customer_message = new Text(lang('thank_you_for_appointment')); - $provider_title = new Text(lang('appointment_added_to_your_plan')); - $provider_message = new Text(lang('appointment_link_description')); + $customer_subject = lang('appointment_booked'); + + $customer_message = lang('thank_you_for_appointment'); + + $provider_subject = lang('appointment_added_to_your_plan'); + + $provider_message = lang('appointment_link_description'); } - $customer_link = new Url(site_url('appointments/index/' . $appointment['hash'])); - $provider_link = new Url(site_url('backend/index/' . $appointment['hash'])); + $customer_link = site_url('appointments/index/' . $appointment['hash']); + + $provider_link = site_url('backend/index/' . $appointment['hash']); $ics_stream = $this->CI->ics_file->get_stream($appointment, $service, $provider, $customer); @@ -91,17 +92,17 @@ class Notifications { if ($send_customer === TRUE) { - $email->send_appointment_details( + $this->CI->email_messages->send_appointment_details( $appointment, $provider, $service, $customer, $settings, - $customer_title, + $customer_subject, $customer_message, $customer_link, - new Email($customer['email']), - new Text($ics_stream), + $customer['email'], + $ics_stream, $customer['timezone'] ); } @@ -114,17 +115,17 @@ class Notifications { if ($send_provider === TRUE) { - $email->send_appointment_details( + $this->CI->email_messages->send_appointment_details( $appointment, $provider, $service, $customer, $settings, - $provider_title, + $provider_subject, $provider_message, $provider_link, - new Email($provider['email']), - new Text($ics_stream), + $provider['email'], + $ics_stream, $provider['timezone'] ); } @@ -139,17 +140,17 @@ class Notifications { continue; } - $email->send_appointment_details( + $this->CI->email_messages->send_appointment_details( $appointment, $provider, $service, $customer, $settings, - $provider_title, + $provider_subject, $provider_message, $provider_link, - new Email($admin['email']), - new Text($ics_stream), + $admin['email'], + $ics_stream, $admin['timezone'] ); } @@ -169,17 +170,17 @@ class Notifications { continue; } - $email->send_appointment_details( + $this->CI->email_messages->send_appointment_details( $appointment, $provider, $service, $customer, $settings, - $provider_title, + $provider_subject, $provider_message, $provider_link, - new Email($secretary['email']), - new Text($ics_stream), + $secretary['email'], + $ics_stream, $secretary['timezone'] ); } @@ -204,8 +205,6 @@ class Notifications { { try { - $email = new EmailClient($this->CI, $this->CI->config->config); - $delete_reason = (string)request('delete_reason'); if (empty($delete_reason)) @@ -214,19 +213,21 @@ class Notifications { } // Notify provider. - $send_provider = filter_var($this->CI->providers_model->get_setting('notifications', $provider['id']), - FILTER_VALIDATE_BOOLEAN); + $send_provider = filter_var( + $this->CI->providers_model->get_setting($provider['id'], 'notifications'), + FILTER_VALIDATE_BOOLEAN + ); if ($send_provider === TRUE) { - $email->send_delete_appointment( + $this->CI->email_messages->send_delete_appointment( $appointment, $provider, $service, $customer, $settings, - new Email($provider['email']), - new Text($delete_reason) + $provider['email'], + $delete_reason ); } @@ -238,14 +239,14 @@ class Notifications { if ($send_customer === TRUE) { - $email->send_delete_appointment( + $this->CI->email_messages->send_delete_appointment( $appointment, $provider, $service, $customer, $settings, - new Email($customer['email']), - new Text($delete_reason) + $customer['email'], + $delete_reason ); } @@ -259,14 +260,14 @@ class Notifications { continue; } - $email->send_delete_appointment( + $this->CI->email_messages->send_delete_appointment( $appointment, $provider, $service, $customer, $settings, - new Email($admin['email']), - new Text($delete_reason) + $admin['email'], + $delete_reason ); } @@ -285,14 +286,14 @@ class Notifications { continue; } - $email->send_delete_appointment( + $this->CI->email_messages->send_delete_appointment( $appointment, $provider, $service, $customer, $settings, - new Email($secretary['email']), - new Text($delete_reason) + $secretary['email'], + $delete_reason ); } }