diff --git a/application/config/aauth.php b/application/config/aauth.php index 9e8f282..5282bbf 100644 --- a/application/config/aauth.php +++ b/application/config/aauth.php @@ -38,7 +38,7 @@ $config['aauth'] = array( // pm table 'pms' => 'aauth_pms', // system variables - 'system_variables' => 'aauth_system_variables', + 'aauth_variables' => 'aauth_system_variables', // user variables 'user_variables' => 'aauth_user_variables', diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index 584b6da..6316e2f 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -1667,6 +1667,41 @@ class Aauth { */ 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'] ); } @@ -1678,6 +1713,18 @@ class Aauth { */ 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