Make use of the dbprefix configuration option so that query builder calls do not need to explicitly use the database prefix.

This commit is contained in:
Alex Tselegidis 2020-04-23 20:48:20 +02:00
parent 63fe772155
commit 8b34d8086e
31 changed files with 359 additions and 374 deletions

View file

@ -54,7 +54,7 @@ $db['default']['username'] = Config::DB_USERNAME;
$db['default']['password'] = Config::DB_PASSWORD;
$db['default']['database'] = Config::DB_NAME;
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['dbprefix'] = 'ea_';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;

View file

@ -11,22 +11,6 @@
*/
$config['migration_enabled'] = TRUE;
/*
|--------------------------------------------------------------------------
| Migrations table
|--------------------------------------------------------------------------
|
| This is the name of the table that will store the current migrations state.
| When migrations runs it will store in a database table which migration
| level the system is at. It then compares the migration level in this
| table to the $config['migration_version'] if they are not the same it
| will migrate up. This must be set.
|
*/
$config['migration_table'] = 'ea_migrations';
/*
|--------------------------------------------------------------------------
| Migrations version

View file

@ -168,7 +168,7 @@ class Backend extends CI_Controller {
// Check if the user has the required privileges for viewing the selected page.
$role_slug = $this->session->userdata('role_slug');
$role_privileges = $this->db->get_where('ea_roles', ['slug' => $role_slug])->row_array();
$role_privileges = $this->db->get_where('roles', ['slug' => $role_slug])->row_array();
if ($role_privileges[$page] < PRIV_VIEW)
{

View file

@ -82,7 +82,7 @@ class Migration_Initial_database_structure extends CI_Migration {
$this->dbforge->add_key('id_users_provider');
$this->dbforge->add_key('id_users_customer');
$this->dbforge->add_key('id_services');
$this->dbforge->create_table('ea_appointments', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('appointments', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id' => [
@ -138,7 +138,7 @@ class Migration_Initial_database_structure extends CI_Migration {
],
]);
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('ea_roles', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('roles', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id_users_secretary' => [
@ -154,7 +154,7 @@ class Migration_Initial_database_structure extends CI_Migration {
]);
$this->dbforge->add_key('id_users_secretary', TRUE);
$this->dbforge->add_key('id_users_provider', TRUE);
$this->dbforge->create_table('ea_secretaries_providers', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('secretaries_providers', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id' => [
@ -196,7 +196,7 @@ class Migration_Initial_database_structure extends CI_Migration {
]);
$this->dbforge->add_key('id', TRUE);
$this->dbforge->add_key('id_service_categories');
$this->dbforge->create_table('ea_services', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('services', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id_users' => [
@ -212,7 +212,7 @@ class Migration_Initial_database_structure extends CI_Migration {
]);
$this->dbforge->add_key('id_users', TRUE);
$this->dbforge->add_key('id_services', TRUE);
$this->dbforge->create_table('ea_services_providers', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('services_providers', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id' => [
@ -233,7 +233,7 @@ class Migration_Initial_database_structure extends CI_Migration {
]);
$this->dbforge->add_key('id', TRUE);
$this->dbforge->add_key('id_service_categories');
$this->dbforge->create_table('ea_service_categories', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('service_categories', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id' => [
@ -253,7 +253,7 @@ class Migration_Initial_database_structure extends CI_Migration {
],
]);
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('ea_settings', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('settings', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id' => [
@ -319,7 +319,7 @@ class Migration_Initial_database_structure extends CI_Migration {
]);
$this->dbforge->add_key('id', TRUE);
$this->dbforge->add_key('id_roles');
$this->dbforge->create_table('ea_users', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('users', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id_users' => [
@ -379,7 +379,7 @@ class Migration_Initial_database_structure extends CI_Migration {
],
]);
$this->dbforge->add_key('id_users', TRUE);
$this->dbforge->create_table('ea_user_settings', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('user_settings', TRUE, ['engine' => 'InnoDB']);
$this->db->query('
ALTER TABLE `ea_appointments`
@ -416,7 +416,7 @@ class Migration_Initial_database_structure extends CI_Migration {
');
$this->db->insert('ea_roles', [
$this->db->insert('roles', [
'name' => 'Administrator',
'slug' => 'admin',
'is_admin' => TRUE,
@ -428,7 +428,7 @@ class Migration_Initial_database_structure extends CI_Migration {
'user_settings' => 15,
]);
$this->db->insert('ea_roles', [
$this->db->insert('roles', [
'name' => 'Provider',
'slug' => 'provider',
'is_admin' => FALSE,
@ -440,7 +440,7 @@ class Migration_Initial_database_structure extends CI_Migration {
'user_settings' => 15,
]);
$this->db->insert('ea_roles', [
$this->db->insert('roles', [
'name' => 'Customer',
'slug' => 'customer',
'is_admin' => FALSE,
@ -452,7 +452,7 @@ class Migration_Initial_database_structure extends CI_Migration {
'user_settings' => 0,
]);
$this->db->insert('ea_roles', [
$this->db->insert('roles', [
'name' => 'Secretary',
'slug' => 'secretary',
'is_admin' => FALSE,
@ -464,12 +464,12 @@ class Migration_Initial_database_structure extends CI_Migration {
'user_settings' => 15,
]);
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'company_working_plan',
'value' => '{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"saturday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"sunday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]}}'
]);
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'book_advance_timeout',
'value' => '30'
]);
@ -491,14 +491,14 @@ class Migration_Initial_database_structure extends CI_Migration {
$this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `ea_users_ibfk_1`');
$this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `ea_user_settings_ibfk_1`');
$this->dbforge->drop_table('ea_appointments');
$this->dbforge->drop_table('ea_roles');
$this->dbforge->drop_table('ea_secretaries_providers');
$this->dbforge->drop_table('ea_services');
$this->dbforge->drop_table('ea_service_categories');
$this->dbforge->drop_table('ea_services_providers');
$this->dbforge->drop_table('ea_settings');
$this->dbforge->drop_table('ea_user_settings');
$this->dbforge->drop_table('ea_users');
$this->dbforge->drop_table('appointments');
$this->dbforge->drop_table('roles');
$this->dbforge->drop_table('secretaries_providers');
$this->dbforge->drop_table('services');
$this->dbforge->drop_table('service_categories');
$this->dbforge->drop_table('services_providers');
$this->dbforge->drop_table('settings');
$this->dbforge->drop_table('user_settings');
$this->dbforge->drop_table('users');
}
}

View file

@ -25,7 +25,7 @@ class Migration_Add_google_analytics_setting extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'google_analytics_code',
'value' => ''
]);
@ -38,6 +38,6 @@ class Migration_Add_google_analytics_setting extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', ['name' => 'google_analytics_code']);
$this->db->delete('settings', ['name' => 'google_analytics_code']);
}
}

View file

@ -25,7 +25,7 @@ class Migration_Add_customer_notifications_setting extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'customer_notifications',
'value' => '1'
]);
@ -38,6 +38,6 @@ class Migration_Add_customer_notifications_setting extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', ['name' => 'customer_notifications']);
$this->db->delete('settings', ['name' => 'customer_notifications']);
}
}

View file

@ -25,7 +25,7 @@ class Migration_Add_date_format_setting extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'date_format',
'value' => 'DMY'
]);
@ -38,6 +38,6 @@ class Migration_Add_date_format_setting extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', ['name' => 'date_format']);
$this->db->delete('settings', ['name' => 'date_format']);
}
}

View file

@ -25,7 +25,7 @@ class Migration_Add_require_captcha_setting extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'require_captcha',
'value' => '0'
]);
@ -38,6 +38,6 @@ class Migration_Add_require_captcha_setting extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', ['name' => 'require_captcha']);
$this->db->delete('settings', ['name' => 'require_captcha']);
}
}

View file

@ -23,7 +23,7 @@ class Migration_Add_calendar_view_setting extends CI_Migration {
*/
public function up()
{
if ( ! $this->db->field_exists('calendar_view', 'ea_user_settings'))
if ( ! $this->db->field_exists('calendar_view', 'user_settings'))
{
$fields = [
'calendar_view' => [
@ -33,9 +33,9 @@ class Migration_Add_calendar_view_setting extends CI_Migration {
]
];
$this->dbforge->add_column('ea_user_settings', $fields);
$this->dbforge->add_column('user_settings', $fields);
$this->db->update('ea_user_settings', ['calendar_view' => 'default']);
$this->db->update('user_settings', ['calendar_view' => 'default']);
}
}
@ -44,9 +44,9 @@ class Migration_Add_calendar_view_setting extends CI_Migration {
*/
public function down()
{
if ($this->db->field_exists('calendar_view', 'ea_user_settings'))
if ($this->db->field_exists('calendar_view', 'user_settings'))
{
$this->dbforge->drop_column('ea_user_settings', 'calendar_view');
$this->dbforge->drop_column('user_settings', 'calendar_view');
}
}
}

View file

@ -23,7 +23,7 @@ class Migration_Add_availabilities_type_to_services_table extends CI_Migration {
*/
public function up()
{
if ( ! $this->db->field_exists('availabilities_type', 'ea_services'))
if ( ! $this->db->field_exists('availabilities_type', 'services'))
{
$fields = [
'availabilities_type' => [
@ -34,9 +34,9 @@ class Migration_Add_availabilities_type_to_services_table extends CI_Migration {
]
];
$this->dbforge->add_column('ea_services', $fields);
$this->dbforge->add_column('services', $fields);
$this->db->update('ea_services', ['availabilities_type' => 'flexible']);
$this->db->update('services', ['availabilities_type' => 'flexible']);
}
}
@ -45,9 +45,9 @@ class Migration_Add_availabilities_type_to_services_table extends CI_Migration {
*/
public function down()
{
if ($this->db->field_exists('availabilities_type', 'ea_services'))
if ($this->db->field_exists('availabilities_type', 'services'))
{
$this->dbforge->drop_column('ea_services', 'availabilities_type');
$this->dbforge->drop_column('services', 'availabilities_type');
}
}
}

View file

@ -23,7 +23,7 @@ class Migration_Add_attendants_number_to_services_table extends CI_Migration {
*/
public function up()
{
if ( ! $this->db->field_exists('attendants_number', 'ea_services'))
if ( ! $this->db->field_exists('attendants_number', 'services'))
{
$fields = [
'attendants_number' => [
@ -34,7 +34,7 @@ class Migration_Add_attendants_number_to_services_table extends CI_Migration {
]
];
$this->dbforge->add_column('ea_services', $fields);
$this->dbforge->add_column('services', $fields);
}
}
@ -43,9 +43,9 @@ class Migration_Add_attendants_number_to_services_table extends CI_Migration {
*/
public function down()
{
if ($this->db->field_exists('attendants_number', 'ea_services'))
if ($this->db->field_exists('attendants_number', 'services'))
{
$this->dbforge->drop_column('ea_services', 'attendants_number');
$this->dbforge->drop_column('services', 'attendants_number');
}
}
}

View file

@ -60,7 +60,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_appointments', $fields);
$this->dbforge->modify_column('appointments', $fields);
// Roles
$fields = [
@ -102,7 +102,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_roles', $fields);
$this->dbforge->modify_column('roles', $fields);
// Secretary Provider
$fields = [
@ -118,7 +118,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_secretaries_providers', $fields);
$this->dbforge->modify_column('secretaries_providers', $fields);
// Services
$fields = [
@ -135,7 +135,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_services', $fields);
$this->dbforge->modify_column('services', $fields);
// Service Providers
$fields = [
@ -151,7 +151,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_services_providers', $fields);
$this->dbforge->modify_column('services_providers', $fields);
// Service Categories
$fields = [
@ -163,7 +163,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_service_categories', $fields);
$this->dbforge->modify_column('service_categories', $fields);
// Settings
$fields = [
@ -175,7 +175,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_settings', $fields);
$this->dbforge->modify_column('settings', $fields);
// Users
$fields = [
@ -192,7 +192,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_users', $fields);
$this->dbforge->modify_column('users', $fields);
// Users Settings
$fields = [
@ -203,7 +203,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_user_settings', $fields);
$this->dbforge->modify_column('user_settings', $fields);
// Add table constraints again.
$this->db->query('ALTER TABLE `ea_appointments`
@ -274,7 +274,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_appointments', $fields);
$this->dbforge->modify_column('appointments', $fields);
// Roles
$fields = [
@ -316,7 +316,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_roles', $fields);
$this->dbforge->modify_column('roles', $fields);
// Secretary Provider
$fields = [
@ -332,7 +332,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_secretaries_providers', $fields);
$this->dbforge->modify_column('secretaries_providers', $fields);
// Services
$fields = [
@ -349,7 +349,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_services', $fields);
$this->dbforge->modify_column('services', $fields);
// Service Providers
$fields = [
@ -365,7 +365,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_services_providers', $fields);
$this->dbforge->modify_column('services_providers', $fields);
// Service Categories
$fields = [
@ -377,7 +377,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_service_categories', $fields);
$this->dbforge->modify_column('service_categories', $fields);
// Settings
$fields = [
@ -389,7 +389,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_settings', $fields);
$this->dbforge->modify_column('settings', $fields);
// Users
$fields = [
@ -406,7 +406,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_users', $fields);
$this->dbforge->modify_column('users', $fields);
// Users Settings
$fields = [
@ -417,7 +417,7 @@ class Migration_Change_column_types extends CI_Migration {
]
];
$this->dbforge->modify_column('ea_user_settings', $fields);
$this->dbforge->modify_column('user_settings', $fields);
// Add database constraints.
$this->db->query('ALTER TABLE `ea_appointments`

View file

@ -23,7 +23,7 @@ class Migration_Add_time_format_setting extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'time_format',
'value' => 'regular'
]);
@ -34,6 +34,6 @@ class Migration_Add_time_format_setting extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', ['name' => 'time_format']);
$this->db->delete('settings', ['name' => 'time_format']);
}
}

View file

@ -23,32 +23,32 @@ class Migration_Create_consents_table extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'display_cookie_notice',
'value' => '0'
]);
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'cookie_notice_content',
'value' => 'Cookie notice content.'
]);
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'display_terms_and_conditions',
'value' => '0'
]);
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'terms_and_conditions_content',
'value' => 'Terms and conditions content.'
]);
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'display_privacy_policy',
'value' => '0'
]);
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'privacy_policy_content',
'value' => 'Privacy policy content.'
]);
@ -96,7 +96,7 @@ class Migration_Create_consents_table extends CI_Migration {
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('ea_consents', TRUE, ['engine' => 'InnoDB']);
$this->dbforge->create_table('consents', TRUE, ['engine' => 'InnoDB']);
}
/**
@ -104,30 +104,30 @@ class Migration_Create_consents_table extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', [
$this->db->delete('settings', [
'name' => 'display_cookie_notice'
]);
$this->db->delete('ea_settings', [
$this->db->delete('settings', [
'name' => 'cookie_notice_content'
]);
$this->db->delete('ea_settings', [
$this->db->delete('settings', [
'name' => 'display_terms_and_conditions'
]);
$this->db->delete('ea_settings', [
$this->db->delete('settings', [
'name' => 'terms_and_conditions_content'
]);
$this->db->delete('ea_settings', [
$this->db->delete('settings', [
'name' => 'display_privacy_policy'
]);
$this->db->delete('ea_settings', [
$this->db->delete('settings', [
'name' => 'privacy_policy_content'
]);
$this->dbforge->drop_table('ea_consents');
$this->dbforge->drop_table('consents');
}
}

View file

@ -23,7 +23,7 @@ class Migration_Add_weekday_start_setting extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'first_weekday',
'value' => 'sunday'
]);
@ -34,6 +34,6 @@ class Migration_Add_weekday_start_setting extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', ['name' => 'first_weekday']);
$this->db->delete('settings', ['name' => 'first_weekday']);
}
}

View file

@ -23,7 +23,7 @@ class Migration_Add_extra_working_plan_to_user_settings extends CI_Migration {
*/
public function up()
{
if ( ! $this->db->field_exists('extra_working_plan', 'ea_user_settings'))
if ( ! $this->db->field_exists('extra_working_plan', 'user_settings'))
{
$fields = [
'extra_working_plan' => [
@ -33,7 +33,7 @@ class Migration_Add_extra_working_plan_to_user_settings extends CI_Migration {
]
];
$this->dbforge->add_column('ea_user_settings', $fields);
$this->dbforge->add_column('user_settings', $fields);
}
}
@ -42,9 +42,9 @@ class Migration_Add_extra_working_plan_to_user_settings extends CI_Migration {
*/
public function down()
{
if ( ! $this->db->field_exists('extra_working_plan', 'ea_user_settings'))
if ( ! $this->db->field_exists('extra_working_plan', 'user_settings'))
{
$this->dbforge->drop_column('ea_user_settings', 'extra_working_plan');
$this->dbforge->drop_column('user_settings', 'extra_working_plan');
}
}
}

View file

@ -23,7 +23,7 @@ class Migration_Add_require_phone_number_setting extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'require_phone_number',
'value' => '1'
]);
@ -34,6 +34,6 @@ class Migration_Add_require_phone_number_setting extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', ['name' => 'require_phone_number']);
$this->db->delete('settings', ['name' => 'require_phone_number']);
}
}

View file

@ -25,7 +25,7 @@ class Migration_Add_api_token_setting extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'api_token',
'value' => ''
]);
@ -38,6 +38,6 @@ class Migration_Add_api_token_setting extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', ['name' => 'api_token']);
$this->db->delete('settings', ['name' => 'api_token']);
}
}

