set('currentuser', $this->Auth->user()); $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); $this->Auth->loginRedirect = array('controller' => 'enquiries', 'action' => 'index'); $this->Auth->allow('display'); $this->Auth->authorize = 'controller'; if($this->RequestHandler->isAjax()) { Configure::write('debug', 0); } } function isAuthorized() { return true; } /** * Check if the current logged in user is an admin * @return boolean */ function isAdmin() { $currentuser = $this->getCurrentUser(); if($currentuser['access_level'] == 'admin') { return true; } else { return false; } } /** * Read the current logged in user. * @return array - the currently logged in user. */ function getCurrentUser() { return $this->Session->read('Auth.User'); } /** * Return the id of the current user. False if not logged in. */ function getCurrentUserID() { $currentuser = $this->getCurrentUser(); if($currentuser) { return $currentuser['id']; } else { return false; } } } ?>