コード例 #1
0
 public function getContent()
 {
     $this->_html = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitUpdate')) {
         if (Tools::getValue('STORE_DELIVERY_SEND_MAIL') !== false && Validate::isBool(Tools::getValue('STORE_DELIVERY_SEND_MAIL'))) {
             Configuration::updateValue('STORE_DELIVERY_SEND_MAIL', Tools::getValue('STORE_DELIVERY_SEND_MAIL'));
         }
         if (Tools::getValue('STORE_DELIVERY_CARRIER') != false && Validate::isInt(Tools::getValue('STORE_DELIVERY_CARRIER'))) {
             Configuration::updateValue('STORE_DELIVERY_CARRIER', Tools::getValue('STORE_DELIVERY_CARRIER'));
             $carrierObj = new Carrier((int) Tools::getValue('STORE_DELIVERY_CARRIER'));
             Configuration::updateValue('STORE_DELIVERY_CARRIER_REFERENCE', $carrierObj->id_reference);
         }
         if (Tools::getValue('STORE_DELIVERY_DISPLAY_MAP') !== false && Validate::isBool(Tools::getValue('STORE_DELIVERY_DISPLAY_MAP'))) {
             Configuration::updateValue('STORE_DELIVERY_DISPLAY_MAP', Tools::getValue('STORE_DELIVERY_DISPLAY_MAP'));
         }
         if (Tools::getValue('STORE_DELIVERY_HEIGHT_MAP') !== false && Validate::isString(Tools::getValue('STORE_DELIVERY_HEIGHT_MAP'))) {
             Configuration::updateValue('STORE_DELIVERY_HEIGHT_MAP', Tools::getValue('STORE_DELIVERY_HEIGHT_MAP'));
         }
         if (Tools::getValue('STORE_DELIVERY_WIDTH_MAP') !== false && Validate::isString(Tools::getValue('STORE_DELIVERY_WIDTH_MAP'))) {
             Configuration::updateValue('STORE_DELIVERY_WIDTH_MAP', Tools::getValue('STORE_DELIVERY_WIDTH_MAP'));
         }
         if (!Validate::isBool(Tools::getValue('STORE_DELIVERY_SEND_MAIL')) || !Validate::isInt(Tools::getValue('STORE_DELIVERY_CARRIER')) || !Validate::isBool(Tools::getValue('STORE_DELIVERY_DISPLAY_MAP')) || !Validate::isString(Tools::getValue('STORE_DELIVERY_HEIGHT_MAP')) || !Validate::isString(Tools::getValue('STORE_DELIVERY_WIDTH_MAP'))) {
             $this->_html .= '<div class="alert">' . $this->l('Error! An information is invalid') . '</div>';
         }
     }
     return $this->_displayForm();
 }
コード例 #2
0
 private function _update_value($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = true;
     switch ($key) {
         case 'PS_ONE_PHONE_AT_LEAST':
         case 'PS_REGISTRATION_PROCESS_TYPE':
         case 'PS_CART_FOLLOWING':
         case 'PS_CUSTOMER_CREATION_EMAIL':
         case 'PS_B2B_ENABLE':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_PASSWD_TIME_FRONT':
             $validValue = Validate::isUnsignedInt($value);
             break;
         default:
             $interface->error("The configuration key {$key} is not handled by this plugin !");
             break;
     }
     if (!$validValue) {
         $interface->error("Invalid value '{$value}' for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated configuration key '{$key}'");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
コード例 #3
0
    /**
     * Lists of items
     * @param int $iIdLang
     * @param bool $active
     * @return array
     */
    public static function getProductsCollection($iIdLang = null, $bActive = true)
    {
        if (!Validate::isBool($bActive)) {
            die(Tools::displayError());
        }
        if (is_null($iIdLang)) {
            $iIdLang = (int) Context::getContext()->language->id;
        }
        $sSQL = '
			SELECT r.`id_product`
			FROM `' . _DB_PREFIX_ . 'now_mea_home` r
			' . Shop::addSqlAssociation('now_mea_home', 'r') . '
			LEFT JOIN `' . _DB_PREFIX_ . 'now_product_type_product` pt ON (pt.`id_product` = r.`id_product`)
			WHERE 1 ' . ($bActive ? ' AND r.`active` = 1 ' : '') . '
			AND pt.`id_now_product_type_product` IS NULL
			ORDER BY RAND() LIMIT 0 , ' . Configuration::get('NOW_MEA_HOME_NB_PRODUCT');
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sSQL);
        $aProducts = array();
        foreach ($result as $row) {
            $oProduct = new Product($row['id_product'], false, $iIdLang);
            $oProduct->loadStockData();
            $aProducts[] = $oProduct;
        }
        return $aProducts;
    }
コード例 #4
0
    /**
     * @param array $aIdProductType
     * @param null $iIdLang
     * @param bool $bActive
     * @return mixed
     * @throws PrestaShopDatabaseException
     */
    public static function getByIdProductTypes($aIdProductType = array(), $iIdLang = null, $bActive = true)
    {
        if (!Validate::isBool($bActive)) {
            die(Tools::displayError());
        }
        if (empty($aIdProductType)) {
            return array();
        }
        if (is_null($iIdLang)) {
            $iIdLang = (int) Context::getContext()->language->id;
        }
        $sSQL = '
			SELECT *
			FROM `' . _DB_PREFIX_ . 'now_product_type` pt
			INNER JOIN `' . _DB_PREFIX_ . 'now_product_type_lang` ptl ON (pt.`id_now_product_type` = ptl.`id_now_product_type` AND ptl.`id_lang` = ' . (int) $iIdLang . ')
			WHERE 1  ' . ($bActive ? 'AND pt.`active` = 1' : '') . '
			AND pt.`id_now_product_type` IN (' . implode(',', $aIdProductType) . ')
		';
        $aResult = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sSQL);
        $aProductTypes = array();
        foreach ($aResult as $aRow) {
            $aProductTypes[$aRow['id_now_product_type']] = $aRow;
        }
        return $aProductTypes;
    }
