Skip to content

Commit

Permalink
set_user_var() implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Emre Akay committed Jun 30, 2014
1 parent 2a74c11 commit 628d6d1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,32 @@ public function set_user_var( $key, $value, $user_id = false ) {
$user_id = $this->CI->session->userdata('id');
}

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

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

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

}
// if var already set, overwrite
else {

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

$this->db->where( 'key', $key );
$this->db->where( 'user_id', $user_id);
$this->db->update( $this->config_vars['user_variables'], $data);

}
}


Expand Down

0 comments on commit 628d6d1

Please sign in to comment.