/** * Init context and dependencies, handles POST and GET */ public function init() { // Has to be removed for the next Prestashop version global $currentIndex; parent::init(); if (Tools::getValue('ajax')) { $this->ajax = '1'; } /* Server Params */ $protocol_link = Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; $protocol_content = Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; $this->context->link = new Link($protocol_link, $protocol_content); if (isset($_GET['logout'])) { $this->context->employee->logout(); } if (isset(Context::getContext()->cookie->last_activity)) { if ($this->context->cookie->last_activity + 900 < time()) { $this->context->employee->logout(); } else { $this->context->cookie->last_activity = time(); } } if ($this->controller_name != 'AdminLogin' && (!isset($this->context->employee) || !$this->context->employee->isLoggedBack())) { if (isset($this->context->employee)) { $this->context->employee->logout(); } $email = false; if (Tools::getValue('email') && Validate::isEmail(Tools::getValue('email'))) { $email = Tools::getValue('email'); } Tools::redirectAdmin($this->context->link->getAdminLink('AdminLogin') . (!isset($_GET['logout']) && $this->controller_name != 'AdminNotFound' && Tools::getValue('controller') ? '&redirect=' . $this->controller_name : '') . ($email ? '&email=' . $email : '')); } // Set current index $current_index = 'index.php' . (($controller = Tools::getValue('controller')) ? '?controller=' . $controller : ''); if ($back = Tools::getValue('back')) { $current_index .= '&back=' . urlencode($back); } self::$currentIndex = $current_index; $currentIndex = $current_index; if ((int) Tools::getValue('liteDisplaying')) { $this->display_header = false; $this->display_footer = false; $this->content_only = false; $this->lite_display = true; } if ($this->ajax && method_exists($this, 'ajaxPreprocess')) { $this->ajaxPreProcess(); } $this->context->smarty->assign(array('table' => $this->table, 'current' => self::$currentIndex, 'token' => $this->token, 'host_mode' => defined('_PS_HOST_MODE_') ? 1 : 0, 'stock_management' => (int) Configuration::get('PS_STOCK_MANAGEMENT'))); if ($this->display_header) { $this->context->smarty->assign('displayBackOfficeHeader', Hook::exec('displayBackOfficeHeader', array())); } $this->context->smarty->assign(array('displayBackOfficeTop' => Hook::exec('displayBackOfficeTop', array()), 'submit_form_ajax' => (int) Tools::getValue('submitFormAjax'))); Employee::setLastConnectionDate($this->context->employee->id); $this->initProcess(); $this->initBreadcrumbs(); $this->initModal(); }
/** * Init context and dependencies, handles POST and GET */ public function init() { // Has to be removed for the next Prestashop version global $currentIndex; parent::init(); if (Tools::getValue('ajax')) { $this->ajax = '1'; } /* Server Params */ $protocol_link = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; $protocol_content = isset($useSSL) && $useSSL && Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; $this->context->link = new Link($protocol_link, $protocol_content); if (isset($_GET['logout'])) { $this->context->employee->logout(); } if ($this->controller_name != 'AdminLogin' && (!isset($this->context->employee) || !$this->context->employee->isLoggedBack())) { Tools::redirectAdmin($this->context->link->getAdminLink('AdminLogin') . (!isset($_GET['logout']) ? '&redirect=' . $this->controller_name : '')); } // Set current index $current_index = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/index.php' . (($controller = Tools::getValue('controller')) ? '?controller=' . $controller : ''); if ($back = Tools::getValue('back')) { $current_index .= '&back=' . urlencode($back); } self::$currentIndex = $current_index; $currentIndex = $current_index; if ((int) Tools::getValue('liteDisplaying')) { $this->display_header = false; $this->display_footer = false; $this->content_only = false; $this->lite_display = true; } if ($this->ajax && method_exists($this, 'ajaxPreprocess')) { $this->ajaxPreProcess(); } $this->context->smarty->assign(array('table' => $this->table, 'current' => self::$currentIndex, 'token' => $this->token)); if ($this->display_header) { $this->context->smarty->assign('displayBackOfficeHeader', Hook::exec('displayBackOfficeHeader', array())); } $this->context->smarty->assign(array('displayBackOfficeTop' => Hook::exec('displayBackOfficeTop', array()), 'submit_form_ajax' => (int) Tools::getValue('submitFormAjax'))); $this->initProcess(); }