/
app_controller.php
49 lines (37 loc) · 1.47 KB
/
app_controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
class AppController extends Controller {
var $components = array( 'Auth', 'RequestHandler', 'Cookie','DebugKit.Toolbar');
var $helpers = array('Form','Javascript','Menu','Cache');
var $publicControllers = array('pages');
var $subheaderTitle = 'Hor pol';
//--------------------------------------------------------------------
function beforeFilter() {
if( isset($this->Auth) ) {
if($this->viewPath == 'pages' && $this->params['action'] != 'admin_index') {
$this->Auth->allow('*');
} else {
$this->Auth->authorize = 'controller';
if ( in_array( low($this->params['controller']), $this->publicControllers) ) {
//$this->Auth->allow('*');
$this->Auth->deny('pages/admin_index');
}
}
$this->Auth->loginAction = array('admin' => false, 'controller' => 'users', 'action' => 'login');
}
}
function isAuthorized() {
if ($this->Auth->user('role') == 'admin') {
return true;
} else {
return false;
}
return true;
}
//--------------------------------------------------------------------
function beforeRender() {
if( ( (isset($this->params['prefix']) && $this->params['prefix'] == 'admin') or isset($this->params['admin']) ) && $this->Session->read('Auth.User.role') == 'admin' ) {
$this->layout = 'admin';
}
}
}
?>