user() helper
I need use in input forms user($key) value. But, sometimes, that key is NULL or doesnt exist, so I get error notice about non exist key. So, I made some upgrade to return NULL if key doesnt exist.
Ok, so this wouldn't be an issue for custom handling.
I didnt understand how to make pull-request..so, this is simple improvement: authit_helper.php:
function user($key = NULL)
{
$CI =& get_instance();
$CI->load->library('session');
$user = $CI->session->userdata('user');
if(!is_null($key))
{
if($key && isset($user->$key))
{
return $user->$key;
} else {
return NULL;
}
}
return $user;
}
With this [user] function it is supposed to return the whole user object if the key is NULL and the related key for the object if the "key" is present, so with your code, you would be returning NULL when there are no specified keys, which is not the intended functionality. To use this correctly, save a user associative array cast to an object to the session, then you can pull the currently logged in user by leaving the key as NULL, or specify the key to get just the key.