// Changes to controller and AdminCustomers refactoring
This commit is contained in:
@@ -231,6 +231,9 @@ class AdminControllerCore extends Controller
|
||||
/** @var instanciation of the class associated with the AdminController */
|
||||
protected $object;
|
||||
|
||||
/** @var current object ID */
|
||||
protected $id_object;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$controller = get_class($this);
|
||||
@@ -1696,6 +1699,8 @@ class AdminControllerCore extends Controller
|
||||
if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false)
|
||||
$this->filter = true;
|
||||
|
||||
$this->id_object = (int)Tools::getValue('id_'.$this->table);
|
||||
|
||||
/* Delete object image */
|
||||
if (isset($_GET['deleteImage']))
|
||||
{
|
||||
@@ -1733,7 +1738,7 @@ class AdminControllerCore extends Controller
|
||||
else if (Tools::getValue('submitAdd'.$this->table) || Tools::getValue('submitAdd'.$this->table.'AndStay'))
|
||||
{
|
||||
// case 1: updating existing entry
|
||||
if ((int)(Tools::getValue('id_'.$this->table)))
|
||||
if ($this->id_object)
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
@@ -1794,7 +1799,7 @@ class AdminControllerCore extends Controller
|
||||
else if (is_array($this->bulk_actions))
|
||||
foreach ($this->bulk_actions as $bulk_action => $params)
|
||||
{
|
||||
if (Tools::isSubmit('submitBulk'.$bulk_action.$this->table))
|
||||
if (Tools::isSubmit('submitBulk'.$bulk_action.$this->table) || Tools::isSubmit('submitBulk'.$bulk_action))
|
||||
{
|
||||
$this->action = 'bulk'.$bulk_action;
|
||||
$this->boxes = Tools::getValue($this->table.'Box');
|
||||
|
||||
+10
-4
@@ -1090,7 +1090,7 @@ class CartCore extends ObjectModel
|
||||
static $cache = false;
|
||||
if ($cache !== false && !$flush)
|
||||
return $cache;
|
||||
|
||||
|
||||
$product_list = $this->getProducts();
|
||||
// Step 1 : Get product informations (warehouse_list and carrier_list), count warehouse
|
||||
// Determine the best warehouse to determine the packages
|
||||
@@ -1331,7 +1331,7 @@ class CartCore extends ObjectModel
|
||||
static $cache = false;
|
||||
if ($cache !== false && !$flush)
|
||||
return $cache;
|
||||
|
||||
|
||||
$delivery_option_list = array();
|
||||
$carriers_price = array();
|
||||
$carrier_collection = array();
|
||||
@@ -1559,7 +1559,7 @@ class CartCore extends ObjectModel
|
||||
public function getDeliveryOption($default_country = null)
|
||||
{
|
||||
$delivery_option_list = $this->getDeliveryOptionList($default_country);
|
||||
|
||||
|
||||
// The delivery option was selected
|
||||
if (isset($this->delivery_option) && $this->delivery_option != '')
|
||||
{
|
||||
@@ -1574,7 +1574,7 @@ class CartCore extends ObjectModel
|
||||
if ($validated)
|
||||
return $delivery_option;
|
||||
}
|
||||
|
||||
|
||||
// No delivery option selected or delivery option selected is not valid, get the better for all options
|
||||
$delivery_option = array();
|
||||
foreach ($delivery_option_list as $id_address => $options)
|
||||
@@ -2028,6 +2028,12 @@ class CartCore extends ObjectModel
|
||||
return self::$_isVirtualCart[$this->id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build cart object from provided id_order
|
||||
*
|
||||
* @param int $id_order
|
||||
* @return Cart|bool
|
||||
*/
|
||||
public static function getCartByOrderId($id_order)
|
||||
{
|
||||
if ($id_cart = self::getCartIdByOrderId($id_order))
|
||||
|
||||
@@ -939,7 +939,6 @@ class CategoryCore extends ObjectModel
|
||||
return isset($row['id_category']);
|
||||
}
|
||||
|
||||
|
||||
public function cleanGroups()
|
||||
{
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'category_group` WHERE `id_category` = '.(int)$this->id);
|
||||
@@ -1005,10 +1004,15 @@ class CategoryCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update customer groups associated to the object
|
||||
*
|
||||
* @param array $list groups
|
||||
*/
|
||||
public function updateGroup($list)
|
||||
{
|
||||
$this->cleanGroups();
|
||||
if ($list && count($list))
|
||||
if ($list && !empty($list))
|
||||
$this->addGroups($list);
|
||||
else
|
||||
$this->addGroups(array(1));
|
||||
|
||||
+29
-20
@@ -108,6 +108,7 @@ class CustomerCore extends ObjectModel
|
||||
public $id_guest;
|
||||
|
||||
protected $tables = array ('customer');
|
||||
public $groupBox;
|
||||
|
||||
protected $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email');
|
||||
protected $fieldsSize = array('lastname' => 32, 'passwd' => 32, 'firstname' => 32, 'email' => 128, 'note' => 65000);
|
||||
@@ -125,7 +126,8 @@ class CustomerCore extends ObjectModel
|
||||
'note' => 'isCleanHtml',
|
||||
'is_guest' => 'isBool',
|
||||
'id_shop' => 'isUnsignedId',
|
||||
'id_group_shop' => 'isUnsignedId'
|
||||
'id_group_shop' => 'isUnsignedId',
|
||||
'groupBox' => 'isArrayWithIds'
|
||||
);
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
@@ -189,14 +191,13 @@ class CustomerCore extends ObjectModel
|
||||
$this->id_default_group = 2;
|
||||
else
|
||||
$this->id_default_group = 3;
|
||||
|
||||
/* Can't create a guest customer, if this feature is disabled */
|
||||
if ($this->is_guest && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))
|
||||
return false;
|
||||
if (!parent::add($autodate, $null_values))
|
||||
return false;
|
||||
|
||||
$row = array('id_customer' => (int)$this->id, 'id_group' => (int)$this->id_default_group);
|
||||
return Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer_group', $row, 'INSERT');
|
||||
$success = parent::add($autodate, $null_values);
|
||||
$this->updateGroup($this->groupBox);
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function update($nullValues = false)
|
||||
@@ -204,6 +205,7 @@ class CustomerCore extends ObjectModel
|
||||
$this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days);
|
||||
if ($this->newsletter && !$this->newsletter_date_add)
|
||||
$this->newsletter_date_add = date('Y-m-d H:i:s');
|
||||
$this->updateGroup($this->groupBox);
|
||||
return parent::update(true);
|
||||
}
|
||||
|
||||
@@ -419,7 +421,7 @@ class CustomerCore extends ObjectModel
|
||||
)'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER);
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Search for customers by ip address
|
||||
*
|
||||
@@ -499,6 +501,20 @@ class CustomerCore extends ObjectModel
|
||||
return isset($row['id_customer']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update customer groups associated to the object
|
||||
*
|
||||
* @param array $list groups
|
||||
*/
|
||||
public function updateGroup($list)
|
||||
{
|
||||
$this->cleanGroups();
|
||||
if ($list && !empty($list))
|
||||
$this->addGroups($list);
|
||||
else
|
||||
$this->addGroups(array($this->id_default_group));
|
||||
}
|
||||
|
||||
public function cleanGroups()
|
||||
{
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'customer_group` WHERE `id_customer` = '.(int)$this->id);
|
||||
@@ -508,19 +524,8 @@ class CustomerCore extends ObjectModel
|
||||
{
|
||||
foreach ($groups as $group)
|
||||
{
|
||||
$groups_customers = $this->getGroups();
|
||||
if (count($groups_customers) == 0)
|
||||
{
|
||||
$row = array('id_customer' => (int)$this->id, 'id_group' => (int)$group);
|
||||
Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer_group', $row, 'INSERT');
|
||||
}
|
||||
else
|
||||
foreach ($groups_customers as $group_customers)
|
||||
if ($group_customers != $group)
|
||||
{
|
||||
$row = array('id_customer' => (int)$this->id, 'id_group' => (int)$group);
|
||||
Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer_group', $row, 'INSERT');
|
||||
}
|
||||
$row = array('id_customer' => (int)$this->id, 'id_group' => (int)$group);
|
||||
Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer_group', $row, 'INSERT');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,8 +552,12 @@ class CustomerCore extends ObjectModel
|
||||
return self::getGroupsStatic((int)$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.5
|
||||
*/
|
||||
public function isUsed()
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@ class FrontControllerCore extends Controller
|
||||
return;
|
||||
self::$initialized = true;
|
||||
|
||||
parent::init();
|
||||
|
||||
// For compatibility with globals, DEPRECATED as of version 1.5
|
||||
$css_files = $this->css_files;
|
||||
$js_files = $this->js_files;
|
||||
@@ -242,11 +244,6 @@ class FrontControllerCore extends Controller
|
||||
$navigationPipe = (Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>');
|
||||
$this->context->smarty->assign('navigationPipe', $navigationPipe);
|
||||
|
||||
if (!defined('_PS_BASE_URL_'))
|
||||
define('_PS_BASE_URL_', Tools::getShopDomain(true));
|
||||
if (!defined('_PS_BASE_URL_SSL_'))
|
||||
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
|
||||
|
||||
// Automatically redirect to the canonical URL if needed
|
||||
if (isset($this->php_self) && !empty($this->php_self) && !Tools::getValue('ajax'))
|
||||
$this->canonicalRedirection($this->context->link->getPageLink($this->php_self, $this->ssl, $this->context->language->id));
|
||||
|
||||
Reference in New Issue
Block a user