Browse Source

Profiles defined in XML: include subclasses (explicit declarations have precedence)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2150 a333f486-631f-4898-b8df-5754b55c2be0
romainq 13 years ago
parent
commit
4dcd49446a
1 changed files with 23 additions and 0 deletions
  1. 23 0
      setup/compiler.class.inc.php

+ 23 - 0
setup/compiler.class.inc.php

@@ -1073,12 +1073,15 @@ EOF;
 						if ($sType == 'stimulus')
 						{
 							$sGrantKey = $iProfile.'_'.$sClass.'_s_'.$sAction;
+							$sGrantKeyPlus = $iProfile.'_'.$sClass.'+_s_'.$sAction; // subclasses inherit this grant
 						}
 						else
 						{
 							$sAction = $aActionsInShort[$sType];
 							$sGrantKey = $iProfile.'_'.$sClass.'_'.$sAction;
+							$sGrantKeyPlus = $iProfile.'_'.$sClass.'+_'.$sAction;  // subclasses inherit this grant
 						}
+						// The class itself
 						if (isset($aGrants[$sGrantKey]))
 						{
 							if (!$bGrant)
@@ -1090,6 +1093,18 @@ EOF;
 						{
 							$aGrants[$sGrantKey] = $bGrant;
 						}
+						// The subclasses
+						if (isset($aGrants[$sGrantKeyPlus]))
+						{
+							if (!$bGrant)
+							{
+								$aGrants[$sGrantKeyPlus] = false;
+							}
+						}
+						else
+						{
+							$aGrants[$sGrantKeyPlus] = $bGrant;
+						}
 					}
 				}
 			}
@@ -1124,6 +1139,14 @@ class ProfilesConfig
 		{
 			return self::\$aGRANTS[\$sGrantKey];
 		}
+		foreach (MetaModel::EnumParentClasses(\$sClass) as \$sParent)
+		{
+			\$sGrantKey = \$iProfileId.'_'.\$sParent.'+_'.\$sAction;
+			if (isset(self::\$aGRANTS[\$sGrantKey]))
+			{
+				return self::\$aGRANTS[\$sGrantKey];
+			}
+		}
 		\$sGrantKey = \$iProfileId.'_*_'.\$sAction;
 		if (isset(self::\$aGRANTS[\$sGrantKey]))
 		{