Skip to content

Commit

Permalink
inserted get_user_var_keys function
Browse files Browse the repository at this point in the history
Function to List All User Variable Keys by UserID
  • Loading branch information
REJack committed Aug 8, 2014
1 parent cbda008 commit a0d4cc4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,41 @@ public function get_user_var( $key, $user_id = false){
}

}


/**
* List User Variable Keys by UserID
* Return array of variable keys or false
* @param int $user_id ; if not given current user
* @return bool|string , false if var is not set, the value of var if set
*/
public function get_user_var_keys($user_id = false){

if ( ! $user_id ){
$user_id = $this->CI->session->userdata('id');
}

// if specified user is not found
if ( ! $this->get_user($user_id)){
return false;
}
$query = $this->CI->db->select('key');

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

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

// if variable not set
if ($query->num_rows() < 1) { return false;}
else {
$clean_array = array();
foreach($query->result_array() as $row){
$clean_array[] = $row['key'];
}
return $clean_array;
}

}

########################
# Aauth System Variables
Expand Down

0 comments on commit a0d4cc4

Please sign in to comment.