-
☆ A M B ☆
- 756 Posts
Alright, so I have a CMP and one of the options in the CMP for an item is "context" which of course I'd like to tie into the users actual context permissions to determine what they can do if anything to the items assigned to that context. Any guidance or suggestions certainly welcome here.
Cheers
[ed. note: charless last edited this post 14 years, 2 months ago.]
Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
Visit
CharlesMx.com for latest news and status updates.
I might be misunderstanding what you want to do, but it seems to me that in order to have granted the Context access for the users, they must already be in separate user groups. In that case (assuming that you have the $user object for the user) you can just use $user->isMember('UserGroupName') to check for context access.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
-
☆ A M B ☆
- 756 Posts
thanks for the feedback Bob, I have a working solution.
Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
Visit
CharlesMx.com for latest news and status updates.
What did you end up doing? It may help others.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
-
☆ A M B ☆
- 756 Posts
yep, in my case I just needed a list of all valid non-mgr context that a user has permissions to regardless of the policy. The code I'm using looks like the following:
$userWUG_arr = $modx->user->getUserGroupNames();
$userid = $modx->user->get('id');
$ug = $modx->newQuery('modUserGroup');
$ug->where(array(
'name:IN' => $userWUG_arr,
));
$mxc_groups = $modx->getIterator('modUserGroup', $ug);
if(count($mxc_groups)){
foreach($mxc_groups AS $mxg){
$webContextAccess = $modx->newQuery('modAccessContext');
$webContextAccess->where(array(
'principal' => $mxg->get('id'),
'AND:target:!=' => 'mgr',
));
$mxc_cntx = $modx->getIterator('modAccessContext', $webContextAccess);
if(count($mxc_cntx)){
foreach($mxc_cntx AS $acl){
if(!in_array($acl->get('target'), $userContextACL_arr))
$list[] = array('key'=>$acl->get('target'));
}
}
}
}
Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
Visit
CharlesMx.com for latest news and status updates.