// Replace shop->addSqlRestriction() and shop->addSqlRestrictionOnLang() by static versions
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13618 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1306,7 +1306,7 @@ abstract class AdminTabCore
|
||||
$selectShop = ', shop.name as shop_name ';
|
||||
$joinShop = ' LEFT JOIN '._DB_PREFIX_.$this->shopLinkType.' shop
|
||||
ON a.id_'.$this->shopLinkType.' = shop.id_'.$this->shopLinkType;
|
||||
$whereShop = $this->context->shop->addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
|
||||
$whereShop = Shop::addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
|
||||
}
|
||||
|
||||
$assos = Shop::getAssoTables();
|
||||
|
||||
@@ -157,7 +157,7 @@ class AttachmentCore extends ObjectModel
|
||||
$ids_attachements[] = $attachement['id_attachment'];
|
||||
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'product_attachment` pa
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pa.`id_product` = pl.`id_product`'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pa.`id_product` = pl.`id_product`'.Shop::addSqlRestrictionOnLang('pl').')
|
||||
WHERE `id_attachment` IN ('.implode(',', array_map('intval', $ids_attachements)).')
|
||||
AND pl.`id_lang` = '.(int)$id_lang;
|
||||
$tmp = Db::getInstance()->executeS($sql);
|
||||
|
||||
+1
-1
@@ -410,7 +410,7 @@ class CarrierCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT c.*, cl.delay
|
||||
FROM `'._DB_PREFIX_.'carrier` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'carrier_lang` cl ON (c.`id_carrier` = cl.`id_carrier` AND cl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'carrier_lang` cl ON (c.`id_carrier` = cl.`id_carrier` AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'carrier_zone` cz ON (cz.`id_carrier` = c.`id_carrier`)'.
|
||||
($id_zone ? 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = '.(int)$id_zone.')' : '').'
|
||||
WHERE c.`deleted` = '.($delete ? '1' : '0').
|
||||
|
||||
+3
-3
@@ -390,7 +390,7 @@ class CartCore extends ObjectModel
|
||||
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
|
||||
$sql->leftJoin('product_lang', 'pl', '
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$this->id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl')
|
||||
AND pl.`id_lang` = '.(int)$this->id_lang.Shop::addSqlRestrictionOnLang('pl')
|
||||
);
|
||||
$sql->leftJoin('product_tax_rules_group_shop', 'ptrgs',
|
||||
'p.`id_product` = ptrgs.`id_product` AND cp.`id_shop` = ptrgs.`id_shop`');
|
||||
@@ -408,7 +408,7 @@ class CartCore extends ObjectModel
|
||||
);
|
||||
$sql->leftJoin('category_lang', 'cl', '
|
||||
p.`id_category_default` = cl.`id_category`
|
||||
AND cl.`id_lang` = '.(int)$this->id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl')
|
||||
AND cl.`id_lang` = '.(int)$this->id_lang.Shop::addSqlRestrictionOnLang('cl')
|
||||
);
|
||||
|
||||
// @todo test if everything is ok, then refactorise call of this method
|
||||
@@ -2531,7 +2531,7 @@ class CartCore extends ObjectModel
|
||||
LEFT JOIN '._DB_PREFIX_.'orders o ON (c.`id_cart` = o.`id_cart`)
|
||||
WHERE c.`id_customer` = '.(int)$id_customer.'
|
||||
AND o.`id_cart` IS NULL
|
||||
'.Context::getContext()->shop->addSqlRestriction(Shop::SHARE_ORDER, 'c').'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'c').'
|
||||
ORDER BY c.`date_upd` DESC';
|
||||
|
||||
if (!$id_cart = Db::getInstance()->getValue($sql))
|
||||
|
||||
+15
-18
@@ -493,7 +493,7 @@ class CategoryCore extends ObjectModel
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').'
|
||||
WHERE 1 '.$sql_filter.' '.($id_lang ? 'AND `id_lang` = '.(int)$id_lang : '').'
|
||||
'.($active ? 'AND `active` = 1' : '').'
|
||||
'.(!$id_lang ? 'GROUP BY c.id_category' : '').'
|
||||
@@ -516,7 +516,7 @@ class CategoryCore extends ObjectModel
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT c.`id_category`, cl.`name`
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
||||
GROUP BY c.id_category
|
||||
ORDER BY c.`position`');
|
||||
@@ -542,7 +542,7 @@ class CategoryCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON (c.`id_category` = cl.`id_category`
|
||||
AND `id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_group` cg
|
||||
ON (cg.`id_category` = c.`id_category`)
|
||||
WHERE `id_parent` = '.(int)$this->id.'
|
||||
@@ -639,10 +639,10 @@ class CategoryCore extends ObjectModel
|
||||
'.Product::sqlStock('p', 'pa', false, $context->shop).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON (p.`id_category_default` = cl.`id_category`
|
||||
AND cl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').')
|
||||
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON (p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').')
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i
|
||||
ON (i.`id_product` = p.`id_product`
|
||||
AND i.`cover` = 1)
|
||||
@@ -733,13 +733,11 @@ class CategoryCore extends ObjectModel
|
||||
if (!Validate::isBool($active))
|
||||
die(Tools::displayError());
|
||||
|
||||
$id = Context::getContext()->shop->id;
|
||||
$id_shop = $id ? $id: Configuration::get('PS_SHOP_DEFAULT');
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
'.Context::getContext()->shop->addSqlAssociation('category', 'c').'
|
||||
WHERE `id_lang` = '.(int)$id_lang.'
|
||||
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
||||
AND c.`id_parent` = '.(int)$id_parent.'
|
||||
@@ -777,8 +775,7 @@ class CategoryCore extends ObjectModel
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$id = $shop->id;
|
||||
$id_shop = $id ? $id: Configuration::get('PS_SHOP_DEFAULT');
|
||||
$id_shop = Configuration::get('PS_SHOP_DEFAULT');
|
||||
$selected_cat = explode(',', str_replace(' ', '', $selected_cat));
|
||||
$sql = 'SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF((
|
||||
SELECT COUNT(*)
|
||||
@@ -792,7 +789,7 @@ class CategoryCore extends ObjectModel
|
||||
AND c3.`id_category` IN ('.implode(',', array_map('intval', $selected_cat)).')
|
||||
)' : '0').' AS nbSelectedSubCat
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.$shop->addSqlRestrictionOnLang('cl');
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl');
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP && $use_shop_context)
|
||||
$sql .= '
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')';
|
||||
@@ -872,7 +869,7 @@ class CategoryCore extends ObjectModel
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').'
|
||||
WHERE `id_lang` = '.(int)$id_lang.'
|
||||
AND c.`id_category` = '.(int)$id_category);
|
||||
self::$_links[$id_category.'-'.$id_lang] = $result['link_rewrite'];
|
||||
@@ -913,7 +910,7 @@ class CategoryCore extends ObjectModel
|
||||
SELECT c.*, cl.*
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
WHERE `name` LIKE \''.pSQL($query).'\'
|
||||
');
|
||||
else
|
||||
@@ -922,7 +919,7 @@ class CategoryCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON (c.`id_category` = cl.`id_category`
|
||||
AND `id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
||||
WHERE `name` LIKE \'%'.pSQL($query).'%\'
|
||||
AND c.`id_category` != 1
|
||||
');
|
||||
@@ -943,7 +940,7 @@ class CategoryCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON (c.`id_category` = cl.`id_category`
|
||||
AND `id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
||||
WHERE `name` LIKE \''.pSQL($category_name).'\'
|
||||
AND c.`id_category` != 1
|
||||
AND c.`id_parent` = '.(int)$id_parent_category
|
||||
@@ -976,7 +973,7 @@ class CategoryCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
|
||||
ON (c.`id_category` = cl.`id_category`
|
||||
AND `id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').')';
|
||||
AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')';
|
||||
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP)
|
||||
$sql .= '
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs
|
||||
@@ -1327,7 +1324,7 @@ class CategoryCore extends ObjectModel
|
||||
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, cl.`id_lang`
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
||||
AND c.`id_category` IN ('.implode(',', array_map('intval', $ids_category)).')
|
||||
');
|
||||
|
||||
@@ -105,11 +105,8 @@ class ConnectionCore extends ObjectModel
|
||||
'time_start' => $time_start);
|
||||
}
|
||||
|
||||
public static function setNewConnection($cookie, Shop $shop = null)
|
||||
public static function setNewConnection($cookie)
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
if (isset($_SERVER['HTTP_USER_AGENT'])
|
||||
&& preg_match('/BotLink|ahoy|AlkalineBOT|anthill|appie|arale|araneo|AraybOt|ariadne|arks|ATN_Worldwide|Atomz|bbot|Bjaaland|Ukonline|borg\-bot\/0\.9|boxseabot|bspider|calif|christcrawler|CMC\/0\.01|combine|confuzzledbot|CoolBot|cosmos|Internet Cruiser Robot|cusco|cyberspyder|cydralspider|desertrealm, desert realm|digger|DIIbot|grabber|downloadexpress|DragonBot|dwcp|ecollector|ebiness|elfinbot|esculapio|esther|fastcrawler|FDSE|FELIX IDE|ESI|fido|H�m�h�kki|KIT\-Fireball|fouineur|Freecrawl|gammaSpider|gazz|gcreep|golem|googlebot|griffon|Gromit|gulliver|gulper|hambot|havIndex|hotwired|htdig|iajabot|INGRID\/0\.1|Informant|InfoSpiders|inspectorwww|irobot|Iron33|JBot|jcrawler|Teoma|Jeeves|jobo|image\.kapsi\.net|KDD\-Explorer|ko_yappo_robot|label\-grabber|larbin|legs|Linkidator|linkwalker|Lockon|logo_gif_crawler|marvin|mattie|mediafox|MerzScope|NEC\-MeshExplorer|MindCrawler|udmsearch|moget|Motor|msnbot|muncher|muninn|MuscatFerret|MwdSearch|sharp\-info\-agent|WebMechanic|NetScoop|newscan\-online|ObjectsSearch|Occam|Orbsearch\/1\.0|packrat|pageboy|ParaSite|patric|pegasus|perlcrawler|phpdig|piltdownman|Pimptrain|pjspider|PlumtreeWebAccessor|PortalBSpider|psbot|Getterrobo\-Plus|Raven|RHCS|RixBot|roadrunner|Robbie|robi|RoboCrawl|robofox|Scooter|Search\-AU|searchprocess|Senrigan|Shagseeker|sift|SimBot|Site Valet|skymob|SLCrawler\/2\.0|slurp|ESI|snooper|solbot|speedy|spider_monkey|SpiderBot\/1\.0|spiderline|nil|suke|http:\/\/www\.sygol\.com|tach_bw|TechBOT|templeton|titin|topiclink|UdmSearch|urlck|Valkyrie libwww\-perl|verticrawl|Victoria|void\-bot|Voyager|VWbot_K|crawlpaper|wapspider|WebBandit\/1\.0|webcatcher|T\-H\-U\-N\-D\-E\-R\-S\-T\-O\-N\-E|WebMoose|webquest|webreaper|webs|webspider|WebWalker|wget|winona|whowhere|wlm|WOLP|WWWC|none|XGET|Nederland\.zoek/i', $_SERVER['HTTP_USER_AGENT']))
|
||||
{
|
||||
@@ -117,7 +114,7 @@ class ConnectionCore extends ObjectModel
|
||||
$sql = 'SELECT `id_connections` FROM `'._DB_PREFIX_.'connections`
|
||||
WHERE ip_address = '.ip2long(Tools::getRemoteAddr()).'
|
||||
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
|
||||
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
ORDER BY `date_add` DESC';
|
||||
if ($id_connections = Db::getInstance()->getValue($sql))
|
||||
{
|
||||
@@ -131,7 +128,7 @@ class ConnectionCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'connections`
|
||||
WHERE `id_guest` = '.(int)$cookie->id_guest.'
|
||||
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
|
||||
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
ORDER BY `date_add` DESC';
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
if (!$result['id_guest'] && (int)$cookie->id_guest)
|
||||
|
||||
+8
-20
@@ -240,14 +240,11 @@ class CustomerCore extends ObjectModel
|
||||
*
|
||||
* @return array Customers
|
||||
*/
|
||||
public static function getCustomers(Shop $shop = null)
|
||||
public static function getCustomers()
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE 1 '.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
WHERE 1 '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
ORDER BY `id_customer` ASC';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
}
|
||||
@@ -259,19 +256,16 @@ class CustomerCore extends ObjectModel
|
||||
* @param string $passwd Password is also checked if specified
|
||||
* @return Customer instance
|
||||
*/
|
||||
public function getByEmail($email, $passwd = null, Shop $shop = null)
|
||||
public function getByEmail($email, $passwd = null)
|
||||
{
|
||||
if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd)))
|
||||
die (Tools::displayError());
|
||||
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE `active` = 1
|
||||
AND `email` = \''.pSQL($email).'\'
|
||||
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
'.(isset($passwd) ? 'AND `passwd` = \''.Tools::encrypt($passwd).'\'' : '').'
|
||||
AND `deleted` = 0
|
||||
AND `is_guest` = 0';
|
||||
@@ -315,18 +309,15 @@ class CustomerCore extends ObjectModel
|
||||
* @param $ignore_guest boolean, to exclude guest customer
|
||||
* @return Customer ID if found, false otherwise
|
||||
*/
|
||||
public static function customerExists($email, $return_id = false, $ignore_guest = true, Shop $shop = null)
|
||||
public static function customerExists($email, $return_id = false, $ignore_guest = true)
|
||||
{
|
||||
if (!Validate::isEmail($email))
|
||||
die (Tools::displayError());
|
||||
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$sql = 'SELECT `id_customer`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE `email` = \''.pSQL($email).'\'
|
||||
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).
|
||||
($ignore_guest ? ' AND `is_guest` = 0' : '');
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
@@ -419,11 +410,8 @@ class CustomerCore extends ObjectModel
|
||||
* @param string $query Searched string
|
||||
* @return array Corresponding customers
|
||||
*/
|
||||
public static function searchByName($query, Shop $shop = null)
|
||||
public static function searchByName($query)
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE (
|
||||
@@ -431,7 +419,7 @@ class CustomerCore extends ObjectModel
|
||||
OR `id_customer` LIKE \'%'.pSQL($query).'%\'
|
||||
OR `lastname` LIKE \'%'.pSQL($query).'%\'
|
||||
OR `firstname` LIKE \'%'.pSQL($query).'%\'
|
||||
)'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER);
|
||||
)'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER);
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
}
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ class DispatcherCore
|
||||
// Load routes from meta table
|
||||
$sql = 'SELECT m.page, ml.url_rewrite
|
||||
FROM `'._DB_PREFIX_.'meta` m
|
||||
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.$context->shop->addSqlRestrictionOnLang('ml').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml').')
|
||||
WHERE id_lang = '.(int)$context->language->id.'
|
||||
ORDER BY LENGTH(ml.url_rewrite) DESC';
|
||||
if ($results = Db::getInstance()->executeS($sql))
|
||||
|
||||
@@ -122,7 +122,7 @@ class GroupReductionCore extends ObjectModel
|
||||
|
||||
public static function getGroupReductions($id_group, $id_lang)
|
||||
{
|
||||
$lang = $id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl');
|
||||
$lang = $id_lang.Shop::addSqlRestrictionOnLang('cl');
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT gr.`id_group_reduction`, gr.`id_group`, gr.`id_category`, gr.`reduction`, cl.`name` AS category_name
|
||||
FROM `'._DB_PREFIX_.'group_reduction` gr
|
||||
|
||||
@@ -331,7 +331,7 @@ class ManufacturerCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (p.`id_product` = pa.`id_product` AND default_on = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('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` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il
|
||||
@@ -380,7 +380,7 @@ class ManufacturerCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
WHERE p.`id_manufacturer` = '.(int)$this->id;
|
||||
|
||||
|
||||
+3
-6
@@ -93,16 +93,13 @@ class MetaCore extends ObjectModel
|
||||
ORDER BY page ASC');
|
||||
}
|
||||
|
||||
public static function getMetasByIdLang($id_lang, Shop $shop = null)
|
||||
public static function getMetasByIdLang($id_lang)
|
||||
{
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'meta` m
|
||||
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON m.`id_meta` = ml.`id_meta`
|
||||
WHERE ml.`id_lang` = '.(int)$id_lang
|
||||
.$shop->addSqlRestrictionOnLang('ml').
|
||||
.Shop::addSqlRestrictionOnLang('ml').
|
||||
'ORDER BY page ASC';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
@@ -118,7 +115,7 @@ class MetaCore extends ObjectModel
|
||||
LEFT JOIN '._DB_PREFIX_.'meta_lang ml on (m.id_meta = ml.id_meta)
|
||||
WHERE m.page = \''.pSQL($page).'\'
|
||||
AND ml.id_lang = '.(int)$id_lang
|
||||
.$context->shop->addSqlRestrictionOnLang('ml');
|
||||
.Shop::addSqlRestrictionOnLang('ml');
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,14 +170,6 @@ abstract class ModuleCore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SQL modules restriction by shop
|
||||
*/
|
||||
protected function sqlShopRestriction($share = false, $alias = null)
|
||||
{
|
||||
return $this->context->shop->addSqlRestriction($share, $alias, 'shop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert module into datable
|
||||
*/
|
||||
|
||||
+3
-3
@@ -114,12 +114,12 @@ class PackCore extends Product
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = a.id_product_item
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.id_product = pl.id_product
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`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_.'category_lang` cl
|
||||
ON p.`id_category_default` = cl.`id_category`
|
||||
AND cl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').'
|
||||
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_tax_rules_group_shop` ptrgs ON (p.`id_product` = ptrgs.`id_product`
|
||||
AND ptrgs.id_shop='.(int)Context::getContext()->shop->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (ptrgs.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
@@ -166,7 +166,7 @@ class PackCore extends Product
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE pl.`id_lang` = '.(int)$id_lang.'
|
||||
'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
|
||||
'.Shop::addSqlRestrictionOnLang('pl').'
|
||||
AND p.`id_product` IN ('.$packs.')';
|
||||
if ($limit)
|
||||
$sql .= ' LIMIT '.(int)$limit;
|
||||
|
||||
+14
-14
@@ -935,7 +935,7 @@ class ProductCore extends ObjectModel
|
||||
$sql = 'SELECT p.*, pl.* , t.`rate` AS tax_rate, m.`name` AS manufacturer_name, s.`name` AS supplier_name
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.$context->shop->addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_tax_rules_group_shop` ptrgs ON (p.`id_product` = ptrgs.`id_product`
|
||||
AND ptrgs.id_shop='.(int)$context->shop->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (ptrgs.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
@@ -964,7 +964,7 @@ class ProductCore extends ObjectModel
|
||||
$sql = 'SELECT p.`id_product`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->addSqlAssociation('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.$context->shop->addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
|
||||
WHERE pl.`id_lang` = '.(int)$id_lang.'
|
||||
ORDER BY pl.`name`';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
@@ -1827,7 +1827,7 @@ class ProductCore extends ObjectModel
|
||||
$sql->join($context->shop->addSqlAssociation('product', 'p'));
|
||||
$sql->leftJoin('product_lang', 'pl', '
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl')
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl')
|
||||
);
|
||||
$sql->leftJoin('image', 'i', 'i.`id_product` = p.`id_product` AND i.`cover` = 1');
|
||||
$sql->leftJoin('image_lang', 'il', 'i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang);
|
||||
@@ -1945,7 +1945,7 @@ class ProductCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
@@ -2031,7 +2031,7 @@ class ProductCore extends ObjectModel
|
||||
'.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.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
@@ -2095,7 +2095,7 @@ class ProductCore extends ObjectModel
|
||||
$ret = array();
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT cp.`id_category`, cl.`name`, cl.`link_rewrite` FROM `'._DB_PREFIX_.'category_product` cp
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cp.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cp.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
WHERE cp.`id_product` = '.(int)$id_product.'
|
||||
AND cl.`id_lang` = '.(int)$id_lang
|
||||
);
|
||||
@@ -2895,7 +2895,7 @@ class ProductCore extends ObjectModel
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
WHERE `id_product_1` = '.(int)$id_product;
|
||||
|
||||
@@ -2928,11 +2928,11 @@ class ProductCore extends ObjectModel
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (
|
||||
p.`id_category_default` = cl.`id_category`
|
||||
AND cl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').'
|
||||
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
@@ -3096,7 +3096,7 @@ class ProductCore extends ObjectModel
|
||||
$sql->join($context->shop->addSqlAssociation('product', 'p'));
|
||||
$sql->leftJoin('product_lang', 'pl', '
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl')
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl')
|
||||
);
|
||||
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
|
||||
|
||||
@@ -4008,7 +4008,7 @@ class ProductCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'stock_mvt` sm
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
sm.id_product = pl.id_product
|
||||
AND pl.id_lang = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'stock_mvt_reason_lang` mrl ON (
|
||||
sm.id_stock_mvt_reason = mrl.id_stock_mvt_reason
|
||||
@@ -4034,9 +4034,9 @@ class ProductCore extends ObjectModel
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT pl.`id_lang`, pl.`link_rewrite`, p.`ean13`, cl.`link_rewrite` AS category_rewrite
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`'.Shop::addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'lang` l ON (pl.`id_lang` = l.`id_lang`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = p.`id_category_default` AND cl.`id_lang` = pl.`id_lang`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = p.`id_category_default` AND cl.`id_lang` = pl.`id_lang`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
WHERE p.`id_product` = '.(int)$id_product.'
|
||||
AND l.`active` = 1
|
||||
');
|
||||
@@ -4777,7 +4777,7 @@ class ProductCore extends ObjectModel
|
||||
$interval = Category::getInterval($this->id_category_default);
|
||||
$sql = new DbQuery();
|
||||
$sql->from('category', 'c');
|
||||
$sql->leftJoin('category_lang', 'cl', 'c.id_category = cl.id_category AND id_lang = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl'));
|
||||
$sql->leftJoin('category_lang', 'cl', 'c.id_category = cl.id_category AND id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl'));
|
||||
$sql->where('c.nleft <= '.(int)$interval['nleft'].' AND c.nright >= '.(int)$interval['nright']);
|
||||
$sql->orderBy('c.nleft');
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class ProductSaleCore
|
||||
'.$context->shop->addSqlAssociation('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`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`)
|
||||
@@ -147,12 +147,12 @@ class ProductSaleCore
|
||||
'.$context->shop->addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`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_.'category_lang` cl
|
||||
ON cl.`id_category` = p.`id_category_default`
|
||||
AND cl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').'
|
||||
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
|
||||
WHERE p.`active` = 1
|
||||
AND p.`id_product` IN (
|
||||
SELECT cp.`id_product`
|
||||
|
||||
+18
-19
@@ -128,7 +128,7 @@ class ReferrerCore extends ObjectModel
|
||||
* @param int $employee
|
||||
* @param Context $context
|
||||
*/
|
||||
public function getStatsVisits($id_product, $employee, Shop $shop)
|
||||
public function getStatsVisits($id_product, $employee)
|
||||
{
|
||||
$join = $where = '';
|
||||
if ($id_product)
|
||||
@@ -151,8 +151,8 @@ class ReferrerCore extends ObjectModel
|
||||
LEFT JOIN '._DB_PREFIX_.'connections_page cp ON cp.id_connections = c.id_connections
|
||||
'.$join.'
|
||||
WHERE cs.date_add BETWEEN '.ModuleGraph::getDateBetween($employee).'
|
||||
'.$shop->addSqlRestriction(false, 'rs').'
|
||||
'.$shop->addSqlRestriction(false, 'c').'
|
||||
'.Shop::addSqlRestriction(false, 'rs').'
|
||||
'.Shop::addSqlRestriction(false, 'c').'
|
||||
AND rc.id_referrer = '.(int)$this->id
|
||||
.$where;
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
@@ -165,7 +165,7 @@ class ReferrerCore extends ObjectModel
|
||||
* @param int $employee
|
||||
* @param Context $context
|
||||
*/
|
||||
public function getRegistrations($id_product, $employee, Shop $shop)
|
||||
public function getRegistrations($id_product, $employee)
|
||||
{
|
||||
$join = $where = '';
|
||||
if ($id_product)
|
||||
@@ -186,9 +186,9 @@ class ReferrerCore extends ObjectModel
|
||||
LEFT JOIN '._DB_PREFIX_.'customer cu ON cu.id_customer = g.id_customer
|
||||
'.$join.'
|
||||
WHERE cu.date_add BETWEEN '.ModuleGraph::getDateBetween($employee).'
|
||||
'.$shop->addSqlRestriction(false, 'rs').'
|
||||
'.$shop->addSqlRestriction(false, 'c').'
|
||||
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER, 'cu').'
|
||||
'.Shop::addSqlRestriction(false, 'rs').'
|
||||
'.Shop::addSqlRestriction(false, 'c').'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'cu').'
|
||||
AND cu.date_add > cs.date_add
|
||||
AND rc.id_referrer = '.(int)$this->id
|
||||
.$where;
|
||||
@@ -201,9 +201,8 @@ class ReferrerCore extends ObjectModel
|
||||
*
|
||||
* @param int $id_product
|
||||
* @param int $employee
|
||||
* @param Context $context
|
||||
*/
|
||||
public function getStatsSales($id_product, $employee, Shop $shop)
|
||||
public function getStatsSales($id_product, $employe)
|
||||
{
|
||||
$join = $where = '';
|
||||
if ($id_product)
|
||||
@@ -221,9 +220,9 @@ class ReferrerCore extends ObjectModel
|
||||
LEFT JOIN '._DB_PREFIX_.'orders oo ON oo.id_customer = g.id_customer
|
||||
'.$join.'
|
||||
WHERE oo.invoice_date BETWEEN '.ModuleGraph::getDateBetween($employee).'
|
||||
'.$shop->addSqlRestriction(false, 'rs').'
|
||||
'.$shop->addSqlRestriction(false, 'c').'
|
||||
'.$shop->addSqlRestriction(Shop::SHARE_ORDER, 'oo').'
|
||||
'.Shop::addSqlRestriction(false, 'rs').'
|
||||
'.Shop::addSqlRestriction(false, 'c').'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'oo').'
|
||||
AND oo.date_add > cs.date_add
|
||||
AND rc.id_referrer = '.(int)$this->id.'
|
||||
AND oo.valid = 1'
|
||||
@@ -240,7 +239,7 @@ class ReferrerCore extends ObjectModel
|
||||
$sql = 'SELECT COUNT(id_order) AS orders, SUM(total_paid_real / conversion_rate) AS sales
|
||||
FROM '._DB_PREFIX_.'orders
|
||||
WHERE id_order IN ('.implode($implode, ',').')
|
||||
'.$shop->addSqlRestriction(Shop::SHARE_ORDER).'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER).'
|
||||
AND valid = 1';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
}
|
||||
@@ -267,9 +266,9 @@ class ReferrerCore extends ObjectModel
|
||||
continue;
|
||||
|
||||
$shop = new Shop($shop_id);
|
||||
$stats_visits = $referrer->getStatsVisits(null, $employee, $shop);
|
||||
$registrations = $referrer->getRegistrations(null, $employee, $shop);
|
||||
$stats_sales = $referrer->getStatsSales(null, $employee, $shop);
|
||||
$stats_visits = $referrer->getStatsVisits(null, $employee);
|
||||
$registrations = $referrer->getRegistrations(null, $employee);
|
||||
$stats_sales = $referrer->getStatsSales(null, $employee);
|
||||
|
||||
Db::getInstance()->update('referrer_shop', array(
|
||||
'cache_visitors' => $stats_visits['uniqs'],
|
||||
@@ -326,9 +325,9 @@ class ReferrerCore extends ObjectModel
|
||||
$product = new Product($id_product, false, Configuration::get('PS_LANG_DEFAULT'));
|
||||
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$referrer = new Referrer($id_referrer);
|
||||
$stats_visits = $referrer->getStatsVisits($id_product, $employee, $context->shop);
|
||||
$registrations = $referrer->getRegistrations($id_product, $employee, $context->shop);
|
||||
$stats_sales = $referrer->getStatsSales($id_product, $employee, $context->shop);
|
||||
$stats_visits = $referrer->getStatsVisits($id_product, $employee);
|
||||
$registrations = $referrer->getRegistrations($id_product, $employee);
|
||||
$stats_sales = $referrer->getStatsSales($id_product, $employee);
|
||||
|
||||
// If it's a product and it has no visits nor orders
|
||||
if ((int)$id_product && !$stats_visits['visits'] && !$stats_sales['orders'])
|
||||
|
||||
+5
-5
@@ -252,11 +252,11 @@ class SearchCore
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (
|
||||
p.`id_category_default` = cl.`id_category`
|
||||
AND cl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').'
|
||||
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
|
||||
)
|
||||
WHERE p.`id_product` '.$product_pool.'
|
||||
ORDER BY position DESC LIMIT 10';
|
||||
@@ -281,7 +281,7 @@ class SearchCore
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)$context->country->id.'
|
||||
@@ -300,7 +300,7 @@ class SearchCore
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)Context::getContext()->country->id.'
|
||||
@@ -628,7 +628,7 @@ class SearchCore
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
)
|
||||
'.$context->shop->addSqlAssociation('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
|
||||
@@ -252,7 +252,7 @@ class SupplierCore extends ObjectModel
|
||||
JOIN `'._DB_PREFIX_.'product_supplier` ps ON (ps.id_product = p.id_product
|
||||
AND ps.id_product_attribute = 0)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`
|
||||
AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image`
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ class TagCore extends ObjectModel
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT pl.name, pl.id_product
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product'.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product'.Shop::addSqlRestrictionOnLang('pl').'
|
||||
WHERE pl.id_lang = '.(int)$id_lang.'
|
||||
AND p.active = 1
|
||||
'.($this->id ? ('AND p.id_product '.$in.' (SELECT pt.id_product FROM `'._DB_PREFIX_.'product_tag` pt WHERE pt.id_tag = '.(int)$this->id.')') : '').'
|
||||
|
||||
+4
-4
@@ -754,7 +754,7 @@ class ToolsCore
|
||||
{
|
||||
$sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description_short`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`'.Shop::addSqlRestrictionOnLang('pl').')
|
||||
WHERE pl.id_lang = '.(int)$id_lang.'
|
||||
AND pl.id_product = '.(int)$id_product.'
|
||||
AND p.active = 1';
|
||||
@@ -776,7 +776,7 @@ class ToolsCore
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description`
|
||||
FROM `'._DB_PREFIX_.'category_lang` cl
|
||||
WHERE cl.`id_lang` = '.(int)($id_lang).' AND cl.`id_category` = '.(int)$id_category.Context::getContext()->shop->addSqlRestrictionOnLang('cl'));
|
||||
WHERE cl.`id_lang` = '.(int)($id_lang).' AND cl.`id_category` = '.(int)$id_category.Shop::addSqlRestrictionOnLang('cl'));
|
||||
if ($row)
|
||||
{
|
||||
if (empty($row['meta_description']))
|
||||
@@ -976,7 +976,7 @@ class ToolsCore
|
||||
{
|
||||
$sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
|
||||
FROM '._DB_PREFIX_.'category c
|
||||
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$context->shop->addSqlRestrictionOnLang('cl').')
|
||||
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
WHERE c.nleft <= '.$interval['nleft'].'
|
||||
AND c.nright >= '.$interval['nright'].'
|
||||
AND c.nleft >= '.$intervalRoot['nleft'].'
|
||||
@@ -1519,7 +1519,7 @@ class ToolsCore
|
||||
public static function cccJS($js_files)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
return Media::cccJS($css_files);
|
||||
return Media::cccJS($js_files);
|
||||
}
|
||||
|
||||
private static $_cache_nb_media_servers = null;
|
||||
|
||||
@@ -1954,7 +1954,7 @@ class AdminControllerCore extends Controller
|
||||
$select_shop = ', shop.name as shop_name ';
|
||||
$join_shop = ' LEFT JOIN '._DB_PREFIX_.$this->shopLinkType.' shop
|
||||
ON a.id_'.$this->shopLinkType.' = shop.id_'.$this->shopLinkType;
|
||||
$where_shop = $this->context->shop->addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
|
||||
$where_shop = Shop::addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
|
||||
}
|
||||
|
||||
if ($this->multishop_context)
|
||||
|
||||
@@ -789,7 +789,7 @@ class OrderCore extends ObjectModel
|
||||
$sql = 'SELECT `id_order`
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE DATE_ADD(date_upd, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\' AND date_upd >= \''.pSQL($date_from).'\'
|
||||
'.Context::getContext()->shop->addSqlRestriction()
|
||||
'.Shop::addSqlRestriction()
|
||||
.($type ? ' AND '.pSQL(strval($type)).'_number != 0' : '')
|
||||
.($id_customer ? ' AND id_customer = '.(int)($id_customer) : '');
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
@@ -815,7 +815,7 @@ class OrderCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`)
|
||||
WHERE 1
|
||||
'.Context::getContext()->shop->addSqlRestriction(false, 'o').'
|
||||
'.Shop::addSqlRestriction(false, 'o').'
|
||||
ORDER BY o.`date_add` DESC
|
||||
'.((int)$limit ? 'LIMIT 0, '.(int)$limit : '');
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
@@ -838,7 +838,7 @@ class OrderCore extends ObjectModel
|
||||
$sql = 'SELECT `id_order`
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE DATE_ADD(invoice_date, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\' AND invoice_date >= \''.pSQL($date_from).'\'
|
||||
'.Context::getContext()->shop->addSqlRestriction()
|
||||
'.Shop::addSqlRestriction()
|
||||
.($type ? ' AND '.pSQL(strval($type)).'_number != 0' : '')
|
||||
.($id_customer ? ' AND id_customer = '.(int)($id_customer) : '').
|
||||
' ORDER BY invoice_date ASC';
|
||||
@@ -863,7 +863,7 @@ class OrderCore extends ObjectModel
|
||||
$sql = 'SELECT id_order
|
||||
FROM '._DB_PREFIX_.'orders o
|
||||
WHERE o.`current_state` = '.(int)$id_order_state.'
|
||||
'.Context::getContext()->shop->addSqlRestriction(false, 'o').'
|
||||
'.Shop::addSqlRestriction(false, 'o').'
|
||||
ORDER BY invoice_date ASC';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
@@ -933,7 +933,7 @@ class OrderCore extends ObjectModel
|
||||
$sql = 'SELECT COUNT(`id_order`) AS nb
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_customer` = '.(int)$id_customer
|
||||
.Context::getContext()->shop->addSqlRestriction();
|
||||
.Shop::addSqlRestriction();
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
|
||||
return isset($result['nb']) ? $result['nb'] : 0;
|
||||
@@ -950,7 +950,7 @@ class OrderCore extends ObjectModel
|
||||
$sql = 'SELECT `id_order`
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_cart` = '.(int)($id_cart)
|
||||
.Context::getContext()->shop->addSqlRestriction();
|
||||
.Shop::addSqlRestriction();
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
return isset($result['id_order']) ? $result['id_order'] : false;
|
||||
@@ -1120,7 +1120,7 @@ class OrderCore extends ObjectModel
|
||||
$sql = 'SELECT id_order
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `delivery_number` = '.(int)($id_delivery).'
|
||||
'.Context::getContext()->shop->addSqlRestriction();
|
||||
'.Shop::addSqlRestriction();
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
return new Order((int)($res['id_order']));
|
||||
}
|
||||
@@ -1159,7 +1159,7 @@ class OrderCore extends ObjectModel
|
||||
WHERE o.`id_order` = '.(int)$this->id.'
|
||||
AND c.`email` = \''.pSQL($email).'\'
|
||||
AND c.`is_guest` = 1
|
||||
'.Context::getContext()->shop->addSqlRestriction(false, 'c');
|
||||
'.Shop::addSqlRestriction(false, 'c');
|
||||
return (bool)Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ class OrderInvoiceCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
|
||||
WHERE DATE_ADD(oi.date_add, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
|
||||
AND oi.date_add >= \''.pSQL($date_from).'\'
|
||||
'.Context::getContext()->shop->addSqlRestriction().'
|
||||
'.Shop::addSqlRestriction().'
|
||||
ORDER BY oi.date_add ASC
|
||||
');
|
||||
|
||||
@@ -393,7 +393,7 @@ class OrderInvoiceCore extends ObjectModel
|
||||
ORDER BY date_add DESC, id_order_history DESC
|
||||
LIMIT 1
|
||||
)
|
||||
'.Context::getContext()->shop->addSqlRestriction(false, 'o').'
|
||||
'.Shop::addSqlRestriction(false, 'o').'
|
||||
ORDER BY oi.`date_add` ASC
|
||||
');
|
||||
|
||||
@@ -415,7 +415,7 @@ class OrderInvoiceCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
|
||||
WHERE DATE_ADD(oi.delivery_date, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
|
||||
AND oi.date_add >= \''.pSQL($date_from).'\'
|
||||
'.Context::getContext()->shop->addSqlRestriction().'
|
||||
'.Shop::addSqlRestriction().'
|
||||
ORDER BY oi.delivery_date ASC
|
||||
');
|
||||
|
||||
|
||||
@@ -696,7 +696,7 @@ class ShopCore extends ObjectModel
|
||||
* @param string $alias
|
||||
* @param string $type shop|group_shop
|
||||
*/
|
||||
public function addSqlRestriction($share = false, $alias = null, $type = 'shop')
|
||||
public static function addSqlRestriction($share = false, $alias = null, $type = 'shop')
|
||||
{
|
||||
if ($type != 'shop' && $type != 'group_shop')
|
||||
$type = 'shop';
|
||||
@@ -753,9 +753,11 @@ class ShopCore extends ObjectModel
|
||||
* @param Context $context
|
||||
* @return string
|
||||
*/
|
||||
public function addSqlRestrictionOnLang($alias = null)
|
||||
public static function addSqlRestrictionOnLang($alias = null, $id_shop = null)
|
||||
{
|
||||
return ' AND '.(($alias) ? $alias.'.' : '').'id_shop = '.$this->id.' ';
|
||||
if (is_null($id_shop))
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
return ' AND '.(($alias) ? $alias.'.' : '').'id_shop = '.$id_shop.' ';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user