PluginProbe
ShiftController Employee Shift Scheduling / 2.1.0
ShiftController Employee Shift Scheduling v2.1.0
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / happ / application / core / MY_Controller.php

MY_Controller.php in ShiftController Employee Shift Scheduling 2.1.0, at happ/application/core/MY_Controller.php

278 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 require NTS_SYSTEM_APPPATH."third_party/MX/Controller.php";
3
4 //class MY_Controller extends CI_Controller
5 class MY_Controller extends MX_Controller
6 {
7 public $conf = array();
8 protected $builtin_views;
9 public $is_module = FALSE;
10
11 function __construct()
12 {
13 parent::__construct();
14 $this->builtin_views = '_boilerplate';
15 $this->load->helper( array('language', 'form') );
16 if( defined('NTS_DEVELOPMENT') )
17 {
18 if( ! ($this->input->is_ajax_request() OR $this->is_module()) )
19 {
20 $this->output->enable_profiler(TRUE);
21 }
22 }
23
24 if( ! isset($this->conf) )
25 $this->conf = array();
26 if( ! isset($this->conf['path']) )
27 $this->conf['path'] = '';
28
29 $this->load->database();
30 $this->load->helper( array('url') );
31 $skip_setup = array('setup', 'demo');
32
33 if(
34 ( ! in_array($this->router->fetch_class(), $skip_setup)) AND
35 ( ! $this->is_setup() )
36 ){
37
38 $setup_redirect = 'setup';
39 $remote_integration = $this->remote_integration();
40 if( $remote_integration )
41 $setup_redirect = $remote_integration . '/setup';
42
43 ci_redirect( $setup_redirect );
44 exit;
45 }
46
47 $this->load->helper( array('hitcode') );
48 $this->load->library( array('form_validation', 'session', 'hc_bootstrap') );
49 $this->load->library( 'hc_modules' );
50 $this->load->library( 'conf/app_conf' );
51
52 /* add module models paths for autoloading */
53 $modules = $this->config->item('modules');
54 $modules_locations = $this->config->item('modules_locations');
55 if( is_array($modules) )
56 {
57 reset($modules);
58 foreach( $modules as $module )
59 {
60 reset( $modules_locations );
61 foreach( $modules_locations as $ml )
62 {
63 $mod_dir = $ml . $module;
64 if( file_exists($mod_dir) )
65 {
66 Datamapper::add_model_path( $mod_dir );
67 $this->load->add_package_path( $mod_dir );
68 }
69 }
70 }
71 }
72
73 /* reload config paths */
74 $this->app_conf->init();
75
76 $this->load->library( 'hc_modules' );
77
78 /* events and notifiers */
79 $this->load->library( array('hc_events', 'hc_notifier', 'hc_email') );
80 $this->hc_email->from = $this->app_conf->get('email_from');
81 $this->hc_email->fromName = $this->app_conf->get('email_from_name');
82
83 $this->form_validation->set_error_delimiters('<div class="hc-form-error">', '</div>');
84
85 // table
86 $this->load->library('table');
87 $table_tmpl = array (
88 'table_open' => '<table class="table table-striped">',
89 );
90 $this->table->set_template( $table_tmpl );
91
92 // pagination
93 $this->load->library('pagination');
94
95 // conf
96 $this->load->library( 'hc_auth', NULL, 'auth' );
97
98 $this->data = array();
99 $this->data['page_title'] = $this->config->item('nts_app_title');
100
101 $this->data['message'] = $this->session->flashdata('message');
102 $this->data['error'] = $this->session->flashdata('error');
103
104 $this->session->set_flashdata('referrer', current_url());
105 $this->set_include( '' );
106
107 $this->set_layout();
108 }
109
110 function check_level( $require_level )
111 {
112 if(
113 ! (
114 $this->auth &&
115 $this->auth->user() &&
116 ($this->auth->user()->level >= $require_level)
117 )
118 )
119 {
120 $this->session->set_flashdata('error', 'You are not allowed to access this page');
121 ci_redirect('');
122 exit;
123 }
124 }
125
126 function set_layout()
127 {
128 if( $this->input->is_ajax_request() )
129 $this->template = '_layout/index_ajax';
130 elseif( $this->is_module() )
131 $this->template = '_layout/index_module';
132 else
133 $this->template = '_layout/index';
134 }
135
136 function is_module()
137 {
138 return $this->is_module;
139 }
140
141 function set_include( $view, $path = '' )
142 {
143 $include = '';
144 $include_submenu = '';
145 $include_tabs = '';
146 $include_header = '';
147
148 if( $path )
149 {
150 }
151 else
152 {
153 $path = $this->conf['path'];
154 }
155
156 $view_dirname = hc_dirname($view);
157 $current_view = hc_basename($view);
158
159 $include = $this->get_view( $view, $path );
160 if( $this->input->is_ajax_request() OR $this->is_module() )
161 {
162 // no submenu or tabs for ajax calls and inline modules
163 }
164 else
165 {
166 /* header */
167 $file = $view_dirname ? $view_dirname . '/_header' : '_header';
168 $my = $path . '/' . $file;
169 $builtin = $this->builtin_views . '/' . $file;
170 if( $this->load->view_exists($my) )
171 $include_header = $my;
172 elseif( $this->load->view_exists($builtin) )
173 $include_header = $builtin;
174
175 /* submenu */
176 // $no_submenu = $path . '/' . $view . '_nomenu';
177 $no_submenu = $path . '/_nomenu';
178 if( ! $this->load->view_exists($no_submenu) )
179 {
180 $file = $view_dirname ? $view_dirname . '/_menu' : '_menu';
181 $my = $path . '/' . $file;
182 $builtin = $this->builtin_views . '/' . $file;
183 if( $this->load->view_exists($my) )
184 $include_submenu = $my;
185 elseif( $this->load->view_exists($builtin) )
186 $include_submenu = $builtin;
187
188 $my_tabs = $path . '/' . $view . '_tabs';
189 $builtin_tabs = $this->builtin_views . '/' . $view . '_tabs';
190 if( $this->load->view_exists($my_tabs) )
191 $include_tabs = $my_tabs;
192 elseif( $this->load->view_exists($builtin_tabs) )
193 $include_tabs = $builtin_tabs;
194 }
195 }
196
197 $this->data['include'] = $include;
198 $this->data['include_submenu'] = $include_submenu;
199 $this->data['include_tabs'] = $include_tabs;
200 $this->data['include_header'] = $include_header;
201 $this->data['current_view'] = $current_view;
202 }
203
204 function get_view( $view, $path = '' )
205 {
206 $include = '';
207 $view_before = $view . '_before';
208 $force_builtin = FALSE;
209 if( isset($this->data[$view_before]) && $this->data[$view_before] )
210 {
211 // $force_builtin = TRUE;
212 }
213
214 if( ! $path )
215 $path = $this->conf['path'];
216 $my_view = $this->fix_path($path) . '/' . $view;
217 $module_view = $this->fix_path($path) . '/' . $view;
218 $builtin_view = $this->builtin_views . '/' . $view;
219
220 if( (! $force_builtin) && $this->load->view_exists($my_view) )
221 $include = $my_view;
222 elseif( $this->load->view_exists($builtin_view) )
223 $include = $builtin_view;
224
225 return $include;
226 }
227
228 function is_setup()
229 {
230 $return = TRUE;
231 if( $this->db->table_exists('conf') ){
232 $return = TRUE;
233 }
234 else {
235 $return = FALSE;
236 }
237 return $return;
238 }
239
240 function fix_path( $path )
241 {
242 $return = str_replace( '-', '_', $path );
243 return $return;
244 }
245
246 function redirect( $to )
247 {
248 if( $this->input->is_ajax_request() )
249 {
250 // if( $this->input->post() )
251 // {
252 // clear flash
253 $this->session->set_flashdata( 'message', NULL );
254 $this->session->set_flashdata( 'error', NULL );
255 // }
256
257 $to = ci_site_url($to);
258 $out = array(
259 'redirect' => $to,
260 );
261 $this->output->set_content_type('application/json');
262 $this->output->enable_profiler(FALSE);
263 echo json_encode($out);
264 hc_ci_before_exit();
265 exit;
266 // return;
267 }
268 else
269 {
270 ci_redirect($to);
271 return;
272 }
273 return;
274 }
275 }
276 include_once( dirname(__FILE__) . '/Front_controller.php' );
277 include_once( dirname(__FILE__) . '/Backend_controller.php' );
278 include_once( dirname(__FILE__) . '/Backend_controller_crud.php' );