From a4034bbacaa6a922c3be8ba3538533c36e08d716 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Mon, 14 May 2012 12:44:56 +0000 Subject: [PATCH] Let the creation of profiles adapt automatically when some classes do not exist... SVN:trunk[1987] --- .../module.itop-profiles-itil.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/datamodel/itop-profiles-itil/module.itop-profiles-itil.php b/datamodel/itop-profiles-itil/module.itop-profiles-itil.php index 51c3feb31..4660f29f1 100644 --- a/datamodel/itop-profiles-itil/module.itop-profiles-itil.php +++ b/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)