Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for ID caching #230

Merged
merged 2 commits into from
May 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,42 +121,41 @@ public function __construct() {
$this->errors = $this->CI->session->flashdata('errors') ?: array();
$this->infos = $this->CI->session->flashdata('infos') ?: array();

// Pre-Cache IDs
$this->precache_ids();

}

/**
* pre_cache_ids() caches all permission and group IDs for later use.
*/
public function precache_ids() {

// Initialize Variables

$this->cache_perm_id = array();
$this->cache_group_id = array();

// Pre-Cache IDs
$this->precache_perms();
$this->precache_groups();

// Permissions

}

/**
* precache_perms() caches all permission IDs for later use.
*/
private function precache_perms {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name line should be as follows:
private function precache_perms() {

Observer the missing '()' after the function name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the same thing with the function
precache_groups

$query = $this->aauth_db->get($this->config_vars['perms']);

foreach ($query->result() as $row) {
$key = str_replace(' ', '', trim(strtolower($row->name)));
$this->cache_perm_id[$key] = $row->id;
}

// Groups

}

/**
* precache_groups() caches all group IDs for later use.
*/
private function precache_groups {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name line should be as follows:
private function precache_groups() {

Observer the missing '()' after the function name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will address issue #234

$query = $this->aauth_db->get($this->config_vars['groups']);

foreach ($query->result() as $row) {
$key = str_replace(' ', '', trim(strtolower($row->name)));
$this->cache_group_id[$key] = $row->id;
}

}



########################
# Login Functions
########################
Expand Down Expand Up @@ -1289,6 +1288,7 @@ public function create_group($group_name, $definition = '') {
'definition'=> $definition
);
$this->aauth_db->insert($this->config_vars['groups'], $data);
$this->precache_groups();
return $this->aauth_db->insert_id();
}

Expand Down Expand Up @@ -1362,6 +1362,7 @@ public function delete_group($group_par) {
return false;
} else {
$this->aauth_db->trans_commit();
$this->precache_groups();
return true;
}

Expand Down Expand Up @@ -1657,6 +1658,7 @@ public function create_perm($perm_name, $definition='') {
'definition'=> $definition
);
$this->aauth_db->insert($this->config_vars['perms'], $data);
$this->precache_perms();
return $this->aauth_db->insert_id();
}
$this->info($this->CI->lang->line('aauth_info_perm_exists'));
Expand Down Expand Up @@ -1716,6 +1718,7 @@ public function delete_perm($perm_par) {
return false;
} else {
$this->aauth_db->trans_commit();
$this->precache_perms();
return true;
}

Expand Down