// clean code

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14543 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
aFolletete
2012-04-07 16:35:14 +00:00
parent 77f96a37d6
commit 8967e72bc1
+23 -25
View File
@@ -241,8 +241,8 @@ class CurrencyCore extends ObjectModel
public static function checkPaymentCurrencies($id_module, $id_shop = null) public static function checkPaymentCurrencies($id_module, $id_shop = null)
{ {
if (empty($id_module)) if (empty($id_module))
return false; return false;
if (is_null($id_shop)) if (is_null($id_shop))
$id_shop = Context::getContext()->shop->id; $id_shop = Context::getContext()->shop->id;
@@ -285,33 +285,31 @@ class CurrencyCore extends ObjectModel
*/ */
public static function getIdByIsoCodeNum($iso_code_num, $id_shop = 0) public static function getIdByIsoCodeNum($iso_code_num, $id_shop = 0)
{ {
$query = Currency::getIdByQuery($id_shop); $query = Currency::getIdByQuery($id_shop);
$query->where('iso_code_num = \''.pSQL($iso_code_num).'\''); $query->where('iso_code_num = \''.pSQL($iso_code_num).'\'');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query->build()); return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query->build());
return (int)$result['id_currency'];
} }
/** /**
* @static * @static
* @param int $id_shop * @param int $id_shop
* @return DbQuery * @return DbQuery
*/ */
public static function getIdByQuery($id_shop = 0) public static function getIdByQuery($id_shop = 0)
{ {
$query = new DbQuery(); $query = new DbQuery();
$query->select('c.id_currency'); $query->select('c.id_currency');
$query->from('currency', 'c'); $query->from('currency', 'c');
$query->where('deleted = 0'); $query->where('deleted = 0');
if (Shop::isFeatureActive() && $id_shop > 0) if (Shop::isFeatureActive() && $id_shop > 0)
{ {
$query->leftJoin('currency_shop', 'cs', 'cs.id_currency = c.id_currency'); $query->leftJoin('currency_shop', 'cs', 'cs.id_currency = c.id_currency');
$query->where('id_shop = '.(int)$id_shop); $query->where('id_shop = '.(int)$id_shop);
} }
return $query; return $query;
} }
/** /**
* Refresh the currency conversion rate * Refresh the currency conversion rate