Use the shorthand method for config items

This commit is contained in:
Alex Tselegidis 2020-12-02 22:12:54 +02:00
parent 77d8d4e5ab
commit 9cde499f9a
7 changed files with 18 additions and 41 deletions

View file

@ -41,18 +41,6 @@ class Appointments extends EA_Controller {
$this->load->library('availability'); $this->load->library('availability');
$this->load->driver('cache', ['adapter' => 'file']); $this->load->driver('cache', ['adapter' => 'file']);
if ($this->session->userdata('language'))
{
// Set the user's selected language.
$this->config->set_item('language', $this->session->userdata('language'));
$this->lang->load('translations', $this->session->userdata('language'));
}
else
{
// Set the default language.
$this->lang->load('translations', $this->config->item('language'));
}
} }
/** /**
@ -475,7 +463,7 @@ class Appointments extends EA_Controller {
} }
// Save customer language (the language which is used to render the booking page). // Save customer language (the language which is used to render the booking page).
$customer['language'] = $this->config->item('language'); $customer['language'] = config('language');
$customer_id = $this->customers_model->add($customer); $customer_id = $this->customers_model->add($customer);
$appointment['id_users_customer'] = $customer_id; $appointment['id_users_customer'] = $customer_id;

View file

@ -66,7 +66,7 @@ class Backend extends EA_Controller {
$user = $this->user_model->get_user($user_id); $user = $this->user_model->get_user($user_id);
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = config('base_url');
$view['page_title'] = lang('calendar'); $view['page_title'] = lang('calendar');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_APPOINTMENTS; $view['active_menu'] = PRIV_APPOINTMENTS;
@ -187,7 +187,7 @@ class Backend extends EA_Controller {
return; return;
} }
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = config('base_url');
$view['page_title'] = lang('customers'); $view['page_title'] = lang('customers');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_CUSTOMERS; $view['active_menu'] = PRIV_CUSTOMERS;
@ -235,7 +235,7 @@ class Backend extends EA_Controller {
return; return;
} }
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = config('base_url');
$view['page_title'] = lang('services'); $view['page_title'] = lang('services');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_SERVICES; $view['active_menu'] = PRIV_SERVICES;
@ -268,7 +268,7 @@ class Backend extends EA_Controller {
return; return;
} }
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = config('base_url');
$view['page_title'] = lang('users'); $view['page_title'] = lang('users');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_USERS; $view['active_menu'] = PRIV_USERS;
@ -308,7 +308,7 @@ class Backend extends EA_Controller {
$user_id = $this->session->userdata('user_id'); $user_id = $this->session->userdata('user_id');
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = config('base_url');
$view['page_title'] = lang('settings'); $view['page_title'] = lang('settings');
$view['user_display_name'] = $this->user_model->get_user_display_name($user_id); $view['user_display_name'] = $this->user_model->get_user_display_name($user_id);
$view['active_menu'] = PRIV_SYSTEM_SETTINGS; $view['active_menu'] = PRIV_SYSTEM_SETTINGS;

View file

@ -42,17 +42,6 @@ class Backend_api extends EA_Controller {
{ {
$this->privileges = $this->roles_model->get_privileges($this->session->userdata('role_slug')); $this->privileges = $this->roles_model->get_privileges($this->session->userdata('role_slug'));
} }
// Set user's selected language.
if ($this->session->userdata('language'))
{
$this->config->set_item('language', $this->session->userdata('language'));
$this->lang->load('translations', $this->session->userdata('language'));
}
else
{
$this->lang->load('translations', $this->config->item('language')); // default
}
} }
/** /**
@ -1616,7 +1605,7 @@ class Backend_api extends EA_Controller {
// Check if language exists in the available languages. // Check if language exists in the available languages.
$found = FALSE; $found = FALSE;
foreach ($this->config->item('available_languages') as $lang) foreach (config('available_languages') as $lang)
{ {
if ($lang == $this->input->post('language')) if ($lang == $this->input->post('language'))
{ {

View file

@ -41,7 +41,7 @@ class Installation extends EA_Controller {
} }
$this->load->view('general/installation', [ $this->load->view('general/installation', [
'base_url' => $this->config->item('base_url') 'base_url' => config('base_url')
]); ]);
} }

View file

@ -40,7 +40,7 @@ class User extends EA_Controller {
{ {
$this->load->model('settings_model'); $this->load->model('settings_model');
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = config('base_url');
$view['dest_url'] = $this->session->userdata('dest_url'); $view['dest_url'] = $this->session->userdata('dest_url');
if ( ! $view['dest_url']) if ( ! $view['dest_url'])
@ -66,7 +66,7 @@ class User extends EA_Controller {
$this->session->unset_userdata('username'); $this->session->unset_userdata('username');
$this->session->unset_userdata('dest_url'); $this->session->unset_userdata('dest_url');
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = config('base_url');
$view['company_name'] = $this->settings_model->get_setting('company_name'); $view['company_name'] = $this->settings_model->get_setting('company_name');
$this->load->view('user/logout', $view); $this->load->view('user/logout', $view);
} }
@ -78,7 +78,7 @@ class User extends EA_Controller {
public function forgot_password() public function forgot_password()
{ {
$this->load->model('settings_model'); $this->load->model('settings_model');
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = config('base_url');
$view['company_name'] = $this->settings_model->get_setting('company_name'); $view['company_name'] = $this->settings_model->get_setting('company_name');
$this->load->view('user/forgot_password', $view); $this->load->view('user/forgot_password', $view);
} }
@ -90,7 +90,7 @@ class User extends EA_Controller {
public function no_privileges() public function no_privileges()
{ {
$this->load->model('settings_model'); $this->load->model('settings_model');
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = config('base_url');
$view['company_name'] = $this->settings_model->get_setting('company_name'); $view['company_name'] = $this->settings_model->get_setting('company_name');
$this->load->view('user/no_privileges', $view); $this->load->view('user/no_privileges', $view);
} }

View file

@ -26,9 +26,9 @@ function asset_url($uri = '', $protocol = NULL)
{ {
$CI =& get_instance(); $CI =& get_instance();
$debug = $CI->config->item('debug'); $debug = config('debug');
$cache_busting_token = ! $debug ? '?' . $CI->config->item('cache_busting_token') : ''; $cache_busting_token = ! $debug ? '?' . config('cache_busting_token') : '';
if (strpos(basename($uri), '.js') !== FALSE && strpos(basename($uri), '.min.js') === FALSE && ! $debug) if (strpos(basename($uri), '.js') !== FALSE && strpos(basename($uri), '.min.js') === FALSE && ! $debug)
{ {

View file

@ -55,10 +55,10 @@ class Google_Sync {
// Initialize google client and calendar service. // Initialize google client and calendar service.
$this->client = new Google_Client(); $this->client = new Google_Client();
$this->client->setApplicationName($this->CI->config->item('google_application_name')); $this->client->setApplicationName(config('google_application_name'));
$this->client->setClientId($this->CI->config->item('google_client_id')); $this->client->setClientId(config('google_client_id'));
$this->client->setClientSecret($this->CI->config->item('google_client_secret')); $this->client->setClientSecret(config('google_client_secret'));
$this->client->setDeveloperKey($this->CI->config->item('google_api_key')); $this->client->setDeveloperKey(config('google_api_key'));
$this->client->setRedirectUri(site_url('google/oauth_callback')); $this->client->setRedirectUri(site_url('google/oauth_callback'));
$this->client->setPrompt('consent'); $this->client->setPrompt('consent');
$this->client->setAccessType('offline'); $this->client->setAccessType('offline');