name = 'adminmenu'; $this->displayName = $this->l('Admin menu manager'); $this->description = $this->l('Module that allows to manage back office menu exactly as it was in old prestashop 1.6'); $this->tab = 'administration'; $this->author = 'MyPresta.eu'; $this->bootstrap = true; $this->mypresta_link = 'https://mypresta.eu/modules/advertising-and-marketing/voucher-code-after-registration.html'; $this->module_key = '3ec1ba193b0e3c189c4f14761c9188e9'; $this->version = '1.2.0'; parent::__construct(); $this->checkforupdates(); } public function psversion() { return 7; } public function install() { if (!parent::install() || !$this->inDelMenu('install', 'AdminMenuTabs', $this->l('Menu'), 'AdminAdvancedParameters')) { return false; } return true; } public function checkforupdates($display_msg = 0, $form = 0) { // ---------- // // ---------- // // VERSION 12 // // ---------- // // ---------- // $this->mkey = "nlc"; if (@file_exists('../modules/' . $this->name . '/key.php')) { @require_once('../modules/' . $this->name . '/key.php'); } else { if (@file_exists(dirname(__FILE__) . $this->name . '/key.php')) { @require_once(dirname(__FILE__) . $this->name . '/key.php'); } else { if (@file_exists('modules/' . $this->name . '/key.php')) { @require_once('modules/' . $this->name . '/key.php'); } } } if ($form == 1) { return '
' . ($this->psversion() == 6 || $this->psversion() == 7 ? '
' . $this->l('MyPresta updates') . '
' : '') . '
' . ($this->psversion() == 5 ? '' . $this->l('MyPresta updates') . '' : '') . '
' . (Tools::isSubmit('submit_settings_updates_now') ? ($this->inconsistency(0) ? '' : '') . $this->checkforupdates(1) : '') . '

' . $this->l('Turn this option on if you want to check MyPresta.eu for module updates automatically. This option will display notification about new versions of this addon.') . '

' . $this->displayName . '

' . $this->l('This is direct link to official addon page, where you can read about changes in the module (changelog)') . '

'; } else { if (defined('_PS_ADMIN_DIR_')) { if (Tools::isSubmit('submit_settings_updates')) { Configuration::updateValue('mypresta_updates', Tools::getValue('mypresta_updates')); } if (Configuration::get('mypresta_updates') != 0 || (bool)Configuration::get('mypresta_updates') == false) { if (Configuration::get('update_' . $this->name) < (date("U") - 259200)) { $actual_version = adminmenuUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version); } if (adminmenuUpdate::version($this->version) < adminmenuUpdate::version(Configuration::get('updatev_' . $this->name))) { $this->warning = $this->l('New version available, check http://MyPresta.eu for more informations'); } } if ($display_msg == 1) { if (adminmenuUpdate::version($this->version) < adminmenuUpdate::version(adminmenuUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version))) { return "" . $this->l('New version available!') . ""; } else { return "" . $this->l('Module is up to date!') . ""; } } } } } private function InDelMenu($what, $controller, $name = null, $parent = null) { if ($what == 'install') { if ($parent == null) { return; } $tab = new Tab(); $tab->class_name = $controller; $tab->id_parent = Tab::getIdFromClassName($parent); $tab->module = $this->name; $languages = Language::getLanguages(false); foreach ($languages as $lang) { $tab->name[$lang['id_lang']] = $name; } if ($tab->save()) { return true; } } elseif ($what == 'uninstall') { $tab = new Tab(Tab::getIdFromClassName($controller)); if ($tab->delete()) { return true; } } return false; } } class adminmenuUpdate extends adminmenu { public static function version($version) { $version = (int)str_replace(".", "", $version); if (strlen($version) == 3) { $version = (int)$version . "0"; } if (strlen($version) == 2) { $version = (int)$version . "00"; } if (strlen($version) == 1) { $version = (int)$version . "000"; } if (strlen($version) == 0) { $version = (int)$version . "0000"; } return (int)$version; } public static function encrypt($string) { return base64_encode($string); } public static function verify($module, $key, $version) { if (ini_get("allow_url_fopen")) { if (function_exists("file_get_contents")) { $actual_version = @file_get_contents('http://dev.mypresta.eu/update/get.php?module=' . $module . "&version=" . self::encrypt($version) . "&lic=$key&u=" . self::encrypt(_PS_BASE_URL_ . __PS_BASE_URI__)); } } Configuration::updateValue("update_" . $module, date("U")); Configuration::updateValue("updatev_" . $module, $actual_version); return $actual_version; } } ?>