Skip to content

Commit

Permalink
user and aauth system variables implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Emre Akay committed Jun 30, 2014
1 parent aea9449 commit 221e686
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion application/config/aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// pm table
'pms' => 'aauth_pms',
// system variables
'system_variables' => 'aauth_system_variables',
'aauth_variables' => 'aauth_system_variables',
// user variables
'user_variables' => 'aauth_user_variables',

Expand Down
47 changes: 47 additions & 0 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,41 @@ public function get_user_var( $key, $user_id = false){
*/
public function set_aauth_var( $key, $value ) {

// if var not set, set
if ( ! $this->get_aauth_var($key) ) {

$data = array(
'key' => $key,
'value' => $value,
);

return $this->db->insert( $this->config_vars['aauth_variables'] , $data);

}
// if var already set, overwrite
else {

$data = array(
'key' => $key,
'value' => $value,
);

$this->db->where( 'key', $key );
return $this->db->update( $this->config_vars['aauth_variables'], $data);
}

}

/**
* Unset Aauth System Variable as key value
* @param string $key
* @return bool
*/
public function unset_aauth_var( $key ) {

$this->db->where('key', $key);

return $this->db->delete( $this->config_vars['aauth_variables'] );

}

Expand All @@ -1678,6 +1713,18 @@ public function set_aauth_var( $key, $value ) {
*/
public function get_aauth_var( $key ){

$query = $this->CI->db->where('key', $key);

$query = $this->CI->db->get( $this->config_vars['aauth_variables'] );

// if variable not set
if ($query->num_rows() < 1) { return false;}

else {

$row = $query->row();
return $row->value;
}
}

} // end class
Expand Down

0 comments on commit 221e686

Please sign in to comment.