cmc-sales/controllers/app_controller.php

72 lines
1.4 KiB
PHP
Raw Normal View History

<?php
/* App Controller */
class AppController extends Controller {
2010-01-10 15:34:31 -08:00
var $components = array('Auth', 'RequestHandler');
var $helpers = array('Javascript', 'Time', 'Html', 'Form');
2010-01-10 15:34:31 -08:00
function beforeFilter() {
$this->set('currentuser', $this->Auth->user());
2010-01-10 10:05:04 -08:00
2010-01-10 15:34:31 -08:00
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'enquiries', 'action' => 'index');
$this->Auth->allow('display');
$this->Auth->authorize = 'controller';
2010-01-10 10:05:04 -08:00
2010-01-10 15:34:31 -08:00
if($this->RequestHandler->isAjax()) {
Configure::write('debug', 0);
}
}
function isAuthorized() {
return true;
}
2010-02-16 19:34:17 -08:00
/**
* 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;
}
}
2010-02-16 19:34:17 -08:00
2010-01-10 10:05:04 -08:00
}
2009-10-10 00:06:46 -07:00
?>