Exemplo n.º 1
0
 /**
  * Returns the current logged in user
  *
  * @return array|null
  */
 function loggedin_user()
 {
     //User is not lgged in
     if (!isLoggedIn()) {
         //we return null
         return null;
     }
     //Check if we have user id
     if (!isset($_SESSION['user_id']) || $_SESSION['user_id'] == '' || $_SESSION['user_id'] == null) {
         //Return null
         return null;
     }
     //Create new user object
     $user = new App\Models\User();
     //Get user id
     $user_id = $_SESSION['user_id'];
     //Get the user
     $results = $user->query("SELECT * FROM users WHERE id = '" . $user_id . "'");
     //We got the results
     if ($results != false) {
         //Return the current user row
         return $results[0];
     } else {
         //No user found
         //return null
         return null;
     }
 }