Database->query('SELECT * FROM `PermissionAssignment` WHERE `User`='.$User); while($DbRow = $DbResult->fetch_assoc()) { if($DbRow['SubGroup'] > 0) $Result = array_merge($Result, $this->LoadForGroup($DbRow['SubGroup'])); if($DbRow['Operation'] > 0) { $DbResult2 = $this->Database->query('SELECT `PermissionOperation`.*, `Module`.`Name` FROM `PermissionOperation` JOIN `Module` ON `Module`.`Id` = `PermissionOperation`.`Module` WHERE `PermissionOperation`.`Id`='.$DbRow['Operation']); $DbRow2 = $DbResult2->fetch_assoc(); $Result[$DbRow2['Name']][$DbRow2['Action']][$DbRow2['Item']] = true; } } $this->Data = $Result; } function LoadForGroup($Group) { $Result = array(); $DbResult = $this->Database->query('SELECT * FROM `PermissionAssignment` WHERE `Group`='.$Group); while($DbRow = $DbResult->fetch_assoc()) { if($DbRow['SubGroup'] > 0) $Result = array_merge($Result, $this->LoadForGroup($DbRow['SubGroup'])); if($DbRow['Operation'] > 0) { $DbResult2 = $this->Database->query('SELECT `PermissionOperation`.*, `Module`.`Name` FROM `PermissionOperation` JOIN `Module` ON `Module`.`Id` = `PermissionOperation`.`Module` WHERE `PermissionOperation`.`Id`='.$DbRow['Operation']); $DbRow2 = $DbResult2->fetch_assoc(); $Result[$DbRow2['Name']][$DbRow2['Action']][$DbRow2['Item']] = true; } } return($Result); } function Check($Module, $Action, $Item = 0) { if(array_key_exists($Module, $this->Data) and array_key_exists($Action, $this->Data[$Module]) and array_key_exists($Item, $this->Data[$Module][$Action])) $Result = true; else $Result = false; return($Result); } }