コード例 #5
0
ファイル: homefeatured.php プロジェクト: jpodracky/dogs
 public function getContent()
 {
     $output = '';
     $errors = array();
     if (Tools::isSubmit('submitHomeFeatured')) {
         $nbr = Tools::getValue('HOME_FEATURED_NBR');
         if (!Validate::isInt($nbr) || $nbr <= 0) {
             $errors[] = $this->l('The number of products is invalid. Please enter a positive number.');
         }
         $cat = Tools::getValue('HOME_FEATURED_CAT');
         if (!Validate::isInt($cat) || $cat <= 0) {
             $errors[] = $this->l('The category ID is invalid. Please choose an existing category ID.');
         }
         $rand = Tools::getValue('HOME_FEATURED_RANDOMIZE');
         if (!Validate::isBool($rand)) {
             $errors[] = $this->l('Invalid value for the "randomize" flag.');
         }
         if (isset($errors) && count($errors)) {
             $output = $this->displayError(implode('<br />', $errors));
         } else {
             Configuration::updateValue('HOME_FEATURED_NBR', (int) $nbr);
             Configuration::updateValue('HOME_FEATURED_CAT', (int) $cat);
             Configuration::updateValue('HOME_FEATURED_RANDOMIZE', (bool) $rand);
             Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('homefeatured.tpl'));
             $output = $this->displayConfirmation($this->l('Your settings have been updated.'));
         }
     }
     return $output . $this->renderForm();
 }
