From 628d6d149a027894bfc8a9b2b0862f3d37070bca Mon Sep 17 00:00:00 2001 From: Emre Akay Date: Mon, 30 Jun 2014 19:14:13 +0300 Subject: [PATCH] set_user_var() implemented --- application/libraries/Aauth.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index ccf0f79..9c05bc3 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -1575,7 +1575,32 @@ class Aauth { $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); + + } }