module access management
This commit is contained in:
@@ -37,6 +37,7 @@ class ProfileEvent extends ActionEvent
|
||||
protected $description = null;
|
||||
protected $postscriptum = null;
|
||||
protected $resourceAccess = null;
|
||||
protected $moduleAccess = null;
|
||||
|
||||
public function __construct(Profile $profile = null)
|
||||
{
|
||||
@@ -139,4 +140,14 @@ class ProfileEvent extends ActionEvent
|
||||
{
|
||||
return $this->resourceAccess;
|
||||
}
|
||||
|
||||
public function setModuleAccess($moduleAccess)
|
||||
{
|
||||
$this->moduleAccess = $moduleAccess;
|
||||
}
|
||||
|
||||
public function getModuleAccess()
|
||||
{
|
||||
return $this->moduleAccess;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,6 +553,7 @@ final class TheliaEvents
|
||||
const PROFILE_UPDATE = "action.updateProfile";
|
||||
const PROFILE_DELETE = "action.deleteProfile";
|
||||
const PROFILE_RESOURCE_ACCESS_UPDATE = "action.updateProfileResourceAccess";
|
||||
const PROFILE_MODULE_ACCESS_UPDATE = "action.updateProfileModuleAccess";
|
||||
|
||||
// -- Tax Rules management ---------------------------------------------
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -56,6 +57,13 @@ class Module extends BaseI18nLoop
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntTypeArgument('profile'),
|
||||
new Argument(
|
||||
'code',
|
||||
new Type\TypeCollection(
|
||||
new Type\AlphaNumStringListType()
|
||||
)
|
||||
),
|
||||
new Argument(
|
||||
'module_type',
|
||||
new Type\TypeCollection(
|
||||
@@ -89,6 +97,20 @@ class Module extends BaseI18nLoop
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$profile = $this->getProfile();
|
||||
|
||||
if (null !== $profile) {
|
||||
$search->leftJoinProfileModule('profile_module')
|
||||
->addJoinCondition('profile_module', 'profile_module.PROFILE_ID=?', $profile, null, \PDO::PARAM_INT)
|
||||
->withColumn('profile_module.access', 'access');
|
||||
}
|
||||
|
||||
$code = $this->getCode();
|
||||
|
||||
if(null !== $code) {
|
||||
$search->filterByCode($code, Criteria::IN);
|
||||
}
|
||||
|
||||
$moduleType = $this->getModule_type();
|
||||
|
||||
if (null !== $moduleType) {
|
||||
@@ -129,6 +151,16 @@ class Module extends BaseI18nLoop
|
||||
->set("CLASS", $module->getFullNamespace())
|
||||
->set("POSITION", $module->getPosition());
|
||||
|
||||
if (null !== $profile) {
|
||||
$accessValue = $module->getVirtualColumn('access');
|
||||
$manager = new AccessManager($accessValue);
|
||||
|
||||
$loopResultRow->set("VIEWABLE", $manager->can(AccessManager::VIEW)? 1 : 0)
|
||||
->set("CREATABLE", $manager->can(AccessManager::CREATE) ? 1 : 0)
|
||||
->set("UPDATABLE", $manager->can(AccessManager::UPDATE)? 1 : 0)
|
||||
->set("DELETABLE", $manager->can(AccessManager::DELETE)? 1 : 0);
|
||||
}
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user