Quote from: xwisdom at Dec 29, 2005, 05:59 PM
The core will check whether or not the user has access to the page. This means that nothing on the page is executed or displayed unless the user has access to it.
I see what you mean by that.
Here is the code that I code to check current document group against current manager user doc group. If they match it will return true, if not than it’s false.
function isMemberOfMgrGroup(){
global $modx;
// Fetch current document groups
$sql = '';
$result = $modx->db->select('document_group', $modx->getFullTableName("document_groups"), 'document = '.$modx->documentIdentifier);
$counter = 0;
while($tempResult = mysql_fetch_array($result)) {
$docGroups[$counter] = $tempResult['document_group'];
$counter++;
}
if(!is_array($docGroups)) return true;
// Fetch current manager groups
$mgrGroups = $_SESSION['mgrDocgroups'];
if(!is_array($docGroups)) return false;
foreach($docGroups as $k=>$v)
if(in_array(trim($v),$mgrGroups)) return true;
return false;
}
For checking current web user group against the current web user, there is a built in modx function to do that
$modx->isMemberOfWebGroup($WebGroup)
$webgroup is an array of group name.