// Release branch merged
This commit is contained in:
@@ -604,8 +604,8 @@ class CategoryCore extends ObjectModel
|
||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
}
|
||||
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`id_product_attribute`, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`,
|
||||
pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, image_shop.`id_image`,
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`,
|
||||
pl.`available_later`, 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, cl.`name` AS category_default,
|
||||
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
|
||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).'
|
||||
@@ -633,12 +633,11 @@ class CategoryCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
|
||||
ON m.`id_manufacturer` = p.`id_manufacturer`
|
||||
WHERE product_shop.`id_shop` = '.(int)$context->shop->id.'
|
||||
AND (pa.id_product_attribute IS NULL OR product_attribute_shop.id_shop='.(int)$context->shop->id.')
|
||||
AND (i.id_image IS NULL OR image_shop.id_shop='.(int)$context->shop->id.')
|
||||
AND cp.`id_category` = '.(int)$this->id
|
||||
.($active ? ' AND product_shop.`active` = 1' : '')
|
||||
.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '')
|
||||
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '');
|
||||
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '')
|
||||
.' GROUP BY product_shop.id_product';
|
||||
|
||||
if ($random === true)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ class CustomerMessageCore extends ObjectModel
|
||||
LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e
|
||||
ON e.`id_employee` = cm.`id_employee`
|
||||
WHERE ct.id_order = '.(int)$id_order.'
|
||||
AND '.(!$private ? 'cm.`private` = 0' : '').'
|
||||
'.(!$private ? 'AND cm.`private` = 0' : '').'
|
||||
GROUP BY cm.id_customer_message
|
||||
ORDER BY cm.date_add DESC
|
||||
');
|
||||
|
||||
+10
-10
@@ -312,16 +312,16 @@ class FeatureCore extends ObjectModel
|
||||
*/
|
||||
public static function cleanPositions()
|
||||
{
|
||||
$return = true;
|
||||
$sql = '
|
||||
UPDATE `'._DB_PREFIX_.'feature` f LEFT JOIN
|
||||
(SELECT @i := @i +1 AS rank, id_feature, position
|
||||
FROM `'._DB_PREFIX_.'feature` JOIN (SELECT @i :=1) dummy
|
||||
ORDER by position) AS f2
|
||||
USING(id_feature)
|
||||
SET f.position = f2.rank-1';
|
||||
$return = Db::getInstance()->executeS($sql);
|
||||
return $return;
|
||||
return Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'feature` f
|
||||
LEFT JOIN (
|
||||
SELECT @i := @i +1 AS rank, id_feature, position
|
||||
FROM `'._DB_PREFIX_.'feature`
|
||||
JOIN (SELECT @i :=1) dummy
|
||||
ORDER by position
|
||||
) AS f2
|
||||
USING (id_feature)
|
||||
SET f.position = f2.rank - 1');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
-1
@@ -393,7 +393,17 @@ class HookCore extends ObjectModel
|
||||
if ($check_exceptions)
|
||||
{
|
||||
$exceptions = $moduleInstance->getExceptions($array['id_hook']);
|
||||
if (in_array(Dispatcher::getInstance()->getController(), $exceptions))
|
||||
$controller = Dispatcher::getInstance()->getController();
|
||||
|
||||
if (in_array($controller, $exceptions))
|
||||
continue;
|
||||
|
||||
//retro compat of controller names
|
||||
$matching_name = array(
|
||||
'authentication' => 'auth',
|
||||
'compare' => 'products-comparison',
|
||||
);
|
||||
if (isset($matching_name[$controller]) && in_array($matching_name[$controller], $exceptions))
|
||||
continue;
|
||||
if (Validate::isLoadedObject($context->employee) && !$moduleInstance->getPermission('view', $context->employee))
|
||||
continue;
|
||||
|
||||
+102
-55
@@ -190,19 +190,22 @@ class LanguageCore extends ObjectModel
|
||||
return $themes;
|
||||
}
|
||||
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
public function add($autodate = true, $nullValues = false, $only_add = false)
|
||||
{
|
||||
if (!parent::add($autodate))
|
||||
return false;
|
||||
|
||||
if ($only_add)
|
||||
return true;
|
||||
|
||||
// create empty files if they not exists
|
||||
$this->_generateFiles();
|
||||
|
||||
// @todo Since a lot of modules are not in right format with their primary keys name, just get true ...
|
||||
$resUpdateSQL = $this->loadUpdateSQL();
|
||||
$resUpdateSQL = true;
|
||||
|
||||
return $resUpdateSQL && Tools::generateHtaccess();
|
||||
Tools::generateHtaccess();
|
||||
return $resUpdateSQL;
|
||||
}
|
||||
|
||||
public function toggleStatus()
|
||||
@@ -681,66 +684,66 @@ class LanguageCore extends ObjectModel
|
||||
return Tools::generateHtaccess();
|
||||
}
|
||||
|
||||
public static function checkAndAddLanguage($iso_code)
|
||||
public static function checkAndAddLanguage($iso_code, $lang_pack = false, $only_add = false, $params_lang = null)
|
||||
{
|
||||
if (Language::getIdByIso($iso_code))
|
||||
return true;
|
||||
else
|
||||
|
||||
$lang = new Language();
|
||||
$lang->iso_code = $iso_code;
|
||||
$lang->active = true;
|
||||
|
||||
if (!$lang_pack)
|
||||
$lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code));
|
||||
|
||||
if ($lang_pack)
|
||||
{
|
||||
if (@fsockopen('www.prestashop.com', 80))
|
||||
if (isset($lang_pack->name)
|
||||
&& isset($lang_pack->version)
|
||||
&& isset($lang_pack->iso_code))
|
||||
$lang->name = $lang_pack->name;
|
||||
}
|
||||
elseif ($params_lang !== null && is_array($params_lang))
|
||||
{
|
||||
foreach ($params_lang as $key => $value)
|
||||
$lang->$key = $value;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
if (!$lang->add(true, false, $only_add))
|
||||
return false;
|
||||
|
||||
$flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg');
|
||||
if ($flag != null && !preg_match('/<body>/', $flag))
|
||||
{
|
||||
$file = fopen(dirname(__FILE__).'/../img/l/'.(int)$lang->id.'.jpg', 'w');
|
||||
if ($file)
|
||||
{
|
||||
$lang = new Language();
|
||||
$lang->iso_code = $iso_code;
|
||||
$lang->active = true;
|
||||
|
||||
if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code)))
|
||||
{
|
||||
if (isset($lang_pack->name)
|
||||
&& isset($lang_pack->version)
|
||||
&& isset($lang_pack->iso_code))
|
||||
$lang->name = $lang_pack->name;
|
||||
}
|
||||
if (!$lang->name || !$lang->add())
|
||||
return false;
|
||||
$insert_id = (int)$lang->id;
|
||||
|
||||
if ($lang_pack)
|
||||
{
|
||||
$flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg');
|
||||
if ($flag != null && !preg_match('/<body>/', $flag))
|
||||
{
|
||||
$file = fopen(dirname(__FILE__).'/../img/l/'.$insert_id.'.jpg', 'w');
|
||||
if ($file)
|
||||
{
|
||||
fwrite($file, $flag);
|
||||
fclose($file);
|
||||
}
|
||||
else
|
||||
Language::_copyNoneFlag($insert_id);
|
||||
}
|
||||
else
|
||||
Language::_copyNoneFlag($insert_id);
|
||||
}
|
||||
else
|
||||
Language::_copyNoneFlag($insert_id);
|
||||
|
||||
$files_copy = array(
|
||||
'/en.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('thickbox').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('home').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('large').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('medium').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('small').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('scene').'.jpg'
|
||||
);
|
||||
foreach (array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_) as $to)
|
||||
foreach ($files_copy as $file)
|
||||
@copy(dirname(__FILE__).'/../img/l'.$file, $to.str_replace('/en', '/'.$iso_code, $file));
|
||||
return true;
|
||||
fwrite($file, $flag);
|
||||
fclose($file);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
Language::_copyNoneFlag((int)$lang->id);
|
||||
}
|
||||
else
|
||||
Language::_copyNoneFlag((int)$lang->id);
|
||||
|
||||
$files_copy = array(
|
||||
'/en.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('thickbox').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('home').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('large').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('medium').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('small').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('scene').'.jpg'
|
||||
);
|
||||
|
||||
foreach (array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_) as $to)
|
||||
foreach ($files_copy as $file)
|
||||
@copy(dirname(__FILE__).'/../img/l'.$file, $to.str_replace('/en', '/'.$iso_code, $file));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static function _copyNoneFlag($id)
|
||||
@@ -772,6 +775,50 @@ class LanguageCore extends ObjectModel
|
||||
return self::$countActiveLanguages;
|
||||
}
|
||||
|
||||
public static function downloadAndInstallLanguagePack($iso, $version = null, $params = null)
|
||||
{
|
||||
require_once(_PS_TOOL_DIR_.'tar/Archive_Tar.php');
|
||||
|
||||
if (!Validate::isLanguageIsoCode($iso))
|
||||
return false;
|
||||
|
||||
if ($version == null)
|
||||
$version = _PS_VERSION_;
|
||||
$lang_pack = false;
|
||||
$lang_pack_ok = false;
|
||||
$errors = array();
|
||||
$file = _PS_TRANSLATIONS_DIR_.$iso.'.gzip';
|
||||
if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.$version.'&iso_lang='.$iso))
|
||||
$errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
|
||||
elseif (!$lang_pack = Tools::jsonDecode($lang_pack_link))
|
||||
$errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
|
||||
elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.$lang_pack->iso_code.'.gzip'))
|
||||
if (!@file_put_contents($file, $content))
|
||||
$errors[] = Tools::displayError('Server does not have permissions for writing.');
|
||||
if (file_exists($file))
|
||||
{
|
||||
$gz = new Archive_Tar($file, true);
|
||||
$files_list = $gz->listContent();
|
||||
if (!$gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
|
||||
$errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ').(string)$iso;
|
||||
if (!Language::checkAndAddLanguage((string)$iso, $lang_pack, false, $params))
|
||||
$errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$iso;
|
||||
else
|
||||
{
|
||||
// Reset cache
|
||||
Language::loadLanguages();
|
||||
|
||||
AdminTranslationsController::checkAndAddMailsFiles($iso, $files_list);
|
||||
AdminTranslationsController::addNewTabs($iso, $files_list);
|
||||
}
|
||||
@unlink($file);
|
||||
}
|
||||
else
|
||||
$errors[] = Tools::displayError('No language pack is available for your version.');
|
||||
|
||||
return count($errors) ? $errors : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if more on than one language is activated
|
||||
*
|
||||
|
||||
@@ -295,47 +295,15 @@ class LocalizationPackCore
|
||||
// if we are not in an installation context or if the pack is not available in the local directory
|
||||
if (Language::getIdByIso($attributes['iso_code']) && !$install_mode)
|
||||
continue;
|
||||
|
||||
$errno = 0;
|
||||
$errstr = '';
|
||||
if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$attributes['iso_code']))
|
||||
$this->_errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
|
||||
elseif (!$lang_pack = Tools::jsonDecode($lang_pack_link))
|
||||
$this->_errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
|
||||
elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.$attributes['iso_code'].'.gzip'))
|
||||
{
|
||||
$file = _PS_TRANSLATIONS_DIR_.$attributes['iso_code'].'.gzip';
|
||||
if (file_put_contents($file, $content))
|
||||
{
|
||||
$gz = new Archive_Tar($file, true);
|
||||
$files_list = $gz->listContent();
|
||||
|
||||
if (!$gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ').(string)$attributes['iso_code'];
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
AdminTranslationsController::checkAndAddMailsFiles($attributes['iso_code'], $files_list);
|
||||
AdminTranslationsController::addNewTabs($attributes['iso_code'], $files_list);
|
||||
}
|
||||
if (!Language::checkAndAddLanguage((string)$attributes['iso_code']))
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$attributes['iso_code'];
|
||||
return false;
|
||||
}
|
||||
@unlink($file);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Server does not have permissions for writing.');
|
||||
}
|
||||
$errors = Language::downloadAndInstallLanguagePack($attributes['iso_code'], $attributes['version']);
|
||||
if ($errors !== true && is_array($errors))
|
||||
$this->_errors = array_merge($this->_errors, $errors);
|
||||
}
|
||||
// change the default language if there is only one language in the localization pack
|
||||
if (!count($this->_errors) && $install_mode && isset($attributes['iso_code']) && count($xml->languages->language) == 1)
|
||||
$this->iso_code_lang = $attributes['iso_code'];
|
||||
|
||||
return true;
|
||||
return !count($this->_errors);
|
||||
}
|
||||
|
||||
protected function _installUnits($xml)
|
||||
|
||||
@@ -325,9 +325,9 @@ class ManufacturerCore extends ObjectModel
|
||||
$alias = 'stock.';
|
||||
else
|
||||
$alias = 'p.';
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pa.`id_product_attribute`,
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute,
|
||||
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`,
|
||||
pl.`meta_title`, pl.`name`, image_shop.`id_image`, il.`legend`, m.`name` AS manufacturer_name,
|
||||
pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
|
||||
DATEDIFF(
|
||||
product_shop.`date_add`,
|
||||
DATE_SUB(
|
||||
@@ -353,7 +353,6 @@ class ManufacturerCore extends ObjectModel
|
||||
WHERE p.`id_manufacturer` = '.(int)$id_manufacturer.'
|
||||
'.($active ? ' AND product_shop.`active` = 1' : '').'
|
||||
'.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').'
|
||||
AND (product_attribute_shop.default_on = 1 OR product_attribute_shop.default_on IS NULL)
|
||||
AND p.`id_product` IN (
|
||||
SELECT cp.`id_product`
|
||||
FROM `'._DB_PREFIX_.'category_group` cg
|
||||
@@ -362,7 +361,7 @@ class ManufacturerCore extends ObjectModel
|
||||
($active_category ? ' INNER JOIN `'._DB_PREFIX_.'category` ca ON cp.`id_category` = ca.`id_category` AND ca.`active` = 1' : '').'
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
GROUP BY product_shop.id_product
|
||||
ORDER BY '.$alias.'`'.bqSQL($order_by).'` '.pSQL($order_way).'
|
||||
LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;
|
||||
|
||||
|
||||
@@ -859,6 +859,8 @@ abstract class ObjectModelCore
|
||||
$values = $this->$field;
|
||||
if (!is_array($values))
|
||||
$values = array($this->id_lang => $values);
|
||||
if (!isset($values[Configuration::get('PS_LANG_DEFAULT')]))
|
||||
$values[Configuration::get('PS_LANG_DEFAULT')] = '';
|
||||
|
||||
foreach ($values as $id_lang => $value)
|
||||
{
|
||||
|
||||
+5
-5
@@ -124,7 +124,7 @@ class PackCore extends Product
|
||||
if (!Pack::isFeatureActive())
|
||||
return array();
|
||||
|
||||
$sql = 'SELECT p.*, product_shop.*, pl.*, image_shop.`id_image`, il.`legend`, cl.`name` AS category_default, a.quantity AS pack_quantity, product_shop.`id_category_default`, a.id_product_pack
|
||||
$sql = 'SELECT p.*, product_shop.*, pl.*, MAX(image_shop.`id_image`) id_image, il.`legend`, cl.`name` AS category_default, a.quantity AS pack_quantity, product_shop.`id_category_default`, a.id_product_pack
|
||||
FROM `'._DB_PREFIX_.'pack` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = a.id_product_item
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
@@ -138,8 +138,8 @@ class PackCore extends Product
|
||||
ON product_shop.`id_category_default` = cl.`id_category`
|
||||
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
|
||||
WHERE product_shop.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
AND a.`id_product_pack` = '.(int)$id_product;
|
||||
AND a.`id_product_pack` = '.(int)$id_product.'
|
||||
GROUP BY product_shop.id_product';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
foreach ($result as &$line)
|
||||
@@ -169,7 +169,7 @@ class PackCore extends Product
|
||||
return array();
|
||||
|
||||
$sql = '
|
||||
SELECT p.*, product_shop.*, pl.*, image_shop.`id_image`, il.`legend`
|
||||
SELECT p.*, product_shop.*, pl.*, MAX(image_shop.`id_image`) id_image, il.`legend`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
NATURAL LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
@@ -179,7 +179,7 @@ class PackCore extends Product
|
||||
WHERE pl.`id_lang` = '.(int)$id_lang.'
|
||||
'.Shop::addSqlRestrictionOnLang('pl').'
|
||||
AND p.`id_product` IN ('.$packs.')
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))';
|
||||
GROUP BY product_shop.id_product';
|
||||
if ($limit)
|
||||
$sql .= ' LIMIT '.(int)$limit;
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
+16
-18
@@ -1991,7 +1991,7 @@ class ProductCore extends ObjectModel
|
||||
$sql = new DbQuery();
|
||||
$sql->select(
|
||||
'p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
|
||||
pl.`meta_keywords`, pl.`meta_title`, pl.`name`, image_shop.`id_image`, il.`legend`, m.`name` AS manufacturer_name,
|
||||
pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
|
||||
DATEDIFF(
|
||||
product_shop.`date_add`,
|
||||
DATE_SUB(
|
||||
@@ -2013,7 +2013,7 @@ class ProductCore extends ObjectModel
|
||||
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
|
||||
|
||||
$sql->where('product_shop.`active` = 1');
|
||||
$sql->where('(image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1)');
|
||||
|
||||
if ($front)
|
||||
$sql->where('product_shop.`visibility` IN ("both", "catalog")');
|
||||
$sql->where('
|
||||
@@ -2032,16 +2032,16 @@ class ProductCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.')'
|
||||
);
|
||||
$sql->groupBy('product_shop.id_product');
|
||||
|
||||
$sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way));
|
||||
$sql->limit($nb_products, $page_number * $nb_products);
|
||||
|
||||
if (Combination::isFeatureActive())
|
||||
{
|
||||
$sql->select('pa.id_product_attribute');
|
||||
$sql->select('MAX(product_attribute_shop.id_product_attribute) id_product_attribute');
|
||||
$sql->leftOuterJoin('product_attribute', 'pa', 'p.`id_product` = pa.`id_product`');
|
||||
$sql->join(Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1'));
|
||||
$sql->where('(pa.id_product_attribute IS NULL OR product_attribute_shop.id_shop='.(int)$context->shop->id.')');
|
||||
}
|
||||
$sql->join(Product::sqlStock('p', Combination::isFeatureActive() ? 'product_attribute_shop' : 0));
|
||||
|
||||
@@ -2111,7 +2111,7 @@ class ProductCore extends ObjectModel
|
||||
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
|
||||
|
||||
// Please keep 2 distinct queries because RAND() is an awful way to achieve this result
|
||||
$sql = 'SELECT product_shop.id_product, product_attribute_shop.id_product_attribute
|
||||
$sql = 'SELECT product_shop.id_product, MAX(product_attribute_shop.id_product_attribute) id_product_attribute
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (product_shop.id_product = pa.id_product)
|
||||
@@ -2125,7 +2125,6 @@ class ProductCore extends ObjectModel
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
'.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').'
|
||||
AND (pa.id_product_attribute IS NULL OR product_attribute_shop.default_on = 1)
|
||||
GROUP BY product_shop.id_product
|
||||
ORDER BY RAND()';
|
||||
|
||||
@@ -2136,7 +2135,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`,
|
||||
pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
|
||||
p.`ean13`, p.`upc`, image_shop.`id_image`, il.`legend`
|
||||
p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
@@ -2148,7 +2147,7 @@ class ProductCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
'.Product::sqlStock('p', 0).'
|
||||
WHERE p.id_product = '.(int)$id_product.'
|
||||
AND (i.id_image IS NULL OR image_shop.id_shop='.(int)$context->shop->id.')';
|
||||
GROUP BY product_shop.id_product';
|
||||
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
if (!$row)
|
||||
@@ -2228,9 +2227,9 @@ class ProductCore extends ObjectModel
|
||||
$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`, product_attribute_shop.id_product_attribute,
|
||||
$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`, image_shop.`id_image`, il.`legend`, m.`name` AS manufacturer_name,
|
||||
pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
|
||||
DATEDIFF(
|
||||
p.`date_add`,
|
||||
DATE_SUB(
|
||||
@@ -2253,7 +2252,6 @@ class ProductCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
|
||||
WHERE product_shop.`active` = 1
|
||||
AND product_shop.`show_price` = 1
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=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).')' : '').'
|
||||
AND p.`id_product` IN (
|
||||
@@ -2262,7 +2260,7 @@ class ProductCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
AND (pa.id_product_attribute IS NULL OR product_attribute_shop.default_on = 1)
|
||||
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;
|
||||
|
||||
@@ -3045,7 +3043,7 @@ class ProductCore extends ObjectModel
|
||||
AND al.`id_lang` = '.(int)$id_lang.'
|
||||
AND agl.`id_lang` = '.(int)$id_lang.'
|
||||
GROUP BY id_attribute_group, id_product_attribute
|
||||
ORDER BY ag.`position` ASC, a.`position` ASC';
|
||||
ORDER BY ag.`position` ASC, a.`position` ASC, agl.`name` ASC';
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
@@ -3107,7 +3105,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`,
|
||||
pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
|
||||
i.`id_image`, il.`legend`, m.`name` as manufacturer_name, cl.`name` AS category_default,
|
||||
MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` as manufacturer_name, cl.`name` AS category_default,
|
||||
DATEDIFF(
|
||||
p.`date_add`,
|
||||
DATE_SUB(
|
||||
@@ -3131,9 +3129,9 @@ class ProductCore extends ObjectModel
|
||||
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 (p.`id_manufacturer`= m.`id_manufacturer`)
|
||||
'.Product::sqlStock('p', 0).'
|
||||
WHERE `id_product_1` = '.(int)$this->id.'
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))'.
|
||||
($active ? ' AND product_shop.`active` = 1' : '');
|
||||
WHERE `id_product_1` = '.(int)$this->id.
|
||||
($active ? ' AND product_shop.`active` = 1' : '').'
|
||||
GROUP BY product_shop.id_product';
|
||||
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
|
||||
return false;
|
||||
foreach ($result as &$row)
|
||||
@@ -4879,7 +4877,7 @@ class ProductCore extends ObjectModel
|
||||
$result[] = array_merge($attribute, $group[0]);
|
||||
}
|
||||
$values_not_custom = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT a.`id_attribute`, a.`id_attribute_group`, a.`id_attribute_group`, al.`name` as `attribute`, agl.`name` as `group`
|
||||
SELECT DISTINCT a.`id_attribute`, a.`id_attribute_group`, al.`name` as `attribute`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
|
||||
@@ -78,7 +78,7 @@ class ProductSaleCore
|
||||
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
|
||||
pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
|
||||
m.`name` AS manufacturer_name, p.`id_manufacturer` as id_manufacturer,
|
||||
image_shop.`id_image`, il.`legend`,
|
||||
MAX(image_shop.`id_image`) id_image, il.`legend`,
|
||||
ps.`quantity` AS sales, t.`rate`, pl.`meta_keywords`, pl.`meta_title`, pl.`meta_description`,
|
||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(),
|
||||
INTERVAL '.$interval.' DAY)) > 0 AS new
|
||||
@@ -105,7 +105,7 @@ class ProductSaleCore
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
GROUP BY product_shop.id_product
|
||||
ORDER BY `'.pSQL($order_by).'` '.pSQL($order_way).'
|
||||
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;
|
||||
|
||||
@@ -136,7 +136,7 @@ class ProductSaleCore
|
||||
$groups = FrontController::getCurrentCustomerGroups();
|
||||
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
|
||||
|
||||
$sql = 'SELECT p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, image_shop.`id_image`, il.`legend`,
|
||||
$sql = 'SELECT p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, MAX(image_shop.`id_image`) id_image, il.`legend`,
|
||||
ps.`quantity` AS sales, p.`ean13`, p.`upc`, cl.`link_rewrite` AS category
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product`
|
||||
@@ -158,7 +158,7 @@ class ProductSaleCore
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
GROUP BY product_shop.id_product
|
||||
ORDER BY sales DESC
|
||||
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;
|
||||
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
|
||||
|
||||
+5
-10
@@ -283,7 +283,7 @@ class SearchCore
|
||||
$alias = 'product_shop.';
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
|
||||
pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
|
||||
image_shop.`id_image`, il.`legend`, m.`name` manufacturer_name '.$score.', product_attribute_shop.`id_product_attribute`,
|
||||
MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name '.$score.', MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute,
|
||||
DATEDIFF(
|
||||
p.`date_add`,
|
||||
DATE_SUB(
|
||||
@@ -305,8 +305,7 @@ class SearchCore
|
||||
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.')
|
||||
WHERE p.`id_product` '.$product_pool.'
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
AND (pa.id_product_attribute IS NULL OR product_attribute_shop.id_shop='.(int)$context->shop->id.')
|
||||
GROUP BY product_shop.id_product
|
||||
'.($order_by ? 'ORDER BY '.$alias.$order_by : '').($order_way ? ' '.$order_way : '').'
|
||||
LIMIT '.(int)(($page_number - 1) * $page_size).','.(int)$page_size;
|
||||
$result = $db->executeS($sql);
|
||||
@@ -319,11 +318,7 @@ class SearchCore
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
|
||||
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.')
|
||||
WHERE p.`id_product` '.$product_pool.'
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))';
|
||||
WHERE p.`id_product` '.$product_pool;
|
||||
$total = $db->getValue($sql);
|
||||
|
||||
if (!$result)
|
||||
@@ -633,7 +628,7 @@ class SearchCore
|
||||
}
|
||||
|
||||
$sql = 'SELECT DISTINCT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description_short`, pl.`link_rewrite`, pl.`name`,
|
||||
image_shop.`id_image`, il.`legend`, m.`name` manufacturer_name, 1 position,
|
||||
MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name, 1 position,
|
||||
DATEDIFF(
|
||||
p.`date_add`,
|
||||
DATE_SUB(
|
||||
@@ -663,7 +658,7 @@ class SearchCore
|
||||
SELECT id_group FROM '._DB_PREFIX_.'customer_group
|
||||
WHERE id_customer = '.(int)$id_customer.')').'
|
||||
AND t.`name` LIKE \'%'.pSQL($tag).'%\'
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
GROUP BY product_shop.id_image
|
||||
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))
|
||||
|
||||
@@ -258,7 +258,7 @@ class SupplierCore extends ObjectModel
|
||||
pl.`meta_keywords`,
|
||||
pl.`meta_title`,
|
||||
pl.`name`,
|
||||
image_shop.`id_image`,
|
||||
MAX(image_shop.`id_image`) id_image,
|
||||
il.`legend`,
|
||||
s.`name` AS supplier_name,
|
||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.($nb_days_new_product).' DAY)) > 0 AS new,
|
||||
@@ -286,7 +286,7 @@ class SupplierCore extends ObjectModel
|
||||
($active_category ? ' INNER JOIN `'._DB_PREFIX_.'category` ca ON cp.`id_category` = ca.`id_category` AND ca.`active` = 1' : '').'
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
|
||||
GROUP BY product_shop.id_product
|
||||
ORDER BY '.$alias.pSQL($order_by).' '.pSQL($order_way).'
|
||||
LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;
|
||||
|
||||
|
||||
@@ -1956,6 +1956,13 @@ exit;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSafeModeStatus()
|
||||
{
|
||||
if (!$safe_mode = @ini_get('safe_mode'))
|
||||
$safe_mode = '';
|
||||
return in_array(Tools::strtolower($safe_mode), array(1, 'on'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc extract a zip file to the given directory
|
||||
* @return bool success
|
||||
@@ -2332,6 +2339,92 @@ exit;
|
||||
return $pattern;
|
||||
return preg_replace('/\\\[px]\{[a-z]\}{1,2}|(\/[a-z]*)u([a-z]*)$/i', "$1$2", $pattern);
|
||||
}
|
||||
|
||||
public static function addonsRequest($request, $params = array())
|
||||
{
|
||||
$addons_url = 'api.addons.prestashop.com';
|
||||
$postData = '';
|
||||
$postDataArray = array(
|
||||
'version' => _PS_VERSION_,
|
||||
'iso_lang' => strtolower(Context::getContext()->language->iso_code),
|
||||
'iso_code' => strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
|
||||
'shop_url' => urlencode(Tools::getShopDomain()),
|
||||
'mail' => urlencode(Configuration::get('PS_SHOP_EMAIL'))
|
||||
);
|
||||
foreach ($postDataArray as $postDataKey => $postDataValue)
|
||||
$postData .= '&'.$postDataKey.'='.$postDataValue;
|
||||
$postData = ltrim($postData, '&');
|
||||
|
||||
// Config for each request
|
||||
if ($request == 'native')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData .= '&method=listing&action=native';
|
||||
}
|
||||
if ($request == 'must-have')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData .= '&method=listing&action=must-have';
|
||||
}
|
||||
if ($request == 'customer')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443);
|
||||
$postData .= '&method=listing&action=customer&username='.urlencode(trim(Context::getContext()->cookie->username_addons)).'&password='.urlencode(trim(Context::getContext()->cookie->password_addons));
|
||||
}
|
||||
if ($request == 'check_customer')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443);
|
||||
$postData .= '&method=check_customer&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
|
||||
}
|
||||
if ($request == 'module')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
if (isset($params['username_addons']) && isset($params['password_addons']))
|
||||
{
|
||||
$protocolsList = array('https://' => 443);
|
||||
$postData .= '&method=module&id_module='.urlencode($params['id_module']).'&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData .= '&method=module&id_module='.urlencode($params['id_module']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($request == 'install-modules')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData .= '&method=listing&action=install-modules';
|
||||
|
||||
}
|
||||
|
||||
// Make the request
|
||||
$opts = array(
|
||||
'http'=>array(
|
||||
'method'=> 'POST',
|
||||
'content' => $postData,
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'timeout' => 5,
|
||||
)
|
||||
);
|
||||
$context = stream_context_create($opts);
|
||||
foreach ($protocolsList as $protocol => $port)
|
||||
{
|
||||
$content = Tools::file_get_contents($protocol.$addons_url, false, $context);
|
||||
|
||||
// If content returned, we cache it
|
||||
if ($content)
|
||||
return $content;
|
||||
}
|
||||
|
||||
// No content, return false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,8 @@ class TranslateCore
|
||||
$iso = Context::getContext()->language->iso_code;
|
||||
if (empty($iso))
|
||||
$iso = Language::getIsoById((int)(Configuration::get('PS_LANG_DEFAULT')));
|
||||
include_once(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
|
||||
if (file_exists(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'))
|
||||
include_once(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
|
||||
}
|
||||
|
||||
if (isset($modules_tabs[strtolower($class)]))
|
||||
|
||||
@@ -34,8 +34,6 @@ class AdminControllerCore extends Controller
|
||||
public $confirmations = array();
|
||||
public $shopShareDatas = false;
|
||||
|
||||
protected $addons_url = 'api.addons.prestashop.com';
|
||||
|
||||
public $_languages = array();
|
||||
public $default_form_language;
|
||||
public $allow_employee_form_lang;
|
||||
@@ -583,7 +581,7 @@ class AdminControllerCore extends Controller
|
||||
|
||||
$headers = array();
|
||||
foreach ($this->fields_list as $datas)
|
||||
$headers[] = $datas['title'];
|
||||
$headers[] = Tools::htmlentitiesDecodeUTF8($datas['title']);
|
||||
|
||||
$content = array();
|
||||
foreach ($this->_list as $i => $row)
|
||||
@@ -591,7 +589,7 @@ class AdminControllerCore extends Controller
|
||||
$content[$i] = array();
|
||||
foreach ($this->fields_list as $key => $value)
|
||||
if (isset($row[$key]))
|
||||
$content[$i][] = $row[$key];
|
||||
$content[$i][] = Tools::htmlentitiesDecodeUTF8($row[$key]);
|
||||
|
||||
}
|
||||
$this->context->smarty->assign(array(
|
||||
@@ -1514,6 +1512,7 @@ class AdminControllerCore extends Controller
|
||||
|
||||
public function renderModulesList()
|
||||
{
|
||||
|
||||
if ($this->getModulesList($this->filter_modules_list))
|
||||
{
|
||||
$helper = new Helper();
|
||||
@@ -2214,7 +2213,18 @@ class AdminControllerCore extends Controller
|
||||
$this->modules_list = array();
|
||||
foreach($all_modules as $module)
|
||||
{
|
||||
if (in_array($module->name, $filter_modules_list))
|
||||
$perm = true;
|
||||
if ($module->id)
|
||||
$perm &= Module::getPermissionStatic($module->id, 'configure');
|
||||
else
|
||||
{
|
||||
$id_admin_module = Tab::getIdFromClassName('AdminModules');
|
||||
$access = Profile::getProfileAccess($this->context->employee->id_profile, $id_admin_module);
|
||||
if (!$access['edit'])
|
||||
$perm &= false;
|
||||
}
|
||||
|
||||
if (in_array($module->name, $filter_modules_list) && $perm)
|
||||
{
|
||||
$this->fillModuleData($module, 'select');
|
||||
$this->modules_list[] = $module;
|
||||
@@ -2853,83 +2863,6 @@ class AdminControllerCore extends Controller
|
||||
return (bool)file_put_contents(_PS_ROOT_DIR_.$file_to_refresh, $content);
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addonsRequest($request, $params = array())
|
||||
{
|
||||
$postData = '';
|
||||
$postDataArray = array(
|
||||
'version' => _PS_VERSION_,
|
||||
'iso_lang' => strtolower(Context::getContext()->language->iso_code),
|
||||
'iso_code' => strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
|
||||
'shop_url' => urlencode(Tools::getShopDomain()),
|
||||
'mail' => urlencode(Configuration::get('PS_SHOP_EMAIL'))
|
||||
);
|
||||
foreach ($postDataArray as $postDataKey => $postDataValue)
|
||||
$postData .= '&'.$postDataKey.'='.$postDataValue;
|
||||
$postData = ltrim($postData, '&');
|
||||
|
||||
// Config for each request
|
||||
if ($request == 'native')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData .= '&method=listing&action=native';
|
||||
}
|
||||
if ($request == 'must-have')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData .= '&method=listing&action=must-have';
|
||||
}
|
||||
if ($request == 'customer')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443);
|
||||
$postData .= '&method=listing&action=customer&username='.urlencode(trim($this->context->cookie->username_addons)).'&password='.urlencode(trim($this->context->cookie->password_addons));
|
||||
}
|
||||
if ($request == 'check_customer')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443);
|
||||
$postData .= '&method=check_customer&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
|
||||
}
|
||||
if ($request == 'module')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
if (isset($params['username_addons']) && isset($params['password_addons']))
|
||||
{
|
||||
$protocolsList = array('https://' => 443);
|
||||
$postData .= '&method=module&id_module='.urlencode($params['id_module']).'&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData .= '&method=module&id_module='.urlencode($params['id_module']);
|
||||
}
|
||||
}
|
||||
|
||||
// Make the request
|
||||
$opts = array(
|
||||
'http'=>array(
|
||||
'method'=> 'POST',
|
||||
'content' => $postData,
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'timeout' => 5,
|
||||
)
|
||||
);
|
||||
$context = stream_context_create($opts);
|
||||
foreach ($protocolsList as $protocol => $port)
|
||||
{
|
||||
$content = Tools::file_get_contents($protocol.$this->addons_url, false, $context);
|
||||
|
||||
// If content returned, we cache it
|
||||
if ($content)
|
||||
return $content;
|
||||
}
|
||||
|
||||
// No content, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
public function fillModuleData(&$module, $output_type = 'link', $back = null)
|
||||
{
|
||||
@@ -2943,9 +2876,11 @@ class AdminControllerCore extends Controller
|
||||
if (file_exists('../modules/'.$module->name.'/logo.png'))
|
||||
$module->logo = 'logo.png';
|
||||
$module->optionsHtml = $this->displayModuleOptions($module, $output_type);
|
||||
$module->options['install_url'] = self::$currentIndex.'&install='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
||||
$module->options['update_url'] = self::$currentIndex.'&update='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
||||
$module->options['uninstall_url'] = self::$currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
||||
$link_admin_modules = $this->context->link->getAdminLink('AdminModules', true);
|
||||
|
||||
$module->options['install_url'] = $link_admin_modules.'&install='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
||||
$module->options['update_url'] = $link_admin_modules.'&update='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
||||
$module->options['uninstall_url'] = $link_admin_modules.'&uninstall='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
||||
|
||||
$module->options['uninstall_onclick'] = ((!$module->onclick_option) ?
|
||||
((empty($module->confirmUninstall)) ? '' : 'return confirm(\''.addslashes($module->confirmUninstall).'\');') :
|
||||
@@ -2983,60 +2918,60 @@ class AdminControllerCore extends Controller
|
||||
$this->translationsTab['Uninstall'] = $this->l('Uninstall');
|
||||
$this->translationsTab['This action will permanently remove the module from the server. Are you sure you want to do this?'] = $this->l('This action will permanently remove the module from the server. Are you sure you want to do this?');
|
||||
}
|
||||
|
||||
$link_admin_modules = $this->context->link->getAdminLink('AdminModules', true);
|
||||
$modules_options = array(
|
||||
'configure-module' => array(
|
||||
'href' => self::$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name),
|
||||
'href' => $link_admin_modules.'&configure='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.urlencode($module->name),
|
||||
'onclick' => $module->onclick_option && isset($module->onclick_option_content['configure']) ? $module->onclick_option_content['configure'] : '',
|
||||
'title' => '',
|
||||
'text' => $this->translationsTab['Configure'],
|
||||
'cond' => $module->id && isset($module->is_configurable) && $module->is_configurable,
|
||||
),
|
||||
'desactive-module' => array(
|
||||
'href' => self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&'.($module->active ? 'enable=0' : 'enable=1').'&tab_module='.$module->tab,
|
||||
'href' => $link_admin_modules.'&module_name='.urlencode($module->name).'&'.($module->active ? 'enable=0' : 'enable=1').'&tab_module='.$module->tab,
|
||||
'onclick' => $module->active && $module->onclick_option && isset($module->onclick_option_content['desactive']) ? $module->onclick_option_content['desactive'] : '' ,
|
||||
'title' => Shop::isFeatureActive() ? htmlspecialchars($module->active ? $this->translationsTab['Disable this module'] : $this->translationsTab['Enable this module for all shops']) : '',
|
||||
'text' => $module->active ? $this->translationsTab['Disable'] : $this->translationsTab['Enable'],
|
||||
'cond' => $module->id,
|
||||
),
|
||||
'reset-module' => array(
|
||||
'href' => self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&reset&tab_module='.$module->tab,
|
||||
'href' => $link_admin_modules.'&module_name='.urlencode($module->name).'&reset&tab_module='.$module->tab,
|
||||
'onclick' => $module->onclick_option && isset($module->onclick_option_content['reset']) ? $module->onclick_option_content['reset'] : '',
|
||||
'title' => '',
|
||||
'text' => $this->translationsTab['Reset'],
|
||||
'cond' => $module->id && $module->active,
|
||||
),
|
||||
'delete-module' => array(
|
||||
'href' => self::$currentIndex.'&delete='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name),
|
||||
'href' => $link_admin_modules.'&delete='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.urlencode($module->name),
|
||||
'onclick' => $module->onclick_option && isset($module->onclick_option_content['delete']) ? $module->onclick_option_content['delete'] : 'return confirm(\''.$this->translationsTab['This action will permanently remove the module from the server. Are you sure you want to do this?'].'\');',
|
||||
'title' => '',
|
||||
'text' => $this->translationsTab['Delete'],
|
||||
'cond' => true,
|
||||
),
|
||||
);
|
||||
$return = '';
|
||||
foreach($modules_options as $option_name => $option)
|
||||
{
|
||||
if ($option['cond'])
|
||||
{
|
||||
if ($output_type == 'link')
|
||||
$return .= '<span class="'.$option_name.'">
|
||||
<a class="action_module" href="'.$option['href'].(!is_null($back) ? '&back='.urlencode($back) : '').'" onclick="'.$option['onclick'].'" title="'.$option['title'].'">'.$option['text'].'</a>
|
||||
</span>';
|
||||
else if ($output_type == 'select')
|
||||
$return .= '<option id="'.$option_name.'" data-href="'.$option['href'].(!is_null($back) ? '&back='.urlencode($back) : '').'" data-onclick="'.$option['onclick'].'">'.$option['text'].'</option>';
|
||||
}
|
||||
}
|
||||
if ($output_type == 'select')
|
||||
{
|
||||
if (!$module->id)
|
||||
$return = '<option data-onclick="" data-href="'.self::$currentIndex.'&install='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(!is_null($back) ? '&back='.urlencode($back) : '').'" >'.$this->translationsTab['Install'].'</option>'.$return;
|
||||
else
|
||||
$return = '<option data-onclick="" data-href="'.self::$currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(!is_null($back) ? '&back='.urlencode($back) : '').'" >'.$this->translationsTab['Uninstall'].'</option>'.$return;
|
||||
$return = '<select id="select_'.$module->name.'">'.$return.'</select>';
|
||||
);
|
||||
|
||||
$return = '';
|
||||
foreach ($modules_options as $option_name => $option)
|
||||
{
|
||||
if ($option['cond'])
|
||||
{
|
||||
if ($output_type == 'link')
|
||||
$return .= '<span class="'.$option_name.'">
|
||||
<a class="action_module" href="'.$option['href'].(!is_null($back) ? '&back='.urlencode($back) : '').'" onclick="'.$option['onclick'].'" title="'.$option['title'].'">'.$option['text'].'</a>
|
||||
</span>';
|
||||
elseif ($output_type == 'select')
|
||||
$return .= '<option id="'.$option_name.'" data-href="'.$option['href'].(!is_null($back) ? '&back='.urlencode($back) : '').'" data-onclick="'.$option['onclick'].'">'.$option['text'].'</option>';
|
||||
}
|
||||
|
||||
}
|
||||
if ($output_type == 'select')
|
||||
{
|
||||
if (!$module->id)
|
||||
$return = '<option data-onclick="" data-href="'.$link_admin_modules.'&install='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(!is_null($back) ? '&back='.urlencode($back) : '').'" >'.$this->translationsTab['Install'].'</option>'.$return;
|
||||
else
|
||||
$return .= '<option data-onclick="" data-href="'.$link_admin_modules.'&uninstall='.urlencode($module->name).'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(!is_null($back) ? '&back='.urlencode($back) : '').'" >'.$this->translationsTab['Uninstall'].'</option>';
|
||||
$return = '<select id="select_'.$module->name.'">'.$return.'</select>';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -178,8 +178,6 @@ abstract class ModuleCore
|
||||
}
|
||||
$this->local_path = _PS_MODULE_DIR_.$this->name.'/';
|
||||
}
|
||||
|
||||
$this->database_version = $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,6 +185,7 @@ abstract class ModuleCore
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
Hook::exec('actionModuleInstallBefore', array('object' => $this));
|
||||
// Check module name validation
|
||||
if (!Validate::isModuleName($this->name))
|
||||
{
|
||||
@@ -265,7 +264,7 @@ abstract class ModuleCore
|
||||
|
||||
// Adding Restrictions for client groups
|
||||
Group::addRestrictionsForModule($this->id, Shop::getShops(true, null, true));
|
||||
|
||||
Hook::exec('actionModuleInstallAfter', array('object' => $this));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1510,11 +1510,12 @@ class OrderCore extends ObjectModel
|
||||
|
||||
/**
|
||||
* @return array return all shipping method for the current order
|
||||
* state_name sql var is now deprecated - use order_state_name for the state name and carrier_name for the carrier_name
|
||||
*/
|
||||
public function getShipping()
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT DISTINCT oc.`id_order_invoice`, oc.`weight`, oc.`shipping_cost_tax_excl`, oc.`shipping_cost_tax_incl`, c.`url`, oc.`id_carrier`, c.`name` as `state_name`, oc.`date_add`, "Delivery" as `type`, "true" as `can_edit`, oc.`tracking_number`, oc.`id_order_carrier`
|
||||
SELECT DISTINCT oc.`id_order_invoice`, oc.`weight`, oc.`shipping_cost_tax_excl`, oc.`shipping_cost_tax_incl`, c.`url`, oc.`id_carrier`, c.`name` as `carrier_name`, oc.`date_add`, "Delivery" as `type`, "true" as `can_edit`, oc.`tracking_number`, oc.`id_order_carrier`, osl.`name` as order_state_name, c.`name` as state_name
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_history` oh
|
||||
ON (o.`id_order` = oh.`id_order`)
|
||||
@@ -1524,7 +1525,8 @@ class OrderCore extends ObjectModel
|
||||
ON (oc.`id_carrier` = c.`id_carrier`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl
|
||||
ON (oh.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE oc.`id_order` = '.(int)$this->id);
|
||||
WHERE o.`id_order` = '.(int)$this->id.'
|
||||
GROUP BY c.id_carrier');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -249,7 +249,17 @@ class OrderDetailCore extends ObjectModel
|
||||
$context = Context::getContext();
|
||||
$this->context = $context->cloneContext();
|
||||
}
|
||||
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if(!$res = parent::delete())
|
||||
return false;
|
||||
|
||||
Db::getInstance()->delete('order_detail_tax', 'id_order_detail='.(int)$this->id);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
protected function setContext($id_shop)
|
||||
{
|
||||
if ($this->context->shop->id != $id_shop)
|
||||
|
||||
@@ -39,7 +39,36 @@ class PDFGeneratorCore extends TCPDF
|
||||
public $content;
|
||||
public $font;
|
||||
|
||||
public $font_by_lang = array('ja' => 'cid0jp', 'bg' => 'freeserif', 'ru' => 'freeserif', 'el' => 'freeserif', 'vn' => 'dejavusans', 'pl' => 'dejavusans');
|
||||
public $font_by_lang = array(
|
||||
'ja' => 'cid0jp',
|
||||
'bg' => 'freeserif',
|
||||
'ru' => 'freeserif',
|
||||
'uk' => 'freeserif',
|
||||
'mk' => 'freeserif',
|
||||
'el' => 'freeserif',
|
||||
'vn' => 'dejavusans',
|
||||
'pl' => 'dejavusans',
|
||||
'ar' => 'dejavusans',
|
||||
'fa' => 'dejavusans',
|
||||
'ur' => 'dejavusans',
|
||||
'az' => 'dejavusans',
|
||||
'ca' => 'dejavusans',
|
||||
'gl' => 'dejavusans',
|
||||
'hr' => 'dejavusans',
|
||||
'sr' => 'dejavusans',
|
||||
'si' => 'dejavusans',
|
||||
'cs' => 'dejavusans',
|
||||
'sk' => 'dejavusans',
|
||||
'ka' => 'dejavusans',
|
||||
'he' => 'dejavusans',
|
||||
'lo' => 'dejavusans',
|
||||
'lv' => 'dejavusans',
|
||||
'tr' => 'dejavusans',
|
||||
'ko' => 'cid0kr',
|
||||
'zh' => 'cid0cs',
|
||||
'tw' => 'cid0cs',
|
||||
'th' => 'freeserif'
|
||||
);
|
||||
|
||||
|
||||
public function __construct($use_cache = false)
|
||||
|
||||
@@ -228,6 +228,7 @@ class WebserviceRequestCore
|
||||
'categories' => array('description' => 'The product categories','class' => 'Category'),
|
||||
'combinations' => array('description' => 'The product combinations','class' => 'Combination'),
|
||||
'configurations' => array('description' => 'Shop configuration', 'class' => 'Configuration'),
|
||||
'contacts' => array('description' => 'Shop contacts','class' => 'Contact'),
|
||||
'countries' => array('description' => 'The countries','class' => 'Country'),
|
||||
'currencies' => array('description' => 'The currencies', 'class' => 'Currency'),
|
||||
'customers' => array('description' => 'The e-shop\'s customers','class' => 'Customer'),
|
||||
|
||||
Reference in New Issue
Block a user