public function logged_in($role = NULL)
{
$status = FALSE;
// Get the user from the session
$user = $this->_session->get($this->_config['session_key']);
if (!is_object($user)) {
// Attempt auto login
if ($this->auto_login()) {
// Success, get the user back out of the session
$user = $this->_session->get($this->_config['session_key']);
}
}
if (is_object($user) and $user instanceof Model_User and $user->loaded()) {
// Everything is okay so far
$status = TRUE;
if (!empty($role)) {
// If role is an array
if (is_array($role)) {
// Check each role
foreach ($role as $role_iteration) {
// If the user doesn't have the role
if (!$user->has_role($role_iteration)) {
// Set the status false and get outta here
$status = FALSE;
break;
}
}
} else {
// Check that the user has the given role
$status = $user->has_role($role);
}
}
}
return $status;
}