72 lines
1.4 KiB
PHP
Executable file
72 lines
1.4 KiB
PHP
Executable file
<?php
|
|
/* App Controller */
|
|
|
|
|
|
class AppController extends Controller {
|
|
|
|
var $components = array('Auth', 'RequestHandler');
|
|
|
|
var $helpers = array('Javascript', 'Time', 'Html', 'Form');
|
|
function beforeFilter() {
|
|
$this->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'] == 1) {
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
?>
|