// Context part 22

This commit is contained in:
tDidierjean committed 2011-07-27 09:01:00 +00:00
1 parent 33b431647d
commit 55ee922b16
6 files changed
+45 -40

No files matched your search

+9 -7
View File
@@ -177,12 +177,14 @@ class CMSCategoryCore extends ObjectModel
); );
} }
static public function getRecurseCategory($id_lang = null, $current = 1, $active = 1, $links = 0, Context $context = null) static public function getRecurseCategory($id_lang = null, $current = 1, $active = 1, $links = 0, Link $link = null, Shop $shop = null)
{ {
if (!$context) if (!$link)
$context = Context::getContext(); $link = Context::getContext()->link;
if (!$shop)
$id_lang = is_null($id_lang) ? $context->language->id : (int)$id_lang; $shop = Context::getContext()->shop;
if (is_null($id_lang))
$id_lang = Context::getContext()->language->id;
$sql = 'SELECT c.`id_cms_category`, c.`id_parent`, c.`level_depth`, cl.`name`, cl.`link_rewrite` $sql = 'SELECT c.`id_cms_category`, c.`id_parent`, c.`level_depth`, cl.`name`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms_category` c FROM `'._DB_PREFIX_.'cms_category` c
@@ -201,7 +203,7 @@ class CMSCategoryCore extends ObjectModel
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite` $sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms` c FROM `'._DB_PREFIX_.'cms` c
'.$context->shop->sqlAsso('cms', 'c', false).' '.$shop->sqlAsso('cms', 'c', false).'
JOIN `'._DB_PREFIX_.'cms_lang` cl ON c.`id_cms` = cl.`id_cms` JOIN `'._DB_PREFIX_.'cms_lang` cl ON c.`id_cms` = cl.`id_cms`
WHERE `id_cms_category` = '.(int)$current.' WHERE `id_cms_category` = '.(int)$current.'
AND cl.`id_lang` = '.$id_lang.($active ? ' AND c.`active` = 1' : '').' AND cl.`id_lang` = '.$id_lang.($active ? ' AND c.`active` = 1' : '').'
@@ -211,7 +213,7 @@ class CMSCategoryCore extends ObjectModel
{ {
$category['link'] = $context->link->getCMSCategoryLink($current, $category['link_rewrite']); $category['link'] = $context->link->getCMSCategoryLink($current, $category['link_rewrite']);
foreach($category['cms'] as $key => $cms) foreach($category['cms'] as $key => $cms)
$category['cms'][$key]['link'] = $context->link->getCMSLink($cms['id_cms'], $cms['link_rewrite']); $category['cms'][$key]['link'] = $link->getCMSLink($cms['id_cms'], $cms['link_rewrite']);
} }
return $category; return $category;
} }
+5 -5
View File
@@ -91,10 +91,10 @@ class ConnectionCore extends ObjectModel
'time_start' => $time_start); 'time_start' => $time_start);
} }
public static function setNewConnection($cookie, Context $context = null) public static function setNewConnection($cookie, Shop $shop = null)
{ {
if (!$context) if (!$shop)
$context = Context::getContext(); $shop = Context::getContext()->shop;
if (isset($_SERVER['HTTP_USER_AGENT']) if (isset($_SERVER['HTTP_USER_AGENT'])
AND 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'])) AND 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']))
@@ -103,7 +103,7 @@ class ConnectionCore extends ObjectModel
$sql = 'SELECT `id_connections` FROM `'._DB_PREFIX_.'connections` $sql = 'SELECT `id_connections` FROM `'._DB_PREFIX_.'connections`
WHERE ip_address = '.ip2long(Tools::getRemoteAddr()).' WHERE ip_address = '.ip2long(Tools::getRemoteAddr()).'
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\' AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER).' '.$shop->sqlRestriction(Shop::SHARE_CUSTOMER).'
ORDER BY `date_add` DESC'; ORDER BY `date_add` DESC';
if ($id_connections = Db::getInstance()->getValue($sql)) if ($id_connections = Db::getInstance()->getValue($sql))
{ {
@@ -117,7 +117,7 @@ class ConnectionCore extends ObjectModel
FROM `'._DB_PREFIX_.'connections` FROM `'._DB_PREFIX_.'connections`
WHERE `id_guest` = '.(int)($cookie->id_guest).' WHERE `id_guest` = '.(int)($cookie->id_guest).'
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\' AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER).' '.$shop->sqlRestriction(Shop::SHARE_CUSTOMER).'
ORDER BY `date_add` DESC'; ORDER BY `date_add` DESC';
$result = Db::getInstance()->getRow($sql); $result = Db::getInstance()->getRow($sql);
if (!$result['id_guest'] AND (int)($cookie->id_guest)) if (!$result['id_guest'] AND (int)($cookie->id_guest))
+5 -5
View File
@@ -59,11 +59,11 @@ class ConnectionsSourceCore extends ObjectModel
return $result; return $result;
} }
public static function logHttpReferer(Context $context = null) public static function logHttpReferer(Cookie $cookie = null)
{ {
if (!$context) if (!$cookie)
$context = Context::getContext(); $cookie = Context::getContext()->cookie;
if (!isset($context->cookie->id_connections) OR !Validate::isUnsignedId($context->cookie->id_connections)) if (!isset($cookie->id_connections) OR !Validate::isUnsignedId($cookie->id_connections))
return false; return false;
if (!isset($_SERVER['HTTP_REFERER']) AND !Configuration::get('TRACKING_DIRECT_TRAFFIC')) if (!isset($_SERVER['HTTP_REFERER']) AND !Configuration::get('TRACKING_DIRECT_TRAFFIC'))
return false; return false;
@@ -85,7 +85,7 @@ class ConnectionsSourceCore extends ObjectModel
} }
} }
$source->id_connections = (int)$context->cookie->id_connections; $source->id_connections = (int)$cookie->id_connections;
$source->request_uri = Tools::getHttpHost(false, false); $source->request_uri = Tools::getHttpHost(false, false);
if (isset($_SERVER['REDIRECT_URL'])) if (isset($_SERVER['REDIRECT_URL']))
$source->request_uri .= strval($_SERVER['REDIRECT_URL']); $source->request_uri .= strval($_SERVER['REDIRECT_URL']);
+4 -4
View File
@@ -76,14 +76,14 @@ class ContactCore extends ObjectModel
* @param Context * @param Context
* @return array Contacts * @return array Contacts
*/ */
static public function getContacts($id_lang, Context $context = null) static public function getContacts($id_lang, Shop $shop = null)
{ {
if (!$context) if (!$shop)
$context = Context::getContext(); $shop = Context::getContext()->shop;
$sql = 'SELECT * $sql = 'SELECT *
FROM `'._DB_PREFIX_.'contact` c FROM `'._DB_PREFIX_.'contact` c
'.$context->shop->sqlAsso('contact', 'c', false).' '.$shop->sqlAsso('contact', 'c', false).'
LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (c.`id_contact` = cl.`id_contact`) LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (c.`id_contact` = cl.`id_contact`)
WHERE cl.`id_lang` = '.(int)$id_lang.' WHERE cl.`id_lang` = '.(int)$id_lang.'
ORDER BY `name` ASC'; ORDER BY `name` ASC';
+9 -6
View File
@@ -118,13 +118,13 @@ class CountryCore extends ObjectModel
* @param boolean $active return only active coutries * @param boolean $active return only active coutries
* @return array Countries and corresponding zones * @return array Countries and corresponding zones
*/ */
static public function getCountries($id_lang, $active = false, $containStates = NULL, Context $context = null) static public function getCountries($id_lang, $active = false, $containStates = NULL, Shop $shop = null)
{ {
if (!Validate::isBool($active)) if (!Validate::isBool($active))
die(Tools::displayError()); die(Tools::displayError());
if (!$context) if (!$shop)
$context = Context::getContext(); $shop = Context::getContext()->shop;
$states = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' $states = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT s.* SELECT s.*
@@ -133,7 +133,7 @@ class CountryCore extends ObjectModel
$sql = 'SELECT cl.*,c.*, cl.`name` AS country, z.`name` AS zone $sql = 'SELECT cl.*,c.*, cl.`name` AS country, z.`name` AS zone
FROM `'._DB_PREFIX_.'country` c FROM `'._DB_PREFIX_.'country` c
'.$context->shop->sqlAsso('country', 'c', false).' '.$shop->sqlAsso('country', 'c', false).'
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'zone` z ON z.`id_zone` = c.`id_zone` LEFT JOIN `'._DB_PREFIX_.'zone` z ON z.`id_zone` = c.`id_zone`
WHERE 1' WHERE 1'
@@ -291,14 +291,17 @@ class CountryCore extends ObjectModel
return Context::getContext()->country->id; return Context::getContext()->country->id;
} }
public static function getCountriesByZoneId($id_zone, $id_lang, Context $context = null) public static function getCountriesByZoneId($id_zone, $id_lang, Shop $shop = null)
{ {
if (empty($id_zone) OR empty($id_lang)) if (empty($id_zone) OR empty($id_lang))
die(Tools::displayError()); die(Tools::displayError());
if (!$shop)
$shop = Context::getContext()->shop;
$sql = ' SELECT DISTINCT c.*, cl.* $sql = ' SELECT DISTINCT c.*, cl.*
FROM `'._DB_PREFIX_.'country` c FROM `'._DB_PREFIX_.'country` c
'.$context->shop->sqlAsso('country', 'c', false).' '.$shop->sqlAsso('country', 'c', false).'
LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_country` = c.`id_country`) LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_country` = c.`id_country`)
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`) LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
WHERE (c.`id_zone` = '.(int)$id_zone.' OR s.`id_zone` = '.(int)$id_zone.') WHERE (c.`id_zone` = '.(int)$id_zone.' OR s.`id_zone` = '.(int)$id_zone.')
+13 -13
View File
@@ -204,15 +204,14 @@ class CustomerCore extends ObjectModel
* *
* @return array Customers * @return array Customers
*/ */
static public function getCustomers(Context $context = null) static public function getCustomers(Shop $shop = null)
{ {
if (!$context) if (!$shop)
$context = Context::getContext(); $shop = Context::getContext()->shop;
$sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname` $sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname`
FROM `'._DB_PREFIX_.'customer` FROM `'._DB_PREFIX_.'customer`
WHERE 1 WHERE 1 '.$shop->sqlRestriction(Shop::SHARE_CUSTOMER).'
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER).'
ORDER BY `id_customer` ASC'; ORDER BY `id_customer` ASC';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
} }
@@ -224,19 +223,19 @@ class CustomerCore extends ObjectModel
* @param string $passwd Password is also checked if specified * @param string $passwd Password is also checked if specified
* @return Customer instance * @return Customer instance
*/ */
public function getByEmail($email, $passwd = NULL, Context $context = null) public function getByEmail($email, $passwd = NULL, Shop $shop = null)
{ {
if (!Validate::isEmail($email) OR ($passwd AND !Validate::isPasswd($passwd))) if (!Validate::isEmail($email) OR ($passwd AND !Validate::isPasswd($passwd)))
die (Tools::displayError()); die (Tools::displayError());
if (!$context) if (!$shop)
$context = Context::getContext(); $shop = Context::getContext()->shop;
$sql = 'SELECT * $sql = 'SELECT *
FROM `'._DB_PREFIX_ .'customer` FROM `'._DB_PREFIX_ .'customer`
WHERE `active` = 1 WHERE `active` = 1
AND `email` = \''.pSQL($email).'\' AND `email` = \''.pSQL($email).'\'
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER).' '.$shop->sqlRestriction(Shop::SHARE_CUSTOMER).'
'.(isset($passwd) ? 'AND `passwd` = \''.md5(_COOKIE_KEY_.$passwd).'\'' : '').' '.(isset($passwd) ? 'AND `passwd` = \''.md5(_COOKIE_KEY_.$passwd).'\'' : '').'
AND `deleted` = 0 AND `deleted` = 0
AND `is_guest` = 0'; AND `is_guest` = 0';
@@ -280,18 +279,18 @@ class CustomerCore extends ObjectModel
* @param $ignoreGuest boolean, for exclure guest customer * @param $ignoreGuest boolean, for exclure guest customer
* @return Customer ID if found, false otherwise * @return Customer ID if found, false otherwise
*/ */
static public function customerExists($email, $return_id = false, $ignoreGuest = true, Context $context = null) static public function customerExists($email, $return_id = false, $ignoreGuest = true, Shop $shop = null)
{ {
if (!Validate::isEmail($email)) if (!Validate::isEmail($email))
die (Tools::displayError()); die (Tools::displayError());
if (!$context) if (!$shop)
$context = Context::getContext(); $shop = Context::getContext()->shop;
$sql = 'SELECT `id_customer` $sql = 'SELECT `id_customer`
FROM `'._DB_PREFIX_.'customer` FROM `'._DB_PREFIX_.'customer`
WHERE `email` = \''.pSQL($email).'\' WHERE `email` = \''.pSQL($email).'\'
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER). '.$shop->sqlRestriction(Shop::SHARE_CUSTOMER).
($ignoreGuest ? 'AND `is_guest` = 0' : ''); ($ignoreGuest ? 'AND `is_guest` = 0' : '');
$result = Db::getInstance()->getRow($sql); $result = Db::getInstance()->getRow($sql);
@@ -367,6 +366,7 @@ class CustomerCore extends ObjectModel
/** /**
* Returns customer last connections * Returns customer last connections
* *
* @deprecated
* @param integer $nb Number of connections wanted * @param integer $nb Number of connections wanted
* @return array Connections * @return array Connections
*/ */