-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_controller.php
More file actions
executable file
·105 lines (97 loc) · 3.08 KB
/
app_controller.php
File metadata and controls
executable file
·105 lines (97 loc) · 3.08 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
App::import(array('type' => 'File', 'name' => 'BlogmillSettings', 'file' => APP . 'config/blogmill_settings.php'));
class AppController extends Controller {
private $__userLevel;
public $activeThemePlugin;
/**
* Default Helpers
*
* @var array helper names
*/
var $helpers = array('Text', 'Html', 'Form', 'Javascript', 'Session', 'Blogmill', 'BlogmillForm', 'Time');
var $components = array('Session', 'Acl', 'RequestHandler', 'Blogmill', 'BlogmillHook', 'BlogmillAction', 'Cookie',
'Auth' => array(
'authorize' => 'controller',
'loginAction' => array('controller' => 'users', 'action' => 'login', 'dashboard' => true),
'logoutAction' => array('controller' => 'users', 'action' => 'logout', 'dashboard' => true),
'loginRedirect' => array('controller' => 'posts', 'action' => 'index', 'dashboard' => true),
'logoutRedirect' => '/'
)
);
var $postTypes = array();
var $themes = array();
var $pageInfo = array();
/**
* Before Filter callback.
*
* @return void
* @author Joaquin Windmuller
*/
public function beforeFilter() {
$this->Blogmill->checkUpgradeRequired();
$this->__setLanguage();
if ($this->Auth) {
// Allow access to public areas to visitors
if (!$this->Auth->user() && $this->isAuthorized()) {
$this->Auth->allow('*');
}
}
}
/**
* Checks wether the current user is authorized to view the current page
*
* @return boolean
* @author Joaquin Windmuller
*/
public function isAuthorized() {
$aro = 'visitor';
if ($this->Auth->user('id')) {
$aro = array('model' => 'User', 'foreign_key' => $this->Auth->user('id'));
}
if ($this->action == 'dashboard_execute_action') {
$isAuthorized = is_array($aro);
} else {
$isAuthorized = $this->Acl->check($aro,'controllers/' . $this->name . '/' . $this->action);
}
return $isAuthorized;
}
/**
* Setup layout for prefixed actions.
*
* @return void
* @author Joaquin Windmuller
*/
public function beforeRender() {
if (isset($this->params['prefix'])) {
$this->layout = $this->params['prefix'];
}
if ($this->name !== 'CakeError') {
$this->__requestRecieved();
}
// HOOK: allow plugins to load js and css resource files
$this->Blogmill->pluginsAttached('load_resources');
}
public function __requestRecieved() {
$plugins = $this->Blogmill->pluginsAttached('request_received');
}
/**
* Loads the locale.php file inside config
*/
private function __setLanguage() {
App::import(array(
'type' => 'File',
'name' => 'BlogmillLocaleSetting',
'file' => APP . 'config' . DS . 'locale.php'
));
}
protected function _blogmill404Error() {
App::import('Core', 'Error');
include_once (APP . 'app_error.php');
$error = new AppError('error404', array(), $this);
$error->error404(array());
}
final function dashboard_execute_action($action, $plugin) {
$this->BlogmillAction->execute_plugin_action($action, $plugin);
$this->redirect($this->referer());
}
}