コード例 #6
0
ファイル: blocktags.php プロジェクト: jpodracky/dogs
 public function getContent()
 {
     $output = '';
     $errors = array();
     if (Tools::isSubmit('submitBlockTags')) {
         $tagsNbr = Tools::getValue('BLOCKTAGS_NBR');
         if (!strlen($tagsNbr)) {
             $errors[] = $this->l('Please complete the "Displayed tags" field.');
         } elseif (!Validate::isInt($tagsNbr) || (int) $tagsNbr <= 0) {
             $errors[] = $this->l('Invalid number.');
         }
         $tagsLevels = Tools::getValue('BLOCKTAGS_MAX_LEVEL');
         if (!strlen($tagsLevels)) {
             $errors[] = $this->l('Please complete the "Tag levels" field.');
         } elseif (!Validate::isInt($tagsLevels) || (int) $tagsLevels <= 0) {
             $errors[] = $this->l('Invalid value for "Tag levels". Choose a positive integer number.');
         }
         $randomize = Tools::getValue('BLOCKTAGS_RANDOMIZE');
         if (!strlen($randomize)) {
             $errors[] = $this->l('Please complete the "Randomize" field.');
         } elseif (!Validate::isBool($randomize)) {
             $errors[] = $this->l('Invalid value for "Randomize". It has to be a boolean.');
         }
         if (count($errors)) {
             $output = $this->displayError(implode('<br />', $errors));
         } else {
             Configuration::updateValue('BLOCKTAGS_NBR', (int) $tagsNbr);
             Configuration::updateValue('BLOCKTAGS_MAX_LEVEL', (int) $tagsLevels);
             Configuration::updateValue('BLOCKTAGS_RANDOMIZE', (bool) $randomize);
             $output = $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->renderForm();
 }
コード例 #7
0
ファイル: Rule.php プロジェクト: yiuked/tmcart
    public static function getRule($active = true, $p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        if (!Validate::isBool($active)) {
            die(Tools::displayError());
        }
        $where = '';
        if (!empty($filter['id_rule']) && Validate::isInt($filter['id_rule'])) {
            $where .= ' AND a.`id_rule`=' . intval($filter['id_rule']);
        }
        if (!empty($filter['entity']) && Validate::isCatalogName($filter['entity'])) {
            $where .= ' AND a.`entity` LIKE "%' . pSQL($filter['entity']) . '%"';
        }
        if (!empty($filter['rule_link']) && Validate::isCatalogName($filter['rule_link'])) {
            $where .= ' AND a.`rule_link` LIKE "%' . pSQL($filter['rule_link']) . '%"';
        }
        if (!empty($filter['id_entity']) && Validate::isInt($filter['id_entity'])) {
            $where .= ' AND a.`id_entity`=' . (int) $filter['id_entity'];
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `position` ASC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'rule` a
				WHERE 1 ' . $where);
        $result = Db::getInstance()->getAll('SELECT * FROM `' . DB_PREFIX . 'rule` a
				WHERE 1 ' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'rules' => $result);
        return $rows;
    }
コード例 #8
0
ファイル: Country.php プロジェクト: sealence/local
    /**
     * Return available countries
     *
     * @param integer $id_lang Language ID
     * @param boolean $active return only active coutries
     * @return array Countries and corresponding zones
     */
    public static function getCountries($id_lang, $active = false, $containStates = NULL)
    {
        if (!Validate::isBool($active)) {
            die(Tools::displayError());
        }
        $states = Db::getInstance()->ExecuteS('
		SELECT s.*
		FROM `' . _DB_PREFIX_ . 'state` s
		');
        $result = Db::getInstance()->ExecuteS('
		SELECT cl.*,c.*, cl.`name` AS country, z.`name` AS zone
		FROM `' . _DB_PREFIX_ . 'country` c
		LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = ' . intval($id_lang) . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'zone` z ON z.`id_zone` = c.`id_zone`
		WHERE 1
		' . ($active ? 'AND c.active = 1' : '') . '
		' . (!is_null($containStates) ? 'AND c.`contains_states` = ' . intval($containStates) : '') . '
		ORDER BY cl.name ASC');
        $countries = array();
        foreach ($result as &$country) {
            $countries[$country['id_country']] = $country;
        }
        foreach ($states as &$state) {
            if (isset($countries[$state['id_country']])) {
                /* Does not keep the state if its country has been disabled and not selected */
                $countries[$state['id_country']]['states'][] = $state;
            }
        }
        return $countries;
    }
コード例 #9
0
ファイル: stores.php プロジェクト: rodrisan/ps-cli
 protected function _update_configuration($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = false;
     switch ($key) {
         case 'PS_STORE_DISPLAY_FOOTER':
         case 'PS_STORE_DISPLAY_SITEMAP':
         case 'PS_STORE_SIMPLIFIED':
             $validValue = Validate::isBool($value);
             break;
         case 'PS_STORES_CENTER_LAT':
         case 'PS_STORES_CENTER_LONG':
             $validValue = Validate::isCoordinate($value);
             break;
         case 'PS_SHOP_NAME':
             $validValue = Validate::isName($value);
             break;
         case 'PS_SHOP_EMAIL':
             $validValue = Validate::isEmail($value);
             break;
         case 'PS_SHOP_DETAILS':
             $validValue = Validate::isString($value);
             break;
         case 'PS_SHOP_ADDR1':
         case 'PS_SHOP_ADDR2':
             $validValue = Validate::isAddress($value);
             break;
         case 'PS_SHOP_CODE':
             $validValue = Validate::isPostCode($value);
             break;
         case 'PS_SHOP_CITY':
             $validValue = Validate::isCityName($value);
             break;
         case 'PS_SHOP_COUNTRY_ID':
             if (Validate::isUnsignedId($value)) {
                 $obj = new Country((int) $value);
                 $validValue = Validate::isLoadedObject($obj);
             }
             break;
         case 'PS_SHOP_STATE_ID':
             $validValue = Validate::isUnsignedId($value);
             break;
         case 'PS_SHOP_PHONE':
         case 'PS_SHOP_FAX':
             $validValue = Validate::isPhoneNumber($value);
             break;
         default:
             $interface->error("Configuration key '{$key}' is not handled by this command");
             break;
     }
     if (!$validValue) {
         $interface->error("value '{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated '{$key}' configuration");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
コード例 #10
0
    public function getCategories($id_categories, $id_lang = false, $active = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
    {
        if (!Validate::isBool($active)) {
            die(Tools::displayError());
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
				SELECT *
				FROM `' . _DB_PREFIX_ . 'category` c
				' . Shop::addSqlAssociation('category', 'c') . '
				LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON c.`id_category` = cl.`id_category`' . Shop::addSqlRestrictionOnLang('cl') . '
				WHERE 1 ' . pSQL($sql_filter) . ' ' . ($id_lang ? 'AND `id_lang` = ' . (int) $id_lang : '') . ($id_categories ? ' AND c.id_category IN (' . pSQL($id_categories) . ')' : '') . ($active ? ' AND `active` = 1' : '') . (!$id_lang ? ' GROUP BY c.id_category' : '') . ($sql_sort != '' ? $sql_sort : ' ORDER BY c.`level_depth` ASC, category_shop.`position` ASC ') . ($sql_limit != '' ? $sql_limit : ''));
        return $result;
    }
コード例 #11
0
ファイル: UniPaySystem.php プロジェクト: Edamaru/universalpay
    public static function getPaySystems($id_lang, $active = true, $id_carrier = false, $groups = array())
    {
        if (!Validate::isBool($active)) {
            die(Tools::displayError());
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
			SELECT *
			FROM `' . _DB_PREFIX_ . 'universalpay_system` us
			LEFT JOIN `' . _DB_PREFIX_ . 'universalpay_system_lang` usl ON us.`id_universalpay_system` = usl.`id_universalpay_system`
			' . ($id_carrier ? 'JOIN `' . _DB_PREFIX_ . 'universalpay_system_carrier` usc
			ON (us.`id_universalpay_system` = usc.`id_universalpay_system` AND usc.`id_carrier`=' . (int) $id_carrier . ')' : '') . '
			' . (!empty($groups) ? 'JOIN `' . _DB_PREFIX_ . 'universalpay_system_group` usg
			ON (us.`id_universalpay_system` = usg.`id_universalpay_system` AND usg.`id_group` IN (' . implode(',', array_map('intval', $groups)) . '))' : '') . 'WHERE `id_lang` = ' . (int) $id_lang . ($active ? ' AND `active` = 1' : '') . '
			GROUP BY us.`id_universalpay_system`
			ORDER BY us.`position` ASC');
        return $result;
    }
コード例 #12
0
    /**
     * Permet de récupèrer tous les produits qui sont "typer"
     * @return array
     */
    public static function getProductsById($bActive = true)
    {
        if (!Validate::isBool($bActive)) {
            die(Tools::displayError());
        }
        $sSQL = '
			SELECT *
			FROM `' . _DB_PREFIX_ . 'now_product_type_product` pt
			' . Shop::addSqlAssociation('now_product_type_product', 'pt') . '
			WHERE 1  ' . ($bActive ? 'AND pt.`active` = 1' : '');
        $aResults = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sSQL);
        $aProductsTypes = array();
        foreach ($aResults as $aRow) {
            $aProductsTypes[$aRow['id_product']] = $aRow['id_now_product_type'];
        }
        return $aProductsTypes;
    }
コード例 #13
0
ファイル: Message.php プロジェクト: Bruno-2M/prestashop
    /**
     * Return name from Order ID
     *
     * @param integer $id_order Order ID
     * @param boolean $private return WITH private messages
     * @return array Messages
     */
    public static function getMessagesByOrderId($id_order, $private = false)
    {
        if (!Validate::isBool($private)) {
            die(Tools::displayError());
        }
        global $cookie;
        $result = Db::getInstance()->ExecuteS('
			SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname, (COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me
			FROM `' . _DB_PREFIX_ . 'message` m
			LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON m.`id_customer` = c.`id_customer`
			LEFT JOIN `' . _DB_PREFIX_ . 'message_readed` mr ON (mr.id_message = m.id_message AND mr.id_employee = ' . intval($cookie->id_employee) . ')
			LEFT OUTER JOIN `' . _DB_PREFIX_ . 'employee` e ON e.`id_employee` = m.`id_employee`
			WHERE id_order = ' . intval($id_order) . '
			' . (!$private ? ' AND m.`private` = 0' : '') . '
			GROUP BY m.id_message
			ORDER BY m.date_add DESC
		');
        return $result;
    }
コード例 #14
0
 public function getContent()
 {
     $this->_html = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitUpdate')) {
         if (isset($_POST['new_page']) and Validate::isBool((int) $_POST['new_page'])) {
             Configuration::updateValue('NW_CONFIRMATION_NEW_PAGE', $_POST['new_page']);
         }
         if (isset($_POST['conf_email']) and VAlidate::isBool((int) $_POST['conf_email'])) {
             Configuration::updateValue('NW_CONFIRMATION_EMAIL', pSQL($_POST['conf_email']));
         }
         if (!empty($_POST['voucher']) and !Validate::isDiscountName($_POST['voucher'])) {
             $this->_html .= '<div class="alert">' . $this->l('Voucher code is invalid') . '</div>';
         } else {
             Configuration::updateValue('NW_VOUCHER_CODE', pSQL($_POST['voucher']));
             $this->_html .= '<div class="conf ok">' . $this->l('Updated') . '</div>';
         }
     }
     return $this->_displayForm();
 }
コード例 #15
0
ファイル: CMSCategory.php プロジェクト: yiuked/tmcart
    public function getCMSCategories($active = true, $order = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
    {
        if (!Validate::isBool($active)) {
            die(Tools::displayError());
        }
        $result = Db::getInstance()->getAll('
		SELECT *
		FROM `' . DB_PREFIX . 'cms_category` c
		WHERE 1 ' . $sql_filter . '
		' . ($active ? 'AND `active` = 1' : '') . '
		' . ($sql_sort != '' ? $sql_sort : 'ORDER BY c.`position` ASC') . '
		' . ($sql_limit != '' ? $sql_limit : ''));
        if (!$order) {
            return $result;
        }
        $categories = array();
        foreach ($result as $row) {
            $categories[$row['id_parent']][$row['id_cms_category']]['infos'] = $row;
        }
        return $categories;
    }
コード例 #16
0
ファイル: Message.php プロジェクト: jpodracky/dogs
    /**
     * Return messages from Cart ID
     *
     * @param int $id_order Order ID
     * @param bool $private return WITH private messages
     * @return array Messages
     */
    public static function getMessagesByCartId($id_cart, $private = false, Context $context = null)
    {
        if (!Validate::isBool($private)) {
            die(Tools::displayError());
        }
        if (!$context) {
            $context = Context::getContext();
        }
        return Db::getInstance()->executeS('
			SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname,
			(COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me
			FROM `' . _DB_PREFIX_ . 'message` m
			LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON m.`id_customer` = c.`id_customer`
			LEFT JOIN `' . _DB_PREFIX_ . 'message_readed` mr ON (mr.id_message = m.id_message AND mr.id_employee = ' . (int) $context->employee->id . ')
			LEFT OUTER JOIN `' . _DB_PREFIX_ . 'employee` e ON e.`id_employee` = m.`id_employee`
			WHERE id_cart = ' . (int) $id_cart . '
			' . (!$private ? ' AND m.`private` = 0' : '') . '
			GROUP BY m.id_message
			ORDER BY m.date_add DESC
		');
    }
コード例 #17
0
 public function getContent()
 {
     $this->_html = '';
     if (Tools::isSubmit('submitUpdate')) {
         $conf_email = Tools::getValue('NW_CONFIRMATION_EMAIL');
         if ($conf_email && Validate::isBool((int) $conf_email)) {
             Configuration::updateValue('NW_CONFIRMATION_EMAIL', (int) $conf_email);
         }
         $verif_email = Tools::getValue('NW_VERIFICATION_EMAIL');
         if ($verif_email && Validate::isBool((int) $verif_email)) {
             Configuration::updateValue('NW_VERIFICATION_EMAIL', (int) $verif_email);
         }
         $voucher = Tools::getValue('NW_VOUCHER_CODE');
         if ($voucher && !Validate::isDiscountName($voucher)) {
             $this->_html .= $this->displayError($this->l('The voucher code is invalid.'));
         } else {
             Configuration::updateValue('NW_VOUCHER_CODE', pSQL($voucher));
             $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $this->_html . $this->renderForm();
 }
コード例 #18
0
 public function getContent()
 {
     $output = null;
     if (Tools::isSubmit('submit' . $this->name)) {
         $dadata_token = strval(Tools::getValue('DADATA_SUGGESTIONS_TOKEN'));
         $dadata_count = strval(Tools::getValue('DADATA_SUGGESTIONS_COUNT'));
         $dadata_trig_sel_spc = strval(Tools::getValue('DADATA_SUGGESTIONS_TRIG_SEL_SPC'));
         $dadata_url = strval(Tools::getValue('DADATA_SUGGESTIONS_URL'));
         $dadata_fio = strval(Tools::getValue('DADATA_SUGGESTIONS_FIO'));
         $dadata_address = strval(Tools::getValue('DADATA_SUGGESTIONS_ADDRESS'));
         $dadata_region_field = strval(Tools::getValue('DADATA_SUGGESTIONS_REGION_FIELD'));
         if (!$dadata_token || empty($dadata_token) || !Validate::isSha1($dadata_token)) {
             $output .= $this->displayError($this->l('Invalid') . ' ' . $this->l('DaData.ru API Token'));
         } elseif (!Validate::isBool($dadata_trig_sel_spc)) {
             $output .= $this->displayError($this->l('Invalid auto correct selection'));
         } elseif (!Validate::isBool($dadata_fio)) {
             $output .= $this->displayError($this->l('Invalid hide selection'));
         } elseif (!Validate::isBool($dadata_address)) {
             $output .= $this->displayError($this->l('Invalid hide selection'));
         } elseif (!array_key_exists($dadata_url, $this->available_urls)) {
             $output .= $this->displayError($this->l('Invalid url selection'));
         } elseif (!in_array($dadata_region_field, $this->valid_fields)) {
             $output .= $this->displayError($this->l('Invalid field name'));
         } elseif (!$dadata_count || empty($dadata_count) || !Validate::isUnsignedInt($dadata_count) || $dadata_count == '0') {
             $output .= $this->displayError($this->l('Invalid') . ' ' . $this->l('Maximum suggestions count in list'));
         } else {
             Configuration::updateValue('DADATA_SUGGESTIONS_TOKEN', $dadata_token);
             Configuration::updateValue('DADATA_SUGGESTIONS_COUNT', $dadata_count);
             Configuration::updateValue('DADATA_SUGGESTIONS_TRIG_SEL_SPC', $dadata_trig_sel_spc);
             Configuration::updateValue('DADATA_SUGGESTIONS_URL', $dadata_url);
             Configuration::updateValue('DADATA_SUGGESTIONS_FIO', $dadata_fio);
             Configuration::updateValue('DADATA_SUGGESTIONS_ADDRESS', $dadata_address);
             Configuration::updateValue('DADATA_SUGGESTIONS_REGION_FIELD', $dadata_region_field);
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->displayForm();
 }
コード例 #19
0
 private function _update_configuration_key($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = true;
     switch ($key) {
         case 'PS_PASSWD_TIME_BACK':
             $validValue = Validate::isUnsignedInt($value);
             break;
         case 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG':
             $validValue = Validate::isBool($value);
             break;
         default:
             $interface->error("This configuration key is not handled by this plugin");
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for configuration key '{$key}'");
     }
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Configuration key '{$key}' successfully updated");
     } else {
         $interface->error("Could not update configuration key '{$key}'");
     }
 }
コード例 #20
0
ファイル: yamarket.php プロジェクト: Beattle/perrino-shop
 private function _postValidation()
 {
     if (Tools::getValue('yamarket_с_shop') && !Validate::isString(Tools::getValue('yamarket_с_shop'))) {
         $this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Shop Name');
     }
     if (Tools::getValue('yamarket_с_company') && !Validate::isString(Tools::getValue('yamarket_с_company'))) {
         $this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Сompany name');
     }
     if (Tools::getValue('yamarket_с_shippingcost') && !Validate::isString(Tools::getValue('yamarket_с_shippingcost'))) {
         $this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Shipping cost');
     }
     if (Tools::getValue('yamarket_с_info') && !Validate::isString(Tools::getValue('yamarket_с_info'))) {
         $this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Information');
     }
     if (Tools::getValue('yamarket_с_gzip') && !Validate::isBool(Tools::getValue('yamarket_с_gzip'))) {
         $this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Gzip compression');
     }
     if (Tools::getValue('yamarket_с_combinations') && !Validate::isBool(Tools::getValue('yamarket_с_combinations'))) {
         $this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Combinations');
     }
     if (Tools::getValue('yamarket_с_currencies') && !Validate::isBool(Tools::getValue('yamarket_с_currencies'))) {
         $this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Currencies');
     }
     if (Tools::getValue('yamarket_с_availability') && !Validate::isInt(Tools::getValue('yamarket_с_availability'))) {
         $this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Availability');
     }
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (Tools::isSubmit('ajax') && Tools::getValue('method') == 'updateExtraCarrier') {
         // Change virtualy the currents delivery options
         $delivery_option = $this->context->cart->getDeliveryOption();
         $delivery_option[(int) Tools::getValue('id_address')] = Tools::getValue('id_delivery_option');
         $this->context->cart->setDeliveryOption($delivery_option);
         $this->context->cart->save();
         $return = array('content' => Hook::exec('displayCarrierList', array('address' => new Address((int) Tools::getValue('id_address')))));
         die(Tools::jsonEncode($return));
     }
     if ($this->nbProducts) {
         $this->context->smarty->assign('virtual_cart', $this->context->cart->isVirtualCart());
     }
     if (!Tools::getValue('multi-shipping')) {
         $this->context->cart->setNoMultishipping();
     }
     // 4 steps to the order
     switch ((int) $this->step) {
         case -1:
             $this->context->smarty->assign('empty', 1);
             $this->setTemplate(_PS_THEME_DIR_ . 'shopping-cart.tpl');
             break;
         case 1:
             $this->_assignAddress();
             $this->processAddressFormat();
             if (Tools::getValue('multi-shipping') == 1) {
                 $this->_assignSummaryInformations();
                 $this->context->smarty->assign('product_list', $this->context->cart->getProducts());
                 $this->setTemplate(_PS_THEME_DIR_ . 'order-address-multishipping.tpl');
             } else {
                 $this->setTemplate(_PS_THEME_DIR_ . 'order-address.tpl');
             }
             break;
         case 2:
             if (Tools::isSubmit('processAddress')) {
                 $this->processAddress();
             }
             $this->autoStep();
             $this->_assignCarrier();
             $this->setTemplate(_PS_THEME_DIR_ . 'order-carrier.tpl');
             break;
         case 3:
             // Check that the conditions (so active) were accepted by the customer
             $cgv = Tools::getValue('cgv') || $this->context->cookie->check_cgv;
             if (Configuration::get('PS_CONDITIONS') && (!Validate::isBool($cgv) || $cgv == false)) {
                 Tools::redirect('index.php?controller=order&step=2');
             }
             Context::getContext()->cookie->check_cgv = true;
             // Check the delivery option is set
             if (!$this->context->cart->isVirtualCart()) {
                 if (!Tools::getValue('delivery_option') && !Tools::getValue('id_carrier') && !$this->context->cart->delivery_option && !$this->context->cart->id_carrier) {
                     Tools::redirect('index.php?controller=order&step=2');
                 } elseif (!Tools::getValue('id_carrier') && !$this->context->cart->id_carrier) {
                     $deliveries_options = Tools::getValue('delivery_option');
                     if (!$deliveries_options) {
                         $deliveries_options = $this->context->cart->delivery_option;
                     }
                     foreach ($deliveries_options as $delivery_option) {
                         if (empty($delivery_option)) {
                             Tools::redirect('index.php?controller=order&step=2');
                         }
                     }
                 }
             }
             $this->autoStep();
             // Bypass payment step if total is 0
             if (($id_order = $this->_checkFreeOrder()) && $id_order) {
                 if ($this->context->customer->is_guest) {
                     $order = new Order((int) $id_order);
                     $email = $this->context->customer->email;
                     $this->context->customer->mylogout();
                     // If guest we clear the cookie for security reason
                     Tools::redirect('index.php?controller=guest-tracking&id_order=' . urlencode($order->reference) . '&email=' . urlencode($email));
                 } else {
                     Tools::redirect('index.php?controller=history');
                 }
             }
             $this->_assignPayment();
             // assign some informations to display cart
             $this->_assignSummaryInformations();
             $this->setTemplate(_PS_THEME_DIR_ . 'order-payment.tpl');
             break;
         default:
             $this->_assignSummaryInformations();
             $this->setTemplate(_PS_THEME_DIR_ . 'shopping-cart.tpl');
             break;
     }
     $this->context->smarty->assign(array('currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank));
 }
コード例 #22
0
    public function customGetNestedCategories($shop_id, $root_category = null, $id_lang = false, $active = false, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
    {
        if (isset($root_category) && !Validate::isInt($root_category)) {
            die(Tools::displayError());
        }
        if (!Validate::isBool($active)) {
            die(Tools::displayError());
        }
        if (isset($groups) && Group::isFeatureActive() && !is_array($groups)) {
            $groups = (array) $groups;
        }
        $cache_id = 'Category::getNestedCategories_' . md5((int) $shop_id . (int) $root_category . (int) $id_lang . (int) $active . (int) $active . (isset($groups) && Group::isFeatureActive() ? implode('', $groups) : ''));
        if (!Cache::isStored($cache_id)) {
            $result = Db::getInstance()->executeS('
							SELECT c.*, cl.*
				FROM `' . _DB_PREFIX_ . 'category` c
				INNER JOIN `' . _DB_PREFIX_ . 'category_shop` category_shop ON (category_shop.`id_category` = c.`id_category` AND category_shop.`id_shop` = "' . (int) $shop_id . '")
				LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_shop` = "' . (int) $shop_id . '")
				WHERE 1 ' . $sql_filter . ' ' . ($id_lang ? 'AND cl.`id_lang` = ' . (int) $id_lang : '') . '
				' . ($active ? ' AND (c.`active` = 1 OR c.`is_root_category` = 1)' : '') . '
				' . (isset($groups) && Group::isFeatureActive() ? ' AND cg.`id_group` IN (' . implode(',', $groups) . ')' : '') . '
				' . (!$id_lang || isset($groups) && Group::isFeatureActive() ? ' GROUP BY c.`id_category`' : '') . '
				' . ($sql_sort != '' ? $sql_sort : ' ORDER BY c.`level_depth` ASC') . '
				' . ($sql_sort == '' && $use_shop_restriction ? ', category_shop.`position` ASC' : '') . '
				' . ($sql_limit != '' ? $sql_limit : ''));
            $categories = array();
            $buff = array();
            foreach ($result as $row) {
                $current =& $buff[$row['id_category']];
                $current = $row;
                if ($row['id_parent'] == 0) {
                    $categories[$row['id_category']] =& $current;
                } else {
                    $buff[$row['id_parent']]['children'][$row['id_category']] =& $current;
                }
            }
            Cache::store($cache_id, $categories);
        }
        return Cache::retrieve($cache_id);
    }
コード例 #23
0
ファイル: Search.php プロジェクト: evilscripts/gy
    public static function searchTag($id_lang, $tag, $count = false, $pageNumber = 0, $pageSize = 10, $orderBy = false, $orderWay = false, $useCookie = true, Context $context = null)
    {
        if (!$context) {
            $context = Context::getContext();
        }
        if (!Module::isInstalled('agilemultipleseller') and !Module::isInstalled('agilesellerlistoptions')) {
            return parent::searchTag($id_lang, $expr, $pageNumber, $pageSize, $orderBy, $orderWay, $ajax, $useCookie, $context);
        }
        $agile_sql_parts = AgileSellerManager::getAdditionalSqlForProducts("p");
        if ($useCookie) {
            $id_customer = (int) $context->customer->id;
        } else {
            $id_customer = 0;
        }
        if (!is_numeric($pageNumber) || !is_numeric($pageSize) || !Validate::isBool($count) || !Validate::isValidSearch($tag) || $orderBy && !$orderWay || $orderBy && !Validate::isOrderBy($orderBy) || $orderWay && !Validate::isOrderBy($orderWay)) {
            return false;
        }
        if ($pageNumber < 1) {
            $pageNumber = 1;
        }
        if ($pageSize < 1) {
            $pageSize = 10;
        }
        $id = Context::getContext()->shop->id;
        $id_shop = $id ? $id : Configuration::get('PS_SHOP_DEFAULT');
        if ($count) {
            $sql = 'SELECT COUNT(DISTINCT pt.`id_product`) nb
					FROM `' . _DB_PREFIX_ . 'product` p
		            ' . $agile_sql_parts['joins'] . '
					' . Shop::addSqlAssociation('product', 'p') . '
					LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
					LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . (int) $id_lang . ')
					LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_product` = p.`id_product`)
					LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = ' . (int) $id_shop . ')
					LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = cp.`id_category`)
					WHERE product_shop.`active` = 1
						' . $agile_sql_parts['wheres'] . '
						AND cs.`id_shop` = ' . (int) Context::getContext()->shop->id . '
						AND cg.`id_group` ' . (!$id_customer ? '= ' . (int) Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
							SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group
							WHERE id_customer = ' . (int) $id_customer . ')') . '
						AND t.`name` LIKE \'%' . pSQL($tag) . '%\'';
            return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
        }
        $sql = 'SELECT DISTINCT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description_short`, pl.`link_rewrite`, pl.`name`,
					MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name, 1 position,
					DATEDIFF(
						p.`date_add`,
						DATE_SUB(
							NOW(),
							INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY
						)
					) > 0 new
	            ' . $agile_sql_parts['selects'] . '
				FROM `' . _DB_PREFIX_ . 'product` p
	            ' . $agile_sql_parts['joins'] . '
				INNER JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
					p.`id_product` = pl.`id_product`
					AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
				)
				' . Shop::addSqlAssociation('product', 'p', false) . '
				LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '		
				LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
				LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
				LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . (int) $id_lang . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_product` = p.`id_product`)
				LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = cp.`id_category`)
				LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (cg.`id_category` = cs.`id_category` AND cs.`id_shop` = ' . (int) $id_shop . ')
				' . Product::sqlStock('p', 0) . '
				WHERE product_shop.`active` = 1
					' . $agile_sql_parts['wheres'] . '
					AND cs.`id_shop` = ' . (int) Context::getContext()->shop->id . '
					AND cg.`id_group` ' . (!$id_customer ? '= ' . (int) Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
						SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group
						WHERE id_customer = ' . (int) $id_customer . ')') . '
					AND t.`name` LIKE \'%' . pSQL($tag) . '%\'
					GROUP BY product_shop.id_product
				ORDER BY position DESC' . ($orderBy ? ', ' . $orderBy : '') . ($orderWay ? ' ' . $orderWay : '') . '
				LIMIT ' . (int) (($pageNumber - 1) * $pageSize) . ',' . (int) $pageSize;
        if (!($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))) {
            return false;
        }
        $results = Product::getProductsProperties((int) $id_lang, $result);
        $results = AgileSellerManager::prepareSellerRattingInfo($results);
        return $results;
    }
コード例 #24
0
ファイル: smartblog.php プロジェクト: johnulist/smartblog
 public static function displayDate($date, $id_lang = null, $full = false, $separator = null)
 {
     if ($id_lang !== null) {
         Tools::displayParameterAsDeprecated('id_lang');
     }
     if ($separator !== null) {
         Tools::displayParameterAsDeprecated('separator');
     }
     if (!$date || !($time = strtotime($date))) {
         return $date;
     }
     if ($date == '0000-00-00 00:00:00' || $date == '0000-00-00') {
         return '';
     }
     if (!Validate::isDate($date) || !Validate::isBool($full)) {
         throw new PrestaShopException('Invalid date');
     }
     $date_format = $full ? Configuration::get('smartdataformat') : Configuration::get('smartdataformat');
     return date($date_format, $time);
 }
コード例 #25
0
ファイル: Carrier.php プロジェクト: M03G/PrestaShop
    /**
     * Get the countries to which can be delivered
     *
     * @param int  $id_lang          Language ID
     * @param bool $active_countries Only return active countries when true
     * @param bool $active_carriers  Only return active carriers when true
     * @param null $contain_states   Only return countries with states
     *
     * @return array Countries to which can be delivered
     */
    public static function getDeliveredCountries($id_lang, $active_countries = false, $active_carriers = false, $contain_states = null)
    {
        if (!Validate::isBool($active_countries) || !Validate::isBool($active_carriers)) {
            die(Tools::displayError());
        }
        $states = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
		SELECT s.*
		FROM `' . _DB_PREFIX_ . 'state` s
		ORDER BY s.`name` ASC');
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
			SELECT cl.*,c.*, cl.`name` AS country, zz.`name` AS zone
			FROM `' . _DB_PREFIX_ . 'country` c' . Shop::addSqlAssociation('country', 'c') . '
			LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = ' . (int) $id_lang . ')
			INNER JOIN (`' . _DB_PREFIX_ . 'carrier_zone` cz INNER JOIN `' . _DB_PREFIX_ . 'carrier` cr ON ( cr.id_carrier = cz.id_carrier AND cr.deleted = 0 ' . ($active_carriers ? 'AND cr.active = 1) ' : ') ') . '
			LEFT JOIN `' . _DB_PREFIX_ . 'zone` zz ON cz.id_zone = zz.id_zone) ON zz.`id_zone` = c.`id_zone`
			WHERE 1
			' . ($active_countries ? 'AND c.active = 1' : '') . '
			' . (!is_null($contain_states) ? 'AND c.`contains_states` = ' . (int) $contain_states : '') . '
			ORDER BY cl.name ASC');
        $countries = array();
        foreach ($result as &$country) {
            $countries[$country['id_country']] = $country;
        }
        foreach ($states as &$state) {
            if (isset($countries[$state['id_country']])) {
                /* Does not keep the state if its country has been disabled and not selected */
                if ($state['active'] == 1) {
                    $countries[$state['id_country']]['states'][] = $state;
                }
            }
        }
        return $countries;
    }
コード例 #26
0
    public function getContent()
    {
        if (Tools::isSubmit('submitUpdate')) {
            $conf_email = Tools::getValue('NW_CONFIRMATION_EMAIL');
            if ($conf_email && Validate::isBool((int) $conf_email)) {
                Configuration::updateValue('NW_CONFIRMATION_EMAIL', (int) $conf_email);
            }
            $verif_email = Tools::getValue('NW_VERIFICATION_EMAIL');
            if ($verif_email && Validate::isBool((int) $verif_email)) {
                Configuration::updateValue('NW_VERIFICATION_EMAIL', (int) $verif_email);
            }
            $voucher = Tools::getValue('NW_VOUCHER_CODE');
            if ($voucher && !Validate::isDiscountName($voucher)) {
                $this->_html .= $this->displayError($this->l('The voucher code is invalid.'));
            } else {
                Configuration::updateValue('NW_VOUCHER_CODE', pSQL($voucher));
                $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
            }
        } elseif (Tools::isSubmit('subscribedcustomer')) {
            $id = Tools::getValue('id');
            if (preg_match('/(^N)/', $id)) {
                $id = (int) substr($id, 1);
                $sql = 'UPDATE ' . _DB_PREFIX_ . 'newsletter SET active = 0 WHERE id = ' . $id;
                Db::getInstance()->execute($sql);
            } else {
                $c = new Customer((int) $id);
                $c->newsletter = (int) (!$c->newsletter);
                $c->update();
            }
            Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&conf=4&token=' . Tools::getAdminTokenLite('AdminModules'));
        } elseif (Tools::isSubmit('exportSubscribers')) {
            $header = array('id', 'shop_name', 'gender', 'lastname', 'firstname', 'email', 'subscribed', 'subscribed_on');
            // TODO
            $array_to_export = array_merge(array($header), $this->getSubscribers());
            $file_name = time() . '.csv';
            $fd = fopen($this->getLocalPath() . $file_name, 'w+');
            foreach ($array_to_export as $tab) {
                $line = implode(';', $tab);
                $line .= "\n";
                fwrite($fd, $line, 4096);
            }
            fclose($fd);
            Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/' . $file_name);
        } elseif (Tools::isSubmit('searchEmail')) {
            $this->_searched_email = Tools::getValue('searched_email');
        }
        $this->_html .= $this->renderForm();
        $this->_html .= $this->renderSearchForm();
        $this->_html .= $this->renderList();
        $this->_html .= '<div class="panel"><a href="' . $this->context->link->getAdminLink('AdminModules', false) . '&exportSubscribers&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '">
    <button class="btn btn-default btn-lg"><span class="icon icon-share"></span> ' . $this->l('Export as CSV') . '</button>
</a></div>';
        return $this->_html;
    }
コード例 #27
0
ファイル: Tools.php プロジェクト: WhisperingTree/etagerca
 /**
  * Display date regarding to language preferences
  *
  * @param string $date Date to display format UNIX
  * @param integer $id_lang Language id DEPRECATED
  * @param boolean $full With time or not (optional)
  * @param string $separator DEPRECATED
  *
  * @return string Date
  */
 public static function displayDate($date, $id_lang = null, $full = false, $separator = null)
 {
     if ($id_lang !== null) {
         Tools::displayParameterAsDeprecated('id_lang');
     }
     if ($separator !== null) {
         Tools::displayParameterAsDeprecated('separator');
     }
     if (!$date || !($time = strtotime($date))) {
         return $date;
     }
     if ($date == '0000-00-00 00:00:00' || $date == '0000-00-00') {
         return '';
     }
     if (!Validate::isDate($date) || !Validate::isBool($full)) {
         throw new PrestaShopException('Invalid date');
     }
     $context = Context::getContext();
     $date_format = $full ? $context->language->date_format_full : $context->language->date_format_lite;
     return date($date_format, $time);
 }
コード例 #28
0
ファイル: advancetab.php プロジェクト: evgrishin/se1614
    public function getPricesDrop($where, $id_lang, $page_number = 0, $nb_products = 10, $count = false, $order_by = null, $order_way = null, $beginning = false, $ending = false, Context $context = null)
    {
        if (!Validate::isBool($count)) {
            die(Tools::displayError());
        }
        if (!$context) {
            $context = Context::getContext();
        }
        if ($page_number < 0) {
            $page_number = 0;
        }
        if ($nb_products < 1) {
            $nb_products = 10;
        }
        if (empty($order_by) || $order_by == 'position') {
            $order_by = 'price';
        }
        if (empty($order_way)) {
            $order_way = 'DESC';
        }
        if ($order_by == 'id_product' || $order_by == 'price' || $order_by == 'date_add' || $order_by == 'date_upd') {
            $order_by_prefix = 'p';
        } else {
            if ($order_by == 'name') {
                $order_by_prefix = 'pl';
            }
        }
        if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) {
            die(Tools::displayError());
        }
        $current_date = date('Y-m-d H:i:s');
        $ids_product = $this->_getProductIdByDate(!$beginning ? $current_date : $beginning, !$ending ? $current_date : $ending, $context);
        $tab_id_product = array();
        foreach ($ids_product as $product) {
            if (is_array($product)) {
                $tab_id_product[] = (int) $product['id_product'];
            } else {
                $tab_id_product[] = (int) $product;
            }
        }
        $front = true;
        if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
            $front = false;
        }
        $sql_groups = '';
        if (Group::isFeatureActive()) {
            $groups = FrontController::getCurrentCustomerGroups();
            $sql_groups = 'AND p.`id_product` IN (
				SELECT cp.`id_product`
				FROM `' . _DB_PREFIX_ . 'category_group` cg
				LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)
				WHERE ' . $where . ' cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1') . '
			)';
        }
        if ($count) {
            return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
			SELECT COUNT(DISTINCT p.`id_product`)
			FROM `' . _DB_PREFIX_ . 'product` p
			' . Shop::addSqlAssociation('product', 'p') . '
			WHERE product_shop.`active` = 1
			AND product_shop.`show_price` = 1
			' . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . '
			' . (!$beginning && !$ending ? 'AND p.`id_product` IN(' . (is_array($tab_id_product) && count($tab_id_product) ? implode(', ', $tab_id_product) : 0) . ')' : '') . '
			' . $sql_groups);
        }
        if (strpos($order_by, '.') > 0) {
            $order_by = explode('.', $order_by);
            $order_by = pSQL($order_by[0]) . '.`' . pSQL($order_by[1]) . '`';
        }
        $sql = '
		SELECT
			p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`,
			MAX(product_attribute_shop.id_product_attribute) id_product_attribute,
			pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`,
			pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
			DATEDIFF(
				p.`date_add`,
				DATE_SUB(
					NOW(),
					INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY
				)
			) > 0 AS new
		FROM `' . _DB_PREFIX_ . 'product` p
		' . Shop::addSqlAssociation('product', 'p') . '
		LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON (pa.id_product = p.id_product)
		' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on=1') . '
		' . Product::sqlStock('p', 0, false, $context->shop) . '
		LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
			p.`id_product` = pl.`id_product`
			AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
		)
		LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
		LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
		WHERE product_shop.`active` = 1
		AND product_shop.`show_price` = 1
		' . ($front ? ' AND p.`visibility` IN ("both", "catalog")' : '') . '
		' . (!$beginning && !$ending ? ' AND p.`id_product` IN (' . (is_array($tab_id_product) && count($tab_id_product) ? implode(', ', $tab_id_product) : 0) . ')' : '') . '
		' . $sql_groups . '
		GROUP BY product_shop.id_product
		ORDER BY ' . (isset($order_by_prefix) ? pSQL($order_by_prefix) . '.' : '') . pSQL($order_by) . ' ' . pSQL($order_way) . '
		LIMIT ' . (int) ($page_number * $nb_products) . ', ' . (int) $nb_products;
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
        if (!$result) {
            return false;
        }
        if ($order_by == 'price') {
            Tools::orderbyPrice($result, $order_way);
        }
        return Product::getProductsProperties($id_lang, $result);
    }
コード例 #29
0
 public function ajaxProcessUpdateDeliveryOption()
 {
     if ($this->tabAccess['edit'] === '1') {
         $delivery_option = Tools::getValue('delivery_option');
         if ($delivery_option !== false) {
             $this->context->cart->setDeliveryOption(array($this->context->cart->id_address_delivery => $delivery_option));
         }
         if (Validate::isBool($recyclable = (int) Tools::getValue('recyclable'))) {
             $this->context->cart->recyclable = $recyclable;
         }
         if (Validate::isBool($gift = (int) Tools::getValue('gift'))) {
             $this->context->cart->gift = $gift;
         }
         if (Validate::isMessage($gift_message = pSQL(Tools::getValue('gift_message')))) {
             $this->context->cart->gift_message = $gift_message;
         }
         $this->context->cart->save();
         echo Tools::jsonEncode($this->ajaxReturnVars());
     }
 }
コード例 #30
0
ファイル: WebserviceRequest.php プロジェクト: dev-lav/htdocs
 public function setOutputEnabled($bool)
 {
     if (Validate::isBool($bool)) {
         $this->_outputEnabled = $bool;
     }
     return $this;
 }