Example #1
0
 public function index()
 {
     $this->lang->load('login');
     if ($this->user->islogged()) {
         redirect('dashboard');
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $data['site_name'] = $this->config->item('site_name');
     $data['reset_url'] = site_url('login/reset');
     if ($this->input->post() and $this->validateLoginForm() === TRUE) {
         if (!$this->user->login($this->input->post('user'), $this->input->post('password'))) {
             // checks if form validation routines ran successfully
             $this->alert->set('danger', $this->lang->line('alert_username_not_found'));
             redirect('login');
         } else {
             log_activity($this->user->getStaffId(), 'logged in', 'staffs', get_activity_message('activity_logged_in', array('{staff}', '{link}'), array($this->user->getStaffName(), admin_url('staffs/edit?id=' . $this->user->getStaffId()))));
             if ($previous_url = $this->session->tempdata('previous_url')) {
                 $this->session->unset_tempdata('previous_url');
                 redirect($previous_url);
             }
             redirect(referrer_url());
         }
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('login', $data);
 }
Example #2
0
 public function index()
 {
     if (!$this->cart->contents()) {
         // checks if cart contents is empty
         $this->alert->set('alert', $this->lang->line('alert_no_menu_to_order'));
         redirect(referrer_url());
         // redirect to menus page and display error
     }
     if ($this->config->item('location_order') === '1' and !$this->location->hasSearchQuery()) {
         // else if local restaurant is not selected
         $this->alert->set('alert', $this->lang->line('alert_no_selected_local'));
         redirect(referrer_url());
         // redirect to menus page and display error
     }
     if (!$this->location->isOpened() and $this->config->item('future_orders') !== '1') {
         // else if local restaurant is not open
         $this->alert->set('alert', $this->lang->line('alert_location_closed'));
         redirect(referrer_url());
         // redirect to previous page and display error
     }
     if (!$this->location->hasDelivery() and !$this->location->hasCollection() and $this->config->item('location_order') === '1') {
         // else if local restaurant is not open
         $this->alert->set('alert', $this->lang->line('alert_order_unavailable'));
         redirect(referrer_url());
         // redirect to previous page and display error
     }
     if ($this->location->orderType() === '1' and !$this->location->checkMinimumOrder($this->cart->total())) {
         // checks if cart contents is empty
         redirect(referrer_url());
         // redirect to previous page and display error
     }
     if (!$this->customer->islogged() and $this->config->item('guest_order') !== '1') {
         // else if customer is not logged in
         $this->alert->set('alert', $this->lang->line('alert_customer_not_logged'));
         redirect('account/login');
         // redirect to account register page and display error
     }
     if ($this->input->post() and $this->_validateCheckout() === TRUE) {
         // check if post data and validate checkout is successful
         redirect('checkout');
     }
     $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/');
     $this->template->setBreadcrumb($this->lang->line('text_heading'), 'checkout');
     $this->template->setTitle($this->lang->line('text_heading'));
     $data['text_login_register'] = $this->customer->isLogged() ? sprintf($this->lang->line('text_logout'), $this->customer->getFirstName(), site_url('account/logout')) : sprintf($this->lang->line('text_registered'), site_url('account/login'));
     $order_data = $this->session->userdata('order_data');
     $data['_action'] = site_url('checkout');
     if (isset($order_data['customer_id']) and $order_data['customer_id'] !== $this->customer->getId()) {
         $order_data = array();
         $this->session->unset_userdata('order_data');
     }
     $data = $this->getFormData($order_data, $data);
     $this->template->setPartials(array('header', 'content_top', 'content_left', 'content_right', 'content_bottom', 'footer'));
     $this->template->render('checkout', $data);
 }
Example #3
0
 public function edit()
 {
     $this->user->restrict('Admin.Modules.Access');
     $extension_name = $this->input->get('name');
     $action = $this->input->get('action');
     $loaded = FALSE;
     $error_msg = FALSE;
     if ($extension = $this->Extensions_model->getExtension('module', $extension_name, FALSE)) {
         $data['extension_name'] = $extension['name'];
         $ext_controller = $extension['name'] . '/admin_' . $extension['name'];
         $ext_class = strtolower('admin_' . $extension['name']);
         if (isset($extension['installed'], $extension['config'], $extension['options']) and $action === 'edit') {
             if ($extension['config'] === FALSE) {
                 $error_msg = $this->lang->line('error_config');
             } else {
                 if ($extension['options'] === FALSE) {
                     $error_msg = $this->lang->line('error_options');
                 } else {
                     if ($extension['installed'] === FALSE) {
                         $error_msg = $this->lang->line('error_installed');
                     } else {
                         $this->load->module($ext_controller);
                         if (class_exists($ext_class, FALSE)) {
                             $data['extension'] = $this->{$ext_class}->index($extension);
                             $loaded = TRUE;
                         } else {
                             $error_msg = sprintf($this->lang->line('error_failed'), $extension_name);
                         }
                     }
                 }
             }
         }
     }
     if ($this->input->get('name') and $this->input->get('action') and $action !== 'edit') {
         $_POST = $_GET;
         if ($this->input->get('action') === 'install' and $this->_install() === TRUE) {
             redirect('extensions');
         } else {
             if ($this->input->get('action') === 'uninstall' and $this->_uninstall() === TRUE) {
                 redirect('extensions');
             } else {
                 if ($this->input->get('action') === 'delete' and $this->_delete() === TRUE) {
                     redirect('extensions');
                 }
             }
         }
     }
     if (!$loaded or $error_msg) {
         $this->alert->set('warning', $error_msg);
         redirect(referrer_url());
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('extensions_edit', $data);
 }
Example #4
0
 public function edit()
 {
     $this->user->restrict('Admin.Modules.Access');
     $extension_name = $this->input->get('name');
     $loaded = FALSE;
     $error_msg = FALSE;
     if ($extension = $this->Extensions_model->getExtension($extension_name)) {
         $data['extension_name'] = $extension_name;
         $ext_controller = $extension['name'] . '/admin_' . $extension['name'];
         $ext_class = ucfirst('admin_' . $extension['name']);
         if (isset($extension['config'], $extension['installed'], $extension['settings'])) {
             if ($extension['config'] !== TRUE) {
                 $error_msg = $this->lang->line('error_config');
             } else {
                 if ($extension['settings'] === FALSE) {
                     $error_msg = $this->lang->line('error_options');
                 } else {
                     if ($extension['installed'] === FALSE) {
                         $error_msg = $this->lang->line('error_installed');
                     } else {
                         $this->load->module($ext_controller);
                         if (class_exists($ext_class, FALSE)) {
                             $data['extension'] = $this->{strtolower($ext_class)}->index($extension);
                             $loaded = TRUE;
                         } else {
                             $error_msg = sprintf($this->lang->line('error_failed'), $ext_class);
                         }
                     }
                 }
             }
         }
     }
     if (!$loaded or $error_msg !== FALSE) {
         $this->alert->set('warning', $error_msg);
         redirect(referrer_url());
     }
     $this->template->render('extensions_edit', $data);
 }
 public function remove()
 {
     // remove() method to update cart
     $json = array();
     if (!$json) {
         if ($this->cart->update(array('rowid' => $this->input->post('row_id'), 'qty' => $this->input->post('quantity')))) {
             // pass the cart_data array to add item to cart, if successful
             $json['success'] = $this->lang->line('alert_menu_updated');
             // display success message
         } else {
             // else redirect to menus page
             $json['redirect'] = site_url(referrer_url());
         }
     }
     $this->output->set_output(json_encode($json));
     // encode the json array and set final out to be sent to jQuery AJAX
 }
Example #6
0
 public function restrict($permission, $uri = '')
 {
     // If user isn't logged in, redirect to the login page.
     if (!$this->is_logged and $this->uri->rsegment(1) !== 'login') {
         redirect(root_url(ADMINDIR . '/login'));
     }
     if (empty($permission)) {
         return TRUE;
     }
     // Split the permission string into array and
     // remove the last element and use it as  the permission action
     $permission = explode('.', $permission);
     $action = '';
     if (count($permission) === 3) {
         $action = strtolower(array_pop($permission));
     }
     $permission = implode('.', $permission);
     // Check whether the user has the proper permissions action.
     if (($has_permission = $this->checkPermittedActions($permission, $action, TRUE)) === TRUE) {
         return TRUE;
     }
     if ($uri === '') {
         // get the previous page from the session.
         $uri = referrer_url();
         // If previous page and current page are the same, but the user no longer
         // has permission, redirect to site URL to prevent an infinite loop.
         if ($uri === current_url() and !$this->CI->input->post()) {
             $uri = site_url();
         }
     }
     if (!$this->CI->input->is_ajax_request()) {
         // remove later
         redirect($uri);
     }
 }
Example #7
0
 public function delete()
 {
     $this->user->restrict('Admin.Extensions.Access');
     $this->user->restrict('Admin.Extensions.Delete');
     $this->template->setTitle($this->lang->line('text_delete_heading'));
     $this->template->setHeading($this->lang->line('text_delete_heading'));
     $data['extension_name'] = $this->input->get('name') ? $this->input->get('name') : $this->uri->rsegment(4);
     if (empty($this->uri->rsegment(3)) or !$this->Extensions_model->extensionExists($data['extension_name'])) {
         redirect(referrer_url());
     }
     $config = $this->extension->loadConfig($data['extension_name'], FALSE, TRUE);
     $data['extension_title'] = isset($config['extension_meta']['title']) ? $config['extension_meta']['title'] : '';
     $data['extension_type'] = isset($config['extension_meta']['type']) ? $config['extension_meta']['type'] : '';
     if ($this->input->post('confirm_delete') === $data['extension_name']) {
         if ($this->Extensions_model->delete($this->uri->rsegment(3), $data['extension_name'])) {
             log_activity($this->user->getStaffId(), 'deleted', 'extensions', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), 'deleted', $data['extension_type'] . ' extension', $data['extension_title'])));
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), "Extension {$data['extension_name']} deleted "));
         } else {
             $this->alert->danger_now($this->lang->line('alert_error_try_again'));
         }
         redirect('extensions?filter_type=' . $data['extension_type']);
     }
     $this->load->helper('directory');
     $files = $this->Extensions_model->getExtensionFiles($data['extension_name']);
     $data['files_to_delete'] = $files;
     $this->template->render('extensions_delete', $data);
 }
