function migrate_block_info_to_cms_block() { //get ids cms of block information $id_blockinfos = Db::getInstance()->getValue('SELECT id_module FROM `' . _DB_PREFIX_ . 'module` WHERE name = \'blockinfos\''); //get ids cms of block information $ids_cms = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'block_cms` WHERE `id_block` = ' . (int) $id_blockinfos); //check if block info is installed and active if (sizeof($ids_cms)) { //install module blockcms if (Module::getInstanceByName('blockcms')->install()) { //add new block in new cms block Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'cms_block` (`id_cms_category`, `name`, `location`, `position`) VALUES( 1, \'\', 0, 0)'); $id_block = Db::getInstance()->Insert_ID(); $languages = Language::getLanguages(false); foreach ($languages as $language) { Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'cms_block_lang` (`id_cms_block`, `id_lang`, `name`) VALUES (' . (int) $id_block . ', ' . (int) $language['id_lang'] . ', \'Information\')'); } //save ids cms of block information in new module cms bloc foreach ($ids_cms as $id_cms) { Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'cms_block_page` (`id_cms_block`, `id_cms`, `is_category`) VALUES (' . (int) $id_block . ', ' . (int) $id_cms['id_cms'] . ', 0)'); } } else { return true; } } else { return true; } }
public function l($string, $class = null, $addslashes = false, $htmlentities = true) { if (!$this->module instanceof Module) { $this->module = Module::getInstanceByName('lgconsultas'); } return $this->module->l($string, 'lgconsultasresponses', $addslashes, $htmlentities); }
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; }
public function getModuleInstance() { if (is_null($this->module_instance)) { $this->module_instance = Module::getInstanceByName($this->module_name); } return $this->module_instance; }
public function initContent() { $admin_seur = new AdminSeur(false); if (!$admin_seur->module_enabled_and_configured) { $admin_seur->displayModuleConfigurationWarning(); $this->content = $admin_seur->content; return parent::initContent(); } $this->display = 'view'; $this->module_instance = Module::getInstanceByName('seur'); Context::getContext()->controller->addJqueryUI('ui.datepicker'); if (Tools::getValue('verDetalle')) { $response = Expedition::getExpeditions($admin_seur->getExpeditionData()); $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries($response, true)); } elseif (Tools::getValue('createPickup')) { $error_response = Pickup::createPickup(); if (!empty($error_response)) { $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries(null, null, $error_response)); } else { $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries()); } } elseif (Tools::getValue('submitFilter')) { $response = Expedition::getExpeditions($admin_seur->getExpeditionData()); $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries($response, false)); } else { $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries()); } $this->content = $admin_seur->content; $this->fields_list = $admin_seur->fields_list; parent::initContent(); }
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(); }
private function ModuleHookExec($moduleName, $hook_name) { $output = ''; $moduleInstance = Module::getInstanceByName($moduleName); if (Validate::isLoadedObject($moduleInstance) && $moduleInstance->id) { $altern = 0; $id_hook = Hook::getIdByName($hook_name); $retro_hook_name = Hook::getRetroHookName($hook_name); $disable_non_native_modules = (bool) Configuration::get('PS_DISABLE_NON_NATIVE_MODULE'); if ($disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($moduleInstance->name, self::$native_module)) { return ''; } //check disable module $device = (int) $this->context->getDevice(); if (Db::getInstance()->getValue(' SELECT COUNT(`id_module`) FROM ' . _DB_PREFIX_ . 'module_shop WHERE enable_device & ' . (int) $device . ' AND id_module=' . (int) $moduleInstance->id . Shop::addSqlRestriction()) == 0) { return ''; } // Check permissions $exceptions = $moduleInstance->getExceptions($id_hook); $controller = Dispatcher::getInstance()->getController(); $controller_obj = Context::getContext()->controller; //check if current controller is a module controller if (isset($controller_obj->module) && Validate::isLoadedObject($controller_obj->module)) { $controller = 'module-' . $controller_obj->module->name . '-' . $controller; } if (in_array($controller, $exceptions)) { return ''; } //retro compat of controller names $matching_name = array('authentication' => 'auth', 'productscomparison' => 'compare'); if (isset($matching_name[$controller]) && in_array($matching_name[$controller], $exceptions)) { return ''; } if (Validate::isLoadedObject($this->context->employee) && !$moduleInstance->getPermission('view', $this->context->employee)) { return ''; } if (!isset($hook_args['cookie']) or !$hook_args['cookie']) { $hook_args['cookie'] = $this->context->cookie; } if (!isset($hook_args['cart']) or !$hook_args['cart']) { $hook_args['cart'] = $this->context->cart; } $hook_callable = is_callable(array($moduleInstance, 'hook' . $hook_name)); $hook_retro_callable = is_callable(array($moduleInstance, 'hook' . $retro_hook_name)); if (($hook_callable || $hook_retro_callable) && Module::preCall($moduleInstance->name)) { $hook_args['altern'] = ++$altern; // Call hook method if ($hook_callable) { $display = $moduleInstance->{'hook' . $hook_name}($hook_args); } elseif ($hook_retro_callable) { $display = $moduleInstance->{'hook' . $retro_hook_name}($hook_args); } $output .= $display; } } return $output; }
/** * Save carrier settings to database * This runs when in frontend changet some drop down */ public function initContent() { $DpdOrderOptions = Module::getInstanceByName('dynamicparceldistribution')->getModel('DpdOrderOptions'); $cartOptions = $this->context->cart; $result = $DpdOrderOptions->setOrderOptions($cartOptions->id, $cartOptions->id_carrier, $cartOptions->id_address_delivery, serialize(array('delivery_option' => Tools::getValue('value'), 'delivery_label' => Tools::getValue('label')))); die($result); //This is need because without that return some HOOK error }
public function initContent() { parent::initContent(); $hipay = Module::getInstanceByName('hipay'); if (Validate::isLoadedObject($hipay)) { $hipay->validation(); } }
public function testUninstall() { $module = Module::getInstanceByName(Tools::strtolower($this->getClass())); if (!$module->id) { $module->install(); } $this->assertTrue($module->uninstall()); }
function hookModule($moduleName, $hookName) { $dbPrefix = _DB_PREFIX_; $module = Module::getInstanceByName($moduleName); $moduleId = $module->id; Db::getInstance()->execute("DELETE FROM {$dbPrefix}hook_module WHERE id_module={$moduleId}"); $module->registerHook($hookName); echo "- module `{$moduleName}` hooked to `{$hookName}`\n"; }
/** * @inheritdoc */ public function init() { parent::init(); $this->module = Module::getInstanceByName(Tools::getValue('module')); if (!$this->module->active) { Tools::redirect('index.php'); } $this->initContent(); }
public function __construct(stdClass $datas) { $this->datas = $datas; $this->context = Context::getContext(); $this->module = Module::getInstanceByName('powatag'); $this->initLang(); $id_group = Group::getCurrent()->id; $this->display_taxes = Group::getPriceDisplayMethod($id_group) == PS_TAX_EXC ? false : true; }
function update_module_followup() { Configuration::loadConfiguration(); $followup = Module::getInstanceByName('followup'); if (!$followup->id) { return; } Db::getInstance()->Execute('ALTER TABLE `' . _DB_PREFIX_ . 'log_email` ADD INDEX `date_add`(`date_add`), ADD INDEX `id_cart`(`id_cart`);'); }
public function __construct() { $this->context = Context::getContext(); $this->client_id = Configuration::get('YA_METRIKA_ID_APPLICATION'); $this->number = Configuration::get('YA_METRIKA_NUMBER'); $this->client_secret = Configuration::get('YA_METRIKA_PASSWORD_APPLICATION'); $this->state = 'Test_1'; $this->token = Configuration::get('YA_METRIKA_TOKEN') ? Configuration::get('YA_METRIKA_TOKEN') : ''; $this->module = Module::getInstanceByName('yamodule'); }
/** * Process the newsletter settings and set the customer infos. * @param Customer $customer Reference on the customer Object. * @note At this point, the email has been validated. */ public static function processCustomerNewsletter(&$customer) { $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr()); $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s')); if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) { if ($module_newsletter->active) { $module_newsletter->confirmSubscription($customer->email); } } }
public function initContent() { parent::initContent(); $_legal = Module::getInstanceByName('eu_legal'); if (Validate::isLoadedObject($_legal) && Module::isInstalled($_legal->name) && Module::isEnabled($_legal->name)) { if ($tpl = $_legal->getThemeOverride('order-detail')) { $this->setTemplate($tpl); } } }
public function __construct() { $this->controller_type = 'modulefront'; $this->module = Module::getInstanceByName(Tools::getValue('module')); if (!$this->module->active) { Tools::redirect('index'); } $this->page_name = 'module-' . $this->module->name . '-' . Dispatcher::getInstance()->getController(); parent::__construct(); }
function moduleReinstaller($moduleName, $force = false) { $module = Module::getInstanceByName($moduleName); if (!is_object($module)) { die(Tools::displayError()); } if ($module->uninstall() or $force) { return $module->install(); } return false; }
public function initContent() { $hipay = Module::getInstanceByName('hipay'); if (Validate::isLoadedObject($hipay)) { if (method_exists($hipay, 'validation')) { $hipay->validation(); } else { $this->HipayLog('marche pas'); } } }
function alter_productcomments_guest_index() { Configuration::loadConfiguration(); $productcomments = Module::getInstanceByName('productcomments'); if (!$productcomments->id) { return; } DB::getInstance()->Execute(' ALTER TABLE `' . _DB_PREFIX_ . 'product_comment` DROP INDEX `id_guest`, ADD INDEX `id_guest` (`id_guest`);'); }
function __construct($module_instance = null, $api_key = null, $api_secret = null) { $this->api_key = !$api_key ? TextMasterConfiguration::get('api_key') : $api_key; $this->api_secret = !$api_secret ? TextMasterConfiguration::get('api_secret') : $api_secret; date_default_timezone_set('UTC'); // timezone must be UTC, otherwise API refuses connection $this->connection &= $this->testConnection(); $this->module_instance = (!$module_instance or !is_object($module_instance)) ? Module::getInstanceByName('textmaster') : $module_instance; // initiates module instance $this->getAuthors(); }
public function __construct() { parent::__construct(); //specific instruction for PS 1.5 and greater if (_PS_VERSION_ >= '1.5') { $this->tpl_folder = AdminModulesController::getController('AdminOrdersController')->tpl_folder; $this->override_folder = AdminModulesController::getController('AdminOrdersController')->override_folder; } $this->calibrate(); $this->module = Module::getInstanceByName('fianetfraud'); }
public static function getVisits($unique = false, $date_from, $date_to, $granularity = false) { $visits = $granularity == false ? 0 : array(); $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); $moduleManager = $moduleManagerBuilder->build(); /** @var Gapi $gapi */ $gapi = $moduleManager->isInstalled('gapi') ? Module::getInstanceByName('gapi') : false; if (Validate::isLoadedObject($gapi) && $gapi->isConfigured()) { $metric = $unique ? 'visitors' : 'visits'; if ($result = $gapi->requestReportData($granularity ? 'ga:date' : '', 'ga:' . $metric, $date_from, $date_to, null, null, 1, 5000)) { foreach ($result as $row) { if ($granularity == 'day') { $visits[strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-$3', $row['dimensions']['date']))] = $row['metrics'][$metric]; } elseif ($granularity == 'month') { if (!isset($visits[strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-01', $row['dimensions']['date']))])) { $visits[strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-01', $row['dimensions']['date']))] = 0; } $visits[strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-01', $row['dimensions']['date']))] += $row['metrics'][$metric]; } else { $visits = $row['metrics'][$metric]; } } } } else { if ($granularity == 'day') { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT LEFT(`date_add`, 10) as date, COUNT(' . ($unique ? 'DISTINCT id_guest' : '*') . ') as visits FROM `' . _DB_PREFIX_ . 'connections` WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" ' . Shop::addSqlRestriction() . ' GROUP BY LEFT(`date_add`, 10)'); foreach ($result as $row) { $visits[strtotime($row['date'])] = $row['visits']; } } elseif ($granularity == 'month') { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT LEFT(`date_add`, 7) as date, COUNT(' . ($unique ? 'DISTINCT id_guest' : '*') . ') as visits FROM `' . _DB_PREFIX_ . 'connections` WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" ' . Shop::addSqlRestriction() . ' GROUP BY LEFT(`date_add`, 7)'); foreach ($result as $row) { $visits[strtotime($row['date'] . '-01')] = $row['visits']; } } else { $visits = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT COUNT(' . ($unique ? 'DISTINCT id_guest' : '*') . ') as visits FROM `' . _DB_PREFIX_ . 'connections` WHERE `date_add` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" ' . Shop::addSqlRestriction()); } } return $visits; }
public function __construct() { $this->app_id = Configuration::get('YA_POKUPKI_ID'); $this->url = Configuration::get('YA_POKUPKI_APIURL'); $this->number = Configuration::get('YA_POKUPKI_NC'); $this->login = Configuration::get('YA_POKUPKI_LOGIN'); $this->app_pw = Configuration::get('YA_POKUPKI_PW'); $this->token = Configuration::get('YA_POKUPKI_TOKEN'); $this->ya_token = Configuration::get('YA_POKUPKI_YATOKEN'); $this->context = Context::getContext(); $this->module = Module::getInstanceByName('yamodule'); }
public function __construct() { $this->controller_type = 'modulefront'; $this->module = Module::getInstanceByName(Tools::getValue('module')); if (!$this->module->active) { Tools::redirect('index'); } $this->page_name = 'module-' . $this->module->name . '-' . Dispatcher::getInstance()->getController(); parent::__construct(); $this->display_column_left = isset($this->page_name) && is_object(Context::getContext()->theme) ? Context::getContext()->theme->hasLeftColumn($this->page_name) : true; $this->display_column_right = isset($this->page_name) && is_object(Context::getContext()->theme) ? Context::getContext()->theme->hasRightColumn($this->page_name) : true; }
public function __construct() { /* * EU-Legal * instantiate EU Legal Module */ parent::__construct(); $instance = Module::getInstanceByName('eu_legal'); if (Validate::isLoadedObject($instance) && Module::isInstalled($instance->name) && Module::isEnabled($instance->name)) { $this->_legal = $instance; } }
public function initContent() { parent::initContent(); if (!Context::getContext()->customer) { Tools::redirect('index.php?controller=authentication&back=order.php'); } $hipay = Module::getInstanceByName('hipay'); if (Validate::isLoadedObject($hipay)) { if ($hipay->payment() === false) { return $this->setTemplate('redirect.tpl'); } } }
/** * @throws PrestaShopException */ public function __construct() { parent::__construct(); $this->controller_type = 'moduleadmin'; $tab = new Tab($this->id); if (!$tab->module) { throw new PrestaShopException('Admin tab ' . get_class($this) . ' is not a module tab'); } $this->module = Module::getInstanceByName($tab->module); if (!$this->module->id) { throw new PrestaShopException("Module {$tab->module} not found"); } }
public function process() { parent::process(); self::$smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); self::$smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(_USER_ID_LANG_, 1, 1, 1)); self::$smarty->assign('voucherAllowed', (int) Configuration::get('PS_VOUCHERS')); $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); self::$smarty->assign('display_manufacturer_link', (int) $blockmanufacturer->id ? true : false); self::$smarty->assign('display_supplier_link', (int) $blocksupplier->id ? true : false); self::$smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); self::$smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); }