[-] BO : #PSCFV-2511 - Country visible in all shop

// Normalize

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15631 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mDeflotte
2012-05-23 07:53:36 +00:00
parent 4420cac66e
commit 633a32d3ec
+49 -49
View File
@@ -92,7 +92,7 @@ class CountryCore extends ObjectModel
) )
); );
protected static $cache_iso_by_id = array(); protected static $cache_iso_by_id = array();
protected $webserviceParameters = array( protected $webserviceParameters = array(
'objectsNodeName' => 'countries', 'objectsNodeName' => 'countries',
@@ -110,16 +110,16 @@ class CountryCore extends ObjectModel
} }
/** /**
* Return available countries * Return available countries
* *
* @param integer $id_lang Language ID * @param integer $id_lang Language ID
* @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
*/ */
public static function getCountries($id_lang, $active = false, $contain_states = null) public static function getCountries($id_lang, $active = false, $contain_states = null)
{ {
if (!Validate::isBool($active)) if (!Validate::isBool($active))
die(Tools::displayError()); die(Tools::displayError());
$states = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' $states = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT s.* SELECT s.*
@@ -128,7 +128,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
'.Shop::addSqlAssociation('country', 'c', false).' '.Shop::addSqlAssociation('country', 'c').'
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.') 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'
@@ -158,11 +158,11 @@ class CountryCore extends ObjectModel
} }
/** /**
* Get a country ID with its iso code * Get a country ID with its iso code
* *
* @param string $iso_code Country iso code * @param string $iso_code Country iso code
* @return integer Country ID * @return integer Country ID
*/ */
public static function getByIso($iso_code) public static function getByIso($iso_code)
{ {
if (!Validate::isLanguageIsoCode($iso_code)) if (!Validate::isLanguageIsoCode($iso_code))
@@ -193,12 +193,12 @@ class CountryCore extends ObjectModel
} }
/** /**
* Get a country name with its ID * Get a country name with its ID
* *
* @param integer $id_lang Language ID * @param integer $id_lang Language ID
* @param integer $id_country Country ID * @param integer $id_country Country ID
* @return string Country name * @return string Country name
*/ */
public static function getNameById($id_lang, $id_country) public static function getNameById($id_lang, $id_country)
{ {
$key = 'country_getNameById_'.$id_country.'_'.$id_lang; $key = 'country_getNameById_'.$id_country.'_'.$id_lang;
@@ -214,31 +214,31 @@ class CountryCore extends ObjectModel
} }
/** /**
* Get a country iso with its ID * Get a country iso with its ID
* *
* @param integer $id_country Country ID * @param integer $id_country Country ID
* @return string Country iso * @return string Country iso
*/ */
public static function getIsoById($id_country) public static function getIsoById($id_country)
{ {
if (!isset(Country::$cache_iso_by_id[$id_country])) if (!isset(Country::$cache_iso_by_id[$id_country]))
{ {
Country::$cache_iso_by_id[$id_country] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' Country::$cache_iso_by_id[$id_country] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `iso_code` SELECT `iso_code`
FROM `'._DB_PREFIX_.'country` FROM `'._DB_PREFIX_.'country`
WHERE `id_country` = '.(int)($id_country)); WHERE `id_country` = '.(int)($id_country));
} }
return Country::$cache_iso_by_id[$id_country]; return Country::$cache_iso_by_id[$id_country];
} }
/** /**
* Get a country id with its name * Get a country id with its name
* *
* @param integer $id_lang Language ID * @param integer $id_lang Language ID
* @param string $country Country Name * @param string $country Country Name
* @return intval Country id * @return intval Country id
*/ */
public static function getIdByName($id_lang = null, $country) public static function getIdByName($id_lang = null, $country)
{ {
$sql = ' $sql = '
@@ -287,20 +287,20 @@ class CountryCore extends ObjectModel
return Context::getContext()->country->id; return Context::getContext()->country->id;
} }
public static function getCountriesByZoneId($id_zone, $id_lang) public static function getCountriesByZoneId($id_zone, $id_lang)
{ {
if (empty($id_zone) || empty($id_lang)) if (empty($id_zone) || empty($id_lang))
die(Tools::displayError()); die(Tools::displayError());
$sql = ' SELECT DISTINCT c.*, cl.* $sql = ' SELECT DISTINCT c.*, cl.*
FROM `'._DB_PREFIX_.'country` c FROM `'._DB_PREFIX_.'country` c
'.Shop::addSqlAssociation('country', 'c', false).' '.Shop::addSqlAssociation('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.')
AND `id_lang` = '.(int)$id_lang; AND `id_lang` = '.(int)$id_lang;
return Db::getInstance()->executeS($sql); return Db::getInstance()->executeS($sql);
} }
public function isNeedDni() public function isNeedDni()
{ {