View file

@ -23,7 +23,7 @@ class Migration_Add_timezone_to_users extends CI_Migration {
*/
public function up()
{
if ( ! $this->db->field_exists('timezone', 'ea_users'))
if ( ! $this->db->field_exists('timezone', 'users'))
{
$fields = [
'timezone' => [
@ -34,7 +34,7 @@ class Migration_Add_timezone_to_users extends CI_Migration {
]
];
$this->dbforge->add_column('ea_users', $fields);
$this->dbforge->add_column('users', $fields);
}
}
@ -43,6 +43,6 @@ class Migration_Add_timezone_to_users extends CI_Migration {
*/
public function down()
{
$this->dbforge->drop_column('ea_users', 'timezone');
$this->dbforge->drop_column('users', 'timezone');
}
}

View file

@ -23,7 +23,7 @@ class Migration_Add_display_any_provider_setting extends CI_Migration {
*/
public function up()
{
$this->db->insert('ea_settings', [
$this->db->insert('settings', [
'name' => 'display_any_provider',
'value' => '1'
]);
@ -34,7 +34,7 @@ class Migration_Add_display_any_provider_setting extends CI_Migration {
*/
public function down()
{
$this->db->delete('ea_settings', [
$this->db->delete('settings', [
'name' => 'display_any_provider'
]);
}

View file

@ -56,11 +56,11 @@ class Admins_Model extends CI_Model {
if ( ! isset($admin['id']))
{
$admin['id'] = $this->_insert($admin);
$admin['id'] = $this->insert($admin);
}
else
{
$admin['id'] = $this->_update($admin);
$admin['id'] = $this->update($admin);
}
return (int)$admin['id'];
@ -82,9 +82,9 @@ class Admins_Model extends CI_Model {
// If a record id is provided then check whether the record exists in the database.
if (isset($admin['id']))
{
$num_rows = $this->db->get_where('ea_users', ['id' => $admin['id']])
->num_rows();
if ($num_rows == 0)
$num_rows = $this->db->get_where('users', ['id' => $admin['id']])->num_rows();
if ($num_rows === 0)
{
throw new Exception('Given admin id does not exist in database: ' . $admin['id']);
}
@ -138,11 +138,11 @@ class Admins_Model extends CI_Model {
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_roles.slug', DB_SLUG_ADMIN)
->where('ea_users.email', $admin['email'])
->where('ea_users.id <>', $admin_id)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('roles.slug', DB_SLUG_ADMIN)
->where('users.email', $admin['email'])
->where('users.id <>', $admin_id)
->get()
->num_rows();
@ -165,7 +165,7 @@ class Admins_Model extends CI_Model {
*/
public function validate_username($username, $user_id)
{
$num_rows = $this->db->get_where('ea_user_settings',
$num_rows = $this->db->get_where('user_settings',
['username' => $username, 'id_users <> ' => $user_id])->num_rows();
return ($num_rows > 0) ? FALSE : TRUE;
}
@ -189,10 +189,10 @@ class Admins_Model extends CI_Model {
// This method shouldn't depend on another method of this class.
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.email', $admin['email'])
->where('ea_roles.slug', DB_SLUG_ADMIN)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.email', $admin['email'])
->where('roles.slug', DB_SLUG_ADMIN)
->get()->num_rows();
return $num_rows > 0;
@ -215,11 +215,11 @@ class Admins_Model extends CI_Model {
}
$result = $this->db
->select('ea_users.id')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.email', $admin['email'])
->where('ea_roles.slug', DB_SLUG_ADMIN)
->select('users.id')
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.email', $admin['email'])
->where('roles.slug', DB_SLUG_ADMIN)
->get();
if ($result->num_rows() == 0)
@ -239,7 +239,7 @@ class Admins_Model extends CI_Model {
*
* @throws Exception When the insert operation fails.
*/
protected function _insert($admin)
protected function insert($admin)
{
$this->load->helper('general');
@ -249,7 +249,7 @@ class Admins_Model extends CI_Model {
$this->db->trans_begin();
if ( ! $this->db->insert('ea_users', $admin))
if ( ! $this->db->insert('users', $admin))
{
throw new Exception('Could not insert admin into the database.');
}
@ -260,7 +260,7 @@ class Admins_Model extends CI_Model {
$settings['password'] = hash_password($settings['salt'], $settings['password']);
// Insert admin settings.
if ( ! $this->db->insert('ea_user_settings', $settings))
if ( ! $this->db->insert('user_settings', $settings))
{
$this->db->trans_rollback();
throw new Exception('Could not insert admin settings into the database.');
@ -278,7 +278,7 @@ class Admins_Model extends CI_Model {
*/
public function get_admin_role_id()
{
return (int)$this->db->get_where('ea_roles', ['slug' => DB_SLUG_ADMIN])->row()->id;
return (int)$this->db->get_where('roles', ['slug' => DB_SLUG_ADMIN])->row()->id;
}
/**
@ -290,7 +290,7 @@ class Admins_Model extends CI_Model {
*
* @throws Exception When the update operation fails.
*/
protected function _update($admin)
protected function update($admin)
{
$this->load->helper('general');
@ -300,18 +300,18 @@ class Admins_Model extends CI_Model {
if (isset($settings['password']))
{
$salt = $this->db->get_where('ea_user_settings', ['id_users' => $admin['id']])->row()->salt;
$salt = $this->db->get_where('user_settings', ['id_users' => $admin['id']])->row()->salt;
$settings['password'] = hash_password($salt, $settings['password']);
}
$this->db->where('id', $admin['id']);
if ( ! $this->db->update('ea_users', $admin))
if ( ! $this->db->update('users', $admin))
{
throw new Exception('Could not update admin record.');
}
$this->db->where('id_users', $settings['id_users']);
if ( ! $this->db->update('ea_user_settings', $settings))
if ( ! $this->db->update('user_settings', $settings))
{
throw new Exception('Could not update admin settings.');
}
@ -338,7 +338,7 @@ class Admins_Model extends CI_Model {
// There must be always at least one admin user. If this is the only admin
// the system, it cannot be deleted.
$admin_count = $this->db->get_where('ea_users',
$admin_count = $this->db->get_where('users',
['id_roles' => $this->get_admin_role_id()])->num_rows();
if ($admin_count == 1)
{
@ -346,13 +346,13 @@ class Admins_Model extends CI_Model {
. 'one admin user.');
}
$num_rows = $this->db->get_where('ea_users', ['id' => $admin_id])->num_rows();
$num_rows = $this->db->get_where('users', ['id' => $admin_id])->num_rows();
if ($num_rows == 0)
{
return FALSE; // Record does not exist in database.
}
return $this->db->delete('ea_users', ['id' => $admin_id]);
return $this->db->delete('users', ['id' => $admin_id]);
}
/**
@ -372,14 +372,14 @@ class Admins_Model extends CI_Model {
}
// Check if record exists
if ($this->db->get_where('ea_users', ['id' => $admin_id])->num_rows() == 0)
if ($this->db->get_where('users', ['id' => $admin_id])->num_rows() == 0)
{
throw new Exception('The given admin id does not match a record in the database.');
}
$admin = $this->db->get_where('ea_users', ['id' => $admin_id])->row_array();
$admin = $this->db->get_where('users', ['id' => $admin_id])->row_array();
$admin['settings'] = $this->db->get_where('ea_user_settings',
$admin['settings'] = $this->db->get_where('user_settings',
['id_users' => $admin_id])->row_array();
unset($admin['settings']['id_users']);
@ -413,7 +413,7 @@ class Admins_Model extends CI_Model {
}
// Check whether the admin record exists.
$result = $this->db->get_where('ea_users', ['id' => $admin_id]);
$result = $this->db->get_where('users', ['id' => $admin_id]);
if ($result->num_rows() == 0)
{
throw new Exception('The record with the given id does not exist in the '
@ -455,12 +455,12 @@ class Admins_Model extends CI_Model {
$this->db->order_by($order_by);
}
$batch = $this->db->get_where('ea_users', ['id_roles' => $role_id], $limit, $offset)->result_array();
$batch = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array();
// Get every admin settings.
foreach ($batch as &$admin)
{
$admin['settings'] = $this->db->get_where('ea_user_settings',
$admin['settings'] = $this->db->get_where('user_settings',
['id_users' => $admin['id']])->row_array();
unset($admin['settings']['id_users']);
}

View file

@ -40,11 +40,11 @@ class Appointments_Model extends CI_Model {
// Perform insert() or update() operation.
if ( ! isset($appointment['id']))
{
$appointment['id'] = $this->_insert($appointment);
$appointment['id'] = $this->insert($appointment);
}
else
{
$this->_update($appointment);
$this->update($appointment);
}
return $appointment['id'];
@ -67,7 +67,7 @@ class Appointments_Model extends CI_Model {
// in the database.
if (isset($appointment['id']))
{
$num_rows = $this->db->get_where('ea_appointments',
$num_rows = $this->db->get_where('appointments',
['id' => $appointment['id']])->num_rows();
if ($num_rows == 0)
{
@ -89,10 +89,10 @@ class Appointments_Model extends CI_Model {
// Check if the provider's id is valid.
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.id', $appointment['id_users_provider'])
->where('ea_roles.slug', DB_SLUG_PROVIDER)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.id', $appointment['id_users_provider'])
->where('roles.slug', DB_SLUG_PROVIDER)
->get()->num_rows();
if ($num_rows == 0)
{
@ -104,10 +104,10 @@ class Appointments_Model extends CI_Model {
// Check if the customer's id is valid.
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.id', $appointment['id_users_customer'])
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.id', $appointment['id_users_customer'])
->where('roles.slug', DB_SLUG_CUSTOMER)
->get()->num_rows();
if ($num_rows == 0)
{
@ -115,7 +115,7 @@ class Appointments_Model extends CI_Model {
}
// Check if the service id is valid.
$num_rows = $this->db->get_where('ea_services',
$num_rows = $this->db->get_where('services',
['id' => $appointment['id_services']])->num_rows();
if ($num_rows == 0)
{
@ -136,12 +136,12 @@ class Appointments_Model extends CI_Model {
*
* @throws Exception If appointment record could not be inserted.
*/
protected function _insert($appointment)
protected function insert($appointment)
{
$appointment['book_datetime'] = date('Y-m-d H:i:s');
$appointment['hash'] = $this->generate_hash();
if ( ! $this->db->insert('ea_appointments', $appointment))
if ( ! $this->db->insert('appointments', $appointment))
{
throw new Exception('Could not insert appointment record.');
}
@ -173,10 +173,10 @@ class Appointments_Model extends CI_Model {
*
* @throws Exception If appointment record could not be updated.
*/
protected function _update($appointment)
protected function update($appointment)
{
$this->db->where('id', $appointment['id']);
if ( ! $this->db->update('ea_appointments', $appointment))
if ( ! $this->db->update('appointments', $appointment))
{
throw new Exception('Could not update appointment record.');
}
@ -208,7 +208,7 @@ class Appointments_Model extends CI_Model {
. print_r($appointment, TRUE));
}
$num_rows = $this->db->get_where('ea_appointments', [
$num_rows = $this->db->get_where('appointments', [
'start_datetime' => $appointment['start_datetime'],
'end_datetime' => $appointment['end_datetime'],
'id_users_provider' => $appointment['id_users_provider'],
@ -245,7 +245,7 @@ class Appointments_Model extends CI_Model {
'id_services' => $appointment['id_services']
]);
$result = $this->db->get('ea_appointments');
$result = $this->db->get('appointments');
if ($result->num_rows() == 0)
{
@ -271,7 +271,7 @@ class Appointments_Model extends CI_Model {
throw new Exception('Invalid argument type $appointment_id (value:"' . $appointment_id . '")');
}
$num_rows = $this->db->get_where('ea_appointments', ['id' => $appointment_id])->num_rows();
$num_rows = $this->db->get_where('appointments', ['id' => $appointment_id])->num_rows();
if ($num_rows == 0)
{
@ -279,7 +279,7 @@ class Appointments_Model extends CI_Model {
}
$this->db->where('id', $appointment_id);
return $this->db->delete('ea_appointments');
return $this->db->delete('appointments');
}
/**
@ -300,7 +300,7 @@ class Appointments_Model extends CI_Model {
. $appointment_id);
}
$appointment = $this->db->get_where('ea_appointments', ['id' => $appointment_id])->row_array();
$appointment = $this->db->get_where('appointments', ['id' => $appointment_id])->row_array();
$this->load->model('timezones_model');
@ -335,13 +335,13 @@ class Appointments_Model extends CI_Model {
throw new Exception('Invalid argument given, expected string for the $field_name: ' . $field_name);
}
if ($this->db->get_where('ea_appointments', ['id' => $appointment_id])->num_rows() == 0)
if ($this->db->get_where('appointments', ['id' => $appointment_id])->num_rows() == 0)
{
throw new Exception('The record with the provided id '
. 'does not exist in the database: ' . $appointment_id);
}
$row_data = $this->db->get_where('ea_appointments', ['id' => $appointment_id])->row_array();
$row_data = $this->db->get_where('appointments', ['id' => $appointment_id])->row_array();
if ( ! isset($row_data[$field_name]))
{
@ -383,7 +383,7 @@ class Appointments_Model extends CI_Model {
$this->db->order_by($order_by);
}
$appointments = $this->db->get('ea_appointments', $limit, $offset)->result_array();
$appointments = $this->db->get('appointments', $limit, $offset)->result_array();
$this->load->model('timezones_model');
@ -409,11 +409,11 @@ class Appointments_Model extends CI_Model {
*/
private function get_aggregates(array $appointment)
{
$appointment['service'] = $this->db->get_where('ea_services',
$appointment['service'] = $this->db->get_where('services',
['id' => $appointment['id_services']])->row_array();
$appointment['provider'] = $this->db->get_where('ea_users',
$appointment['provider'] = $this->db->get_where('users',
['id' => $appointment['id_users_provider']])->row_array();
$appointment['customer'] = $this->db->get_where('ea_users',
$appointment['customer'] = $this->db->get_where('users',
['id' => $appointment['id_users_customer']])->row_array();
return $appointment;
}
@ -441,10 +441,10 @@ class Appointments_Model extends CI_Model {
// Validate provider record
$where_clause = [
'id' => $unavailable['id_users_provider'],
'id_roles' => $this->db->get_where('ea_roles', ['slug' => DB_SLUG_PROVIDER])->row()->id
'id_roles' => $this->db->get_where('roles', ['slug' => DB_SLUG_PROVIDER])->row()->id
];
if ($this->db->get_where('ea_users', $where_clause)->num_rows() == 0)
if ($this->db->get_where('users', $where_clause)->num_rows() == 0)
{
throw new Exception('Provider id was not found in database.');
}
@ -455,13 +455,13 @@ class Appointments_Model extends CI_Model {
$unavailable['book_datetime'] = date('Y-m-d H:i:s');
$unavailable['is_unavailable'] = TRUE;
$this->db->insert('ea_appointments', $unavailable);
$this->db->insert('appointments', $unavailable);
$unavailable['id'] = $this->db->insert_id();
}
else
{
$this->db->where(['id' => $unavailable['id']]);
$this->db->update('ea_appointments', $unavailable);
$this->db->update('appointments', $unavailable);
}
return $unavailable['id'];
@ -483,7 +483,7 @@ class Appointments_Model extends CI_Model {
throw new Exception('Invalid argument type $unavailable_id: ' . $unavailable_id);
}
$num_rows = $this->db->get_where('ea_appointments', ['id' => $unavailable_id])->num_rows();
$num_rows = $this->db->get_where('appointments', ['id' => $unavailable_id])->num_rows();
if ($num_rows == 0)
{
@ -492,7 +492,7 @@ class Appointments_Model extends CI_Model {
$this->db->where('id', $unavailable_id);
return $this->db->delete('ea_appointments');
return $this->db->delete('appointments');
}
/**
@ -509,7 +509,7 @@ class Appointments_Model extends CI_Model {
throw new Exception('Invalid argument type $provider_id: ' . $provider_id);
}
$this->db->update('ea_appointments', ['id_google_calendar' => NULL],
$this->db->update('appointments', ['id_google_calendar' => NULL],
['id_users_provider' => $provider_id]);
}
@ -524,7 +524,7 @@ class Appointments_Model extends CI_Model {
*/
public function appointment_count_for_hour($service_id, $selected_date, $hour)
{
return $this->db->get_where('ea_appointments', [
return $this->db->get_where('appointments', [
'id_services' => $service_id,
'start_datetime' => date('Y-m-d H:i:s', strtotime($selected_date . ' ' . $hour . ':00'))
])->num_rows();
@ -543,7 +543,7 @@ class Appointments_Model extends CI_Model {
{
return (int)$this->db
->select('count(*) AS attendants_number')
->from('ea_appointments')
->from('appointments')
->group_start()
->where('start_datetime <=', $slot_start->format('Y-m-d H:i:s'))
->where('end_datetime >', $slot_start->format('Y-m-d H:i:s'))

View file

@ -35,11 +35,11 @@ class Consents_model extends CI_Model {
if ( ! isset($consent['id']))
{
$consent['id'] = $this->_insert($consent);
$consent['id'] = $this->insert($consent);
}
else
{
$this->_update($consent);
$this->update($consent);
}
return $consent['id'];
@ -75,12 +75,12 @@ class Consents_model extends CI_Model {
*
* @throws Exception If consent record could not be inserted.
*/
protected function _insert($consent)
protected function insert($consent)
{
$consent['created'] = time();
$consent['modified'] = time();
if ( ! $this->db->insert('ea_consents', $consent))
if ( ! $this->db->insert('consents', $consent))
{
throw new Exception('Could not insert consent to the database.');
}
@ -99,11 +99,11 @@ class Consents_model extends CI_Model {
*
* @throws Exception If consent record could not be updated.
*/
protected function _update($consent)
protected function update($consent)
{
$consent['modified'] = time();
if ( ! $this->db->update('ea_consents', $consent, ['id' => $consent['id']]))
if ( ! $this->db->update('consents', $consent, ['id' => $consent['id']]))
{
throw new Exception('Could not update consent to the database.');
}

View file

@ -30,6 +30,7 @@ class Customers_Model extends CI_Model {
* fields.
*
* @return int Returns the customer id.
* @throws Exception
*/
public function add($customer)
{
@ -46,11 +47,11 @@ class Customers_Model extends CI_Model {
// :: INSERT OR UPDATE CUSTOMER RECORD
if ( ! isset($customer['id']))
{
$customer['id'] = $this->_insert($customer);
$customer['id'] = $this->insert($customer);
}
else
{
$this->_update($customer);
$this->update($customer);
}
return $customer['id'];
@ -73,7 +74,7 @@ class Customers_Model extends CI_Model {
// exist in the database.
if (isset($customer['id']))
{
$num_rows = $this->db->get_where('ea_users',
$num_rows = $this->db->get_where('users',
['id' => $customer['id']])->num_rows();
if ($num_rows == 0)
{
@ -82,7 +83,7 @@ class Customers_Model extends CI_Model {
}
}
$query = $this->db->get_where('ea_settings', ['name' => 'require_phone_number']);
$query = $this->db->get_where('settings', ['name' => 'require_phone_number']);
$phone_number_required = $query->num_rows() > 0 ? $query->row() === '1' : FALSE;
// Validate required fields
@ -107,11 +108,11 @@ class Customers_Model extends CI_Model {
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
->where('ea_users.email', $customer['email'])
->where('ea_users.id <>', $customer_id)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('roles.slug', DB_SLUG_CUSTOMER)
->where('users.email', $customer['email'])
->where('users.id <>', $customer_id)
->get()
->num_rows();
@ -147,10 +148,10 @@ class Customers_Model extends CI_Model {
// This method shouldn't depend on another method of this class.
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.email', $customer['email'])
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.email', $customer['email'])
->where('roles.slug', DB_SLUG_CUSTOMER)
->get()->num_rows();
return ($num_rows > 0) ? TRUE : FALSE;
@ -180,11 +181,11 @@ class Customers_Model extends CI_Model {
// Get customer's role id
$result = $this->db
->select('ea_users.id')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.email', $customer['email'])
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
->select('users.id')
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.email', $customer['email'])
->where('roles.slug', DB_SLUG_CUSTOMER)
->get();
if ($result->num_rows() == 0)
@ -205,19 +206,19 @@ class Customers_Model extends CI_Model {
*
* @throws Exception If customer record could not be inserted.
*/
protected function _insert($customer)
protected function insert($customer)
{
// Before inserting the customer we need to get the customer's role id
// from the database and assign it to the new record as a foreign key.
$customer_role_id = $this->db
->select('id')
->from('ea_roles')
->from('roles')
->where('slug', DB_SLUG_CUSTOMER)
->get()->row()->id;
$customer['id_roles'] = $customer_role_id;
if ( ! $this->db->insert('ea_users', $customer))
if ( ! $this->db->insert('users', $customer))
{
throw new Exception('Could not insert customer to the database.');
}
@ -237,11 +238,11 @@ class Customers_Model extends CI_Model {
*
* @throws Exception If customer record could not be updated.
*/
protected function _update($customer)
protected function update($customer)
{
$this->db->where('id', $customer['id']);
if ( ! $this->db->update('ea_users', $customer))
if ( ! $this->db->update('users', $customer))
{
throw new Exception('Could not update customer to the database.');
}
@ -265,13 +266,13 @@ class Customers_Model extends CI_Model {
throw new Exception('Invalid argument type $customer_id: ' . $customer_id);
}
$num_rows = $this->db->get_where('ea_users', ['id' => $customer_id])->num_rows();
$num_rows = $this->db->get_where('users', ['id' => $customer_id])->num_rows();
if ($num_rows == 0)
{
return FALSE;
}
return $this->db->delete('ea_users', ['id' => $customer_id]);
return $this->db->delete('users', ['id' => $customer_id]);
}
/**
@ -290,7 +291,7 @@ class Customers_Model extends CI_Model {
{
throw new Exception('Invalid argument provided as $customer_id : ' . $customer_id);
}
return $this->db->get_where('ea_users', ['id' => $customer_id])->row_array();
return $this->db->get_where('users', ['id' => $customer_id])->row_array();
}
/**
@ -320,13 +321,13 @@ class Customers_Model extends CI_Model {
. $field_name);
}
if ($this->db->get_where('ea_users', ['id' => $customer_id])->num_rows() == 0)
if ($this->db->get_where('users', ['id' => $customer_id])->num_rows() == 0)
{
throw new Exception('The record with the $customer_id argument '
. 'does not exist in the database: ' . $customer_id);
}
$row_data = $this->db->get_where('ea_users', ['id' => $customer_id]
$row_data = $this->db->get_where('users', ['id' => $customer_id]
)->row_array();
if ( ! isset($row_data[$field_name]))
{
@ -334,7 +335,7 @@ class Customers_Model extends CI_Model {
. 'exist in the database: ' . $field_name);
}
$customer = $this->db->get_where('ea_users', ['id' => $customer_id])->row_array();
$customer = $this->db->get_where('users', ['id' => $customer_id])->row_array();
return $customer[$field_name];
}
@ -366,7 +367,7 @@ class Customers_Model extends CI_Model {
$this->db->order_by($order_by);
}
return $this->db->get_where('ea_users', ['id_roles' => $role_id], $limit, $offset)->result_array();
return $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array();
}
/**
@ -376,6 +377,6 @@ class Customers_Model extends CI_Model {
*/
public function get_customers_role_id()
{
return $this->db->get_where('ea_roles', ['slug' => DB_SLUG_CUSTOMER])->row()->id;
return $this->db->get_where('roles', ['slug' => DB_SLUG_CUSTOMER])->row()->id;
}
}

View file

@ -70,11 +70,11 @@ class Providers_Model extends CI_Model {
if ( ! isset($provider['id']))
{
$provider['id'] = $this->_insert($provider);
$provider['id'] = $this->insert($provider);
}
else
{
$provider['id'] = $this->_update($provider);
$provider['id'] = $this->update($provider);
}
return (int)$provider['id'];
@ -96,7 +96,7 @@ class Providers_Model extends CI_Model {
// If a provider id is present, check whether the record exist in the database.
if (isset($provider['id']))
{
$num_rows = $this->db->get_where('ea_users',
$num_rows = $this->db->get_where('users',
['id' => $provider['id']])->num_rows();
if ($num_rows == 0)
{
@ -176,11 +176,11 @@ class Providers_Model extends CI_Model {
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_roles.slug', DB_SLUG_PROVIDER)
->where('ea_users.email', $provider['email'])
->where('ea_users.id <>', $provider_id)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('roles.slug', DB_SLUG_PROVIDER)
->where('users.email', $provider['email'])
->where('users.id <>', $provider_id)
->get()
->num_rows();
@ -203,7 +203,7 @@ class Providers_Model extends CI_Model {
*/
public function validate_username($username, $user_id)
{
$num_rows = $this->db->get_where('ea_user_settings',
$num_rows = $this->db->get_where('user_settings',
['username' => $username, 'id_users <> ' => $user_id])->num_rows();
return ($num_rows > 0) ? FALSE : TRUE;
}
@ -227,10 +227,10 @@ class Providers_Model extends CI_Model {
// This method shouldn't depend on another method of this class.
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.email', $provider['email'])
->where('ea_roles.slug', DB_SLUG_PROVIDER)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.email', $provider['email'])
->where('roles.slug', DB_SLUG_PROVIDER)
->get()->num_rows();
return ($num_rows > 0) ? TRUE : FALSE;
@ -253,11 +253,11 @@ class Providers_Model extends CI_Model {
}
$result = $this->db
->select('ea_users.id')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.email', $provider['email'])
->where('ea_roles.slug', DB_SLUG_PROVIDER)
->select('users.id')
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.email', $provider['email'])
->where('roles.slug', DB_SLUG_PROVIDER)
->get();
if ($result->num_rows() == 0)
@ -277,7 +277,7 @@ class Providers_Model extends CI_Model {
*
* @throws Exception When the insert operation fails.
*/
protected function _insert($provider)
protected function insert($provider)
{
$this->load->helper('general');
@ -291,7 +291,7 @@ class Providers_Model extends CI_Model {
unset($provider['settings']);
// Insert provider record and save settings.
if ( ! $this->db->insert('ea_users', $provider))
if ( ! $this->db->insert('users', $provider))
{
throw new Exception('Could not insert provider into the database');
}
@ -314,7 +314,7 @@ class Providers_Model extends CI_Model {
*/
public function get_providers_role_id()
{
return $this->db->get_where('ea_roles', ['slug' => DB_SLUG_PROVIDER])->row()->id;
return $this->db->get_where('roles', ['slug' => DB_SLUG_PROVIDER])->row()->id;
}
/**
@ -339,10 +339,10 @@ class Providers_Model extends CI_Model {
}
// Check if the setting record exists in db.
if ($this->db->get_where('ea_user_settings', ['id_users' => $provider_id])
if ($this->db->get_where('user_settings', ['id_users' => $provider_id])
->num_rows() == 0)
{
$this->db->insert('ea_user_settings', ['id_users' => $provider_id]);
$this->db->insert('user_settings', ['id_users' => $provider_id]);
}
foreach ($settings as $name => $value)
@ -371,7 +371,7 @@ class Providers_Model extends CI_Model {
public function set_setting($setting_name, $value, $provider_id)
{
$this->db->where(['id_users' => $provider_id]);
return $this->db->update('ea_user_settings', [$setting_name => $value]);
return $this->db->update('user_settings', [$setting_name => $value]);
}
/**
@ -397,14 +397,14 @@ class Providers_Model extends CI_Model {
}
// Save provider services in the database (delete old records and add new).
$this->db->delete('ea_services_providers', ['id_users' => $provider_id]);
$this->db->delete('services_providers', ['id_users' => $provider_id]);
foreach ($services as $service_id)
{
$service_provider = [
'id_users' => $provider_id,
'id_services' => $service_id
];
$this->db->insert('ea_services_providers', $service_provider);
$this->db->insert('services_providers', $service_provider);
}
}
@ -417,7 +417,7 @@ class Providers_Model extends CI_Model {
*
* @throws Exception When the update operation fails.
*/
protected function _update($provider)
protected function update($provider)
{
$this->load->helper('general');
@ -429,13 +429,13 @@ class Providers_Model extends CI_Model {
if (isset($settings['password']))
{
$salt = $this->db->get_where('ea_user_settings', ['id_users' => $provider['id']])->row()->salt;
$salt = $this->db->get_where('user_settings', ['id_users' => $provider['id']])->row()->salt;
$settings['password'] = hash_password($salt, $settings['password']);
}
// Update provider record.
$this->db->where('id', $provider['id']);
if ( ! $this->db->update('ea_users', $provider))
if ( ! $this->db->update('users', $provider))
{
throw new Exception('Could not update provider record.');
}
@ -463,13 +463,13 @@ class Providers_Model extends CI_Model {
throw new Exception('Invalid argument type $provider_id: ' . $provider_id);
}
$num_rows = $this->db->get_where('ea_users', ['id' => $provider_id])->num_rows();
$num_rows = $this->db->get_where('users', ['id' => $provider_id])->num_rows();
if ($num_rows == 0)
{
return FALSE; // Record does not exist in database.
}
return $this->db->delete('ea_users', ['id' => $provider_id]);
return $this->db->delete('users', ['id' => $provider_id]);
}
/**
@ -490,17 +490,17 @@ class Providers_Model extends CI_Model {
}
// Check if selected record exists on database.
if ($this->db->get_where('ea_users', ['id' => $provider_id])->num_rows() == 0)
if ($this->db->get_where('users', ['id' => $provider_id])->num_rows() == 0)
{
throw new Exception('Selected record does not exist in the database.');
}
// Get provider data.
$provider = $this->db->get_where('ea_users', ['id' => $provider_id])->row_array();
$provider = $this->db->get_where('users', ['id' => $provider_id])->row_array();
// Include provider services.
$services = $this->db->get_where('ea_services_providers',
$services = $this->db->get_where('services_providers',
['id_users' => $provider_id])->result_array();
$provider['services'] = [];
foreach ($services as $service)
@ -509,7 +509,7 @@ class Providers_Model extends CI_Model {
}
// Include provider settings.
$provider['settings'] = $this->db->get_where('ea_user_settings',
$provider['settings'] = $this->db->get_where('user_settings',
['id_users' => $provider_id])->row_array();
unset($provider['settings']['id_users']);
@ -543,7 +543,7 @@ class Providers_Model extends CI_Model {
}
// Check whether the provider record exists in database.
$result = $this->db->get_where('ea_users', ['id' => $provider_id]);
$result = $this->db->get_where('users', ['id' => $provider_id]);
if ($result->num_rows() == 0)
{
throw new Exception('The record with the $provider_id argument does not exist in '
@ -590,13 +590,13 @@ class Providers_Model extends CI_Model {
$this->db->order_by($order_by);
}
$batch = $this->db->get_where('ea_users', ['id_roles' => $role_id], $limit, $offset)->result_array();
$batch = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array();
// Include each provider services and settings.
foreach ($batch as &$provider)
{
// Services
$services = $this->db->get_where('ea_services_providers',
$services = $this->db->get_where('services_providers',
['id_users' => $provider['id']])->result_array();
$provider['services'] = [];
foreach ($services as $service)
@ -605,7 +605,7 @@ class Providers_Model extends CI_Model {
}
// Settings
$provider['settings'] = $this->db->get_where('ea_user_settings',
$provider['settings'] = $this->db->get_where('user_settings',
['id_users' => $provider['id']])->row_array();
unset($provider['settings']['id_users']);
}
@ -625,10 +625,10 @@ class Providers_Model extends CI_Model {
{
// Get provider records from database.
$this->db
->select('ea_users.*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_roles.slug', DB_SLUG_PROVIDER)
->select('users.*')
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('roles.slug', DB_SLUG_PROVIDER)
->order_by('first_name ASC, last_name ASC, email ASC');
$providers = $this->db->get()->result_array();
@ -637,7 +637,7 @@ class Providers_Model extends CI_Model {
foreach ($providers as &$provider)
{
// Services
$services = $this->db->get_where('ea_services_providers',
$services = $this->db->get_where('services_providers',
['id_users' => $provider['id']])->result_array();
$provider['services'] = [];
@ -647,7 +647,7 @@ class Providers_Model extends CI_Model {
}
// Settings
$provider['settings'] = $this->db->get_where('ea_user_settings',
$provider['settings'] = $this->db->get_where('user_settings',
['id_users' => $provider['id']])->row_array();
unset($provider['settings']['username']);
unset($provider['settings']['password']);
@ -683,10 +683,10 @@ class Providers_Model extends CI_Model {
// Validate provider record
$where_clause = [
'id' => $provider_id,
'id_roles' => $this->db->get_where('ea_roles', ['slug' => DB_SLUG_PROVIDER])->row()->id
'id_roles' => $this->db->get_where('roles', ['slug' => DB_SLUG_PROVIDER])->row()->id
];
if ($this->db->get_where('ea_users', $where_clause)->num_rows() == 0)
if ($this->db->get_where('users', $where_clause)->num_rows() == 0)
{
throw new Exception('Provider id was not found in database.');
}
@ -715,7 +715,7 @@ class Providers_Model extends CI_Model {
*/
public function get_setting($setting_name, $provider_id)
{
$provider_settings = $this->db->get_where('ea_user_settings', ['id_users' => $provider_id])->row_array();
$provider_settings = $this->db->get_where('user_settings', ['id_users' => $provider_id])->row_array();
return $provider_settings[$setting_name];
}
@ -734,10 +734,10 @@ class Providers_Model extends CI_Model {
// Validate provider record
$where_clause = [
'id' => $provider_id,
'id_roles' => $this->db->get_where('ea_roles', ['slug' => DB_SLUG_PROVIDER])->row()->id
'id_roles' => $this->db->get_where('roles', ['slug' => DB_SLUG_PROVIDER])->row()->id
];
if ($this->db->get_where('ea_users', $where_clause)->num_rows() == 0)
if ($this->db->get_where('users', $where_clause)->num_rows() == 0)
{
throw new Exception('Provider id was not found in database.');
}

View file

@ -29,7 +29,7 @@ class Roles_Model extends CI_Model {
*/
public function get_role_id($role_slug)
{
return $this->db->get_where('ea_roles', ['slug' => $role_slug])->row()->id;
return $this->db->get_where('roles', ['slug' => $role_slug])->row()->id;
}
/**
@ -44,7 +44,7 @@ class Roles_Model extends CI_Model {
*/
public function get_privileges($slug)
{
$privileges = $this->db->get_where('ea_roles', ['slug' => $slug])->row_array();
$privileges = $this->db->get_where('roles', ['slug' => $slug])->row_array();
unset($privileges['id'], $privileges['name'], $privileges['slug'], $privileges['is_admin']);
// Convert the int values to bool so that is easier to check whether a

View file

@ -58,11 +58,11 @@ class Secretaries_Model extends CI_Model {
if ( ! isset($secretary['id']))
{
$secretary['id'] = $this->_insert($secretary);
$secretary['id'] = $this->insert($secretary);
}
else
{
$secretary['id'] = $this->_update($secretary);
$secretary['id'] = $this->update($secretary);
}
return (int)$secretary['id'];
@ -84,7 +84,7 @@ class Secretaries_Model extends CI_Model {
// If a record id is provided then check whether the record exists in the database.
if (isset($secretary['id']))
{
$num_rows = $this->db->get_where('ea_users', ['id' => $secretary['id']])
$num_rows = $this->db->get_where('users', ['id' => $secretary['id']])
->num_rows();
if ($num_rows == 0)
{
@ -146,11 +146,11 @@ class Secretaries_Model extends CI_Model {
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_roles.slug', DB_SLUG_SECRETARY)
->where('ea_users.email', $secretary['email'])
->where('ea_users.id <>', $secretary_id)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('roles.slug', DB_SLUG_SECRETARY)
->where('users.email', $secretary['email'])
->where('users.id <>', $secretary_id)
->get()
->num_rows();
@ -173,7 +173,7 @@ class Secretaries_Model extends CI_Model {
*/
public function validate_username($username, $user_id)
{
$num_rows = $this->db->get_where('ea_user_settings',
$num_rows = $this->db->get_where('user_settings',
['username' => $username, 'id_users <> ' => $user_id])->num_rows();
return ($num_rows > 0) ? FALSE : TRUE;
}
@ -197,10 +197,10 @@ class Secretaries_Model extends CI_Model {
// This method shouldn't depend on another method of this class.
$num_rows = $this->db
->select('*')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.email', $secretary['email'])
->where('ea_roles.slug', DB_SLUG_SECRETARY)
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.email', $secretary['email'])
->where('roles.slug', DB_SLUG_SECRETARY)
->get()->num_rows();
return ($num_rows > 0) ? TRUE : FALSE;
@ -223,11 +223,11 @@ class Secretaries_Model extends CI_Model {
}
$result = $this->db
->select('ea_users.id')
->from('ea_users')
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
->where('ea_users.email', $secretary['email'])
->where('ea_roles.slug', DB_SLUG_SECRETARY)
->select('users.id')
->from('users')
->join('roles', 'roles.id = ea_users.id_roles', 'inner')
->where('users.email', $secretary['email'])
->where('roles.slug', DB_SLUG_SECRETARY)
->get();
if ($result->num_rows() == 0)
@ -247,7 +247,7 @@ class Secretaries_Model extends CI_Model {
*
* @throws Exception When the insert operation fails.
*/
protected function _insert($secretary)
protected function insert($secretary)
{
$this->load->helper('general');
@ -258,7 +258,7 @@ class Secretaries_Model extends CI_Model {
$secretary['id_roles'] = $this->get_secretary_role_id();
if ( ! $this->db->insert('ea_users', $secretary))
if ( ! $this->db->insert('users', $secretary))
{
throw new Exception('Could not insert secretary into the database.');
}
@ -280,7 +280,7 @@ class Secretaries_Model extends CI_Model {
*/
public function get_secretary_role_id()
{
return (int)$this->db->get_where('ea_roles', ['slug' => DB_SLUG_SECRETARY])->row()->id;
return (int)$this->db->get_where('roles', ['slug' => DB_SLUG_SECRETARY])->row()->id;
}
/**
@ -299,13 +299,13 @@ class Secretaries_Model extends CI_Model {
}
// Delete old connections
$this->db->delete('ea_secretaries_providers', ['id_users_secretary' => $secretary_id]);
$this->db->delete('secretaries_providers', ['id_users_secretary' => $secretary_id]);
if (count($providers) > 0)
{
foreach ($providers as $provider_id)
{
$this->db->insert('ea_secretaries_providers', [
$this->db->insert('secretaries_providers', [
'id_users_secretary' => $secretary_id,
'id_users_provider' => $provider_id
]);
@ -335,11 +335,11 @@ class Secretaries_Model extends CI_Model {
}
// Check if the setting record exists in db.
$num_rows = $this->db->get_where('ea_user_settings',
$num_rows = $this->db->get_where('user_settings',
['id_users' => $secretary_id])->num_rows();
if ($num_rows == 0)
{
$this->db->insert('ea_user_settings', ['id_users' => $secretary_id]);
$this->db->insert('user_settings', ['id_users' => $secretary_id]);
}
foreach ($settings as $name => $value)
@ -360,7 +360,7 @@ class Secretaries_Model extends CI_Model {
public function set_setting($setting_name, $value, $secretary_id)
{
$this->db->where(['id_users' => $secretary_id]);
return $this->db->update('ea_user_settings', [$setting_name => $value]);
return $this->db->update('user_settings', [$setting_name => $value]);
}
/**
@ -372,7 +372,7 @@ class Secretaries_Model extends CI_Model {
*
* @throws Exception When the update operation fails.
*/
protected function _update($secretary)
protected function update($secretary)
{
$this->load->helper('general');
@ -383,12 +383,12 @@ class Secretaries_Model extends CI_Model {
if (isset($settings['password']))
{
$salt = $this->db->get_where('ea_user_settings', ['id_users' => $secretary['id']])->row()->salt;
$salt = $this->db->get_where('user_settings', ['id_users' => $secretary['id']])->row()->salt;
$settings['password'] = hash_password($salt, $settings['password']);
}
$this->db->where('id', $secretary['id']);
if ( ! $this->db->update('ea_users', $secretary))
if ( ! $this->db->update('users', $secretary))
{
throw new Exception('Could not update secretary record.');
}
@ -415,13 +415,13 @@ class Secretaries_Model extends CI_Model {
throw new Exception('Invalid argument type $secretary_id: ' . $secretary_id);
}
$num_rows = $this->db->get_where('ea_users', ['id' => $secretary_id])->num_rows();
$num_rows = $this->db->get_where('users', ['id' => $secretary_id])->num_rows();
if ($num_rows == 0)
{
return FALSE; // Record does not exist in database.
}
return $this->db->delete('ea_users', ['id' => $secretary_id]);
return $this->db->delete('users', ['id' => $secretary_id]);
}
/**
@ -442,14 +442,14 @@ class Secretaries_Model extends CI_Model {
}
// Check if record exists
if ($this->db->get_where('ea_users', ['id' => $secretary_id])->num_rows() == 0)
if ($this->db->get_where('users', ['id' => $secretary_id])->num_rows() == 0)
{
throw new Exception('The given secretary id does not match a record in the database.');
}
$secretary = $this->db->get_where('ea_users', ['id' => $secretary_id])->row_array();
$secretary = $this->db->get_where('users', ['id' => $secretary_id])->row_array();
$secretary_providers = $this->db->get_where('ea_secretaries_providers',
$secretary_providers = $this->db->get_where('secretaries_providers',
['id_users_secretary' => $secretary['id']])->result_array();
$secretary['providers'] = [];
foreach ($secretary_providers as $secretary_provider)
@ -457,7 +457,7 @@ class Secretaries_Model extends CI_Model {
$secretary['providers'][] = $secretary_provider['id_users_provider'];
}
$secretary['settings'] = $this->db->get_where('ea_user_settings',
$secretary['settings'] = $this->db->get_where('user_settings',
['id_users' => $secretary['id']])->row_array();
unset($secretary['settings']['id_users'], $secretary['settings']['salt']);
@ -490,7 +490,7 @@ class Secretaries_Model extends CI_Model {
}
// Check whether the secretary record exists.
$result = $this->db->get_where('ea_users', ['id' => $secretary_id]);
$result = $this->db->get_where('users', ['id' => $secretary_id]);
if ($result->num_rows() == 0)
{
throw new Exception('The record with the given id does not exist in the '
@ -532,12 +532,12 @@ class Secretaries_Model extends CI_Model {
$this->db->order_by($order_by);
}
$batch = $this->db->get_where('ea_users', ['id_roles' => $role_id], $limit, $offset)->result_array();
$batch = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array();
// Include every secretary providers.
foreach ($batch as &$secretary)
{
$secretary_providers = $this->db->get_where('ea_secretaries_providers',
$secretary_providers = $this->db->get_where('secretaries_providers',
['id_users_secretary' => $secretary['id']])->result_array();
$secretary['providers'] = [];
@ -546,7 +546,7 @@ class Secretaries_Model extends CI_Model {
$secretary['providers'][] = $secretary_provider['id_users_provider'];
}
$secretary['settings'] = $this->db->get_where('ea_user_settings',
$secretary['settings'] = $this->db->get_where('user_settings',
['id_users' => $secretary['id']])->row_array();
unset($secretary['settings']['id_users']);
}
@ -564,7 +564,7 @@ class Secretaries_Model extends CI_Model {
*/
public function get_setting($setting_name, $secretary_id)
{
$provider_settings = $this->db->get_where('ea_user_settings',
$provider_settings = $this->db->get_where('user_settings',
['id_users' => $secretary_id])->row_array();
return $provider_settings[$setting_name];
}

View file

@ -34,11 +34,11 @@ class Services_Model extends CI_Model {
if ( ! isset($service['id']))
{
$service['id'] = $this->_insert($service);
$service['id'] = $this->insert($service);
}
else
{
$this->_update($service);
$this->update($service);
}
return (int)$service['id'];
@ -61,7 +61,7 @@ class Services_Model extends CI_Model {
// in the database.
if (isset($service['id']))
{
$num_rows = $this->db->get_where('ea_services', ['id' => $service['id']])
$num_rows = $this->db->get_where('services', ['id' => $service['id']])
->num_rows();
if ($num_rows == 0)
{
@ -72,7 +72,7 @@ class Services_Model extends CI_Model {
// Check if service category id is valid (only when present).
if ( ! empty($service['id_service_categories']))
{
$num_rows = $this->db->get_where('ea_service_categories',
$num_rows = $this->db->get_where('service_categories',
['id' => $service['id_service_categories']])->num_rows();
if ($num_rows == 0)
{
@ -131,9 +131,9 @@ class Services_Model extends CI_Model {
*
* @throws Exception If service record could not be inserted.
*/
protected function _insert($service)
protected function insert($service)
{
if ( ! $this->db->insert('ea_services', $service))
if ( ! $this->db->insert('services', $service))
{
throw new Exception('Could not insert service record.');
}
@ -147,10 +147,10 @@ class Services_Model extends CI_Model {
*
* @throws Exception If service record could not be updated.
*/
protected function _update($service)
protected function update($service)
{
$this->db->where('id', $service['id']);
if ( ! $this->db->update('ea_services', $service))
if ( ! $this->db->update('services', $service))
{
throw new Exception('Could not update service record');
}
@ -176,7 +176,7 @@ class Services_Model extends CI_Model {
. 'a service record already exists: ' . print_r($service, TRUE));
}
$num_rows = $this->db->get_where('ea_services', [
$num_rows = $this->db->get_where('services', [
'name' => $service['name'],
'duration' => $service['duration'],
'price' => $service['price']
@ -206,7 +206,7 @@ class Services_Model extends CI_Model {
. 'service record id.');
}
$result = $this->db->get_where('ea_services', [
$result = $this->db->get_where('services', [
'name' => $service['name'],
'duration' => $service['duration'],
'price' => $service['price']
@ -236,13 +236,13 @@ class Services_Model extends CI_Model {
throw new Exception('Invalid argument type $service_id (value:"' . $service_id . '"');
}
$num_rows = $this->db->get_where('ea_services', ['id' => $service_id])->num_rows();
$num_rows = $this->db->get_where('services', ['id' => $service_id])->num_rows();
if ($num_rows == 0)
{
return FALSE; // Record does not exist
}
return $this->db->delete('ea_services', ['id' => $service_id]);
return $this->db->delete('services', ['id' => $service_id]);
}
/**
@ -261,7 +261,7 @@ class Services_Model extends CI_Model {
{
throw new Exception('$service_id argument is not an numeric (value: "' . $service_id . '")');
}
return $this->db->get_where('ea_services', ['id' => $service_id])->row_array();
return $this->db->get_where('services', ['id' => $service_id])->row_array();
}
/**
@ -290,18 +290,18 @@ class Services_Model extends CI_Model {
throw new Exception('$field_name argument is not a string: ' . $field_name);
}
if ($this->db->get_where('ea_services', ['id' => $service_id])->num_rows() == 0)
if ($this->db->get_where('services', ['id' => $service_id])->num_rows() == 0)
{
throw new Exception('The record with the $service_id argument does not exist in the database: ' . $service_id);
}
$row_data = $this->db->get_where('ea_services', ['id' => $service_id])->row_array();
$row_data = $this->db->get_where('services', ['id' => $service_id])->row_array();
if ( ! isset($row_data[$field_name]))
{
throw new Exception('The given $field_name argument does not exist in the database: ' . $field_name);
}
$setting = $this->db->get_where('ea_services', ['id' => $service_id])->row_array();
$setting = $this->db->get_where('services', ['id' => $service_id])->row_array();
return $setting[$field_name];
}
@ -327,7 +327,7 @@ class Services_Model extends CI_Model {
$this->db->order_by($order_by);
}
return $this->db->get('ea_services', $limit, $offset)->result_array();
return $this->db->get('services', $limit, $offset)->result_array();
}
/**
@ -339,13 +339,13 @@ class Services_Model extends CI_Model {
{
$this->db->distinct();
return $this->db
->select('ea_services.*, ea_service_categories.name AS category_name, '
. 'ea_service_categories.id AS category_id')
->from('ea_services')
->join('ea_services_providers',
'ea_services_providers.id_services = ea_services.id', 'inner')
->join('ea_service_categories',
'ea_service_categories.id = ea_services.id_service_categories', 'left')
->select('services.*, ea_service_categories.name AS category_name, '
. 'service_categories.id AS category_id')
->from('services')
->join('services_providers',
'services_providers.id_services = ea_services.id', 'inner')
->join('service_categories',
'service_categories.id = ea_services.id_service_categories', 'left')
->order_by('name ASC')
->get()->result_array();
}
@ -368,13 +368,13 @@ class Services_Model extends CI_Model {
if ( ! isset($category['id']))
{
$this->db->insert('ea_service_categories', $category);
$this->db->insert('service_categories', $category);
$category['id'] = $this->db->insert_id();
}
else
{
$this->db->where('id', $category['id']);
$this->db->update('ea_service_categories', $category);
$this->db->update('service_categories', $category);
}
return (int)$category['id'];
@ -430,7 +430,7 @@ class Services_Model extends CI_Model {
throw new Exception('Invalid argument given for $category_id: ' . $category_id);
}
$num_rows = $this->db->get_where('ea_service_categories', ['id' => $category_id])
$num_rows = $this->db->get_where('service_categories', ['id' => $category_id])
->num_rows();
if ($num_rows == 0)
{
@ -438,7 +438,7 @@ class Services_Model extends CI_Model {
}
$this->db->where('id', $category_id);
return $this->db->delete('ea_service_categories');
return $this->db->delete('service_categories');
}
/**
@ -458,7 +458,7 @@ class Services_Model extends CI_Model {
throw new Exception('Invalid argument type given $category_id: ' . $category_id);
}
$result = $this->db->get_where('ea_service_categories', ['id' => $category_id]);
$result = $this->db->get_where('service_categories', ['id' => $category_id]);
if ($result->num_rows() == 0)
{
@ -485,6 +485,6 @@ class Services_Model extends CI_Model {
$this->db->order_by($order_by);
}
return $this->db->get('ea_service_categories', $limit, $offset)->result_array();
return $this->db->get('service_categories', $limit, $offset)->result_array();
}
}

View file

@ -39,12 +39,12 @@ class Settings_Model extends CI_Model {
throw new Exception('$name argument is not a string: ' . $name);
}
if ($this->db->get_where('ea_settings', ['name' => $name])->num_rows() == 0)
if ($this->db->get_where('settings', ['name' => $name])->num_rows() == 0)
{ // Check if setting exists in db.
throw new Exception('$name setting does not exist in database: ' . $name);
}
$query = $this->db->get_where('ea_settings', ['name' => $name]);
$query = $this->db->get_where('settings', ['name' => $name]);
$setting = $query->num_rows() > 0 ? $query->row() : '';
return $setting->value;
}
@ -69,15 +69,15 @@ class Settings_Model extends CI_Model {
throw new Exception('$name argument is not a string: ' . $name);
}
$query = $this->db->get_where('ea_settings', ['name' => $name]);
$query = $this->db->get_where('settings', ['name' => $name]);
if ($query->num_rows() > 0)
{
// Update setting
if ( ! $this->db->update('ea_settings', ['value' => $value], ['name' => $name]))
if ( ! $this->db->update('settings', ['value' => $value], ['name' => $name]))
{
throw new Exception('Could not update database setting.');
}
$setting_id = (int)$this->db->get_where('ea_settings', ['name' => $name])->row()->id;
$setting_id = (int)$this->db->get_where('settings', ['name' => $name])->row()->id;
}
else
{
@ -86,7 +86,7 @@ class Settings_Model extends CI_Model {
'name' => $name,
'value' => $value
];
if ( ! $this->db->insert('ea_settings', $insert_data))
if ( ! $this->db->insert('settings', $insert_data))
{
throw new Exception('Could not insert database setting');
}
@ -112,12 +112,12 @@ class Settings_Model extends CI_Model {
throw new Exception('$name is not a string: ' . $name);
}
if ($this->db->get_where('ea_settings', ['name' => $name])->num_rows() == 0)
if ($this->db->get_where('settings', ['name' => $name])->num_rows() == 0)
{
return FALSE; // There is no such setting.
}
return $this->db->delete('ea_settings', ['name' => $name]);
return $this->db->delete('settings', ['name' => $name]);
}
/**
@ -142,7 +142,7 @@ class Settings_Model extends CI_Model {
foreach ($settings as $setting)
{
$this->db->where('name', $setting['name']);
if ( ! $this->db->update('ea_settings', ['value' => $setting['value']]))
if ( ! $this->db->update('settings', ['value' => $setting['value']]))
{
throw new Exception('Could not save setting (' . $setting['name']
. ' - ' . $setting['value'] . ')');
@ -155,10 +155,10 @@ class Settings_Model extends CI_Model {
/**
* Returns all the system settings at once.
*
* @return array Array of all the system settings stored in the 'ea_settings' table.
* @return array Array of all the system settings stored in the 'settings' table.
*/
public function get_settings()
{
return $this->db->get('ea_settings')->result_array();
return $this->db->get('settings')->result_array();
}
}

View file

@ -505,7 +505,7 @@ class Timezones_Model extends CI_Model {
*/
public function get_user_timezone($id)
{
$row = $this->db->get_where('ea_users', ['id' => $id])->row_array();
$row = $this->db->get_where('users', ['id' => $id])->row_array();
return $row ? $row['timezone'] : NULL;
}

View file

@ -31,8 +31,8 @@ class User_Model extends CI_Model {
*/
public function get_user($user_id)
{
$user = $this->db->get_where('ea_users', ['id' => $user_id])->row_array();
$user['settings'] = $this->db->get_where('ea_user_settings', ['id_users' => $user_id])->row_array();
$user = $this->db->get_where('users', ['id' => $user_id])->row_array();
$user['settings'] = $this->db->get_where('user_settings', ['id_users' => $user_id])->row_array();
unset($user['settings']['id_users']);
return $user;
}
@ -54,16 +54,16 @@ class User_Model extends CI_Model {
if (isset($user_settings['password']))
{
$this->load->helper('general');
$salt = $this->db->get_where('ea_user_settings', ['id_users' => $user['id']])->row()->salt;
$salt = $this->db->get_where('user_settings', ['id_users' => $user['id']])->row()->salt;
$user_settings['password'] = hash_password($salt, $user_settings['password']);
}
if ( ! $this->db->update('ea_users', $user, ['id' => $user['id']]))
if ( ! $this->db->update('users', $user, ['id' => $user['id']]))
{
return FALSE;
}
if ( ! $this->db->update('ea_user_settings', $user_settings, ['id_users' => $user['id']]))
if ( ! $this->db->update('user_settings', $user_settings, ['id_users' => $user['id']]))
{
return FALSE;
}
@ -85,7 +85,7 @@ class User_Model extends CI_Model {
$salt = $this->get_salt($username);
$password = hash_password($salt, $password);
$user_settings = $this->db->get_where('ea_user_settings', [
$user_settings = $this->db->get_where('user_settings', [
'username' => $username,
'password' => $password
])->row_array();
@ -95,14 +95,14 @@ class User_Model extends CI_Model {
return NULL;
}
$user = $this->db->get_where('ea_users', ['id' => $user_settings['id_users']])->row_array();
$user = $this->db->get_where('users', ['id' => $user_settings['id_users']])->row_array();
if (empty($user))
{
return NULL;
}
$role = $this->db->get_where('ea_roles', ['id' => $user['id_roles']])->row_array();
$role = $this->db->get_where('roles', ['id' => $user['id_roles']])->row_array();
if (empty($role))
{
@ -131,7 +131,7 @@ class User_Model extends CI_Model {
*/
public function get_salt($username)
{
$user = $this->db->get_where('ea_user_settings', ['username' => $username])->row_array();
$user = $this->db->get_where('user_settings', ['username' => $username])->row_array();
return ($user) ? $user['salt'] : '';
}
@ -151,7 +151,7 @@ class User_Model extends CI_Model {
throw new Exception ('Invalid argument given: ' . $user_id);
}
$user = $this->db->get_where('ea_users', ['id' => $user_id])->row_array();
$user = $this->db->get_where('users', ['id' => $user_id])->row_array();
return $user['first_name'] . ' ' . $user['last_name'];
}
@ -170,11 +170,11 @@ class User_Model extends CI_Model {
$this->load->helper('general');
$result = $this->db
->select('ea_users.id')
->from('ea_users')
->join('ea_user_settings', 'ea_user_settings.id_users = ea_users.id', 'inner')
->where('ea_users.email', $email)
->where('ea_user_settings.username', $username)
->select('users.id')
->from('users')
->join('user_settings', 'user_settings.id_users = ea_users.id', 'inner')
->where('users.email', $email)
->where('user_settings.username', $username)
->get();
if ($result->num_rows() == 0)
@ -186,9 +186,9 @@ class User_Model extends CI_Model {
// Create a new password and send it with an email to the given email address.
$new_password = generate_random_string();
$salt = $this->db->get_where('ea_user_settings', ['id_users' => $user_id])->row()->salt;
$salt = $this->db->get_where('user_settings', ['id_users' => $user_id])->row()->salt;
$hash_password = hash_password($salt, $new_password);
$this->db->update('ea_user_settings', ['password' => $hash_password], ['id_users' => $user_id]);
$this->db->update('user_settings', ['password' => $hash_password], ['id_users' => $user_id]);
return $new_password;
}