/**
  * Check then return multilingual fields for database interaction
  *
  * @return array Multilingual fields
  */
 public function getTranslationsFieldsChild()
 {
     parent::validateFieldsLang();
     $fieldsArray = array('title', 'url');
     $fields = array();
     $languages = Language::getLanguages(false);
     $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
     foreach ($languages as $language) {
         $fields[$language['id_lang']]['id_lang'] = (int) $language['id_lang'];
         $fields[$language['id_lang']][self::$definition['primary']] = (int) $this->id;
         foreach ($fieldsArray as $field) {
             if (!Validate::isTableOrIdentifier($field)) {
                 die(Tools::displayError());
             }
             if (isset($this->{$field}[$language['id_lang']]) and !empty($this->{$field}[$language['id_lang']])) {
                 $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']], true);
             } elseif (in_array($field, $this->fieldsRequiredLang)) {
                 $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage], true);
             } else {
                 $fields[$language['id_lang']][$field] = '';
             }
         }
     }
     return $fields;
 }
示例#2
0
 public function getFields()
 {
     parent::validateFields();
     $fields['id_lang'] = (int) $this->id_lang;
     $fields['name'] = pSQL($this->name);
     return $fields;
 }
function add_module_to_hook($module_name, $hook_name)
{
    $res = true;
    $id_module = Db::getInstance()->getValue('
	SELECT `id_module` FROM `' . _DB_PREFIX_ . 'module`
	WHERE `name` = "' . $module_name . '"');
    if ((int) $id_module > 0) {
        $id_hook = Db::getInstance()->getValue('SELECT `id_hook` FROM `' . _DB_PREFIX_ . 'hook` WHERE `name` = "' . $hook_name . '"');
        if (!$id_hook) {
            if (!Db::getInstance()->execute('
			INSERT IGNORE INTO `' . _DB_PREFIX_ . 'hook` (`name`, `title`)
			VALUES ("' . pSQL($hook_name) . '", "' . pSQL($hook_name) . '")')) {
                $res = false;
            } else {
                $id_hook = Db::getInstance()->Insert_ID();
            }
        }
        if ((int) $id_hook > 0) {
            if (!Db::getInstance()->execute('
			INSERT IGNORE INTO `' . _DB_PREFIX_ . 'hook_module` (`id_module`, `id_hook`, `position`)
			VALUES (
			' . (int) $id_module . ',
			' . (int) $id_hook . ',
			(SELECT IFNULL(
				(SELECT max_position from (SELECT MAX(position)+1 as max_position  FROM `' . _DB_PREFIX_ . 'hook_module`  WHERE `id_hook` = ' . (int) $id_hook . ') AS max_position), 1))
			)')) {
                $res = false;
            }
        }
    }
    return $res;
}
示例#4
0
 public function getFields()
 {
     parent::validateFields();
     $fields['id_country'] = (int) $this->id_country;
     $fields['format'] = pSQL($this->format);
     return $fields;
 }
示例#5
0
 public function getFields()
 {
     parent::validateFields();
     $fields['server'] = pSQL($this->server);
     $fields['getvar'] = pSQL($this->getvar);
     return $fields;
 }
示例#6
0
 public function getFields()
 {
     parent::validateFields();
     $fields['file'] = pSQL($this->file);
     $fields['mime'] = pSQL($this->mime);
     return $fields;
 }
示例#7
0
function add_new_groups($french, $standard)
{
    $res = Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'group` (`id_group`, `date_add`, `date_upd`) VALUES (NULL, NOW(), NOW())');
    $last_id = Db::getInstance()->Insert_ID();
    $languages = Db::getInstance()->executeS('SELECT id_lang, iso_code FROM `' . _DB_PREFIX_ . 'lang`');
    $sql = '';
    foreach ($languages as $lang) {
        if (strtolower($lang['iso_code']) == 'fr') {
            $sql .= '(' . (int) $last_id . ', ' . (int) $lang['id_lang'] . ', "' . pSQL($french) . '"),';
        } else {
            $sql .= '(' . (int) $last_id . ', ' . (int) $lang['id_lang'] . ', "' . pSQL($standard) . '"),';
        }
    }
    $sql = substr($sql, 0, strlen($sql) - 1);
    $res &= Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'group_lang` (`id_group`, `id_lang`, `name`) VALUES ' . $sql);
    // we add the different id_group in the configuration
    if (strtolower($standard) == 'visitor') {
        $res &= Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'configuration` (`id_configuration`, `name`, `value`, `date_add`, `date_upd`) VALUES (NULL, "PS_UNIDENTIFIED_GROUP", "' . (int) $last_id . '", NOW(), NOW())');
    } else {
        if (strtolower($standard) == 'guest') {
            $res &= Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'configuration` (`id_configuration`, `name`, `value`, `date_add`, `date_upd`) VALUES (NULL, "PS_GUEST_GROUP", "' . (int) $last_id . '", NOW(), NOW())');
        } else {
            if (strtolower($standard) == 'test') {
                $res &= Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'configuration` (`id_configuration`, `name`, `value`, `date_add`, `date_upd`) VALUES (NULL, "PS_TEST", "' . (int) $last_id . '", NOW(), NOW())');
            }
        }
    }
    // Add shop association
    $res &= Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'group_shop` (`id_group`, `id_shop`) (SELECT ' . (int) $last_id . ', `value` FROM `' . _DB_PREFIX_ . 'configuration` WHERE `name` = \'PS_SHOP_DEFAULT\')');
    // Copy categories associations from the group of id 1 (default group for both visitors and customers in version 1.4) to the new group
    $res &= Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'category_group` (`id_category`, `id_group`) (SELECT `id_category`, ' . (int) $last_id . ' FROM `' . _DB_PREFIX_ . 'category_group` WHERE `id_group` = 1)');
    return $res;
}
示例#8
0
 /**
  * Get all available glossaries
  *
  * @param integer $id_lang Language id
  * @param array $criteria Criterias for where clause
  * @param integer $start Start number
  * @param integer $limit Number of glossaries to return
  * @param string $order_by Field for ordering
  * @param string $order_way Way for ordering (ASC or DESC)
  * @param boolean $only_active Returns only active glossaries if TRUE
  * @param Context|null $context
  *
  * @return array list of glossaries
  */
 public static function getGlossaries($id_lang, $criteria = array(), $start = null, $limit = null, $order_by = null, $order_way = null, $only_active = false, Context $context = null)
 {
     $where = '';
     if (!$context) {
         $context = Context::getContext();
     }
     if ($order_by !== null) {
         if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) {
             die(Tools::displayError());
         }
         if ($order_by == 'id') {
             $order_by_prefix = 'l';
         } else {
             $order_by_prefix = 'll';
         }
         if (strpos($order_by, '.') > 0) {
             $order_by = explode('.', $order_by);
             $order_by_prefix = $order_by[0];
             $order_by = $order_by[1];
         }
     }
     if (isset($criteria['k'])) {
         $where .= " AND ll.name LIKE '" . pSQL($criteria['k']) . "%' ";
     }
     $sql = 'SELECT l.*, ll.*
             FROM `' . _DB_PREFIX_ . 'lexikotron` l
             LEFT JOIN `' . _DB_PREFIX_ . 'lexikotron_lang` ll ON (l.`id_lexikotron` = ll.`id_lexikotron`)
             WHERE ll.`id_lang` = ' . (int) $id_lang . ($only_active ? ' AND l.`active` = 1' : '') . '
                 ' . $where . '
                 ' . ($order_by != null ? 'ORDER BY ' . (isset($order_by_prefix) ? pSQL($order_by_prefix) . '.' : '') . '`' . pSQL($order_by) . '` ' . pSQL($order_way) : '') . ($limit > 0 ? ' LIMIT ' . (int) $start . ',' . (int) $limit : '');
     $rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
     return $rows;
 }
 public static function getBlockContent($params, &$smarty)
 {
     //use in template as {getBelvgBlockContent id="block_identifier"}
     if (!Module::isEnabled('belvg_staticblocks')) {
         return FALSE;
     }
     if (isset($params['id'])) {
         $block_identifier = $params['id'];
         $sql = '
         SELECT `id_belvg_staticblocks`
         FROM `' . _DB_PREFIX_ . 'belvg_staticblocks`
         WHERE `block_identifier` = "' . pSQL($block_identifier) . '" AND `status` = "1"';
         if (Shop::isFeatureActive()) {
             $sql .= ' AND `id_belvg_staticblocks` IN (
                 SELECT sa.`id_belvg_staticblocks`
                 FROM `' . _DB_PREFIX_ . 'belvg_staticblocks_shop` sa
                 WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
             )';
         }
         $block_id = (int) Db::getInstance()->getValue($sql);
         if ($block_id) {
             $id_lang = Context::getContext()->cookie->id_lang;
             $block = new self($block_id);
             if (isset($block->content[$id_lang])) {
                 return $block->content[$id_lang];
             }
         }
     }
 }
