diff --git a/classes/AdminController.php b/classes/AdminController.php index 9c4060b4c..88e289cc3 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -1993,7 +1993,7 @@ class AdminControllerCore extends Controller /* Cache */ $this->_lang = (int)$id_lang; - $this->_orderBy = $order_by; + $this->_orderBy = substr($order_by, strpos($order_by, '.') + 1); $this->_orderWay = Tools::strtoupper($order_way); /* SQL table : orders, but class name is Order */ @@ -2061,7 +2061,11 @@ class AdminControllerCore extends Controller if (isset($this->_having)) $having_clause .= $this->_having.' '; } - + if (strpos($order_by, '.') > 0) + { + $order_by = explode('.', $order_by); + $order_by = pSQL($order_by[0]).'.`'.pSQL($order_by[1]).'`'; + } $sql = 'SELECT SQL_CALC_FOUND_ROWS '.($this->_tmpTableFilter ? ' * FROM (SELECT ' : '').' '.($this->lang ? 'b.*, ' : '').'a.*'.(isset($this->_select) ? ', '.$this->_select.' ' : '').$select_shop.' @@ -2074,7 +2078,7 @@ class AdminControllerCore extends Controller (isset($this->_filter) ? $this->_filter : '').$where_shop.' '.(isset($this->_group) ? $this->_group.' ' : '').' '.$having_clause.' - ORDER BY '.(($order_by == $this->identifier) ? 'a.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way). + ORDER BY '.(($order_by == $this->identifier) ? 'a.' : '').pSQL($order_by).' '.pSQL($order_way). ($this->_tmpTableFilter ? ') tmpTable WHERE 1'.$this->_tmpTableFilter : ''). (($use_limit === true) ? ' LIMIT '.(int)$start.','.(int)$limit : ''); diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 393cb822a..fffadb838 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -154,7 +154,7 @@ class ShopCore extends ObjectModel public function delete() { - if (Shop::has_dependency($this->id) || !$res = parent::delete()) + if (Shop::hasDependency($this->id) || !$res = parent::delete()) return false; foreach (Shop::getAssoTables() as $table_name => $row) @@ -185,7 +185,7 @@ class ShopCore extends ObjectModel * * @return bool */ - public static function has_dependency($id_shop) + public static function hasDependency($id_shop) { $has_dependency = false; $nbr_customer = (int)Db::getInstance()->getValue(' @@ -228,7 +228,6 @@ class ShopCore extends ObjectModel */ public static function initialize() { - // Get list of excluded uri $dirname = dirname(__FILE__); $directories = scandir($dirname.'/../'); @@ -293,7 +292,7 @@ class ShopCore extends ObjectModel if (!Validate::isLoadedObject($default_shop)) throw new PrestaShopException('Shop not found'); - $url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php'.'?'.$_SERVER['QUERY_STRING']; + $url = 'http://'.$default_shop->domain.$default_shop->getBaseURI().'index.php?'.$_SERVER['QUERY_STRING']; header('location: '.$url); exit; } @@ -391,7 +390,7 @@ class ShopCore extends ObjectModel { if (defined('_PS_ADMIN_DIR_')) return Shop::getContextGroupID(); - return (isset($this->id_group_shop)) ? (int)$this->id_group_shop : NULL; + return (isset($this->id_group_shop)) ? (int)$this->id_group_shop : null; } /** @@ -662,8 +661,8 @@ class ShopCore extends ObjectModel $sql = sprintf(' SELECT `id_shop`, `%s` FROM `'._DB_PREFIX_.'%s_shop` - WHERE `%s` = %d' - , $identifier, $table, $identifier, $id); + WHERE `%s` = %d', + $identifier, $table, $identifier, $id); return Db::getInstance()->executeS($sql); }