Example #8
0
 public function restrict($permission, $uri = '')
 {
     // If user isn't logged in, redirect to the login page.
     if (!$this->is_logged and $this->uri->rsegment(1) !== 'login') {
         redirect(admin_url('login'));
     }
     // Check whether the user has the proper permissions action.
     if (($has_permission = $this->checkPermittedActions($permission, TRUE)) === TRUE) {
         return TRUE;
     }
     if ($uri === '') {
         // get the previous page from the session.
         $uri = referrer_url();
         // If previous page and current page are the same, but the user no longer
         // has permission, redirect to site URL to prevent an infinite loop.
         if (empty($uri) or $uri === current_url() and !$this->CI->input->post()) {
             $uri = site_url();
         }
     }
     if (!$this->CI->input->is_ajax_request()) {
         // remove later
         redirect($uri);
     }
 }
Example #9
0
 public function coupon()
 {
     // _updateModule() method to update cart
     $json = array();
     if (!$json and $this->cart->contents() and is_string($this->input->post('code'))) {
         switch ($this->input->post('action')) {
             case 'remove':
                 $this->cart->remove_coupon($this->input->post('code'));
                 $json['success'] = $this->lang->line('alert_coupon_removed');
                 // display success message
                 break;
             case 'add':
                 if (($response = $this->validateCoupon($this->input->post('code'))) === TRUE) {
                     $json['success'] = $this->lang->line('alert_coupon_applied');
                     // display success message
                 } else {
                     $json['error'] = $response;
                 }
                 break;
             default:
                 $json['redirect'] = site_url(referrer_url());
                 break;
         }
     }
     $this->output->set_output(json_encode($json));
     // encode the json array and set final out to be sent to jQuery AJAX
 }
