// Filter list of entities per shop in admin if employee is not super admin #PSCFV-2525
This commit is contained in:
+15
-5
@@ -174,7 +174,7 @@ class EmployeeCore extends ObjectModel
|
||||
$this->id = $result['id_employee'];
|
||||
$this->id_profile = $result['id_profile'];
|
||||
foreach ($result as $key => $value)
|
||||
if (key_exists($key, $this))
|
||||
if (property_exists($this, $key))
|
||||
$this->{$key} = $value;
|
||||
return $this;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ class EmployeeCore extends ObjectModel
|
||||
|
||||
public function isLastAdmin()
|
||||
{
|
||||
return ($this->id_profile == _PS_ADMIN_PROFILE_
|
||||
return ($this->isSuperAdmin()
|
||||
&& Employee::countProfile($this->id_profile, true) == 1
|
||||
&& $this->active
|
||||
);
|
||||
@@ -272,7 +272,7 @@ class EmployeeCore extends ObjectModel
|
||||
*/
|
||||
public function hasAuthOnShop($id_shop)
|
||||
{
|
||||
return $this->id_profile == _PS_ADMIN_PROFILE_ || in_array($id_shop, $this->associated_shops);
|
||||
return $this->isSuperAdmin() || in_array($id_shop, $this->associated_shops);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,7 +284,7 @@ class EmployeeCore extends ObjectModel
|
||||
*/
|
||||
public function hasAuthOnShopGroup($id_shop_group)
|
||||
{
|
||||
if ($this->id_profile == _PS_ADMIN_PROFILE_)
|
||||
if ($this->isSuperAdmin())
|
||||
return true;
|
||||
|
||||
foreach ($this->associated_shops as $id_shop)
|
||||
@@ -301,7 +301,7 @@ class EmployeeCore extends ObjectModel
|
||||
*/
|
||||
public function getDefaultShopID()
|
||||
{
|
||||
if ($this->id_profile == _PS_ADMIN_PROFILE_ || in_array(Configuration::get('PS_SHOP_DEFAULT'), $this->associated_shops))
|
||||
if ($this->isSuperAdmin() || in_array(Configuration::get('PS_SHOP_DEFAULT'), $this->associated_shops))
|
||||
return Configuration::get('PS_SHOP_DEFAULT');
|
||||
return $this->associated_shops[0];
|
||||
}
|
||||
@@ -314,4 +314,14 @@ class EmployeeCore extends ObjectModel
|
||||
WHERE `id_profile` = '.(int)$id_profile.'
|
||||
'.($active_only ? ' AND `active` = 1' : ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current employee is super administrator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuperAdmin()
|
||||
{
|
||||
return $this->id_profile == _PS_ADMIN_PROFILE_;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1988,7 +1988,7 @@ class AdminControllerCore extends Controller
|
||||
if ($this->multishop_context && Shop::isTableAssociated($this->table) && !empty($this->className))
|
||||
{
|
||||
$def = ObjectModel::getDefinition($this->className);
|
||||
if (Shop::getContext() != Shop::CONTEXT_ALL || !empty($def['multishop']))
|
||||
if (Shop::getContext() != Shop::CONTEXT_ALL || !empty($def['multishop']) || !$this->context->employee->isSuperAdmin())
|
||||
{
|
||||
$idenfier_shop = Shop::getContextListShopID();
|
||||
if (!$this->_group)
|
||||
|
||||
Reference in New Issue
Block a user