示例#10
0
    public static function addAlert($email, $id_product)
    {
        $res = Db::getInstance()->execute('
			INSERT INTO `' . _DB_PREFIX_ . 'stock_alert` (`id_product`, `email`)
			VALUES (' . (int) $id_product . ', \'' . pSQL($email) . '\')');
        return $res;
    }
示例#11
0
 public function init()
 {
     if ($cms_rewrite = Tools::getValue('cms_rewrite')) {
         $sql = 'SELECT l.`id_cms`
             FROM `' . _DB_PREFIX_ . 'cms_lang` l
             LEFT JOIN `' . _DB_PREFIX_ . 'cms_shop` s ON (l.`id_cms` = s.`id_cms`)
             WHERE l.`link_rewrite` = \'' . pSQL(str_replace('.html', '', $cms_rewrite)) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_cms = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_cms > 0) {
             $_GET['id_cms'] = $id_cms;
         }
     } elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) {
         $sql = 'SELECT `id_cms_category`
             FROM `' . _DB_PREFIX_ . 'cms_category_lang`
             WHERE `link_rewrite` = \'' . pSQL($cms_category_rewrite) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_cms_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_cms_category > 0) {
             $_GET['id_cms_category'] = $id_cms_category;
         }
     }
     parent::init();
 }
function add_unknown_gender()
{
    $res = true;
    // creates the new gender
    $id_type = 2;
    $res &= Db::getInstance()->execute('
		INSERT INTO `' . _DB_PREFIX_ . 'gender` (`type`)
		VALUES (' . (int) $id_type . ')');
    // retrieves its id
    $id_gender = Db::getInstance()->Insert_ID();
    // inserts lang values
    $languages = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'lang`');
    $lang_names = array('en' => 'Unknown', 'de' => 'Unbekannte', 'es' => 'Desconocido', 'fr' => 'Inconnu', 'it' => 'Sconosciuto');
    foreach ($languages as $lang) {
        $name = isset($lang_names[$lang['iso_code']]) ? $lang_names[$lang['iso_code']] : 'Unknown';
        $res &= Db::getInstance()->execute('
			INSERT INTO `' . _DB_PREFIX_ . 'gender_lang` (`id_gender`, `id_lang`, `name`) VALUES
				(' . (int) $id_gender . ', ' . (int) $lang['id_lang'] . ', \'' . pSQL($name) . '\')');
    }
    // for all clients where id gender is 0, sets the new id gender
    $res &= Db::getInstance()->execute('
		UPDATE `' . _DB_PREFIX_ . 'customers`
		SET `id_gender` = ' . (int) $id_gender . '
		WHERE `id_gender` = 0');
}
示例#13
0
    /**
     * Get a zone ID from its default language name
     *
     * @return integer id_zone
     */
    public static function getIdByName($name)
    {
        return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
		SELECT `id_zone`
		FROM `' . _DB_PREFIX_ . 'zone`
		WHERE `name` = \'' . pSQL($name) . '\'');
    }
示例#14
0
 public static function getForSellerByModuleName($module_name, $id_seller)
 {
     ${"GLOBALS"}["zkcagbwt"] = "id_seller";
     $gzcdohkbbg = "key";
     ${"GLOBALS"}["ktsfkx"] = "module_name";
     $xigepp = "id_seller";
     $ttfaclm = "result";
     ${"GLOBALS"}["ctufmpefcs"] = "id_seller";
     $cgjureyee = "obj";
     if (!isset(${${"GLOBALS"}["zkcagbwt"]}) or intval(${$xigepp}) <= 0) {
         return false;
     }
     ${${"GLOBALS"}["pqnbriqkmcpj"]} = "\n\t\tSELECT a.* \n\t\tFROM `" . _DB_PREFIX_ . "agile_seller_paymentinfo` a\n\t\tWHERE 1\n\t\t    AND a.`module_name` = '" . pSQL(${${"GLOBALS"}["ktsfkx"]}) . "'\n\t\t    AND a.`id_seller` = " . pSQL(${${"GLOBALS"}["ctufmpefcs"]}) . "\n\t\t";
     ${${"GLOBALS"}["plodwcumusd"]} = new AgileSellerPaymentInfo();
     ${"GLOBALS"}["gsvthjtmecpa"] = "result";
     ${${"GLOBALS"}["gsvthjtmecpa"]} = Db::getInstance()->getRow(${${"GLOBALS"}["pqnbriqkmcpj"]});
     if (!${${"GLOBALS"}["jvynnnsmtb"]}) {
         return ${$cgjureyee};
     }
     ${"GLOBALS"}["pmnmlsxn"] = "value";
     $obj->id = ${$ttfaclm}[$obj->identifier];
     foreach (${${"GLOBALS"}["jvynnnsmtb"]} as ${$gzcdohkbbg} => ${${"GLOBALS"}["pmnmlsxn"]}) {
         ${"GLOBALS"}["yyqgjlxussf"] = "obj";
         $tmxdrdkyc = "value";
         if (key_exists(${${"GLOBALS"}["lpbzrpslxl"]}, ${${"GLOBALS"}["yyqgjlxussf"]})) {
             $obj->{${${"GLOBALS"}["lpbzrpslxl"]}} = ${$tmxdrdkyc};
         }
     }
     return ${${"GLOBALS"}["plodwcumusd"]};
 }
示例#15
0
    /**
     * Return the product tax
     *
     * @param integer $id_product
     * @param integer $id_address
     * @return Tax Rate
     */
    public static function getProductTaxRate($id_product, $id_address = null, $getCarrierRate = false)
    {
        include_once _PS_ROOT_DIR_ . '/modules/avalaratax/avalaratax.php';
        /* Instanciate the Avalara module and check if active */
        $avalara = new AvalaraTax();
        if (!$avalara->active) {
            return parent::getProductTaxRate($id_product, $id_address, $getCarrierRate);
        }
        /* With Avalara, we disable the tax for non logged users */
        if (!(int) $id_address) {
            return 0.0;
        }
        $region = Db::getInstance()->getValue('SELECT s.`iso_code`
									FROM ' . _DB_PREFIX_ . 'address a
									LEFT JOIN ' . _DB_PREFIX_ . 'state s ON (s.`id_state` = a.`id_state`)
									WHERE a.`id_address` = ' . (int) $id_address);
        /* If the Merchant does not want to calculate taxes outside his state and we are outside the state, we return 0 */
        if (!empty($region) && $region != Configuration::get('AVALARATAX_STATE') && !Configuration::get('AVALARATAX_TAX_OUTSIDE')) {
            return 0.0;
        }
        return (double) Db::getInstance()->getValue('SELECT ac.`tax_rate`
		FROM ' . _DB_PREFIX_ . 'avalara_' . ($getCarrierRate ? 'carrier' : 'product') . '_cache ac
		WHERE ac.`id_' . ($getCarrierRate ? 'carrier' : 'product') . '` = ' . (int) $id_product . '
		AND ac.`region` = \'' . pSQL($region) . '\'');
    }
示例#16
0
 public function SmartHookInsert()
 {
     $hookvalue = array();
     require_once dirname(__FILE__) . '/sql/addhook.php';
     foreach ($hookvalue as $hkv) {
         $hookid = Hook::getIdByName($hkv['name']);
         if (!$hookid) {
             $add_hook = new Hook();
             $add_hook->name = pSQL($hkv['name']);
             $add_hook->title = pSQL($hkv['title']);
             $add_hook->description = pSQL($hkv['description']);
             $add_hook->position = pSQL($hkv['position']);
             $add_hook->live_edit = $hkv['live_edit'];
             $add_hook->add();
             $hookid = $add_hook->id;
             if (!$hookid) {
                 return false;
             }
         } else {
             $up_hook = new Hook($hookid);
             $up_hook->update();
         }
     }
     return true;
 }
示例#17
0
    public function install()
    {
        // check if the order status is defined
        if (!defined('PS_OS_PAYFORT_PENDING')) {
            // order status is not defined - check if, it exists in the table
            $rq = Db::getInstance()->getRow('

            SELECT `id_order_state` FROM `' . _DB_PREFIX_ . 'order_state_lang`

            WHERE id_lang = \'' . pSQL('1') . '\' AND  name = \'' . pSQL('Pending Payfort Payment') . '\'');
            if ($rq && isset($rq['id_order_state']) && intval($rq['id_order_state']) > 0) {
                // order status exists in the table - define it.
                define('PS_OS_PAYFORT_PENDING', $rq['id_order_state']);
            } else {
                // order status doesn't exist in the table
                // insert it into the table and then define it.
                Db::getInstance()->Execute('

                INSERT INTO `' . _DB_PREFIX_ . 'order_state` (`unremovable`, `color`) VALUES(1, \'orange\')');
                $stateid = Db::getInstance()->Insert_ID();
                Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'order_state_lang` (`id_order_state`, `id_lang`, `name`, `template`)

                VALUES(' . intval($stateid) . ', 1, \'Pending Payfort Payment\', \'\')');
                define('PS_OS_PAYFORT_PENDING', $stateid);
            }
        }
        return parent::install() && $this->registerHook('orderConfirmation') && $this->registerHook('payment') && $this->registerHook('header') && $this->registerHook('backOfficeHeader') && Configuration::updateValue('PAYFORT_FORT_SANDBOX_MODE', 1) && Configuration::updateValue('PAYFORT_FORT_LANGUAGE', 'en') && Configuration::updateValue('PAYFORT_FORT_COMMAND', 'AUTHORIZATION') && Configuration::updateValue('PAYFORT_HASH_ALGORITHM', 'SHA1') && Configuration::updateValue('PAYFORT_FORT_HOLD_REVIEW_OS', _PS_OS_PAYMENT_) && Configuration::updateValue('PS_OS_PAYFORT_PENDING', PS_OS_PAYFORT_PENDING) && Configuration::updateValue('PAYFORT_FORT_INTEGRATION_TYPE', 'redirection') && Configuration::updateValue('PAYFORT_FORT_DEBUG_MODE', 0) && Configuration::updateValue('PAYFORT_FORT_GATEWAY_CURRENCY', 'base');
    }
 public static function doSearchProducts($searchtext, $idcate, $idlang)
 {
     $sql = 'SELECT ' . _DB_PREFIX_ . 'product_lang.id_product FROM ' . _DB_PREFIX_ . 'product_lang INNER JOIN ' . _DB_PREFIX_ . 'product ON ' . _DB_PREFIX_ . 'product.id_product = ' . _DB_PREFIX_ . 'product_lang.id_product WHERE (';
     if (Configuration::get('TCS_PRODUCT_S_NAME') == 1) {
         $sql .= ' name LIKE ' . '"%' . pSQL($searchtext) . '%"';
     }
     if (Configuration::get('TCS_PRODUCT_S_REF') == 1) {
         $sql .= Configuration::get('TCS_PRODUCT_S_NAME') == 1 ? ' OR reference LIKE ' . '"%' . pSQL($searchtext) . '%"' : 'reference LIKE ' . '"%' . pSQL($searchtext) . '%"';
     }
     if (Configuration::get('TCS_PRODUCT_S_SHORTD') == 1) {
         $sql .= (Configuration::get('TCS_PRODUCT_S_NAME') == 1 or Configuration::get('TCS_PRODUCT_S_REF') == 1) ? ' OR description_short LIKE  ' . '"%' . pSQL($searchtext) . '%"' : 'description_short LIKE  ' . '"%' . pSQL($searchtext) . '%"';
     }
     if (Configuration::get('TCS_PRODUCT_S_DES') == 1) {
         $sql .= (Configuration::get('TCS_PRODUCT_S_NAME') == 1 or Configuration::get('TCS_PRODUCT_S_REF') == 1 or Configuration::get('TCS_PRODUCT_S_SHORTD') == 1) ? ' OR description LIKE ' . '"%' . pSQL($searchtext) . '%"' : 'description LIKE ' . '"%' . pSQL($searchtext) . '%"';
     }
     $sql .= ' ) AND id_lang =' . (int) $idlang;
     if ($idcate != 'All') {
         $sql .= ' AND id_category_default =' . (int) $idcate;
     }
     if (Configuration::get('TCS_PRODUCT_S_SUP') == 1) {
         if (Configuration::get('TCS_PRODUCT_S_NAME') == 1 or Configuration::get('TCS_PRODUCT_S_SHORTD') or Configuration::get('TCS_PRODUCT_S_REF') == 1 or Configuration::get('TCS_PRODUCT_S_DES') == 1) {
             $sql .= ' UNION SELECT ' . _DB_PREFIX_ . 'product_lang.id_product FROM ' . _DB_PREFIX_ . 'product INNER JOIN ' . _DB_PREFIX_ . 'product_lang ON ' . _DB_PREFIX_ . 'product_lang.id_product = ' . _DB_PREFIX_ . 'product.id_product INNER JOIN ' . _DB_PREFIX_ . 'supplier ON ' . _DB_PREFIX_ . 'supplier.id_supplier = ' . _DB_PREFIX_ . 'product.id_supplier WHERE ' . _DB_PREFIX_ . 'supplier.name LIKE ' . '"%' . pSQL($searchtext) . '%"';
         } else {
             $sql = 'SELECT ' . _DB_PREFIX_ . 'product_lang.id_product FROM ' . _DB_PREFIX_ . 'product INNER JOIN ' . _DB_PREFIX_ . 'product_lang ON ' . _DB_PREFIX_ . 'product_lang.id_product = ' . _DB_PREFIX_ . 'product.id_product INNER JOIN ' . _DB_PREFIX_ . 'supplier ON ' . _DB_PREFIX_ . 'supplier.id_supplier = ' . _DB_PREFIX_ . 'product.id_supplier WHERE ' . _DB_PREFIX_ . 'supplier.name LIKE ' . '"%' . pSQL($searchtext) . '%"';
         }
     }
     if (Configuration::get('TCS_PRODUCT_S_MAN') == 1) {
         if (Configuration::get('TCS_PRODUCT_S_NAME') == 1 or Configuration::get('TCS_PRODUCT_S_REF') == 1 or Configuration::get('TCS_PRODUCT_S_SHORTD') == 1 or Configuration::get('TCS_PRODUCT_S_DES') == 1 or Configuration::get('TCS_PRODUCT_S_SUP') == 1) {
             $sql .= ' UNION SELECT ' . _DB_PREFIX_ . 'product_lang.id_product FROM ' . _DB_PREFIX_ . 'product INNER JOIN ' . _DB_PREFIX_ . 'product_lang ON ' . _DB_PREFIX_ . 'product_lang.id_product = ' . _DB_PREFIX_ . 'product.id_product INNER JOIN ' . _DB_PREFIX_ . 'manufacturer ON ' . _DB_PREFIX_ . 'manufacturer.id_manufacturer = ' . _DB_PREFIX_ . 'product.id_manufacturer WHERE ' . _DB_PREFIX_ . 'manufacturer.name LIKE ' . '"%' . pSQL($searchtext) . '%"';
         } else {
             $sql = 'SELECT ' . _DB_PREFIX_ . 'product_lang.id_product FROM ' . _DB_PREFIX_ . 'product INNER JOIN ' . _DB_PREFIX_ . 'product_lang ON ' . _DB_PREFIX_ . 'product_lang.id_product = ' . _DB_PREFIX_ . 'product.id_product INNER JOIN ' . _DB_PREFIX_ . 'manufacturer ON ' . _DB_PREFIX_ . 'manufacturer.id_manufacturer = ' . _DB_PREFIX_ . 'product.id_manufacturer WHERE ' . _DB_PREFIX_ . 'manufacturer.name LIKE ' . '"%' . pSQL($searchtext) . '%"';
         }
     }
     return Db::getInstance()->executeS($sql);
 }
示例#19
0
 public function getFields()
 {
     parent::validateFields();
     $fields['id_attribute_group'] = intval($this->id_attribute_group);
     $fields['color'] = pSQL($this->color);
     return $fields;
 }
function add_order_state($conf_name, $name, $invoice, $send_email, $color, $unremovable, $logable, $delivery, $template = null)
{
    $name_lang = array();
    $template_lang = array();
    foreach (explode('|', $name) as $item) {
        $temp = explode(':', $item);
        $name_lang[$temp[0]] = $temp[1];
    }
    if ($template) {
        foreach (explode('|', $template) as $item) {
            $temp = explode(':', $item);
            $template_lang[$temp[0]] = $temp[1];
        }
    }
    Db::getInstance()->Execute('
		INSERT INTO `' . _DB_PREFIX_ . 'order_state` (`invoice`, `send_email`, `color`, `unremovable`, `logable`, `delivery`) 
		VALUES (' . (int) $invoice . ', ' . (int) $send_email . ', \'' . pSQL($color) . '\', ' . (int) $unremovable . ', ' . (int) $logable . ', ' . (int) $delivery . ')');
    $id_order_state = Db::getInstance()->getValue('
		SELECT MAX(`id_order_state`)
		FROM `' . _DB_PREFIX_ . 'order_state`
	');
    foreach (Language::getLanguages() as $lang) {
        Db::getInstance()->Execute('
		INSERT IGNORE INTO `' . _DB_PREFIX_ . 'order_state_lang` (`id_lang`, `id_order_state`, `name`, `template`) 
		VALUES (' . (int) $lang['id_lang'] . ', ' . (int) $id_order_state . ', \'' . pSQL(isset($name_lang[$lang['iso_code']]) ? $name_lang[$lang['iso_code']] : $name_lang['en']) . '\', \'' . pSQL(isset($template_lang[$lang['iso_code']]) ? $template_lang[$lang['iso_code']] : (isset($template_lang['en']) ? $template_lang['en'] : '')) . '\')
		');
    }
    Configuration::updateValue($conf_name, $id_order_state);
}
示例#21
0
function add_new_tab($className, $name, $id_parent)
{
    $array = array();
    foreach (explode('|', $name) as $item) {
        $temp = explode(':', $item);
        $array[$temp[0]] = $temp[1];
    }
    if (!(int) Db::getInstance()->getValue('SELECT count(id_tab) FROM `' . _DB_PREFIX_ . 'tab` WHERE `class_name` = \'' . pSQL($className) . '\' ')) {
        Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'tab` (`id_parent`, `class_name`, `module`, `position`) VALUES (' . (int) $id_parent . ', \'' . pSQL($className) . '\', \'\', 
									(SELECT MAX(t.position)+ 1 FROM `' . _DB_PREFIX_ . 'tab` t WHERE t.id_parent = ' . (int) $id_parent . '))');
    }
    $languages = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'lang`');
    foreach ($languages as $lang) {
        Db::getInstance()->Execute('
		INSERT IGNORE INTO `' . _DB_PREFIX_ . 'tab_lang` (`id_lang`, `id_tab`, `name`) 
		VALUES (' . (int) $lang['id_lang'] . ', (
				SELECT `id_tab`
				FROM `' . _DB_PREFIX_ . 'tab`
				WHERE `class_name` = \'' . pSQL($className) . '\' LIMIT 0,1
			), \'' . pSQL(isset($array[$lang['iso_code']]) ? $array[$lang['iso_code']] : $array['en']) . '\')
		');
    }
    Db::getInstance()->Execute('INSERT IGNORE INTO `' . _DB_PREFIX_ . 'access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) 
								(SELECT `id_profile`, (
								SELECT `id_tab`
								FROM `' . _DB_PREFIX_ . 'tab`
								WHERE `class_name` = \'' . pSQL($className) . '\' LIMIT 0,1
								), 1, 1, 1, 1 FROM `' . _DB_PREFIX_ . 'profile` )');
}
 /**
  * Initialise the object variables
  *
  */
 public function __construct($oContext = false)
 {
     if (is_object($oContext) && get_class($oContext) == 'Context') {
         $this->oContext = $oContext;
     }
     $aLanguages = Language::getLanguages(false);
     foreach ($this->aConfs as $var => $aConf) {
         $aParams = array(0 => $aConf['name'], 1 => false, 2 => false, 3 => false);
         if ($this->oContext) {
             if ((int) $aConf['multishopgroup']) {
                 $aParams[2] = (int) $this->oContext->shop->id_shop_group;
             }
             if ((int) $aConf['multishop']) {
                 $aParams[3] = (int) $this->oContext->shop->id;
             }
         }
         switch ($aConf['type']) {
             case 'int':
                 $this->{$var} = (int) call_user_func_array(array('Configuration', 'get'), $aParams);
                 break;
             default:
                 if ($this->oContext && (int) $aConf['multilang']) {
                     // Set the multilingual configurations
                     foreach ($aLanguages as $aLanguage) {
                         $aParams[1] = (int) $aLanguage['id_lang'];
                         $this->{$var}[(int) $aLanguage['id_lang']] = pSQL(call_user_func_array(array('Configuration', 'get'), $aParams));
                     }
                 } else {
                     $this->{$var} = pSQL(call_user_func_array(array('Configuration', 'get'), $aParams));
                 }
                 break;
         }
     }
 }
示例#23
0
 public function getFields()
 {
     parent::validateFields();
     $fields['link'] = pSQL($this->link);
     $fields['new_window'] = intval($this->new_window);
     return $fields;
 }
示例#24
0
 public static function getVersion($label)
 {
     return Db::getInstance()->getValue('
     SELECT `version` FROM `' . _DB_PREFIX_ . 'help_access`
     WHERE `label` = \'' . pSQL($label) . '\'
     ');
 }
示例#25
0
 protected function changePassword()
 {
     $token = Tools::getValue('token');
     $id_customer = (int) Tools::getValue('id_customer');
     if ($email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . $id_customer)) {
         $customer = new Customer();
         $customer->getByEmail($email);
         if (!Validate::isLoadedObject($customer)) {
             $this->errors[] = $this->trans('Customer account not found', array(), 'Shop.Notifications.Error');
         } elseif (!$customer->active) {
             $this->errors[] = $this->trans('You cannot regenerate the password for this account.', array(), 'Shop.Notifications.Error');
         }
         // Case if both password params not posted or different, then "change password" form is not POSTED, show it.
         if (!Tools::isSubmit('passwd') || !Tools::isSubmit('confirmation') || ($passwd = Tools::getValue('passwd')) !== ($confirmation = Tools::getValue('confirmation')) || !Validate::isPasswd($passwd) || !Validate::isPasswd($confirmation)) {
             // Check if passwords are here anyway, BUT does not match the password validation format
             if (Tools::isSubmit('passwd') || Tools::isSubmit('confirmation')) {
                 $this->errors[] = $this->trans('The password and its confirmation do not match.', array(), 'Shop.Notifications.Error');
             }
             $this->context->smarty->assign(['customer_email' => $customer->email, 'customer_token' => $token, 'id_customer' => $id_customer, 'reset_token' => Tools::getValue('reset_token')]);
             $this->setTemplate('customer/password-new');
         } else {
             // Both password fields posted. Check if all is right and store new password properly.
             if (!Tools::getValue('reset_token') || strtotime($customer->last_passwd_gen . '+' . (int) Configuration::get('PS_PASSWD_TIME_FRONT') . ' minutes') - time() > 0) {
                 Tools::redirect('index.php?controller=authentication&error_regen_pwd');
             } else {
                 // To update password, we must have the temporary reset token that matches.
                 if ($customer->getValidResetPasswordToken() !== Tools::getValue('reset_token')) {
                     $this->errors[] = $this->trans('The password change request expired. You should ask for a new one.', array(), 'Shop.Notifications.Error');
                 } else {
                     try {
                         $crypto = new Hashing();
                     } catch (\PrestaShop\PrestaShop\Adapter\CoreException $e) {
                         $this->errors[] = $this->trans('An error occurred with your account, which prevents us from updating the new password. Please report this issue using the contact form.', array(), 'Shop.Notifications.Error');
                         return false;
                     }
                     $customer->passwd = $crypto->encrypt($password = Tools::getValue('passwd'), _COOKIE_KEY_);
                     $customer->last_passwd_gen = date('Y-m-d H:i:s', time());
                     if ($customer->update()) {
                         Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password));
                         $customer->removeResetPasswordToken();
                         $customer->update();
                         $mail_params = ['{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname];
                         if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                             $this->context->smarty->assign(['customer_email' => $customer->email]);
                             $this->success[] = $this->trans('Your password has been successfully reset and a confirmation has been sent to your email address: %s', array($customer->email), 'Shop.Notifications.Success');
                             $this->context->updateCustomer($customer);
                             $this->redirectWithNotifications('index.php?controller=my-account');
                         } else {
                             $this->errors[] = $this->trans('An error occurred while sending the email.', array(), 'Shop.Notifications.Error');
                         }
                     } else {
                         $this->errors[] = $this->trans('An error occurred with your account, which prevents us from updating the new password. Please report this issue using the contact form.', array(), 'Shop.Notifications.Error');
                     }
                 }
             }
         }
     } else {
         $this->errors[] = $this->trans('We cannot regenerate your password with the data you\'ve submitted', array(), 'Shop.Notifications.Error');
     }
 }
示例#26
0
function upgrade_module_1_3_2_11($object)
{
    $themes = Theme::getThemes();
    $theme_meta_value = array();
    foreach ($object->controllers as $controller) {
        $page = 'module-' . $object->name . '-' . $controller;
        $result = Db::getInstance()->getValue('SELECT * FROM ' . _DB_PREFIX_ . 'meta WHERE page="' . pSQL($page) . '"');
        if ((int) $result > 0) {
            continue;
        }
        $meta = new Meta();
        $meta->page = $page;
        $meta->configurable = 0;
        $meta->save();
        if ((int) $meta->id > 0) {
            foreach ($themes as $theme) {
                $theme_meta_value[] = array('id_theme' => $theme->id, 'id_meta' => $meta->id, 'left_column' => (int) $theme->default_left_column, 'right_column' => (int) $theme->default_right_column);
            }
        } else {
            $object->_errors[] = sprintf(Tools::displayError('Unable to install controller: %s'), $controller);
        }
    }
    if (count($theme_meta_value) > 0) {
        return Db::getInstance()->insert('theme_meta', $theme_meta_value);
    }
    return true;
}
示例#27
0
 public function getFields()
 {
     parent::validateFields();
     $fields['email'] = pSQL($this->email);
     $fields['customer_service'] = (int) $this->customer_service;
     return $fields;
 }
示例#28
0
    /**
     * Get the detailed payment of an order
     * @param int $order_reference
     * @return array
     * @since 1.5.0.13
     */
    public static function getByOrderReference($order_reference)
    {
        return ObjectModel::hydrateCollection('OrderPayment', Db::getInstance()->executeS('
			SELECT *
			FROM `' . _DB_PREFIX_ . 'order_payment`
			WHERE `order_reference` = \'' . pSQL($order_reference) . '\''));
    }
 public function addQuickLink()
 {
     if (!isset($this->className) || empty($this->className)) {
         return false;
     }
     $this->validateRules();
     if (count($this->errors) <= 0) {
         $this->object = new $this->className();
         $this->copyFromPost($this->object, $this->table);
         $exists = Db::getInstance()->getValue('SELECT id_quick_access FROM ' . _DB_PREFIX_ . 'quick_access WHERE link = "' . pSQL($this->object->link) . '"');
         if ($exists) {
             return true;
         }
         $this->beforeAdd($this->object);
         if (method_exists($this->object, 'add') && !$this->object->add()) {
             $this->errors[] = Tools::displayError('An error occurred while creating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
         } elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect) {
             PrestaShopLogger::addLog(sprintf($this->l('%s addition', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int) $this->object->id, true, (int) $this->context->employee->id);
             $this->afterAdd($this->object);
         }
     }
     $this->errors = array_unique($this->errors);
     if (!empty($this->errors)) {
         d($this->errors);
         return false;
     }
     return $this->getQuickAccessesList();
 }
示例#30
-1
    public function getList($order_by, $order_way, $filter, $start, $pagination)
    {
        $order_way = Validate::isOrderWay($order_way) ? $order_way : 'ASC';
        $id_shop = (int) Context::getContext()->shop->id;
        $id_lang = (int) Context::getContext()->language->id;
        if (version_compare(_PS_VERSION_, '1.5', '<')) {
            $countries = DB::getInstance()->executeS('
				SELECT
					c.`id_country` AS `id_country`,
					cl.`name` AS `name`,
					c.`iso_code` AS `iso_code`,
					IF(dpdc.`enabled` IS NULL, 1, dpdc.`enabled`) AS `enabled`
				FROM `' . _DB_PREFIX_ . 'country` c
				LEFT JOIN `' . _DB_PREFIX_ . _DPDPOLAND_COUNTRY_DB_ . '` dpdc ON (dpdc.`id_country` = c.`id_country` AND dpdc.`id_shop` = "' . (int) $id_shop . '")
				LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (cl.`id_country` = c.`id_country` AND cl.`id_lang` = "' . (int) $id_lang . '")' . $filter . ($order_by && $order_way ? ' ORDER BY `' . bqSQL($order_by) . '` ' . pSQL($order_way) : '') . ($start !== null && $pagination !== null ? ' LIMIT ' . (int) $start . ', ' . (int) $pagination : ''));
        } else {
            $countries = DB::getInstance()->executeS('
				SELECT
					c.`id_country` AS `id_country`,
					cl.`name` AS `name`,
					c.`iso_code` AS `iso_code`,
					IF(dpdc.`enabled` IS NULL, 1, dpdc.`enabled`) AS `enabled`
				FROM `' . _DB_PREFIX_ . 'country` c
				LEFT JOIN `' . _DB_PREFIX_ . _DPDPOLAND_COUNTRY_DB_ . '` dpdc ON (dpdc.`id_country` = c.`id_country` AND dpdc.`id_shop` = "' . (int) $id_shop . '")
				LEFT JOIN `' . _DB_PREFIX_ . 'country_shop` cs ON (cs.`id_country` = c.`id_country`)
				LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (cl.`id_country` = c.`id_country` AND cl.`id_lang` = "' . (int) $id_lang . '")
				WHERE cs.`id_shop` = "' . (int) $id_shop . '" ' . $filter . ($order_by && $order_way ? ' ORDER BY `' . bqSQL($order_by) . '` ' . pSQL($order_way) : '') . ($start !== null && $pagination !== null ? ' LIMIT ' . (int) $start . ', ' . (int) $pagination : ''));
        }
        if (!$countries) {
            $countries = array();
        }
        return $countries;
    }