Example #10
0
 public function delete()
 {
     $this->user->restrict('Site.Themes.Access');
     $this->user->restrict('Site.Themes.Delete');
     $this->template->setTitle($this->lang->line('text_delete_heading'));
     $this->template->setHeading($this->lang->line('text_delete_heading'));
     $theme = $this->Themes_model->getTheme($this->uri->rsegment(3));
     if (!$this->uri->rsegment(3) or empty($theme)) {
         redirect(referrer_url());
     } else {
         if ($this->config->item(MAINDIR, 'default_themes') === $theme['name'] . '/') {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $this->lang->line('text_deleted') . $this->lang->line('text_theme_is_active')));
             redirect(referrer_url());
         } else {
             if ($this->config->item(MAINDIR . '_parent', 'default_themes') === $theme['name'] . '/') {
                 $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $this->lang->line('text_deleted') . $this->lang->line('text_theme_is_child_active')));
                 redirect(referrer_url());
             }
         }
     }
     $data['theme_title'] = $theme['title'];
     $data['theme_name'] = $theme['name'];
     $data['theme_data'] = !empty($theme['data']) ? TRUE : FALSE;
     $data['delete_action'] = !empty($theme['data']) ? $this->lang->line('text_files_data') : $this->lang->line('text_files');
     if ($this->input->post('confirm_delete') === $theme['name']) {
         $delete_data = $this->input->post('delete_data') === '1' ? TRUE : FALSE;
         if ($this->Themes_model->deleteTheme($theme['name'], $delete_data)) {
             log_activity($this->user->getStaffId(), 'deleted', 'themes', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), 'deleted', 'theme', $data['theme_title'])));
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Theme [' . $theme['name'] . '] ' . $this->lang->line('text_deleted')));
         } else {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $this->lang->line('text_deleted')));
         }
         redirect('themes');
     }
     $data['files_to_delete'] = array();
     $files = find_theme_files($theme['name']);
     foreach ($files as $file) {
         $data['files_to_delete'][] = str_replace(ROOTPATH, '', $file['path']);
     }
     $this->template->render('themes_delete', $data);
 }