From 635380512d5f0f132c62ef5a0e96714a3c05e9fc Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 7 Mar 2016 20:59:04 +0100 Subject: [PATCH] Converted all the hard-coded urls to site_url() function calls. --- src/application/controllers/appointments.php | 14 ++++---------- src/application/controllers/backend.php | 14 +++++++------- src/application/controllers/backend_api.php | 12 ++---------- src/application/controllers/test.php | 4 ++-- src/application/controllers/user.php | 4 ++-- src/application/libraries/google_sync.php | 4 ++-- src/application/views/appointments/book.php | 7 +++---- src/application/views/backend/footer.php | 2 +- src/application/views/general/error404.php | 2 +- src/application/views/user/forgot_password.php | 4 ++-- src/application/views/user/login.php | 2 +- src/application/views/user/logout.php | 4 ++-- src/application/views/user/no_privileges.php | 2 +- 13 files changed, 30 insertions(+), 45 deletions(-) diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index 717c941a..7636e11a 100755 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -417,25 +417,19 @@ class Appointments extends CI_Controller { if ($post_data['manage_mode'] == FALSE) { $customer_title = $this->lang->line('appointment_booked'); $customer_message = $this->lang->line('thank_you_for_appointment'); - $customer_link = $this->config->item('base_url') . '/index.php/appointments/index/' - . $appointment['hash']; - $provider_title = $this->lang->line('appointment_added_to_your_plan'); $provider_message = $this->lang->line('appointment_link_description'); - $provider_link = $this->config->item('base_url') . '/index.php/backend/index/' - . $appointment['hash']; + } else { $customer_title = $this->lang->line('appointment_changes_saved'); $customer_message = ''; - $customer_link = $this->config->item('base_url') . '/index.php/appointments/index/' - . $appointment['hash']; - $provider_title = $this->lang->line('appointment_details_changed'); $provider_message = ''; - $provider_link = $this->config->item('base_url') . '/index.php/backend/index/' - . $appointment['hash']; } + $customer_link = site_url('appointments/index/' . $appointment['hash']); + $provider_link = site_url('backend/index/' . $appointment['hash']); + $send_customer = filter_var($this->settings_model->get_setting('customer_notifications'), FILTER_VALIDATE_BOOLEAN); diff --git a/src/application/controllers/backend.php b/src/application/controllers/backend.php index 23a8f634..eadde513 100644 --- a/src/application/controllers/backend.php +++ b/src/application/controllers/backend.php @@ -42,7 +42,7 @@ class Backend extends CI_Controller { * appear when the page loads. */ public function index($appointment_hash = '') { - $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend'); + $this->session->set_userdata('dest_url', site_url('backend')); if (!$this->has_privileges(PRIV_APPOINTMENTS)) return; $this->load->model('appointments_model'); @@ -92,7 +92,7 @@ class Backend extends CI_Controller { * In this page the user can manage all the customer records of the system. */ public function customers() { - $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/customers'); + $this->session->set_userdata('dest_url', site_url('backend/customers')); if (!$this->has_privileges(PRIV_CUSTOMERS)) return; $this->load->model('providers_model'); @@ -126,7 +126,7 @@ class Backend extends CI_Controller { * from the backend services page. */ public function services() { - $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/services'); + $this->session->set_userdata('dest_url', site_url('backend/services')); if (!$this->has_privileges(PRIV_SERVICES)) return; $this->load->model('customers_model'); @@ -156,7 +156,7 @@ class Backend extends CI_Controller { * the page where the admin defines which service can each provider provide. */ public function users() { - $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/users'); + $this->session->set_userdata('dest_url', site_url('backend/users')); if (!$this->has_privileges(PRIV_USERS)) return; $this->load->model('providers_model'); @@ -191,7 +191,7 @@ class Backend extends CI_Controller { * installation (core settings like company name, book timeout etc). */ public function settings() { - $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/settings'); + $this->session->set_userdata('dest_url', site_url('backend/settings')); if (!$this->has_privileges(PRIV_SYSTEM_SETTINGS, FALSE) && !$this->has_privileges(PRIV_USER_SETTINGS)) return; @@ -241,7 +241,7 @@ class Backend extends CI_Controller { $user_id = $this->session->userdata('user_id'); if ($user_id == FALSE) { // User not logged in, display the login view. if ($redirect) { - header('Location: ' . $this->config->item('base_url') . '/index.php/user/login'); + header('Location: ' . site_url('user/login')); } return FALSE; } @@ -251,7 +251,7 @@ class Backend extends CI_Controller { $role_priv = $this->db->get_where('ea_roles', array('slug' => $role_slug))->row_array(); if ($role_priv[$page] < PRIV_VIEW) { // User does not have the permission to view the page. if ($redirect) { - header('Location: ' . $this->config->item('base_url') . '/index.php/user/no_privileges'); + header('Location: ' . site_url('user/no_privileges')); } return FALSE; } diff --git a/src/application/controllers/backend_api.php b/src/application/controllers/backend_api.php index f793d9ea..26fbd398 100644 --- a/src/application/controllers/backend_api.php +++ b/src/application/controllers/backend_api.php @@ -208,25 +208,17 @@ class Backend_api extends CI_Controller { if (!$manage_mode) { $customer_title = $this->lang->line('appointment_booked'); $customer_message = $this->lang->line('thank_you_for_appointment'); - $customer_link = $this->config->item('base_url') . '/index.php/appointments/index/' - . $appointment['hash']; - $provider_title = $this->lang->line('appointment_added_to_your_plan'); $provider_message = $this->lang->line('appointment_link_description'); - $provider_link = $this->config->item('base_url') . '/index.php/backend/index/' - . $appointment['hash']; } else { $customer_title = $this->lang->line('appointment_changes_saved'); $customer_message = ''; - $customer_link = $this->config->item('base_url') . '/index.php/appointments/index/' - . $appointment['hash']; - $provider_title = $this->lang->line('appointment_details_changed'); $provider_message = ''; - $provider_link = $this->config->item('base_url') . '/index.php/backend/index/' - . $appointment['hash']; } + $customer_link = site_url('appointments/index/' . $appointment['hash']); + $provider_link = site_url('backend/index/' . $appointment['hash']); $send_customer = $this->settings_model->get_setting('customer_notifications'); diff --git a/src/application/controllers/test.php b/src/application/controllers/test.php index bdaed42a..4ffd3f0f 100644 --- a/src/application/controllers/test.php +++ b/src/application/controllers/test.php @@ -38,9 +38,9 @@ class Test extends CI_Controller { public function index() { // User must be logged in as an admin in order to run the tests. $this->load->library('session'); - $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/test'); + $this->session->set_userdata('dest_url', site_url('test')); if ($this->session->userdata('role_slug') != DB_SLUG_ADMIN) { - header('Location: ' . $this->config->item('base_url') . '/index.php/user/login'); + header('Location: ' . site_url('user/login')); return; } diff --git a/src/application/controllers/user.php b/src/application/controllers/user.php index b5cddce6..27f3321c 100644 --- a/src/application/controllers/user.php +++ b/src/application/controllers/user.php @@ -39,7 +39,7 @@ class User extends CI_Controller { * The default method will redirect the browser to the user/login URL. */ public function index() { - header('Location: ' . $this->config->item('base_url') . '/index.php/user/login'); + header('Location: ' . site_url('user/login')); } /** @@ -52,7 +52,7 @@ class User extends CI_Controller { $view['dest_url'] = $this->session->userdata('dest_url'); if (!$view['dest_url']) { - $view['dest_url'] = $view['base_url'] . '/index.php/backend'; + $view['dest_url'] = site_url('backend'); } $view['company_name'] = $this->settings_model->get_setting('company_name'); diff --git a/src/application/libraries/google_sync.php b/src/application/libraries/google_sync.php index ce3c236a..1055a54c 100644 --- a/src/application/libraries/google_sync.php +++ b/src/application/libraries/google_sync.php @@ -1,4 +1,4 @@ -client->setClientId(Config::GOOGLE_CLIENT_ID); $this->client->setClientSecret(Config::GOOGLE_CLIENT_SECRET); $this->client->setDeveloperKey(Config::GOOGLE_API_KEY); - $this->client->setRedirectUri($this->CI->config->item('base_url') . '/index.php/google/oauth_callback'); + $this->client->setRedirectUri(site_url('google/oauth_callback')); $this->service = new Google_CalendarService($this->client); } diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php index a694be30..5050828d 100644 --- a/src/application/views/appointments/book.php +++ b/src/application/views/appointments/book.php @@ -141,8 +141,7 @@
+ action="' . site_url('appointments/cancel/' . $appointment_data['hash']) . '">
@@ -423,7 +422,7 @@ session->userdata('user_id')): ?> | - + lang->line('backend_section'); ?> diff --git a/src/application/views/backend/footer.php b/src/application/views/backend/footer.php index f89111fc..95c29611 100644 --- a/src/application/views/backend/footer.php +++ b/src/application/views/backend/footer.php @@ -15,7 +15,7 @@ config->item('language')); ?> | - + lang->line('go_to_booking_page') ?> diff --git a/src/application/views/general/error404.php b/src/application/views/general/error404.php index 94203ffa..a6f5e43d 100644 --- a/src/application/views/general/error404.php +++ b/src/application/views/general/error404.php @@ -113,7 +113,7 @@ lang->line('book_appointment_title'); ?> - + lang->line('backend_section'); ?> diff --git a/src/application/views/user/forgot_password.php b/src/application/views/user/forgot_password.php index cde1a0b4..e9e10bb1 100644 --- a/src/application/views/user/forgot_password.php +++ b/src/application/views/user/forgot_password.php @@ -100,7 +100,7 @@ $('.alert').removeClass('hidden alert-danger alert-success'); $('#get-new-password').prop('disabled', false); - + if (!GeneralFunctions.handleAjaxExceptions(response)) return; if (response == GlobalVariables.AJAX_SUCCESS) { @@ -138,7 +138,7 @@ lang->line('regenerate_password'); ?> - + lang->line('go_to_login'); ?> diff --git a/src/application/views/user/login.php b/src/application/views/user/login.php index c2b7da38..1646546c 100644 --- a/src/application/views/user/login.php +++ b/src/application/views/user/login.php @@ -140,7 +140,7 @@

- + lang->line('forgot_your_password'); ?> | diff --git a/src/application/views/user/logout.php b/src/application/views/user/logout.php index 8754f20c..e3bac1b3 100644 --- a/src/application/views/user/logout.php +++ b/src/application/views/user/logout.php @@ -71,12 +71,12 @@
- + lang->line('book_appointment_title'); ?> - + lang->line('backend_section'); ?> diff --git a/src/application/views/user/no_privileges.php b/src/application/views/user/no_privileges.php index 3c486559..f1723d3f 100644 --- a/src/application/views/user/no_privileges.php +++ b/src/application/views/user/no_privileges.php @@ -70,7 +70,7 @@
- + lang->line('backend_calendar'); ?>