diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index 1cab75cc1c..6d159ecf70 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -648,7 +648,7 @@ class UserRightsProfile extends UserRightsAddOnAPI $aConditions = array(); // Determine if this class is part of a silo and build the filter for it - $sAttCode = self::GetOwnerOrganizationAttCode($sClass); + $sAttCode = UserRights::GetOwnerOrganizationAttCode($sClass); if (!is_null($sAttCode)) { $aUserOrgs = $this->GetUserOrgs($oUser, $sClass); @@ -834,7 +834,7 @@ class UserRightsProfile extends UserRightsAddOnAPI // But currently we are checking wether the objects might be written... // Let's exclude the objects based on the relevant criteria - $sOrgAttCode = self::GetOwnerOrganizationAttCode($sClass); + $sOrgAttCode = UserRights::GetOwnerOrganizationAttCode($sClass); if (!is_null($sOrgAttCode)) { $aUserOrgs = $this->GetUserOrgs($oUser, $sClass); diff --git a/addons/userrights/userrightsprofile.db.class.inc.php b/addons/userrights/userrightsprofile.db.class.inc.php index 7ae7214b02..ab22fe0f1d 100644 --- a/addons/userrights/userrightsprofile.db.class.inc.php +++ b/addons/userrights/userrightsprofile.db.class.inc.php @@ -778,7 +778,7 @@ exit; // Determine how to position the objects of this class // - $sAttCode = self::GetOwnerOrganizationAttCode($sClass); + $sAttCode = UserRights::GetOwnerOrganizationAttCode($sClass); if (is_null($sAttCode)) { // No filtering for this object @@ -909,7 +909,7 @@ exit; // But currently we are checking wether the objects might be written... // Let's exclude the objects based on the relevant criteria - $sOrgAttCode = self::GetOwnerOrganizationAttCode($sClass); + $sOrgAttCode = UserRights::GetOwnerOrganizationAttCode($sClass); if (!is_null($sOrgAttCode)) { $aUserOrgs = $this->GetUserOrgs($oUser, $sClass); @@ -1015,28 +1015,7 @@ exit; */ public static function GetOwnerOrganizationAttCode($sClass) { - $sAttCode = null; - - $aCallSpec = array($sClass, 'MapContextParam'); - if (($sClass == 'Organization') || is_subclass_of($sClass, 'Organization')) - { - $sAttCode = 'id'; - } - elseif (is_callable($aCallSpec)) - { - $sAttCode = call_user_func($aCallSpec, 'org_id'); // Returns null when there is no mapping for this parameter - if (!MetaModel::IsValidAttCode($sClass, $sAttCode)) - { - // Skip silently. The data model checker will tell you something about this... - $sAttCode = null; - } - } - elseif(MetaModel::IsValidAttCode($sClass, 'org_id')) - { - $sAttCode = 'org_id'; - } - - return $sAttCode; + return UserRights::GetOwnerOrganizationAttCode($sClass);; } /** diff --git a/core/inlineimage.class.inc.php b/core/inlineimage.class.inc.php index 1f58569d18..a0ec221c52 100644 --- a/core/inlineimage.class.inc.php +++ b/core/inlineimage.class.inc.php @@ -140,10 +140,12 @@ class InlineImage extends DBObject */ public function SetDefaultOrgId() { + // If the item class has no organization attribute, then no need to set the organization id if (is_null(UserRights::GetOwnerOrganizationAttCode( $this->Get('item_class')))) { // No need for silos return; } + // get organization attribute code for the person class $sOrgAttrCodeForPerson = UserRights::GetOwnerOrganizationAttCode('Person'); if (is_null($sOrgAttrCodeForPerson)) { // No need for silos diff --git a/datamodels/2.x/itop-structure/module.itop-structure.php b/datamodels/2.x/itop-structure/module.itop-structure.php index f2d72272e6..aa3e2aa978 100644 --- a/datamodels/2.x/itop-structure/module.itop-structure.php +++ b/datamodels/2.x/itop-structure/module.itop-structure.php @@ -142,7 +142,7 @@ if (!class_exists('StructureInstaller')) $sPersonClass = 'Person'; $sPersonStateAttCode = MetaModel::GetStateAttributeCode($sPersonClass); - $sPersonOwnerOrgAttCode = UserRightsProfile::GetOwnerOrganizationAttCode($sPersonClass); + $sPersonOwnerOrgAttCode = UserRights::GetOwnerOrganizationAttCode($sPersonClass); $iClassesWithLogCount = 0; $aCreatedTriggerIds = []; @@ -177,7 +177,7 @@ if (!class_exists('StructureInstaller')) ); // Filter on class owner org. if any - $sClassOwnerOrgAttCode = UserRightsProfile::GetOwnerOrganizationAttCode($sClass); + $sClassOwnerOrgAttCode = UserRights::GetOwnerOrganizationAttCode($sClass); $oOwnerOrgExpr = empty($sClassOwnerOrgAttCode) ? null : new BinaryExpression( new FieldExpression($sPersonOwnerOrgAttCode), '=',