public function displayList() { global $cookie, $currentIndex; $warnings = array(); if (!file_exists(_PS_ROOT_DIR_ . '/.htaccess')) { $warnings[] = $this->l('In order to enable the PrestaShop Webservice, please generate the .htaccess file via the "Generators" tab (in the "Tools" tab).'); } if (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) { $warnings[] = $this->l('To avoid operating problems, please use an Apache server.'); } if (function_exists('apache_get_modules')) { $apache_modules = apache_get_modules(); if (!in_array('mod_auth_basic', $apache_modules)) { $warnings[] = $this->l('Please activate the Apache module \'mod_auth_basic\' to allow authentication of PrestaShop webservice.'); } if (!in_array('mod_rewrite', $apache_modules)) { $warnings[] = $this->l('Please activate the Apache module \'mod_rewrite\' to allow using the PrestaShop webservice.'); } } else { $warnings[] = $this->l('We could not check if basic authentication and rewrite extensions are activated. Please manually check if they are activated in order to use the PrestaShop webservice.'); } if (!extension_loaded('SimpleXML')) { $warnings[] = $this->l('Please activate the PHP extension \'SimpleXML\' to allow testing of PrestaShop webservice.'); } if (!configuration::get('PS_SSL_ENABLED')) { $warnings[] = $this->l('If possible, it is preferable to use SSL (https) for webservice calls, as it avoids the security issues of type "man in the middle".'); } $this->displayWarning($warnings); foreach ($this->_list as $k => $item) { if ($item['is_module'] && $item['class_name'] && $item['module_name'] && ($instance = Module::getInstanceByName($item['module_name'])) && !$instance->useNormalPermissionBehaviour()) { unset($this->_list[$k]); } } parent::displayList(); }
public function hookLeftColumn($params) { if (Module::isInstalled('smartblog') != 1) { $this->smarty->assign(array('smartmodname' => $this->name)); return $this->display(__FILE__, 'views/templates/front/install_required.tpl'); } else { if (!$this->isCached('smartblogtag.tpl', $this->getCacheId())) { $view_data = array(); $id_lang = $this->context->language->id; if (Configuration::get('smartshowposttag') != '' && Configuration::get('smartshowposttag') != null) { $limit = Configuration::get('smartshowposttag'); } else { $limit = 10; } $id_lang_default = configuration::get('PS_LANG_DEFAULT'); $sqllangdefault = 'SELECT * FROM ' . _DB_PREFIX_ . 'smart_blog_post_tag p INNER JOIN ' . _DB_PREFIX_ . 'smart_blog_post_shop s ON p.id_post=s.id_smart_blog_post AND s.id_shop = ' . (int) Context::getContext()->shop->id . ' INNER JOIN ' . _DB_PREFIX_ . 'smart_blog_tag t ON p.id_tag= t.id_tag where t.id_lang = ' . (int) $id_lang_default . ' LIMIT ' . $limit; $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'smart_blog_post_tag p INNER JOIN ' . _DB_PREFIX_ . 'smart_blog_post_shop s ON p.id_post=s.id_smart_blog_post AND s.id_shop = ' . (int) Context::getContext()->shop->id . ' INNER JOIN ' . _DB_PREFIX_ . 'smart_blog_tag t ON p.id_tag= t.id_tag where t.id_lang = ' . (int) $id_lang . ' LIMIT ' . $limit; $tags = Db::getInstance()->ExecuteS($sql); if (empty($tags)) { $tags = Db::getInstance()->ExecuteS($sqllangdefault); } $this->smarty->assign(array('tags' => $tags)); } return $this->display(__FILE__, 'views/templates/front/smartblogtag.tpl', $this->getCacheId()); } }
public function checkForWarning() { if (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) { $this->warnings[] = $this->l('To avoid operating problems, please use an Apache server.'); if (function_exists('apache_get_modules')) { $apache_modules = apache_get_modules(); if (!in_array('mod_auth_basic', $apache_modules)) { $this->warnings[] = $this->l('Please activate the \'mod_auth_basic\' Apache module to allow authentication of PrestaShop\'s webservice.'); } if (!in_array('mod_rewrite', $apache_modules)) { $this->warnings[] = $this->l('Please activate the \'mod_rewrite\' Apache module to allow the PrestaShop webservice.'); } } else { $this->warnings[] = $this->l('We could not check to see if basic authentication and rewrite extensions have been activated. Please manually check if they\'ve been activated in order to use the PrestaShop webservice.'); } } if (!extension_loaded('SimpleXML')) { $this->warnings[] = $this->l('Please activate the \'SimpleXML\' PHP extension to allow testing of PrestaShop\'s webservice.'); } if (!configuration::get('PS_SSL_ENABLED')) { $this->warnings[] = $this->l('It is preferable to use SSL (https:) for webservice calls, as it avoids the "man in the middle" type security issues.'); } foreach ($this->_list as $k => $item) { if ($item['is_module'] && $item['class_name'] && $item['module_name'] && ($instance = Module::getInstanceByName($item['module_name'])) && !$instance->useNormalPermissionBehaviour()) { unset($this->_list[$k]); } } $this->renderList(); }
public function testHandleMissingSubKeys() { $options = $this->_options; unset($options['expire_options']['1week']); unset($options['expire_options']['1year']); unset($options['expire_options']['never']); helper::createIniFile(CONF, $options); $conf = new configuration(); $options['expire']['default'] = '5min'; $this->assertEquals($options, $conf->get(), 'not overriding "missing" subkeys'); }
public function hookExtraRight() { if (Configuration::get('AV_MULTILINGUE') == 'checked') { $this->id_lang = $this->context->language->id; $this->iso_lang = pSQL(Language::getIsoById($this->id_lang)); $this->group_name = $this->getIdConfigurationGroup($this->iso_lang); } if (version_compare(_PS_VERSION_, '1.5', '<')) { $display_prod_reviews = configuration::get('AV_DISPLAYPRODREVIEWS' . $this->group_name); } else { $display_prod_reviews = configuration::get('AV_DISPLAYPRODREVIEWS' . $this->group_name, null, null, $this->context->shop->getContextShopID()); } $id_product = (int) Tools::getValue('id_product'); $o = new NetReviewsModel(); $reviews = $o->getStatsProduct($id_product, $this->group_name, $this->context->shop->getContextShopID()); if ($reviews['nb_reviews'] < 1 || $display_prod_reviews != 'yes') { return ''; } //Si Aucun avis, on retourne vide $percent = round($reviews['rate']) * 20; $this->context->smarty->assign(array('av_nb_reviews' => $reviews['nb_reviews'], 'av_rate' => $reviews['rate'], 'av_rate_percent' => $percent ? $percent : 100)); if (Configuration::get('AV_LIGHTWIDGET') == 'checked') { $tpl = 'avisverifies-extraright-light.tpl'; } else { $tpl = 'avisverifies-extraright.tpl'; } if (version_compare(_PS_VERSION_, '1.5', '<')) { return $this->display(__FILE__, "/views/templates/hook/{$tpl}"); } else { return $this->display(__FILE__, $tpl); } }
public function hookmyAccountBlock($params) { if (configuration::get('OF_CACCOUNT') == 1) { $var = $this->getconf(); if ($var['OF_MYACCOUNTBLOCK'] == 1) { if ($this->psversion() == 5 || $this->psversion() == 6) { if ($this->context->customer->isLogged() == 1) { return $this->display(__FILE__, 'my-account.tpl'); } } global $cookie; if ($this->psversion() == 4) { if ($cookie->isLogged() == 1) { return $this->display(__FILE__, 'my-account-14.tpl'); } } } } }
private function _displaySync() { /* * Number of products * Parent without child = 1 * Parent with 2 child = 2 (don't add the parent if there are children) */ $nbProd = Db::getInstance()->getRow("SELECT count(*) FROM " . _DB_PREFIX_ . "product p LEFT JOIN " . _DB_PREFIX_ . "product_attribute pa ON p.id_product = pa.id_product"); /* Number of parent products */ $nbParentProd = Db::getInstance()->getRow("SELECT count(*) FROM " . _DB_PREFIX_ . "product"); /* Number of child products */ $nbChildProd = $nbProd['count(*)'] - $nbParentProd['count(*)']; /* Number of products without reference */ $nbProdNoRef = Db::getInstance()->getRow("SELECT count(*) FROM " . _DB_PREFIX_ . "product p LEFT JOIN " . _DB_PREFIX_ . "product_attribute pa ON p.id_product = pa.id_product where (pa.id_product_attribute is null and p.reference = '') or (p.reference='' and pa.reference='')"); /* Number of orders */ $nbOrder = Db::getInstance()->getRow("SELECT count(*) FROM `" . _DB_PREFIX_ . "orders`"); /* Number of clients */ $nbClient = Db::getInstance()->getRow("SELECT count(*) FROM `" . _DB_PREFIX_ . "customer`"); /* * Get configuration mode * 1 => Production * 2 => Test */ $confMod = Db::getInstance()->getRow("SELECT * FROM `" . _DB_PREFIX_ . "configuration` WHERE name = 'OSI_CONFIGURATION_MODE'"); $confMode = $confMod["value"]; /* html */ $html = '<fieldset><legend><img src="' . $this->_path . 'img/mode.png" alt="" />' . $this->l('Configuration parameters') . '</legend>'; if ($confMode == '1') { /* Production configuration mode */ $html .= ' <label>' . $this->l('Configuration mode') . ' <sup>*</sup></label> <div class="margin-form"> <select style="width:360px" id="osi_configuration_mode" name="osi_configuration_mode"> <option value="1" selected="selected">Production</option> <option value="2">Test</option> </select> </div> '; } else { /* Test configuration mode */ $html .= ' <label>' . $this->l('Configuration mode') . ' <sup>*</sup></label> <div class="margin-form"> <select style="width:510px" id="osi_configuration_mode" name="osi_configuration_mode" onchange="changeValueFrequencies()"> <option value="1">Production</option> <option value="2" selected="selected">Test</option> </select> </div> '; } $html .= ' </fieldset> <br /><br /> <fieldset> <legend><img src="' . $this->_path . 'img/parameters.png" alt="" />' . $this->l('Synchronizations configuration') . '</legend> <i class="mini">' . $this->l('Note : Frequencies are expressed in minutes') . '.<br /><span class="brown">' . $this->l('We advise you to get closer to the editor module before changing synchronization settings.') . '</span></i><br /><br /> <label class="strong">' . $this->l('PRODUCTS') . ' (' . $nbProd['count(*)'] . ')</label><br /> '; if ($nbProdNoRef['count(*)'] > 0) { $html .= '<div class="mini clear info_box">' . $this->l('Warning, your catalog has') . ' <strong>' . $nbProdNoRef['count(*)'] . ' ' . $this->l('products without references') . '</strong> !<br />' . $this->l('Please note that any product without reference will not be synchronized with OpenSi.') . '</div>'; } $html .= ' <table width="100%" class="wso"> <tr> <td>' . $this->l('Create products') . ' <sup>*</sup></td> <td class="sync-p"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-P005')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-P005', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_p005" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-P005') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-P005') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> <tr> <td>' . $this->l('Update products') . ' <sup>*</sup></td> <td class="sync-p"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-P006')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-P006', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_p006" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-P006') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-P006') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> <tr> <td width="300">' . $this->l('Update stocks') . ' <sup>*</sup></td> <td class="sync-o"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-G002')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-G002', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_g002" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-G002') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-G002') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> <tr> <td>' . $this->l('Update prices') . ' <sup>*</sup></td> <td class="sync-o"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-G009')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-G009', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_g009" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-G009') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-G009') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> </table> <br /><hr /><br /> <label class="strong">' . $this->l('ORDERS') . ' (' . $nbOrder['count(*)'] . ')</label><br /><br /> <table width="100%" class="wso"> <tr> <td width="300">' . $this->l('Create orders') . ' <sup>*</sup></td> <td class="sync-p"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-P011')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-P011', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_p011" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-P011') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-P011') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> <tr> <td>' . $this->l('Create transactions') . ' <sup>*</sup></td> <td class="sync-p"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-P015')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-P015', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_p015" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-P015') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-P015') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> <tr> <td>' . $this->l('Update states orders') . ' <sup>*</sup></td> <td class="sync-o"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-G008')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-G008', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_g008" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-G008') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-G008') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> <tr> <td>' . $this->l('Update orders tracking codes') . ' <sup>*</sup></<td> <td class="sync-o"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-G003')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-G003', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_g003" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-G003') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-G003') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> </table> <br /><hr /><br /> <label class="strong">' . $this->l('CUSTOMERS') . ' (' . $nbClient['count(*)'] . ')</label><br /><br /> <table width="100%" class="wso"> <tr> <td width="300">' . $this->l('Create customers') . ' <sup>*</sup></td> <td class="sync-p"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-P010')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-P010', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_p010" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-P010') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-P010') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> <tr> <td>' . $this->l('Update customers') . ' <sup>*</sup></td> <td class="sync-p"> <input type="text" class="ws-freq" name="' . Tools::htmlentitiesUTF8(strtolower($this->cachetimeLbl . 'WSO-P025')) . '" value="' . Tools::htmlentitiesUTF8(configuration::get($this->cachetimeLbl . 'WSO-P025', 2)) . '" /> <span class="mini grey">(Min : 1)</span> </td> <td width="120"> <select name="active_wso_p025" class="tinysel active_wso"> <option value="1"'; if (Configuration::get('OSI_ACTIVE_WSO-P025') == 1) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Enable') . '</option> <option value="0"'; if (Configuration::get('OSI_ACTIVE_WSO-P025') == 0) { $html .= 'selected="selected"'; } $html .= '>' . $this->l('Disable') . '</option> </select> </td> </tr> </table> <br /><hr /> <table class="wso"> <tr><td class="sync-o brown mini"><i>' . $this->l('Synchronization from OpenSi to Prestashop') . '</i></td></tr> <tr><td class="sync-p brown mini"><i>' . $this->l('Synchronization from Prestashop to OpenSi') . '</i></td></tr> </table> </fieldset> '; return $html; }