Updated the new accounts library.

This commit is contained in:
Alex Tselegidis 2021-10-28 13:29:15 +02:00
parent 198db17100
commit b2d2a5a1ce
3 changed files with 13 additions and 31 deletions

View file

@ -51,6 +51,7 @@
* @property Settings_model $settings_model * @property Settings_model $settings_model
* @property Users_model $users_model * @property Users_model $users_model
* *
* @property Accounts $accounts
* @property Availability $availability * @property Availability $availability
* @property Google_Sync $google_sync * @property Google_Sync $google_sync
* @property Ics_file $ics_file * @property Ics_file $ics_file
@ -74,9 +75,11 @@ class EA_Controller extends CI_Controller {
*/ */
private function configure_language() private function configure_language()
{ {
if ($this->session->has_userdata('language')) $session_language = session('language');
if ($session_language)
{ {
$this->config->set_item('language', $this->session->userdata('language')); config(['language' => $session_language]);
} }
$this->lang->load('translations'); $this->lang->load('translations');

View file

@ -51,6 +51,7 @@
* @property Settings_model $settings_model * @property Settings_model $settings_model
* @property Users_model $users_model * @property Users_model $users_model
* *
* @property Accounts $accounts
* @property Availability $availability * @property Availability $availability
* @property Google_Sync $google_sync * @property Google_Sync $google_sync
* @property Ics_file $ics_file * @property Ics_file $ics_file

View file

@ -13,9 +13,11 @@
/** /**
* Accounts * Accounts library
* *
* Handles any account related functionality. * Handles account related functionality.
*
* @package Libraries
*/ */
class Accounts { class Accounts {
/** /**
@ -24,40 +26,16 @@ class Accounts {
protected $CI; protected $CI;
/** /**
* Availability constructor. * Accounts constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->CI =& get_instance(); $this->CI =& get_instance();
$this->CI->load->model('users'); $this->CI->load->model('users_model');
$this->CI->load->model('roles_model');
$this->CI->load->library('timezones'); $this->CI->load->library('timezones');
$this->CI->load->helper('password');
$this->CI->load->helper('string');
}
/**
* Get the user data from the database.
*
* @param int $user_id User ID.
*
* @return array Returns an array with user data.
*/
public function get_user(int $user_id): array
{
return $this->CI->users_model->find($user_id);
}
/**
* Update a user.
*
* @param array $user Associative array with the user data.
*/
public function save_user(array $user): void
{
$this->CI->users_model->save($user);
} }
/** /**