-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootstrap.php
171 lines (142 loc) · 5.51 KB
/
Bootstrap.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/**
* This file is part of SNEP.
*
* SNEP is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SNEP is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SNEP. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'Zend/Session.php';
require_once 'Zend/Application/Bootstrap/Bootstrap.php';
require_once 'Snep/Locale.php';
require_once 'modules/default/model/PermissionPlugin.php';
Zend_Session::start();
/**
* Bootstrap
*
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
/*
* _initLogin - Agendamento de verificação de login
*/
protected function _initLogin() {
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Snep_AuthPlugin());
}
/**
* _initRouter
*/
protected function _initRouter() {
$front_controller = Zend_Controller_Front::getInstance();
$front_controller->setBaseUrl($_SERVER['SCRIPT_NAME']);
$router = $front_controller->getRouter();
$router->addRoute('route_edit', new Zend_Controller_Router_Route('route/edit/:id', array('controller' => 'route', 'action' => 'edit'))
);
$router->addRoute('route_duplicate', new Zend_Controller_Router_Route('route/duplicate/:id', array('controller' => 'route', 'action' => 'duplicate'))
);
$router->addRoute('route_delete', new Zend_Controller_Router_Route('route/delete/:id', array('controller' => 'route', 'action' => 'delete'))
);
$router->addRoute('route_permission', new Zend_Controller_Router_Route('permission/:exten', array('controller' => 'permission', 'action' => 'index'))
);
}
/**
* _initLocale
*/
protected function _initLocale() {
$locale = Snep_Locale::getInstance();
Zend_Registry::set("i18n", $locale->getZendTranslate());
}
/**
* _initViewHelpers - Starts the system view and layout
* @return Zend_View
*/
protected function _initViewHelpers() {
// Initialize view
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('HTML5');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('SNEP');
$view->headLink()->setStylesheet($view->baseUrl() . "/css/systemstatus.css");
$view->headScript()->appendFile($view->baseUrl() . "/includes/javascript/snep-env.js.php", 'text/javascript');
$view->headScript()->appendFile($view->baseUrl() . "/includes/javascript/jquery.min.js", 'text/javascript');
//$view->headScript()->appendFile($view->baseUrl() . "/includes/javascript/geral.js", 'text/javascript');
//List installed modules to be used on the modules menu
$systemInfo['modules'] = array();
$modules = Snep_Modules::getInstance()->getRegisteredModules();
foreach ($modules as $module) {
$systemInfo['modules'][] = array(
"id" => $module->getModuleId(),
"name" => $module->getName(),
"version" => $module->getVersion(),
"description" => $module->getDescription()
);
}
$view->indexData = $systemInfo;
// Return it, so that it can be stored by the bootstrap
return $view;
}
/**
* _initCCustos
*/
protected function _initCCustos() {
$db = Snep_Db::getInstance();
$ccustos = Snep_CentroCustos::getInstance();
$select = $db->select()
->from('ccustos')
->order("codigo");
$stmt = $db->query($select);
$result = $stmt->fetchAll();
foreach ($result as $ccusto) {
$ccustos->register(array("codigo" => $ccusto['codigo'], "nome" => $ccusto['nome']));
}
}
/**
* _initQueues
*/
protected function _initQueues() {
$db = Snep_Db::getInstance();
$queues = Snep_Queues::getInstance();
$select = $db->select()->from('queues');
$stmt = $db->query($select);
$result = $stmt->fetchAll();
foreach ($result as $queue) {
$queues->register($queue['name']);
}
}
/**
* _initLogger
*/
protected function _initLogger() {
$log = Snep_Logger::getInstance();
$config = Snep_Config::getConfig();
$writer = new Zend_Log_Writer_Stream($config->system->path->log . '/ui.log');
// Filtramos a 'sujeira' dos logs se não estamos em debug mode.
if (!$config->system->debug) {
$filter = new Zend_Log_Filter_Priority(Zend_Log::WARN);
$writer->addFilter($filter);
}
$log->addWriter($writer);
}
/*
* _initPermission - Agendamento de verificação de permissão
*/
protected function _initPermission() {
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Snep_PermissionPlugin());
}
}
}