diff --git a/application/controllers/Account.php b/application/controllers/Account.php index c7e47686..b95923db 100644 --- a/application/controllers/Account.php +++ b/application/controllers/Account.php @@ -86,7 +86,7 @@ class Account extends EA_Controller { { if (cannot('edit', PRIV_USER_SETTINGS)) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $account = request('account'); diff --git a/application/controllers/Booking.php b/application/controllers/Booking.php index fdf1caa8..25ace397 100755 --- a/application/controllers/Booking.php +++ b/application/controllers/Booking.php @@ -447,7 +447,7 @@ class Booking extends EA_Controller { if ( ! $appointment['id_users_provider']) { - throw new Exception(lang('requested_hour_is_unavailable')); + throw new RuntimeException(lang('requested_hour_is_unavailable')); } $provider = $this->providers_model->find($appointment['id_users_provider']); diff --git a/application/controllers/Booking_settings.php b/application/controllers/Booking_settings.php index 13603c89..1796e82f 100644 --- a/application/controllers/Booking_settings.php +++ b/application/controllers/Booking_settings.php @@ -87,7 +87,7 @@ class Booking_settings extends EA_Controller { { if (cannot('edit', PRIV_SYSTEM_SETTINGS)) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $settings = request('booking_settings', []); diff --git a/application/controllers/Business_settings.php b/application/controllers/Business_settings.php index 3152dcb8..db04ebd2 100644 --- a/application/controllers/Business_settings.php +++ b/application/controllers/Business_settings.php @@ -89,7 +89,7 @@ class Business_settings extends EA_Controller { { if (cannot('edit', PRIV_SYSTEM_SETTINGS)) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $settings = request('business_settings', []); @@ -129,7 +129,7 @@ class Business_settings extends EA_Controller { { if (cannot('edit', PRIV_SYSTEM_SETTINGS)) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $working_plan = request('working_plan'); diff --git a/application/controllers/Calendar.php b/application/controllers/Calendar.php index bfa79d60..d53ee156 100644 --- a/application/controllers/Calendar.php +++ b/application/controllers/Calendar.php @@ -190,7 +190,7 @@ class Calendar extends EA_Controller { if ( ! $required_permissions) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $this->customers_model->only($customer, [ @@ -225,7 +225,7 @@ class Calendar extends EA_Controller { if ($required_permissions == FALSE) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } // If the appointment does not contain the customer record id, then it means that is going to be @@ -298,14 +298,14 @@ class Calendar extends EA_Controller { { if (cannot('delete', 'appointments')) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $appointment_id = request('appointment_id'); if (empty($appointment_id)) { - throw new Exception('No appointment id provided.'); + throw new InvalidArgumentException('No appointment id provided.'); } // Store appointment data for later use in this method. @@ -357,7 +357,7 @@ class Calendar extends EA_Controller { if ( ! $required_permissions) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $provider = $this->providers_model->find($unavailability['id_users_provider']); @@ -390,7 +390,7 @@ class Calendar extends EA_Controller { { if (cannot('delete', PRIV_APPOINTMENTS)) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $unavailability_id = request('unavailability_id'); @@ -424,7 +424,7 @@ class Calendar extends EA_Controller { { if (cannot('edit', PRIV_USERS)) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $date = request('date'); @@ -456,7 +456,7 @@ class Calendar extends EA_Controller { if ( ! $required_permissions) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $date = request('date'); @@ -574,7 +574,7 @@ class Calendar extends EA_Controller { { if (cannot('view', PRIV_APPOINTMENTS)) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $record_id = request('record_id'); diff --git a/application/controllers/General_settings.php b/application/controllers/General_settings.php index dc3b5af5..6d885334 100644 --- a/application/controllers/General_settings.php +++ b/application/controllers/General_settings.php @@ -85,7 +85,7 @@ class General_settings extends EA_Controller { { if (cannot('edit', PRIV_SYSTEM_SETTINGS)) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $settings = request('general_settings', []); diff --git a/application/controllers/Google.php b/application/controllers/Google.php index 83657565..db2186af 100644 --- a/application/controllers/Google.php +++ b/application/controllers/Google.php @@ -386,7 +386,7 @@ class Google extends EA_Controller { if (cannot('edit', PRIV_USERS) && (int)$user_id !== (int)$provider_id) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $calendar_id = request('calendar_id'); @@ -427,7 +427,7 @@ class Google extends EA_Controller { cannot('edit', PRIV_USERS) && (int)$user_id !== (int)$provider_id) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $this->providers_model->set_setting($provider_id, 'google_sync', FALSE); diff --git a/application/controllers/Legal_settings.php b/application/controllers/Legal_settings.php index 4c6196ce..06c30ec4 100644 --- a/application/controllers/Legal_settings.php +++ b/application/controllers/Legal_settings.php @@ -78,7 +78,7 @@ class Legal_settings extends EA_Controller { { if (cannot('edit', PRIV_SYSTEM_SETTINGS)) { - throw new Exception('You do not have the required permissions for this task.'); + throw new RuntimeException('You do not have the required permissions for this task.'); } $settings = request('legal_settings', []); diff --git a/application/controllers/Localization.php b/application/controllers/Localization.php index 1063a007..b04ccb3f 100644 --- a/application/controllers/Localization.php +++ b/application/controllers/Localization.php @@ -35,7 +35,7 @@ class Localization extends EA_Controller { if ( ! in_array($language, config('available_languages'))) { - throw new Exception('Translations for the given language does not exist (' . request('language') . ').'); + throw new RuntimeException('Translations for the given language does not exist (' . request('language') . ').'); } $language = request('language'); diff --git a/application/controllers/api/v1/Providers_api_v1.php b/application/controllers/api/v1/Providers_api_v1.php index f0dc8dba..a42a5e4c 100644 --- a/application/controllers/api/v1/Providers_api_v1.php +++ b/application/controllers/api/v1/Providers_api_v1.php @@ -139,12 +139,12 @@ class Providers_api_v1 extends EA_Controller { if ( ! array_key_exists('services', $provider)) { - throw new Exception('No services property provided.'); + throw new InvalidArgumentException('No services property provided.'); } if ( ! array_key_exists('settings', $provider)) { - throw new Exception('No settings property provided.'); + throw new InvalidArgumentException('No settings property provided.'); } if ( ! array_key_exists('working_plan', $provider['settings'])) diff --git a/application/controllers/api/v1/Secretaries_api_v1.php b/application/controllers/api/v1/Secretaries_api_v1.php index bb9ed64c..fa4cc442 100644 --- a/application/controllers/api/v1/Secretaries_api_v1.php +++ b/application/controllers/api/v1/Secretaries_api_v1.php @@ -49,7 +49,7 @@ class Secretaries_api_v1 extends EA_Controller { $order_by = $this->api->request_order_by(); $fields = $this->api->request_fields(); - + $with = $this->api->request_with(); $secretaries = empty($keyword) @@ -132,12 +132,12 @@ class Secretaries_api_v1 extends EA_Controller { if ( ! array_key_exists('providers', $secretary)) { - throw new Exception('No providers property provided.'); + throw new InvalidArgumentException('No providers property provided.'); } if ( ! array_key_exists('settings', $secretary)) { - throw new Exception('No settings property provided.'); + throw new InvalidArgumentException('No settings property provided.'); } $secretary_id = $this->secretaries_model->save($secretary); diff --git a/application/helpers/password_helper.php b/application/helpers/password_helper.php index 4c86809e..7dbe4707 100644 --- a/application/helpers/password_helper.php +++ b/application/helpers/password_helper.php @@ -29,7 +29,7 @@ function hash_password(string $salt, string $password): string { if (strlen($password) > MAX_PASSWORD_LENGTH) { - throw new Exception('The provided password is too long, please use a shorter value.'); + throw new InvalidArgumentException('The provided password is too long, please use a shorter value.'); } $half = (int)(strlen($salt) / 2); diff --git a/application/libraries/Email_messages.php b/application/libraries/Email_messages.php index dc0ba91a..ede1fd34 100644 --- a/application/libraries/Email_messages.php +++ b/application/libraries/Email_messages.php @@ -190,7 +190,7 @@ class Email_messages { $date_format = 'Y/m/d'; break; default: - throw new Exception('Invalid date_format value: ' . $settings['date_format']); + throw new InvalidArgumentException('Invalid date_format value: ' . $settings['date_format']); } switch ($settings['time_format']) @@ -202,7 +202,7 @@ class Email_messages { $time_format = 'g:i a'; break; default: - throw new Exception('Invalid time_format value: ' . $settings['time_format']); + throw new InvalidArgumentException('Invalid time_format value: ' . $settings['time_format']); } $appointment_timezone = new DateTimeZone($provider['timezone']); diff --git a/application/libraries/Google_sync.php b/application/libraries/Google_sync.php index 84bd0c7d..e9b15c00 100644 --- a/application/libraries/Google_sync.php +++ b/application/libraries/Google_sync.php @@ -110,7 +110,7 @@ class Google_sync { if (isset($response['error'])) { - throw new Exception('Google Authentication Error (' . $response['error'] . '): ' . $response['error_description']); + throw new RuntimeException('Google Authentication Error (' . $response['error'] . '): ' . $response['error_description']); } return $response; diff --git a/application/libraries/Instance.php b/application/libraries/Instance.php index 12554e68..03c1c0ef 100644 --- a/application/libraries/Instance.php +++ b/application/libraries/Instance.php @@ -161,12 +161,12 @@ class Instance { if ( ! file_exists($path)) { - throw new Exception('The backup path does not exist: ' . $path); + throw new InvalidArgumentException('The backup path does not exist: ' . $path); } if ( ! is_writable($path)) { - throw new Exception('The backup path is not writable: ' . $path); + throw new RuntimeException('The backup path is not writable: ' . $path); } $contents = $this->CI->dbutil->backup(); diff --git a/application/models/Services_model.php b/application/models/Services_model.php index b7aaeff0..3754b9ab 100644 --- a/application/models/Services_model.php +++ b/application/models/Services_model.php @@ -123,7 +123,7 @@ class Services_model extends EA_Model { if ($service['availabilities_type'] !== NULL && $service['availabilities_type'] !== AVAILABILITIES_TYPE_FLEXIBLE && $service['availabilities_type'] !== AVAILABILITIES_TYPE_FIXED) { - throw new Exception('Service availabilities type must be either ' . AVAILABILITIES_TYPE_FLEXIBLE + throw new InvalidArgumentException('Service availabilities type must be either ' . AVAILABILITIES_TYPE_FLEXIBLE . ' or ' . AVAILABILITIES_TYPE_FIXED . ' (given ' . $service['availabilities_type'] . ')'); } @@ -156,7 +156,7 @@ class Services_model extends EA_Model { { $service['create_datetime'] = date('Y-m-d H:i:s'); $service['update_datetime'] = date('Y-m-d H:i:s'); - + if ( ! $this->db->insert('services', $service)) { throw new RuntimeException('Could not insert service.'); @@ -177,7 +177,7 @@ class Services_model extends EA_Model { protected function update(array $service): int { $service['update_datetime'] = date('Y-m-d H:i:s'); - + if ( ! $this->db->update('services', $service, ['id' => $service['id']])) { throw new RuntimeException('Could not update service.'); @@ -222,7 +222,7 @@ class Services_model extends EA_Model { { $this->db->where('delete_datetime IS NULL'); } - + $service = $this->db->get_where('services', ['id' => $service_id])->row_array(); if ( ! $service) @@ -286,7 +286,7 @@ class Services_model extends EA_Model { * @param int|null $offset Record offset. * @param string|null $order_by Order by. * @param bool $with_trashed - * + * * @return array Returns an array of services. */ public function get($where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array @@ -368,7 +368,7 @@ class Services_model extends EA_Model { * @param int|null $offset Record offset. * @param string|null $order_by Order by. * @param bool $with_trashed - * + * * @return array Returns an array of services. */ public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array @@ -377,7 +377,7 @@ class Services_model extends EA_Model { { $this->db->where('delete_datetime IS NULL'); } - + $services = $this ->db ->select()