protected function getOptionFields()
 {
     $forms = array();
     $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
     $carriers = Carrier::getCarriers($this->context->language->id, true);
     $modules = Module::getModulesOnDisk(true);
     $forms = array('payment' => array('title' => $this->l('Average bank fees per payment method'), 'id' => 'payment'), 'carriers' => array('title' => $this->l('Average shipping fees per shipping method'), 'id' => 'carriers'), 'other' => array('title' => $this->l('Other settings'), 'id' => 'other'), 'expenses' => array('title' => $this->l('Other expenses (monthly)'), 'id' => 'expenses'));
     foreach ($forms as &$form) {
         $form['icon'] = 'tab-preferences';
         $form['fields'] = array();
         $form['submit'] = array('title' => $this->l('Save'));
     }
     foreach ($modules as $module) {
         if ($module->tab == 'payments_gateways' && $module->id) {
             $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed in %1$s with %2$s.'), $currency->iso_code, $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
             $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed in %1$s with %2$s. It will be applied on the total paid with taxes.'), $currency->iso_code, $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
             if (Currency::isMultiCurrencyActivated()) {
                 $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed with a foreign currency with %s.'), $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
                 $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed with a foreign currency with %s. It will be applied on the total paid with taxes.'), $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
             }
         }
     }
     foreach ($carriers as $carrier) {
         $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('%% of what you charged the customer for domestic delivery with %s.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
         $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP_OVERSEAS'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('%% of what you charged the customer for overseas delivery with %s.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
     }
     $forms['other']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array('title' => $this->l('Average gross margin (Selling price / Buying price)'), 'desc' => $this->l('Only used if you do not specify your buying price for each product.'), 'validation' => 'isPercentage', 'cast' => 'intval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
     $forms['other']['fields']['CONF_ORDER_FIXED'] = array('title' => $this->l('Other fee per order'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
     $expense_types = array('hosting' => $this->l('Hosting'), 'tools' => $this->l('Tools (E-mailing, etc.)'), 'acounting' => $this->l('Accounting'), 'development' => $this->l('Development'), 'marketing' => $this->l('Marketing (Adwords, etc.)'), 'others' => $this->l('Others'));
     foreach ($expense_types as $expense_type => $expense_label) {
         $forms['expenses']['fields']['CONF_MONTHLY_' . strtoupper($expense_type)] = array('title' => $expense_label, 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
     }
     return $forms;
 }
 public function __construct()
 {
     /* Get all modules then select only payment ones*/
     $modules = Module::getModulesOnDisk();
     foreach ($modules as $module) {
         if ($module->tab == 'Payment') {
             if ($module->id) {
                 $module->country = array();
                 $countries = DB::getInstance()->ExecuteS('SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country WHERE id_module = ' . intval($module->id));
                 foreach ($countries as $country) {
                     $module->country[] = $country['id_country'];
                 }
                 $module->currency = array();
                 $currencies = DB::getInstance()->ExecuteS('SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency WHERE id_module = ' . intval($module->id));
                 foreach ($currencies as $currency) {
                     $module->currency[] = $currency['id_currency'];
                 }
                 $module->group = array();
                 $groups = DB::getInstance()->ExecuteS('SELECT id_group FROM ' . _DB_PREFIX_ . 'module_group WHERE id_module = ' . intval($module->id));
                 foreach ($groups as $group) {
                     $module->group[] = $group['id_group'];
                 }
             } else {
                 $module->country = NULL;
                 $module->currency = NULL;
                 $module->group = NULL;
             }
             $this->paymentModules[] = $module;
         }
     }
     parent::__construct();
 }
 protected function getOptionFields()
 {
     $forms = array();
     $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
     $carriers = Carrier::getCarriers($this->context->language->id, true);
     $modules = Module::getModulesOnDisk(true);
     $forms = array('payment' => array('title' => $this->l('Average bank fees per payment method'), 'id' => 'payment'), 'carriers' => array('title' => $this->l('Average shipping fees per shipping method'), 'id' => 'carriers'), 'other' => array('title' => $this->l('Other settings'), 'id' => 'other'));
     foreach ($forms as &$form) {
         $form['icon'] = 'tab-preferences';
         $form['fields'] = array();
         $form['submit'] = array('title' => $this->l('Save'));
     }
     foreach ($modules as $module) {
         if (isset($module->tab) && $module->tab == 'payments_gateways' && $module->id) {
             $moduleClass = Module::getInstanceByName($module->name);
             if (!$moduleClass->isEnabledForShopContext()) {
                 continue;
             }
             $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed in %1$s with %2$s.'), $currency->iso_code, $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
             $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed in %1$s with %2$s. It will be applied on the total paid with taxes.'), $currency->iso_code, $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
             if (Currency::isMultiCurrencyActivated()) {
                 $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed with a foreign currency with %s.'), $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
                 $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed with a foreign currency with %s. It will be applied on the total paid with taxes.'), $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
             }
         }
     }
     foreach ($carriers as $carrier) {
         $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('For the carrier named %s, indicate the domestic delivery costs  in percentage of the price charged to customers.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
         $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP_OVERSEAS'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('For the carrier named %s, indicate the overseas delivery costs in percentage of the price charged to customers.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
     }
     $forms['carriers']['description'] = $this->l('Method: Indicate the percentage of your carrier margin. For example, if you charge $10 of shipping fees to your customer for each shipment, but you really pay $4 to this carrier, then you should indicate "40" in the percentage field.');
     $forms['other']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array('title' => $this->l('Average gross margin'), 'desc' => $this->l('You should calculate this percentage as follows: ((total sales revenue) - (cost of goods sold)) / (total sales revenue) * 100. This value is only used to calculate the Dashboard approximate gross margin, if you do not specify the wholesale price for each product.'), 'validation' => 'isPercentage', 'cast' => 'intval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
     $forms['other']['fields']['CONF_ORDER_FIXED'] = array('title' => $this->l('Other fees per order'), 'desc' => $this->l('You should calculate this value by making the sum of all of your additional costs per order.'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
     return $forms;
 }
Example #4
0
 public static function ps_cli_load_ps_core()
 {
     //todo: load path
     $configuration = PS_CLI_Configure::getInstance();
     if (!defined('_PS_ADMIN_DIR_')) {
         //	define('_PS_ADMIN_DIR_', getcwd());
         define('_PS_ADMIN_DIR_', $configuration->boPath);
     }
     if (!defined('PS_ADMIN_DIR')) {
         define('PS_ADMIN_DIR', _PS_ADMIN_DIR_);
     }
     /*
        Prestashop checks if config/settings.inc.php exists
        before loading. If it does not exists, it performs
        header('location'). ps-cli must check for this before
        loading prestashop core
     */
     if (!file_exists(_PS_ADMIN_DIR_ . '/../config/settings.inc.php')) {
         echo "Prestashop seems not installed ! (no config/settings.inc.php found)\n";
         die;
     }
     require_once _PS_ADMIN_DIR_ . '/../config/config.inc.php';
     require_once _PS_ADMIN_DIR_ . '/../config/autoload.php';
     require_once _PS_ADMIN_DIR_ . '/functions.php';
     // Load modules
     $modules = Module::getModulesOnDisk(true);
     foreach ($modules as $mod) {
         Module::getInstanceByName($mod);
     }
     $configuration->psCoreLoaded = true;
 }
Example #5
0
 public static function getImportModulesOnDisk()
 {
     $modules = Module::getModulesOnDisk(true);
     foreach ($modules as $key => $module) {
         if (get_parent_class($module) != 'ImportModule') {
             unset($modules[$key]);
         }
     }
     return $modules;
 }
 public function ajaxProcessGetModuleQuickView()
 {
     $modules = Module::getModulesOnDisk();
     foreach ($modules as $module) {
         if ($module->name == Tools::getValue('module')) {
             break;
         }
     }
     $this->context->smarty->assign(array('displayName' => $module->displayName, 'image' => $module->image, 'nb_rates' => (int) $module->nb_rates[0], 'avg_rate' => (int) $module->avg_rate[0], 'badges' => $module->badges, 'compatibility' => $module->compatibility, 'description_full' => $module->description_full, 'additional_description' => $module->additional_description, 'url' => $module->url));
     $this->smartyOutputContent('controllers/modules/quickview.tpl');
     die(1);
 }
    public function __construct()
    {
        $this->bootstrap = true;
        parent::__construct();
        $shop_id = Context::getContext()->shop->id;
        /* Get all modules then select only payment ones */
        $modules = Module::getModulesOnDisk(true);
        foreach ($modules as $module) {
            if ($module->tab == 'payments_gateways') {
                if ($module->id) {
                    if (!get_class($module) == 'SimpleXMLElement') {
                        $module->country = array();
                    }
                    $countries = DB::getInstance()->executeS('
						SELECT id_country
						FROM ' . _DB_PREFIX_ . 'module_country
						WHERE id_module = ' . (int) $module->id . ' AND `id_shop`=' . (int) $shop_id);
                    foreach ($countries as $country) {
                        $module->country[] = $country['id_country'];
                    }
                    if (!get_class($module) == 'SimpleXMLElement') {
                        $module->currency = array();
                    }
                    $currencies = DB::getInstance()->executeS('
						SELECT id_currency
						FROM ' . _DB_PREFIX_ . 'module_currency
						WHERE id_module = ' . (int) $module->id . ' AND `id_shop`=' . (int) $shop_id);
                    foreach ($currencies as $currency) {
                        $module->currency[] = $currency['id_currency'];
                    }
                    if (!get_class($module) == 'SimpleXMLElement') {
                        $module->group = array();
                    }
                    $groups = DB::getInstance()->executeS('
						SELECT id_group
						FROM ' . _DB_PREFIX_ . 'module_group
						WHERE id_module = ' . (int) $module->id . ' AND `id_shop`=' . (int) $shop_id);
                    foreach ($groups as $group) {
                        $module->group[] = $group['id_group'];
                    }
                } else {
                    $module->country = null;
                    $module->currency = null;
                    $module->group = null;
                }
                $this->payment_modules[] = $module;
            }
        }
    }
 public function ajaxProcessGetModuleQuickView()
 {
     $modules = Module::getModulesOnDisk();
     foreach ($modules as $module) {
         if ($module->name == Tools::getValue('module')) {
             break;
         }
     }
     $url = $module->url;
     if (isset($module->type) && ($module->type == 'addonsPartner' || $module->type == 'addonsNative')) {
         $url = $this->context->link->getAdminLink('AdminModules') . '&install=' . urlencode($module->name) . '&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=' . ucfirst($module->name);
     }
     $this->context->smarty->assign(array('displayName' => $module->displayName, 'image' => $module->image, 'nb_rates' => (int) $module->nb_rates[0], 'avg_rate' => (int) $module->avg_rate[0], 'badges' => $module->badges, 'compatibility' => $module->compatibility, 'description_full' => $module->description_full, 'additional_description' => $module->additional_description, 'is_addons_partner' => isset($module->type) && ($module->type == 'addonsPartner' || $module->type == 'addonsNative'), 'url' => $url));
     $this->smartyOutputContent('controllers/modules/quickview.tpl');
     die(1);
 }
 public function searchModule()
 {
     $this->_list['modules'] = array();
     $all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
     foreach ($all_modules as $module) {
         if (stripos($module->name, $this->query) !== false || stripos($module->displayName, $this->query) !== false || stripos($module->description, $this->query) !== false) {
             $module->linkto = 'index.php?tab=AdminModules&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=' . ucfirst($module->name) . '&token=' . Tools::getAdminTokenLite('AdminModules');
             $this->_list['modules'][] = $module;
         }
     }
     if (!is_numeric(trim($this->query)) && !Validate::isEmail($this->query)) {
         $iso_lang = Tools::strtolower(Context::getContext()->language->iso_code);
         $iso_country = Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
         if (($json_content = Tools::file_get_contents('https://api.addons.prestashop.com/' . _PS_VERSION_ . '/search/' . urlencode($this->query) . '/' . $iso_country . '/' . $iso_lang . '/')) != false) {
             $this->_list['addons'] = Tools::jsonDecode($json_content, true);
         }
     }
 }
Example #10
0
 public static function upgrade_all_modules_database()
 {
     //reload modules from disk and perform upgrades
     $modules = Module::getModulesOnDisk();
     foreach ($modules as $module) {
         if (Module::initUpgradeModule($module)) {
             if (!class_exists($module->name)) {
                 if (!file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) {
                     echo "Could not find {$module->name}.php file\n";
                     continue;
                 }
                 require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php';
             }
             if ($object = new $module->name()) {
                 $object->runUpgradeModule();
                 if (count($errors_module_list = $object->getErrors())) {
                     $upgradeErrors[] = 'name: ' . $module->displayName . 'message: ' . $errors_module_list;
                 }
                 unset($object);
             } else {
                 echo "error, could not create object from {$module->name}\n";
             }
         }
         Language::updateModulesTranslations(array($module->name));
     }
     if (empty($upgradeErrors)) {
         return true;
     } else {
         foreach ($upgradeErrors as $error) {
             echo $error['name'] . ': ' . $error['message'] . "\n";
         }
         return false;
     }
 }
 public static function getModulesToUpdate()
 {
     $context = Context::getContext();
     $logged_on_addons = false;
     if (isset($context->cookie->username_addons) && isset($context->cookie->password_addons) && !empty($context->cookie->username_addons) && !empty($context->cookie->password_addons)) {
         $logged_on_addons = true;
     }
     $modules = Module::getModulesOnDisk(true, $logged_on_addons, $context->employee->id);
     $upgrade_available = 0;
     foreach ($modules as $km => $module) {
         if ($module->installed && isset($module->version_addons) && $module->version_addons) {
             // SimpleXMLElement
             ++$upgrade_available;
         }
     }
     return $upgrade_available;
 }
 public function initContent()
 {
     // Adding Css
     $this->addCSS(__PS_BASE_URI__ . str_replace(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR, '', _PS_ADMIN_DIR_) . '/themes/' . $this->bo_theme . '/css/modules.css', 'all');
     // If we are on a module configuration, no need to load all modules
     if (Tools::getValue('configure') != '') {
         return true;
     }
     // Init
     $smarty = $this->context->smarty;
     $autocompleteList = 'var moduleList = [';
     $nameCountryDefault = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT'));
     $categoryFiltered = array();
     $filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_' . (int) $this->id_employee));
     if (count($filterCategories) > 0) {
         foreach ($filterCategories as $fc) {
             if (!empty($fc)) {
                 $categoryFiltered[$fc] = 1;
             }
         }
     }
     foreach ($this->list_modules_categories as $k => $v) {
         $this->list_modules_categories[$k]['nb'] = 0;
     }
     // Retrieve Modules Preferences
     $modules_preferences = '';
     $tab_modules_preferences = array();
     $modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'module_preference` WHERE `id_employee` = ' . (int) $this->id_employee);
     $tab_modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'tab_module_preference` WHERE `id_employee` = ' . (int) $this->id_employee);
     foreach ($tab_modules_preferences_tmp as $i => $j) {
         $tab_modules_preferences[$j['module']][] = $j['id_tab'];
     }
     foreach ($modules_preferences_tmp as $k => $v) {
         if ($v['interest'] == null) {
             unset($v['interest']);
         }
         if ($v['favorite'] == null) {
             unset($v['favorite']);
         }
         $modules_preferences[$v['module']] = $v;
     }
     // Retrieve Modules List
     $modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
     $this->initModulesList($modules);
     $this->nb_modules_total = count($modules);
     $module_errors = array();
     $module_success = array();
     // Browse modules list
     foreach ($modules as $km => $module) {
         //if we are in favorites view we only display installed modules
         if (Tools::getValue('select') == 'favorites' && !$module->id) {
             unset($modules[$km]);
             continue;
         }
         // Upgrade Module process, init check if a module could be upgraded
         if (Module::initUpgradeModule($module)) {
             // When the XML cache file is up-to-date, the module may not be loaded yet
             if (!class_exists($module->name)) {
                 if (!file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) {
                     continue;
                 }
                 require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php';
             }
             if ($object = new $module->name()) {
                 $object->runUpgradeModule();
                 if (count($errors_module_list = $object->getErrors())) {
                     $module_errors[] = array('name' => $module->name, 'message' => $errors_module_list);
                 } else {
                     if (count($conf_module_list = $object->getConfirmations())) {
                         $module_success[] = array('name' => $module->name, 'message' => $conf_module_list);
                     }
                 }
                 unset($object);
             }
         } elseif (Module::getUpgradeStatus($module->name)) {
             // When the XML cache file is up-to-date, the module may not be loaded yet
             if (!class_exists($module->name)) {
                 if (file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) {
                     require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php';
                     $object = new $module->name();
                     $module_success[] = array('name' => $module->name, 'message' => array(0 => $this->l('Current version:') . $object->version, 1 => $this->l('No file upgrades applied (none exist).')));
                 } else {
                     continue;
                 }
             }
             unset($object);
         }
         // Make modules stats
         $this->makeModulesStats($module);
         // Assign warnings
         if ($module->active && isset($module->warning) && !empty($module->warning)) {
             $this->warnings[] = sprintf($this->l('%1$s: %2$s'), $module->displayName, $module->warning);
         }
         // AutoComplete array
         $autocompleteList .= Tools::jsonEncode(array('displayName' => (string) $module->displayName, 'desc' => (string) $module->description, 'name' => (string) $module->name, 'author' => (string) $module->author, 'image' => isset($module->image) ? (string) $module->image : '', 'option' => '')) . ', ';
         // Apply filter
         if ($this->isModuleFiltered($module) && Tools::getValue('select') != 'favorites') {
             unset($modules[$km]);
         } else {
             $this->fillModuleData($module);
             $module->categoryName = isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name'];
             if (isset($modules_preferences[$modules[$km]->name])) {
                 $modules[$km]->preferences = $modules_preferences[$modules[$km]->name];
             }
         }
         unset($object);
     }
     // Don't display categories without modules
     $cleaned_list = array();
     foreach ($this->list_modules_categories as $k => $list) {
         if ($list['nb'] > 0) {
             $cleaned_list[$k] = $list;
         }
     }
     // Actually used for the report of the upgraded errors
     if (count($module_errors)) {
         $html = $this->generateHtmlMessage($module_errors);
         $this->errors[] = sprintf(Tools::displayError('The following module(s) were not upgraded successfully: %s'), $html);
     }
     if (count($module_success)) {
         $html = $this->generateHtmlMessage($module_success);
         $this->confirmations[] = sprintf($this->l('The following module(s) were upgraded successfully:') . ' %s', $html);
     }
     // Init tpl vars for smarty
     $tpl_vars = array();
     $tpl_vars['token'] = $this->token;
     $tpl_vars['currentIndex'] = self::$currentIndex;
     $tpl_vars['dirNameCurrentIndex'] = dirname(self::$currentIndex);
     $tpl_vars['ajaxCurrentIndex'] = str_replace('index', 'ajax-tab', self::$currentIndex);
     $tpl_vars['autocompleteList'] = rtrim($autocompleteList, ' ,') . '];';
     $tpl_vars['showTypeModules'] = $this->filter_configuration['PS_SHOW_TYPE_MODULES_' . (int) $this->id_employee];
     $tpl_vars['showCountryModules'] = $this->filter_configuration['PS_SHOW_COUNTRY_MODULES_' . (int) $this->id_employee];
     $tpl_vars['showInstalledModules'] = $this->filter_configuration['PS_SHOW_INSTALLED_MODULES_' . (int) $this->id_employee];
     $tpl_vars['showEnabledModules'] = $this->filter_configuration['PS_SHOW_ENABLED_MODULES_' . (int) $this->id_employee];
     $tpl_vars['nameCountryDefault'] = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT'));
     $tpl_vars['isoCountryDefault'] = $this->iso_default_country;
     $tpl_vars['categoryFiltered'] = $categoryFiltered;
     $tpl_vars['modules'] = $modules;
     $tpl_vars['nb_modules'] = $this->nb_modules_total;
     $tpl_vars['nb_modules_favorites'] = Db::getInstance()->getValue('SELECT COUNT(`id_module_preference`) FROM `' . _DB_PREFIX_ . 'module_preference` WHERE `id_employee` = ' . (int) $this->id_employee . ' AND `favorite` = 1 AND (`interest` = 1 OR `interest` IS NULL)');
     $tpl_vars['nb_modules_installed'] = $this->nb_modules_installed;
     $tpl_vars['nb_modules_uninstalled'] = $tpl_vars['nb_modules'] - $tpl_vars['nb_modules_installed'];
     $tpl_vars['nb_modules_activated'] = $this->nb_modules_activated;
     $tpl_vars['nb_modules_unactivated'] = $tpl_vars['nb_modules_installed'] - $tpl_vars['nb_modules_activated'];
     $tpl_vars['list_modules_categories'] = $cleaned_list;
     $tpl_vars['list_modules_authors'] = $this->modules_authors;
     $tpl_vars['check_url_fopen'] = ini_get('allow_url_fopen') ? 'ok' : 'ko';
     $tpl_vars['check_openssl'] = extension_loaded('openssl') ? 'ok' : 'ko';
     $tpl_vars['add_permission'] = $this->tabAccess['add'];
     $tpl_vars['tab_modules_preferences'] = $tab_modules_preferences;
     if ($this->logged_on_addons) {
         $tpl_vars['logged_on_addons'] = 1;
         $tpl_vars['username_addons'] = $this->context->cookie->username_addons;
     }
     $smarty->assign($tpl_vars);
 }
 public function searchModule()
 {
     $this->_list['modules'] = array();
     $all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
     foreach ($all_modules as $module) {
         if (stripos($module->name, $this->query) !== false || stripos($module->displayName, $this->query) !== false || stripos($module->description, $this->query) !== false) {
             $module->linkto = 'index.php?tab=AdminModules&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=anchor' . ucfirst($module->name) . '&token=' . Tools::getAdminTokenLite('AdminModules');
             $this->_list['modules'][] = $module;
         }
     }
 }
Example #14
0
 /**
  * Get list of all available Module Front controllers
  *
  * @return array
  */
 public static function getModuleControllers($type = 'all', $module = null)
 {
     $modules_controllers = array();
     if (is_null($module)) {
         $modules = Module::getModulesOnDisk(true);
     } elseif (!is_array($module)) {
         $modules = array(Module::getInstanceByName($module));
     } else {
         $modules = array();
         foreach ($module as $_mod) {
             $modules[] = Module::getInstanceByName($_mod);
         }
     }
     foreach ($modules as $mod) {
         foreach (Dispatcher::getControllersInDirectory(_PS_MODULE_DIR_ . $mod->name . '/controllers/') as $controller) {
             if ($type == 'admin') {
                 if (strpos($controller, 'Admin') !== false) {
                     $modules_controllers[$mod->name][] = $controller;
                 }
             } elseif ($type == 'front') {
                 if (strpos($controller, 'Admin') === false) {
                     $modules_controllers[$mod->name][] = $controller;
                 }
             } else {
                 $modules_controllers[$mod->name][] = $controller;
             }
         }
     }
     return $modules_controllers;
 }
 public function __construct()
 {
     $this->bootstrap = true;
     parent::__construct();
     $id_shop = Context::getContext()->shop->id;
     /* Get all modules then select only payment ones */
     $modules = Module::getModulesOnDisk(true);
     $moduleManagerBuilder = ModuleManagerBuilder::getInstance();
     $moduleRepository = $moduleManagerBuilder->buildRepository();
     foreach ($modules as $module) {
         $addonModule = $moduleRepository->getModule($module->name);
         if ($addonModule->attributes->get('parent_class') == 'PaymentModule') {
             if ($module->id) {
                 if (!get_class($module) == 'SimpleXMLElement') {
                     $module->country = array();
                 }
                 $sql = new DbQuery();
                 $sql->select('`id_country`');
                 $sql->from('module_country');
                 $sql->where('`id_module` = ' . (int) $module->id);
                 $sql->where('`id_shop` = ' . (int) $id_shop);
                 $countries = Db::getInstance()->executeS($sql);
                 foreach ($countries as $country) {
                     $module->country[] = $country['id_country'];
                 }
                 if (!get_class($module) == 'SimpleXMLElement') {
                     $module->currency = array();
                 }
                 $sql = new DbQuery();
                 $sql->select('`id_currency`');
                 $sql->from('module_currency');
                 $sql->where('`id_module` = ' . (int) $module->id);
                 $sql->where('`id_shop` = ' . (int) $id_shop);
                 $currencies = Db::getInstance()->executeS($sql);
                 foreach ($currencies as $currency) {
                     $module->currency[] = $currency['id_currency'];
                 }
                 if (!get_class($module) == 'SimpleXMLElement') {
                     $module->group = array();
                 }
                 $sql = new DbQuery();
                 $sql->select('`id_group`');
                 $sql->from('module_group');
                 $sql->where('`id_module` = ' . (int) $module->id);
                 $sql->where('`id_shop` = ' . (int) $id_shop);
                 $groups = Db::getInstance()->executeS($sql);
                 foreach ($groups as $group) {
                     $module->group[] = $group['id_group'];
                 }
                 if (!get_class($module) == 'SimpleXMLElement') {
                     $module->reference = array();
                 }
                 $sql = new DbQuery();
                 $sql->select('`id_reference`');
                 $sql->from('module_carrier');
                 $sql->where('`id_module` = ' . (int) $module->id);
                 $sql->where('`id_shop` = ' . (int) $id_shop);
                 $carriers = Db::getInstance()->executeS($sql);
                 foreach ($carriers as $carrier) {
                     $module->reference[] = $carrier['id_reference'];
                 }
             } else {
                 $module->country = null;
                 $module->currency = null;
                 $module->group = null;
             }
             $this->payment_modules[] = $module;
         }
     }
 }
Example #16
0
    public function getContent()
    {
        if (isset($_POST['submitSettings'])) {
            $this->_postProcess();
        }
        $id_lang = Configuration::get('PS_LANG_DEFAULT');
        $categories = Category::getSimpleCategories($id_lang);
        $carriers = Carrier::getCarriers($id_lang);
        $this->_html .= '
		<fieldset><legend>FIA-NET - Système d\'Analyse des Commandes</legend>
			<img src="../modules/' . $this->name . '/logo.jpg" style="float:right;margin:5px 10px 5px 0" />
			FIA-NET, le leader français de la lutte contre la fraude à la carte bancaire sur internet !<br /><br />
			Avec son réseau mutualisé de plus de 1 700 sites marchands, et sa base de données de 14 millions de cyber-acheteurs, le Système d’Analyse des Commandes vous offre une protection complète et unique contre le risque d’impayé.<br /><br />
			Le logiciel expert (SAC) score vos transactions en quasi temps réel à partir de plus de 200 critères pour valider plus de 92 % de vos transactions.<br />
			Le contrôle humain, prenant en charge les transactions les plus risqués, associé à l’assurance FIA-NET vous permet de valider et garantir jusqu’à 100 % de vos transactions.<br /><br />
			Ne restez pas isolé face à l’explosion des réseaux de fraudeurs !
			<p>' . $this->l('To sign in, check out: ') . ' <u><a href="https://www.fia-net.com/marchands/devispartenaire.php?p=185" target="_blank">' . $this->l('Fia-net Website') . '</a></u></p>
		</fieldset><br />
		<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post">
			<fieldset>
				<legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Settings') . '</legend>
				<label>' . $this->l('Login') . '</label>
				<div class="margin-form">
					<input type="text" name="fianetfraud_login" value="' . Configuration::get('SAC_LOGIN') . '"/>
				</div>
				<label>' . $this->l('Password') . '</label>
				<div class="margin-form">
					<input type="text" name="fianetfraud_password" value="' . Configuration::get('SAC_PASSWORD') . '"/>
				</div>
				<label>' . $this->l('Site ID') . '</label>
				<div class="margin-form">
					<input type="text" name="fianetfraud_siteid" value="' . Configuration::get('SAC_SITEID') . '"/>
				</div>
				<label>' . $this->l('Production mode') . '</label>
				<div class="margin-form">
					<input type="checkbox" name="fianetfraud_production" id="activated_on" value="1" ' . (Configuration::get('SAC_PRODUCTION') == 1 ? 'checked="checked" ' : '') . '/>
				</div>
				<label>' . $this->l('Default Product Type') . '</label>
				<div class="margin-form">
					<select name="fianetfraud_product_type">
						<option value="0">' . $this->l('-- Choose --') . '</option>';
        foreach ($this->_product_type as $k => $product_type) {
            $this->_html .= '<option value="' . $k . '"' . (Configuration::get('SAC_DEFAULT_PRODUCT_TYPE') == $k ? ' selected="selected"' : '') . '>' . $product_type . '</option>';
        }
        $this->_html .= '</select>
				</div>
			</fieldset><br />
			<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Category Detail') . '</legend>
			<label>' . $this->l('Category Detail') . '</label>
			<div class="margin-form">
			<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Category') . '</th><th>' . $this->l('Category Type') . '</th></tr></thead><tbody>';
        foreach ($categories as $category) {
            $this->_html .= '<tr><td>' . $category['name'] . '</td><td>
			<select name="cat_' . $category['id_category'] . '" id="cat_' . $category['id_category'] . '">
				<option value="0">' . $this->l('Choose a category...') . '</option>';
            foreach ($this->_product_type as $id => $cat) {
                $this->_html .= '<option value="' . $id . '" ' . (Configuration::get('SAC_CATEGORY_TYPE_' . $category['id_category']) == $id ? ' selected="true"' : '') . '>' . $cat . '</option>';
            }
            $this->_html .= '</select></td></tr>';
        }
        $this->_html .= '</tbody></table></div>
			</fieldset>
			<div class="clear">&nbsp;</div>
			<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Carrier Configuration') . '</legend>
				<label>' . $this->l('Carrier Detail') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Carrier') . '</th><th>' . $this->l('Carrier Type') . '</th></tr></thead><tbody>';
        foreach ($carriers as $carrier) {
            $this->_html .= '<tr><td>' . $carrier['name'] . '</td><td><select name="carrier_' . $carrier['id_carrier'] . '" id="cat_' . $carrier['id_carrier'] . '">
			<option value="0">' . $this->l('Choose a carrier type...') . '</option>';
            foreach ($this->_carrier_type as $id => $type) {
                $this->_html .= '<option value="' . $id . '"' . (Configuration::get('SAC_CARRIER_TYPE_' . $carrier['id_carrier']) == $id ? ' selected="true"' : '') . '>' . $type . '</option>';
            }
            $this->_html .= '</select></td>';
        }
        $this->_html .= '</tbody></table></margin>
			</div>
			<div class="clear">&nbsp;</div>
			<label>' . $this->l('Default Carrier Type') . '</label>
			<div class="margin-form">
				<select name="fianetfraud_default_carrier">';
        foreach ($this->_carrier_type as $k => $type) {
            $this->_html .= '<option value="' . $k . '"' . ($k == Configuration::get('SAC_DEFAULT_CARRIER_TYPE') ? ' selected' : '') . '>' . $type . '</option>';
        }
        $this->_html .= '</select>
			</div>
			</fieldset><div class="clear">&nbsp;</div>';
        /* Get all modules then select only payment ones*/
        $modules = Module::getModulesOnDisk();
        $modules_is_fianet = explode(',', Configuration::get('SAC_PAYMENT_MODULE'));
        $this->paymentModules = array();
        foreach ($modules as $module) {
            if (method_exists($module, 'hookPayment')) {
                if ($module->id) {
                    $module->country = array();
                    $countries = DB::getInstance()->ExecuteS('SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country WHERE id_module = ' . (int) $module->id);
                    foreach ($countries as $country) {
                        $module->country[] = $country['id_country'];
                    }
                    $module->currency = array();
                    $currencies = DB::getInstance()->ExecuteS('SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency WHERE id_module = ' . (int) $module->id);
                    foreach ($currencies as $currency) {
                        $module->currency[] = $currency['id_currency'];
                    }
                    $module->group = array();
                    $groups = DB::getInstance()->ExecuteS('SELECT id_group FROM ' . _DB_PREFIX_ . 'module_group WHERE id_module = ' . (int) $module->id);
                    foreach ($groups as $group) {
                        $module->group[] = $group['id_group'];
                    }
                } else {
                    $module->country = NULL;
                    $module->currency = NULL;
                    $module->group = NULL;
                }
                $this->paymentModules[] = $module;
            }
        }
        $this->_html .= '<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Payment Configuration') . '</legend>
				<label>' . $this->l('Payment Detail') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table" ><thead><tr>
						<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'payementBox[]\', this.checked)" /></th>	
						<th>' . $this->l('Payment Module') . '</th><th>' . $this->l('Payment Type') . '</th></tr></thead><tbody>';
        foreach ($this->paymentModules as $module) {
            $this->_html .= '<tr><td><input type="checkbox" class="noborder" value="' . substr($module->name, 0, 15) . '" name="payementBox[]" ' . (in_array(substr($module->name, 0, 15), $modules_is_fianet) ? 'checked="checked"' : '') . '></td>';
            $this->_html .= '<td><img src="' . __PS_BASE_URI__ . 'modules/' . $module->name . '/logo.gif" alt="' . $module->name . '" title="' . $module->displayName . '" />' . stripslashes($module->displayName) . '</td><td><select name="' . substr($module->name, 0, 15) . '">';
            $this->_html .= '<option value="0">' . $this->l('-- Choose --') . '</option>';
            foreach ($this->_payement_type as $type) {
                $this->_html .= '<option ' . (Configuration::get('SAC_PAYMENT_TYPE_' . substr($module->name, 0, 15)) == $type ? 'selected="true"' : '') . '>' . $type . '</option>';
            }
            $this->_html .= '</select></tr>';
        }
        $this->_html .= '</tbody></table></margin></fieldset><br class="clear" /><br />
			<center><input type="submit" name="submitSettings" value="' . $this->l('Save') . '" class="button" /></center>
		</form>
		<div class="clear">&nbsp;</div>';
        return $this->_html;
    }
Example #17
0
    public function displayList()
    {
        global $currentIndex, $cookie;
        $modulesAuthors = array();
        $autocompleteList = 'var moduleList = [';
        $showTypeModules = Configuration::get('PS_SHOW_TYPE_MODULES_' . (int) $cookie->id_employee);
        $showInstalledModules = Configuration::get('PS_SHOW_INSTALLED_MODULES_' . (int) $cookie->id_employee);
        $showEnabledModules = Configuration::get('PS_SHOW_ENABLED_MODULES_' . (int) $cookie->id_employee);
        $showCountryModules = Configuration::get('PS_SHOW_COUNTRY_MODULES_' . (int) $cookie->id_employee);
        $nameCountryDefault = Country::getNameById($cookie->id_lang, _PS_COUNTRY_DEFAULT_);
        $isoCountryDefault = Country::getIsoById(_PS_COUNTRY_DEFAULT_);
        $serialModules = '';
        $modules = Module::getModulesOnDisk(true);
        foreach ($modules as $module) {
            if (!in_array($module->name, $this->listNativeModules)) {
                $serialModules .= $module->name . ' ' . $module->version . '-' . ($module->active ? 'a' : 'i') . "\n";
            }
            $moduleAuthor = $module->author;
            if (!empty($moduleAuthor) && $moduleAuthor != "") {
                $modulesAuthors[(string) $moduleAuthor] = true;
            }
        }
        $serialModules = urlencode($serialModules);
        $filterName = Tools::getValue('filtername');
        if (!empty($filterName)) {
            echo '
			<script type="text/javascript">
				$(document).ready(function() {	
					$(\'#all_open\').hide();
					$(\'#all_close\').show();			 
					$(\'.tab_module_content\').each(function(){
						$(this).slideDown();
						$(\'.header_module_img\').each(function(){
							$(this).attr(\'src\', \'../img/admin/less.png\');
						});
					});
				});
			</script>';
        }
        //filter module list
        foreach ($modules as $key => $module) {
            switch ($showTypeModules) {
                case 'nativeModules':
                    if (!in_array($module->name, $this->listNativeModules)) {
                        unset($modules[$key]);
                    }
                    break;
                case 'partnerModules':
                    if (!in_array($module->name, $this->listPartnerModules)) {
                        unset($modules[$key]);
                    }
                    break;
                case 'otherModules':
                    if (in_array($module->name, $this->listPartnerModules) or in_array($module->name, $this->listNativeModules)) {
                        unset($modules[$key]);
                    }
                    break;
                default:
                    if (strpos($showTypeModules, 'authorModules[') !== false) {
                        $author_selected = $this->_getSubmitedModuleAuthor($showTypeModules);
                        $modulesAuthors[$author_selected] = 'selected';
                        // setting selected author in authors set
                        if (empty($module->author) || $module->author != $author_selected) {
                            unset($modules[$key]);
                        }
                    }
                    break;
            }
            switch ($showInstalledModules) {
                case 'installed':
                    if (!$module->id) {
                        unset($modules[$key]);
                    }
                    break;
                case 'unistalled':
                    if ($module->id) {
                        unset($modules[$key]);
                    }
                    break;
            }
            switch ($showEnabledModules) {
                case 'enabled':
                    if (!$module->active) {
                        unset($modules[$key]);
                    }
                    break;
                case 'disabled':
                    if ($module->active) {
                        unset($modules[$key]);
                    }
                    break;
            }
            if ($showCountryModules) {
                if (isset($module->limited_countries) and !empty($module->limited_countries) and (is_array($module->limited_countries) and sizeof($module->limited_countries) and !in_array(strtolower($isoCountryDefault), $module->limited_countries) or !is_array($module->limited_countries) and strtolower($isoCountryDefault) != strval($module->limited_countries))) {
                    unset($modules[$key]);
                }
            }
            if (!empty($filterName)) {
                if (stristr($module->name, $filterName) === false and stristr($module->displayName, $filterName) === false and stristr($module->description, $filterName) === false) {
                    unset($modules[$key]);
                }
            }
        }
        foreach ($modules as $module) {
            $autocompleteList .= Tools::jsonEncode(array('displayName' => (string) $module->displayName, 'desc' => (string) $module->description, 'name' => (string) $module->name, 'author' => (string) $module->author)) . ', ';
        }
        $autocompleteList = rtrim($autocompleteList, ' ,') . '];';
        // Display CSS Fancy Box
        echo '<link href="' . _PS_CSS_DIR_ . 'jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" media="screen" />';
        echo '<script type="text/javascript">' . $autocompleteList . '</script>';
        $this->displayJavascript();
        echo '
		<span onclick="$(\'#module_install\').slideToggle()" style="cursor:pointer"><img src="../img/admin/add.gif" alt="' . $this->l('Add a new module') . '" class="middle" />
			' . $this->l('Add a module from my computer') . '
		</span>
		&nbsp;|&nbsp;';
        echo '<a href="index.php?tab=AdminAddonsMyAccount&token=' . Tools::getAdminTokenLite('AdminAddonsMyAccount') . '">
			<img src="https://addons.prestashop.com/modules.php?' . (isset($_SERVER['SERVER_ADDR']) ? 'server=' . ip2long($_SERVER['SERVER_ADDR']) . '&' : '') . 'mods=' . $serialModules . '" alt="Add" class="middle" />
			' . $this->l('Add a module from PrestaShop Addons') . '
		</a>';
        echo '<form action="' . $currentIndex . '&token=' . $this->token . '" method="post" id="filternameForm" style="float:right"><input type="text" name="filtername" value="' . Tools::htmlentitiesUTF8(Tools::getValue('filtername')) . '" /> <input type="submit" value="' . $this->l('Search') . '" class="button" /></form>
		<div class="clear">&nbsp;</div>
		<div id="module_install" style="width:900px; ' . ((Tools::isSubmit('submitDownload') or Tools::isSubmit('submitDownload2')) ? '' : 'display: none;') . '">
			<fieldset>
				<legend><img src="../img/admin/add.gif" alt="' . $this->l('Add a new module') . '" class="middle" /> ' . $this->l('Add a new module') . '</legend>
				<p>' . $this->l('The module must either be a zip file or a tarball.') . '</p>
				<hr />
				<div style="float:right;margin-right:50px;border-left:solid 1px #DFD5C3">
					<form action="' . $currentIndex . '&token=' . $this->token . '" method="post" enctype="multipart/form-data">
						<label style="width: 100px">' . $this->l('Module file') . '</label>
						<div class="margin-form" style="padding-left: 140px">
							<input type="file" name="file" />
							<p>' . $this->l('Upload the module from your computer.') . '</p>
						</div>
						<div class="margin-form" style="padding-left: 140px">
							<input type="submit" name="submitDownload2" value="' . $this->l('Upload this module') . '" class="button" />
						</div>
					</form>
				</div>
				<div>
				<form action="' . $currentIndex . '&token=' . $this->token . '" method="post">
					<label style="width: 100px">' . $this->l('Module URL') . '</label>
					<div class="margin-form" style="padding-left: 140px">
						<input type="text" name="url" style="width: 200px;" value="' . (Tools::getValue('url') ? Tools::getValue('url') : 'http://') . '" />
						<p>' . $this->l('Download the module directly from a website.') . '</p>
					</div>
					<div class="margin-form" style="padding-left: 140px">
						<input type="submit" name="submitDownload" value="' . $this->l('Download this module') . '" class="button" />
					</div>
				</form>
				</div>
			</fieldset>
			<br />
		</div>';
        if (Configuration::get('PRESTASTORE_LIVE')) {
            echo '
			<div id="prestastore" style="margin-left:40px; display:none; float: left" class="width1">
			</div>';
        }
        /* Scan modules directories and load modules classes */
        $warnings = array();
        $orderModule = array();
        $irow = 0;
        foreach ($modules as $module) {
            $orderModule[(isset($module->tab) and !empty($module->tab) and array_key_exists(strval($module->tab), $this->listTabModules)) ? strval($module->tab) : 'others'][] = $module;
        }
        uasort($orderModule, array('AdminModules', 'sortModule'));
        $concatWarning = array();
        foreach ($orderModule as $tabModule) {
            foreach ($tabModule as $module) {
                if ($module->active and $module->warning) {
                    $warnings[] = '<a href="' . $currentIndex . '&configure=' . urlencode($module->name) . '&token=' . $this->token . '">' . $module->displayName . '</a> - ' . stripslashes(pSQL($module->warning));
                }
            }
        }
        $this->displayWarning($warnings);
        echo '<form method="POST">
			<table cellpadding="0" cellspacing="0" style="width:100%;margin-bottom:5px;">
				<tr>
					<th style="border-right:solid 1px;border:inherit">
						<span class="button" style="padding:0.4em;">
							<a id="all_open" class="module_toggle_all" style="display:inherit;text-decoration:none;" href="#">
								<span style="padding-right:0.5em">
									<img src="../img/admin/more.png" alt="" />
								</span>
								<span id="all_open">' . $this->l('Open all tabs') . '</span>
							</a>
							<a id="all_close" class="module_toggle_all" style="display:none;text-decoration:none;" href="#">
								<span style="padding-right:0.5em">
									<img src="../img/admin/less.png" alt="" />
								</span>
								<span id="all_open">' . $this->l('Close all tabs') . '</span>
							</a>
						</span>
					</th>
					<th colspan="3" style="border:inherit">
						<select name="module_type">
							<option value="allModules" ' . ($showTypeModules == 'allModules' ? 'selected="selected"' : '') . '>' . $this->l('All Modules') . '</option>
							<option value="nativeModules" ' . ($showTypeModules == 'nativeModules' ? 'selected="selected"' : '') . '>' . $this->l('Native Modules') . '</option>
							<option value="partnerModules" ' . ($showTypeModules == 'partnerModules' ? 'selected="selected"' : '') . '>' . $this->l('Partner Modules') . '</option>' . $this->_buildModuleAuthorsOptGroup($modulesAuthors, 'authorModules') . '
							<option value="otherModules" ' . ($showTypeModules == 'otherModules' ? 'selected="selected"' : '') . '>' . $this->l('Other Modules') . '</option>
						</select>
						&nbsp;
						<select name="module_install">
							<option value="installedUninstalled" ' . ($showInstalledModules == 'installedUninstalled' ? 'selected="selected"' : '') . '>' . $this->l('Installed & Uninstalled') . '</option>
							<option value="installed" ' . ($showInstalledModules == 'installed' ? 'selected="selected"' : '') . '>' . $this->l('Installed Modules') . '</option>
							<option value="unistalled" ' . ($showInstalledModules == 'unistalled' ? 'selected="selected"' : '') . '>' . $this->l('Uninstalled Modules') . '</option>
						</select>
						&nbsp;
						<select name="module_status">
							<option value="enabledDisabled" ' . ($showEnabledModules == 'enabledDisabled' ? 'selected="selected"' : '') . '>' . $this->l('Enabled & Disabled') . '</option>
							<option value="enabled" ' . ($showEnabledModules == 'enabled' ? 'selected="selected"' : '') . '>' . $this->l('Enabled Modules') . '</option>
							<option value="disabled" ' . ($showEnabledModules == 'disabled' ? 'selected="selected"' : '') . '>' . $this->l('Disabled Modules') . '</option>
						</select>
						&nbsp;
						<select name="country_module_value">
							<option value="0" >' . $this->l('All countries') . '</option>
							<option value="1" ' . ($showCountryModules == 1 ? 'selected="selected"' : '') . '>' . $this->l('Current country:') . ' ' . $nameCountryDefault . '</option>
						</select>
					</th>
					<th style="border:inherit">
						<div style="float:right">
							<input type="submit" class="button" name="resetFilterModules" value="' . $this->l('Reset') . '">
							<input type="submit" class="button" name="filterModules" value="' . $this->l('Filter') . '">
						</div>
					</th>
			  	</tr>
			</table>
			</form>';
        echo $this->displaySelectedFilter();
        if ($tab_module = Tools::getValue('tab_module')) {
            if (array_key_exists($tab_module, $this->listTabModules)) {
                $goto = $tab_module;
            } else {
                $goto = 'others';
            }
        } else {
            $goto = false;
        }
        echo '
  		<script src="' . __PS_BASE_URI__ . 'js/jquery/jquery.scrollTo-1.4.2-min.js"></script>
		<script>
		 $(document).ready(function() {
		 
		 $(\'.header_module_toggle, .module_toggle_all\').unbind(\'click\').click(function(){
		 	var id = $(this).attr(\'id\');
			if (id == \'all_open\')
				$(\'.tab_module_content\').each(function(){
					$(this).slideDown();
					$(\'#all_open\').hide();
					$(\'#all_close\').show();
					$(\'.header_module_img\').each(function(){
						$(this).attr(\'src\', \'../img/admin/less.png\');
					});
				});
			else if (id == \'all_close\')
				$(\'.tab_module_content\').each(function(){
					$(\'#all_open\').show();
					$(\'#all_close\').hide();
					$(this).slideUp();
					$(\'.header_module_img\').each(function(){
						$(this).attr(\'src\', \'../img/admin/more.png\');
					});
				});
			else
			{
				if ($(\'#\'+id+\'_content\').css(\'display\') == \'none\')
		 			$(\'#\'+id+\'_img\').attr(\'src\', \'../img/admin/less.png\');
		 		else
		 			$(\'#\'+id+\'_img\').attr(\'src\', \'../img/admin/more.png\');
		 		
		 		$(\'#\'+$(this).attr(\'id\')+\'_content\').slideToggle();
		 	}
		 	return false;
		 });
		' . (!$goto ? '' : 'if ($(\'#' . $goto . '_content\').length > 0) $(\'#' . $goto . '_content\').slideToggle( function (){
		$(\'#' . $goto . '_img\').attr(\'src\', \'../img/admin/less.png\');
		' . (!$goto ? '' : 'if ($("#modgo_' . Tools::getValue('module_name') . '").length > 0) $.scrollTo($("#modgo_' . Tools::getValue('module_name') . '"), 300 , 
		{onAfter:function(){
			$("#modgo_' . Tools::getValue('module_name') . '").fadeTo(100, 0, function (){
				$(this).fadeTo(100, 0, function (){
					$(this).fadeTo(50, 1, function (){
						$(this).fadeTo(50, 0, function (){
							$(this).fadeTo(50, 1 )}
								)}
							)}
						)}
					)}
				});') . '
		});') . '
		
			});
		 </script>';
        if (!empty($orderModule)) {
            /* Browse modules by tab type */
            foreach ($orderModule as $tab => $tabModule) {
                echo '
				<div id="' . $tab . '" class="header_module">
				<span class="nbr_module" style="width:100px;text-align:right">' . sizeof($tabModule) . ' ' . (sizeof($tabModule) > 1 ? $this->l('modules') : $this->l('module')) . '</span>
					<a class="header_module_toggle" id="' . $tab . '" href="modgo_' . $tab . '" style="margin-left: 5px;">
						<span style="padding-right:0.5em">
						<img class="header_module_img" id="' . $tab . '_img" src="../img/admin/more.png" alt="" />
						</span>' . $this->listTabModules[$tab] . '</a> 
				</div>
				<div id="' . $tab . '_content" class="tab_module_content" style="display:none;border:solid 1px #CCC">';
                /* Display modules for each tab type */
                foreach ($tabModule as $module) {
                    echo '<div id="modgo_' . $module->name . '" title="' . $module->name . '">';
                    if ($module->id) {
                        $img = '<img src="../img/admin/module_install.png" alt="' . $this->l('Module enabled') . '" title="' . $this->l('Module enabled') . '" />';
                        if ($module->warning) {
                            $img = '<img src="../img/admin/module_warning.png" alt="' . $this->l('Module installed but with warnings') . '" title="' . $this->l('Module installed but with warnings') . '" />';
                        }
                        if (!$module->active) {
                            $img = '<img src="../img/admin/module_disabled.png" alt="' . $this->l('Module disabled') . '" title="' . $this->l('Module disabled') . '" />';
                        }
                    } else {
                        $img = '<img src="../img/admin/module_notinstall.png" alt="' . $this->l('Module not installed') . '" title="' . $this->l('Module not installed') . '" />';
                    }
                    $disp_author = $this->_getDispAuthor($module->author);
                    $disp_author = empty($disp_author) ? '' : ' ' . $this->l('by') . ' <i>' . Tools::htmlentitiesUTF8($disp_author) . '</i>';
                    echo '<table style="width:100%" cellpadding="0" cellspacing="0" >
					<tr' . ($irow % 2 ? ' class="alt_row"' : '') . ' style="height: 42px;">
						<td style="padding-right: 10px;padding-left:10px;width:30px">
							<input type="checkbox" name="modules" value="' . urlencode($module->name) . '" ' . (empty($module->confirmUninstall) ? 'rel="false"' : 'rel="' . addslashes($module->confirmUninstall) . '"') . ' />
						</td>
						<td style="padding:2px 4px 2px 10px;width:500px"><img src="../modules/' . $module->name . '/logo.gif" alt="" /> <b>' . stripslashes($module->displayName) . '</b>' . ($module->version ? ' v' . $module->version . (strpos($module->version, '.') !== false ? '' : '.0') : '') . $disp_author . '<br />' . stripslashes($module->description) . '</td>
						<td rowspan="2">';
                    if (Tools::getValue('module_name') == $module->name || in_array($module->name, explode('|', Tools::getValue('modules_list'))) && (int) Tools::getValue('conf') > 0) {
                        $this->displayConf();
                    }
                    echo '</td>
						<td class="center" style="width:60px" rowspan="2">';
                    if ($module->id) {
                        echo '<a href="' . $currentIndex . '&token=' . $this->token . '&module_name=' . $module->name . '&' . ($module->active ? 'desactive' : 'active') . '">';
                    }
                    echo $img;
                    if ($module->id) {
                        '</a>';
                    }
                    $href = $currentIndex . '&uninstall=' . urlencode($module->name) . '&token=' . $this->token . '&tab_module=' . $module->tab . '&module_name=' . $module->name;
                    echo '
						</td>
						<td class="center" width="120" rowspan="2">' . (!$module->id ? '<input type="button" class="button small" name="Install" value="' . $this->l('Install') . '"
						onclick="javascript:document.location.href=\'' . $currentIndex . '&install=' . urlencode($module->name) . '&token=' . $this->token . '&tab_module=' . $module->tab . '&module_name=' . $module->name . '\'">' : '<input type="button" class="button small" name="Uninstall" value="' . $this->l('Uninstall') . '"
						onclick="' . (!method_exists($module, 'onclickOption') ? (empty($module->confirmUninstall) ? '' : 'if (confirm(\'' . addslashes($module->confirmUninstall) . '\')) ') . 'document.location.href=\'' . $href . '\'' : $module->onclickOption('uninstall', $href)) . '">') . '</td>
						
					</tr>
					<tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . '>
						<td style="padding-left:50px;padding-bottom:5px;padding-top:5px" colspan="2">' . $this->displayOptions($module) . '</td>
					</tr>
					</table>
					</div>';
                }
                echo '</div>';
            }
            echo '
				<div style="margin-top: 12px; width:600px;">
					<input type="button" class="button big" value="' . $this->l('Install the selection') . '" onclick="modules_management(\'install\')"/>
					<input type="button" class="button big" value="' . $this->l('Uninstall the selection') . '" onclick="modules_management(\'uninstall\')" />
				</div>
				<br />
				<table cellpadding="0" cellspacing="0" class="table" style="width:100%;">
					<tr style="height:35px;background-color:#EEEEEE">
						<td><strong>' . $this->l('Icon legend') . ' : </strong></td>
						<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_install.png" />&nbsp;&nbsp;' . $this->l('Module installed and enabled') . '</td>
						<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_disabled.png" />&nbsp;&nbsp;' . $this->l('Module installed but disabled') . '</td>
						<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_warning.png" />&nbsp;&nbsp;' . $this->l('Module installed but with warnings') . '</td>
						<td style="text-align:center"><img src="../img/admin/module_notinstall.png" />&nbsp;&nbsp;' . $this->l('Module not installed') . '</td>
					</tr>
				</table>
			<div style="clear:both">&nbsp;</div>';
        } else {
            echo '<table cellpadding="0" cellspacing="0" class="table" style="width:100%;"><tr><td align="center">' . $this->l('No module found') . '</td></tr></table>';
        }
    }
    private function _displayConfiguration()
    {
        global $cookie;
        $this->_html .= '<script type="text/javascript">
									$(document).ready(function() {
										$(\'#submitCreateAccount\').unbind(\'click\').click(function() {
										if (!$(\'#terms_and_conditions\').attr(\'checked\'))
										{
											alert(\'' . $this->l('Please accept the terms of service.') . '\');
											return false;
										}
									});										
									});
								</script>
		<fieldset><legend>' . $this->l('PrestaShop Security configuration') . '</legend>
			<div id="choose_account">
				<center>
				<form>
					<input type="radio" ' . (!Configuration::get('PS_TRUST_SHOP_ID') ? 'checked="checked"' : '') . ' onclick="$(\'#create_account\').show(); $(\'#module_configuration\').hide();" id="trust_account_on" name="trust_account" value="0"/> <b>' . $this->l('My shop does not have a PrestaShop Security account yet') . '</b>&nbsp;&nbsp;&nbsp;
					<input type="radio" ' . (Configuration::get('PS_TRUST_SHOP_ID') ? 'checked="checked"' : '') . ' onclick="$(\'#create_account\').hide(); $(\'#module_configuration\').show();"  id="trust_account_off" name="trust_account" value="1" /> <b>' . $this->l('I already have an account') . '</b>
				</form>
				</center>
			</div>
			<div class="clear">&nbsp;</div>
			<div id="create_account" ' . (Configuration::get('PS_TRUST_SHOP_ID') ? 'style="display:none;"' : '') . '>
				<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post" name="prestashop_trust" id="prestashop_trust">
					<label>' . $this->l('Your email:') . '</label>
					<div class="margin-form">
						<input type="text" style="width:200px;" name="email" />
					</div>
					<label>' . $this->l('Shop Url:') . '</label>
					<div class="margin-form">
						<input type="text" style="width:400px;" name="shop_url" value="http://www.' . Tools::getHttpHost() . __PS_BASE_URI__ . '"/>
					</div>
					<div class="margin-form">
						<input id="terms_and_conditions" type="checkbox" value="1" />' . $this->l('I agree with the terms of PrestaShop Security service and i adhere to them unconditionally.') . '</label>
					</div>
					<div id="terms" class="margin-form">';
        $terms = file_get_contents(self::$_trustUrl . 'terms.php?lang=' . Language::getIsoById((int) $cookie->id_lang));
        $this->_html .= $terms;
        $this->_html .= '</div>
					<div class="margin-form">
						<input class="button" type="submit" id="submitCreateAccount" name="submitCreateAccount" value="' . $this->l('Create account') . '"/>
					</div>
				</form>
				<div class="clear">&nbsp;</div>
			</div>
			<div id="module_configuration" ' . (!Configuration::get('PS_TRUST_SHOP_ID') ? 'style="display:none;"' : '') . '>
			<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post" name="prestashop_trust" id="prestashop_trust">
				<label>' . $this->l('Shop ID:') . '</label>
				<div class="margin-form">
					<input type="text" style="width:150px"  name="shop_id" value="' . Configuration::get('PS_TRUST_SHOP_ID') . '"/>
				</div>
				<label>' . $this->l('Shop KEY:') . '</label>
				<div class="margin-form">
					<input type="text" style="width:300px" name="shop_key" value="' . Configuration::get('PS_TRUST_SHOP_KEY') . '"/>
				</div>
				<div class="clear">&nbsp;</div>
				<label>' . $this->l('Shop activity:') . '
				<div class="margin-form">
					<select name="shop_activity">';
        foreach ($this->_activities as $k => $activity) {
            $this->_html .= '<option value="' . $k . '" ' . ($k == Configuration::get('PS_SHOP_ACTIVITY') ? 'selected="selected"' : '') . '>' . $activity . '</option>';
        }
        $this->_html .= '</select>
				</div>';
        $carriers = Carrier::getCarriers((int) $cookie->id_lang, true);
        $trust_carriers_type = $this->_getPrestaTrustCarriersType();
        $configured_carriers = $this->_getConfiguredCarriers();
        $this->_html .= '
				<label>' . $this->l('Carriers:') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Carrier') . '</th><th>' . $this->l('Carrier Type') . '</th></tr></thead><tbody>';
        foreach ($carriers as $carrier) {
            $this->_html .= '<tr><td>' . $carrier['name'] . '</td><td><select name="carrier_' . $carrier['id_carrier'] . '">
			<option value="0">' . $this->l('Choose a carrier type...') . '</option>';
            foreach ($this->_getPrestaTrustCarriersType() as $type => $name) {
                $this->_html .= '<option value="' . $type . '"' . ((isset($configured_carriers[$carrier['id_carrier']]) and $type == $configured_carriers[$carrier['id_carrier']]) ? ' selected="selected"' : '') . '>' . $name . '</option>';
            }
            $this->_html .= '</select></td>';
        }
        $this->_html .= '</tbody></table></margin>
			</div>';
        $modules = Module::getModulesOnDisk();
        $configured_payments = $this->_getConfiguredPayments();
        $this->_html .= '
				<label>' . $this->l('Payments:') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Payment Module') . '</th><th>' . $this->l('Payment Type') . '</th></tr></thead><tbody>';
        foreach ($modules as $module) {
            if (!method_exists($module, 'hookPayment') or !$module->id) {
                continue;
            }
            $this->_html .= '<tr><td>' . $module->displayName . '</td><td><select name="paymentmodule_' . $module->id . '">
			<option value="0">' . $this->l('Choose a payment type...') . '</option>';
            foreach ($this->_payment_types as $type => $name) {
                $this->_html .= '<option value="' . $type . '"' . ((isset($configured_payments[$module->id]) and $type == $configured_payments[$module->id]) ? ' selected="true"' : '') . '>' . $name . '</option>';
            }
            $this->_html .= '</select></td>';
        }
        $this->_html .= '</tbody></table></margin>
			</div>';
        $this->_html .= '<center><input type="submit" name="submitSettings" value="' . $this->l('Save') . '" class="button" /></center>
		</form>
		</div>
		</fieldset>';
        return $this->_html;
    }
Example #19
0
    public static function getModulosPago()
    {
        $modules = Module::getModulesOnDisk();
        $paymentModules = array();
        foreach ($modules as $module) {
            if ($module->tab == 'payments_gateways') {
                if ($module->id) {
                    if (!get_class($module) == 'SimpleXMLElement') {
                        $module->country = array();
                    }
                    $countries = DB::getInstance()->ExecuteS('
						SELECT `id_country`
						FROM `' . _DB_PREFIX_ . 'module_country`
						WHERE `id_module` = ' . (int) $module->id);
                    foreach ($countries as $country) {
                        $module->country[] = (int) $country['id_country'];
                    }
                    if (!get_class($module) == 'SimpleXMLElement') {
                        $module->currency = array();
                    }
                    $currencies = DB::getInstance()->ExecuteS('
						SELECT `id_currency`
						FROM `' . _DB_PREFIX_ . 'module_currency`
						WHERE `id_module` = "' . (int) $module->id . '"
					');
                    foreach ($currencies as $currency) {
                        $module->currency[] = (int) $currency['id_currency'];
                    }
                    if (!get_class($module) == 'SimpleXMLElement') {
                        $module->group = array();
                    }
                    $groups = DB::getInstance()->ExecuteS('
						SELECT `id_group`
						FROM `' . _DB_PREFIX_ . 'module_group`
						WHERE `id_module` = "' . (int) $module->id . '"
					');
                    foreach ($groups as $group) {
                        $module->group[] = (int) $group['id_group'];
                    }
                } else {
                    $module->country = null;
                    $module->currency = null;
                    $module->group = null;
                }
                $paymentModules[] = $module;
            }
        }
        return $paymentModules;
    }
Example #20
0
 public function getModulesList($filter_modules_list)
 {
     if (!is_array($filter_modules_list) && !is_null($filter_modules_list)) {
         $filter_modules_list = array($filter_modules_list);
     }
     if (!count($filter_modules_list)) {
         return false;
     }
     //if there is no modules to display just return false;
     $all_modules = Module::getModulesOnDisk(true);
     $this->modules_list = array();
     foreach ($all_modules as $module) {
         $perm = true;
         if ($module->id) {
             $perm &= Module::getPermissionStatic($module->id, 'configure');
         } else {
             $id_admin_module = Tab::getIdFromClassName('AdminModules');
             $access = Profile::getProfileAccess($this->context->employee->id_profile, $id_admin_module);
             if (!$access['edit']) {
                 $perm &= false;
             }
         }
         if (in_array($module->name, $filter_modules_list) && $perm) {
             $this->fillModuleData($module, 'array');
             $this->modules_list[array_search($module->name, $filter_modules_list)] = $module;
         }
     }
     ksort($this->modules_list);
     if (count($this->modules_list)) {
         return true;
     }
     return false;
     //no module found on disk just return false;
 }
 public function assignReadMoreSmartyVar()
 {
     $modules = Module::getModulesOnDisk();
     foreach ($modules as $module) {
         if ($module->name == Tools::getValue('module')) {
             break;
         }
     }
     $url = $module->url;
     if (isset($module->type) && ($module->type == 'addonsPartner' || $module->type == 'addonsNative')) {
         $url = $this->context->link->getAdminLink('AdminModules') . '&install=' . urlencode($module->name) . '&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=' . ucfirst($module->name);
         if ($admin_list_from_source = Tools::getValue('admin_list_from_source')) {
             $url .= '&source=' . $admin_list_from_source;
         }
     } else {
         if ($admin_list_from_source = Tools::getValue('admin_list_from_source')) {
             $url .= '&utm_term=' . $admin_list_from_source;
         }
     }
     $this->fillModuleData($module, 'array');
     $this->context->smarty->assign(array('displayName' => $module->displayName, 'image' => $module->image, 'nb_rates' => (int) $module->nb_rates[0], 'avg_rate' => (int) $module->avg_rate[0], 'badges' => $module->badges, 'compatibility' => $module->compatibility, 'description_full' => $module->description_full, 'additional_description' => $module->additional_description, 'is_addons_partner' => isset($module->type) && ($module->type == 'addonsPartner' || $module->type == 'addonsNative'), 'url' => $url, 'price' => $module->price, 'options' => $module->optionsHtml, 'installed' => (bool) $module->installed));
 }
Example #22
0
    public function displayList()
    {
        global $currentIndex;
        $serialModules = '';
        $modules = Module::getModulesOnDisk();
        foreach ($modules as $module) {
            $serialModules .= $module->name . ' ' . $module->version . "\n";
        }
        $serialModules = urlencode($serialModules);
        $this->displayJavascript();
        echo '<span onclick="openCloseLayer(\'module_install\', 0);" style="cursor: pointer;font-weight: 700; float: left;"><img src="../img/admin/add.gif" alt="' . $this->l('Add a new module') . '" class="middle" /> ' . $this->l('Add a new module') . '</span>';
        if (@ini_get('allow_url_fopen')) {
            echo '<script type="text/javascript">
				function getPrestaStore(){if (getE("prestastore").style.display!=\'block\')return;$.post("' . dirname($currentIndex) . '/ajax.php",{page:"prestastore"},function(a){getE("prestastore-content").innerHTML=a;})}
			</script>
			<span onclick="openCloseLayer(\'prestastore\', 0); getPrestaStore();" style="cursor: pointer;font-weight: 700; float: left;margin-left:20px;"><img src="../img/admin/prestastore.gif" class="middle" /> ' . $this->l('PrestaStore') . '</span>';
        }
        echo '
		<div class="clear">&nbsp;</div>
		<div id="module_install" style="float: left;' . ((Tools::isSubmit('submitDownload') or Tools::isSubmit('submitDownload2')) ? '' : 'display: none;') . '" class="width1">
			<fieldset>
				<legend><img src="../img/admin/add.gif" alt="' . $this->l('Add a new module') . '" class="middle" /> ' . $this->l('Add a new module') . '</legend>
				<p>' . $this->l('The module must be either a zip file or a tarball.') . '</p>
				<hr />
				<form action="' . $currentIndex . '&token=' . $this->token . '" method="post">
					<label style="width: 100px">' . $this->l('Module URL:') . '</label>
					<div class="margin-form" style="padding-left: 140px">
						<input type="text" name="url" style="width: 200px;" value="' . (Tools::getValue('url') ? Tools::getValue('url') : 'http://') . '" />
						<p>' . $this->l('Download the module directly from a website.') . '</p>
					</div>
					<div class="margin-form" style="padding-left: 140px">
						<input type="submit" name="submitDownload" value="' . $this->l('Download this module') . '" class="button" />
					</div>
				</form>
				<hr />
				<form action="' . $currentIndex . '&token=' . $this->token . '" method="post" enctype="multipart/form-data">
					<label style="width: 100px">' . $this->l('Module file:') . '</label>
					<div class="margin-form" style="padding-left: 140px">
						<input type="file" name="file" />
						<p>' . $this->l('Upload the module from your computer.') . '</p>
					</div>
					<div class="margin-form" style="padding-left: 140px">
						<input type="submit" name="submitDownload2" value="' . $this->l('Upload this module') . '" class="button" />
					</div>
				</form>
			</fieldset>
		</div>
		<div id="prestastore" style="margin-left:40px; display:none; float: left" class="width1">
			<fieldset>
				<legend><img src="http://www.prestastore.com/modules.php?' . (isset($_SERVER['SERVER_ADDR']) ? 'server=' . ip2long($_SERVER['SERVER_ADDR']) . '&' : '') . 'mods=' . $serialModules . '" class="middle" />' . $this->l('Live from PrestaStore!') . '</legend>
				<div id="prestastore-content"></div>
			</fieldset>
		</div>
		<div class="clear">&nbsp;</div>';
        /* Scan modules directories and load modules classes */
        $warnings = array();
        $orderModule = array();
        $irow = 0;
        foreach ($modules as $module) {
            $orderModule[(isset($module->tab) and !empty($module->tab)) ? $module->tab : $this->l('Not specified')][] = $module;
        }
        asort($orderModule);
        foreach ($orderModule as $tabModule) {
            foreach ($tabModule as $module) {
                if ($module->active and $module->warning) {
                    $this->displayWarning('<a href="' . $currentIndex . '&configure=' . urlencode($module->name) . '&token=' . $this->token . '">' . $module->displayName . '</a> - ' . stripslashes(pSQL($module->warning)));
                }
            }
        }
        echo '
		<div style="float:left; width:300px;">';
        /* Browse modules by tab type */
        foreach ($orderModule as $tab => $tabModule) {
            echo '<br />
			<table cellpadding="0" cellspacing="0" class="table width3">
				<tr>
					<th colspan="4" class="center" style="cursor: pointer" onclick="openCloseLayer(\'' . addslashes($tab) . '\');"><b>' . $tab . '</b> - <span style="color: red">' . sizeof($tabModule) . '</span> ' . (sizeof($tabModule) > 1 ? $this->l('modules') : $this->l('module')) . '</th>
				</tr>
			</table>
			<div id="' . $tab . '" style="width:600px;">
			<table cellpadding="0" cellspacing="0" class="table width3">';
            /* Display modules for each tab type */
            foreach ($tabModule as $module) {
                if ($module->id) {
                    $img = '<img src="../img/admin/enabled.gif" alt="' . $this->l('Module enabled') . '" title="' . $this->l('Module enabled') . '" />';
                    if ($module->warning) {
                        $img = '<img src="../img/admin/warning.gif" alt="' . $this->l('Module installed but with warnings') . '" title="' . $this->l('Module installed but with warnings') . '" />';
                    }
                    if (!$module->active) {
                        $img = '<img src="../img/admin/disabled.gif" alt="' . $this->l('Module disabled') . '" title="' . $this->l('Module disabled') . '" />';
                    }
                } else {
                    $img = '<img src="../img/admin/cog.gif" alt="' . $this->l('Module not installed') . '" title="' . $this->l('Module not installed') . '" />';
                }
                echo '
				<tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' style="height: 42px;">
					<td style="padding-left: 10px;"><img src="../modules/' . $module->name . '/logo.gif" alt="" /> <b>' . stripslashes($module->displayName) . '</b>' . ($module->version ? ' v' . $module->version . (strpos($module->version, '.') !== false ? '' : '.0') : '') . '<br />' . $module->description . '</td>
					<td width="85">' . (($module->active and method_exists($module, 'getContent')) ? '<a href="' . $currentIndex . '&configure=' . urlencode($module->name) . '&token=' . $this->token . '">&gt;&gt;&nbsp;' . $this->l('Configure') . '</a>' : '') . '</td>
					<td class="center" width="20">';
                if ($module->id) {
                    echo '<a href="' . $currentIndex . '&token=' . $this->token . '&module_name=' . $module->name . '&' . ($module->active ? 'desactive' : 'active') . '">';
                }
                echo $img;
                if ($module->id) {
                    '</a>';
                }
                echo '
					</td>
					<td class="center" width="80">' . (!$module->id ? '<input type="button" class="button small" name="Install" value="' . $this->l('Install') . '"
					onclick="javascript:document.location.href=\'' . $currentIndex . '&install=' . urlencode($module->name) . '&token=' . $this->token . '\'" />' : '<input type="button" class="button small" name="Uninstall" value="' . $this->l('Uninstall') . '"
					onclick="' . (empty($module->confirmUninstall) ? '' : 'if(confirm(\'' . addslashes($module->confirmUninstall) . '\')) ') . 'document.location.href=\'' . $currentIndex . '&uninstall=' . urlencode($module->name) . '&token=' . $this->token . '\';" />') . '</td>
					<td style="padding-right: 10px">
						<input type="checkbox" name="modules" value="' . urlencode($module->name) . '" ' . (empty($module->confirmUninstall) ? 'rel="false"' : 'rel="' . addslashes($module->confirmUninstall) . '"') . ' />
					</td>
				</tr>';
            }
            echo '</table>
			</div>';
        }
        echo '
		<div style="margin-top: 12px; width:600px;" class="center">
			<input type="button" class="button small" value="' . $this->l('Install the selection') . '" onclick="modules_management(\'install\')"/>
			<input type="button" class="button small" value="' . $this->l('Uninstall the selection') . '" onclick="modules_management(\'uninstall\')" />
		</div>
		</div>
		<div style="float:right; width:300px;">
		<br />
		<table cellpadding="0" cellspacing="0" class="table width3" style="width:300px;"><tr><th colspan="4" class="center"><strong>' . $this->l('Icon legend') . '</strong></th></tr></table>
		<table cellpadding="0" cellspacing="0" class="table width3" style="width:300px;"><tr style="height: 42px;">
			<td>
				<table cellpadding="10" cellspacing="5">
					<tr><td><img src="../img/admin/cog.gif" />&nbsp;&nbsp;' . $this->l('Module not installed') . '</td></tr>
					<tr><td><img src="../img/admin/enabled.gif" />&nbsp;&nbsp;' . $this->l('Module installed and enabled') . '</td></tr>
					<tr><td><img src="../img/admin/disabled.gif" />&nbsp;&nbsp;' . $this->l('Module installed but disabled') . '</td></tr>
					<tr><td><img src="../img/admin/warning.gif" />&nbsp;&nbsp;' . $this->l('Module installed but some warnings') . '</td></tr>
				</table>
			</td>
		</tr></table>
		</div>
		<div style="clear:both">&nbsp;</div>';
    }