[*] BO #PSFV-94 : Added AdminFeatureController

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10137 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2011-11-15 15:37:04 +00:00
parent 6b502937dd
commit 764ccc45a3
13 changed files with 835 additions and 604 deletions
+45 -24
View File
@@ -30,31 +30,31 @@
*/
class GroupShopCore extends ObjectModel
{
public $name;
public $active;
public $share_customer;
public $share_order;
public $deleted;
public $name;
public $active;
public $share_customer;
public $share_order;
public $deleted;
protected $fieldsSize = array('name' => 64);
protected $fieldsValidate = array(
protected $fieldsSize = array('name' => 64);
protected $fieldsValidate = array(
'active' => 'isBool',
'share_customer' => 'isBool',
'share_order' => 'isBool',
'name' => 'isGenericName',
);
protected $table = 'group_shop';
protected $identifier = 'id_group_shop';
protected $table = 'group_shop';
protected $identifier = 'id_group_shop';
private static $assoTables = array(
'attribute_group' => array('type' => 'group_shop'),
'attribute' => array('type' => 'group_shop'),
'feature' => array('type' => 'group_shop'),
'group' => array('type' => 'group_shop'),
'manufacturer' => array('type' => 'group_shop'),
'supplier' => array('type' => 'group_shop'),
'zone' => array('type' => 'shop'),
'tax_rules_group' => array('type' => 'group_shop'),
'attribute_group' => array('type' => 'group_shop'),
'attribute' => array('type' => 'group_shop'),
'feature' => array('type' => 'group_shop'),
'group' => array('type' => 'group_shop'),
'manufacturer' => array('type' => 'group_shop'),
'supplier' => array('type' => 'group_shop'),
'zone' => array('type' => 'shop'),
'tax_rules_group' => array('type' => 'group_shop'),
);
public function getFields()
@@ -71,9 +71,11 @@ class GroupShopCore extends ObjectModel
public static function getGroupShops($active = true)
{
return Db::getInstance()->executeS('SELECT *
FROM '._DB_PREFIX_.'group_shop
WHERE `deleted`= 0 AND `active`='.(int)$active);
return Db::getInstance()->executeS('
SELECT *
FROM '._DB_PREFIX_.'group_shop
WHERE `deleted`= 0 AND `active`='.(int)$active
);
}
public function delete()
@@ -81,7 +83,7 @@ class GroupShopCore extends ObjectModel
if (!$res = parent::delete())
return false;
foreach (Shop::getAssoTables() AS $table_name => $row)
foreach (Shop::getAssoTables() as $table_name => $row)
{
$id = 'id_'.$row['type'];
if ($row['type'] == 'fk_group_shop')
@@ -96,7 +98,7 @@ class GroupShopCore extends ObjectModel
public static function getAssoTables()
{
return self::$assoTables;
return self::$assoTables;
}
/**
@@ -104,7 +106,7 @@ class GroupShopCore extends ObjectModel
*/
public static function getTotalGroupShops($active = true)
{
return sizeof(GroupShop::getGroupShops($active));
return count(GroupShop::getGroupShops($active));
}
public function haveShops()
@@ -134,9 +136,28 @@ class GroupShopCore extends ObjectModel
return (int)Db::getInstance()->getValue($sql);
}
/**
* Return the list of group shop by id
*
* @param int $id
* @param string $identifier
* @param string $table
* @return array
*/
public static function getGroupShopById($id, $identifier, $table)
{
$sql = sprintf('
SELECT `id_group_shop`, `%s`
FROM `'._DB_PREFIX_.'%s_group_shop`
WHERE `%s` = %d'
, $identifier, $table, $identifier, $id);
return Db::getInstance()->executeS($sql);
}
public function copyGroupShopData($old_id, $tables_import = false, $deleted = false)
{
foreach (GroupShop::getAssoTables() AS $table_name => $row)
foreach (GroupShop::getAssoTables() as $table_name => $row)
{
if ($tables_import && !isset($tables_import[$table_name]))
continue;
+35 -5
View File
@@ -167,7 +167,10 @@ class ShopCore extends ObjectModel
$id = 'id_shop';
else
$table_name .= '_'.$row['type'];
$res &= Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.$table_name.'` WHERE `'.$id.'`='.(int)$this->id);
$res &= Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.$table_name.'`
WHERE `'.$id.'`='.(int)$this->id
);
}
Shop::cacheShops(true);
@@ -183,13 +186,21 @@ class ShopCore extends ObjectModel
public static function has_dependency($id_shop)
{
$has_dependency = false;
$nbr_customer = (int)Db::getInstance()->getValue('SELECT `id_customer` FROM `'._DB_PREFIX_.'customer` WHERE `id_shop`='.(int)$id_shop);
if($nbr_customer)
$nbr_customer = (int)Db::getInstance()->getValue('
SELECT `id_customer`
FROM `'._DB_PREFIX_.'customer`
WHERE `id_shop`='.(int)$id_shop
);
if ($nbr_customer)
$has_dependency = true;
else
{
$nbr_order= (int)Db::getInstance()->getValue('SELECT `id_order` FROM `'._DB_PREFIX_.'orders` WHERE `id_shop`='.(int)$id_shop);
if($nbr_order)
$nbr_order = (int)Db::getInstance()->getValue('
SELECT `id_order`
FROM `'._DB_PREFIX_.'orders`
WHERE `id_shop`='.(int)$id_shop
);
if ($nbr_order)
$has_dependency = true;
}
@@ -609,6 +620,25 @@ class ShopCore extends ObjectModel
return $list;
}
/**
* Return the list of shop by id
*
* @param int $id
* @param string $identifier
* @param string $table
* @return array
*/
public static function getShopById($id, $identifier, $table)
{
$sql = sprintf('
SELECT `id_shop`, `%s`
FROM `'._DB_PREFIX_.'%s_shop`
WHERE `%s` = %d'
, $identifier, $table, $identifier, $id);
return Db::getInstance()->executeS($sql);
}
/**
* Retrieve the current shop context in FO or BO
*