瀏覽代碼

Let the creation of profiles adapt automatically when some classes do not exist...

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1987 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 年之前
父節點
當前提交
d9b70f863f
共有 1 個文件被更改,包括 14 次插入5 次删除
  1. 14 5
      datamodel/itop-profiles-itil/module.itop-profiles-itil.php

+ 14 - 5
datamodel/itop-profiles-itil/module.itop-profiles-itil.php

@@ -214,12 +214,21 @@ class CreateITILProfilesInstaller extends ModuleInstallerAPI
 			URP_Profiles::DoCreateActionGrant($iNewId, UR_ACTION_BULK_READ, $sClass);
 		}
 		// Can create UserRequests and attach Documents to it
-		URP_Profiles::DoCreateActionGrant($iNewId, UR_ACTION_MODIFY, 'UserRequest');
-		URP_Profiles::DoCreateActionGrant($iNewId, UR_ACTION_MODIFY, 'lnkTicketToDoc');
-		URP_Profiles::DoCreateActionGrant($iNewId, UR_ACTION_DELETE, 'lnkTicketToDoc');
-		URP_Profiles::DoCreateActionGrant($iNewId, UR_ACTION_MODIFY, 'FileDoc');
+		self::SafeCreateActionGrant($iNewId, UR_ACTION_MODIFY, 'UserRequest');
+		self::SafeCreateActionGrant($iNewId, UR_ACTION_MODIFY, 'lnkTicketToDoc');
+		self::SafeCreateActionGrant($iNewId, UR_ACTION_DELETE, 'lnkTicketToDoc');
+		self::SafeCreateActionGrant($iNewId, UR_ACTION_MODIFY, 'FileDoc');
 		// Can close user requests
-		URP_Profiles::DoCreateStimulusGrant($iNewId, 'ev_close', 'UserRequest');
+		self::SafeCreateStimulusGrant($iNewId, 'ev_close', 'UserRequest');
+	}
+	protected static function SafeCreateActionGrant($iProfile, $iAction, $sClass, $bPermission = true)
+	{
+		if (MetaModel::IsValidClass($sClass)) URP_Profiles::DoCreateActionGrant($iProfile, $iAction, $sClass, $bPermission);
+	}
+
+	protected static function SafeCreateStimulusGrant($iProfile, $sStimulusCode, $sClass)
+	{
+		if (MetaModel::IsValidClass($sClass)) URP_Profiles::DoCreateStimulusGrant($iProfile, $sStimulusCode, $sClass);
 	}
 
 	public static function DoCreateProfiles($bFirstInstall = true)