diff --git a/src/application/controllers/Appointments.php b/src/application/controllers/Appointments.php index 1c880153..a13bdbbe 100755 --- a/src/application/controllers/Appointments.php +++ b/src/application/controllers/Appointments.php @@ -121,12 +121,18 @@ class Appointments extends CI_Controller { $provider = $this->providers_model->get_row($appointment['id_users_provider']); $customer = $this->customers_model->get_row($appointment['id_users_customer']); + $customer_token = md5(uniqid(mt_rand(), true)); + + $this->load->driver('cache', ['adapter' => 'file']); + + $this->cache->save('customer-token-' . $customer_token, $customer['id'], 600); // save for 10 minutes } else { // The customer is going to book a new appointment so there is no // need for the manage functionality to be initialized. $manage_mode = FALSE; + $customer_token = FALSE; $appointment = []; $provider = []; $customer = []; @@ -138,6 +144,7 @@ class Appointments extends CI_Controller { 'available_providers' => $available_providers, 'company_name' => $company_name, 'manage_mode' => $manage_mode, + 'customer_token' => $customer_token, 'date_format' => $date_format, 'time_format' => $time_format, 'appointment_data' => $appointment, diff --git a/src/application/controllers/Privacy.php b/src/application/controllers/Privacy.php new file mode 100644 index 00000000..7ace6546 --- /dev/null +++ b/src/application/controllers/Privacy.php @@ -0,0 +1,62 @@ + + * @copyright Copyright (c) 2013 - 2018, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.3.2 + * ---------------------------------------------------------------------------- */ + +/** + * Class Privacy + * + * @package Controllers + */ +class Privacy extends CI_Controller { + /** + * Remove all customer data (including appointments from the system). + */ + public function ajax_delete_personal_information() + { + try + { + $customer_token = $this->input->post('customer_token'); + + if (empty($customer_token)) + { + throw new InvalidArgumentException('Invalid customer token value provided.'); + } + + $this->load->driver('cache', ['adapter' => 'file']); + + $customer_id = $this->cache->get('customer-token-' . $customer_token); + + if (empty($customer_id)) + { + throw new InvalidArgumentException('Customer ID could not be found, please reload the page and try again.'); + } + + $this->load->model('customers_model'); + + $this->customers_model->delete($customer_id); + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode([ + 'success' => TRUE + ])); + } + catch (Exception $exc) + { + $this->output + ->set_content_type('application/json') + ->set_output(json_encode([ + 'exceptions' => [exceptionToJavaScript($exc)] + ])); + } + } +} diff --git a/src/application/language/english/translations_lang.php b/src/application/language/english/translations_lang.php index 081308af..fcb7c6e5 100755 --- a/src/application/language/english/translations_lang.php +++ b/src/application/language/english/translations_lang.php @@ -295,3 +295,6 @@ $lang['privacy_policy_content'] = 'Privacy Policy Content'; $lang['website_using_cookies_to_ensure_best_experience'] = 'This website uses cookies to ensure you get the best experience on our website.'; $lang['read_and_agree_to_terms_and_conditions'] = 'I have read and agree to the {$link}Terms & Conditions{/$link}.'; $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link}Privacy Policy{/$link}.'; +$lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; +$lang['delete_personal_information'] = 'Delete Personal Information'; +$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php index 6d08a11b..20b99982 100755 --- a/src/application/views/appointments/book.php +++ b/src/application/views/appointments/book.php @@ -46,27 +46,29 @@ - -
' . - lang('cancel_appointment_hint') . - '
-