mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 23:32:17 +02:00
Replace UserRightsProfile::GetOwnerOrganizationAttCode($sClass) by UserRights::GetOwnerOrganizationAttCode($sClass)
This commit is contained in:
@@ -648,7 +648,7 @@ class UserRightsProfile extends UserRightsAddOnAPI
|
|||||||
$aConditions = array();
|
$aConditions = array();
|
||||||
|
|
||||||
// Determine if this class is part of a silo and build the filter for it
|
// 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))
|
if (!is_null($sAttCode))
|
||||||
{
|
{
|
||||||
$aUserOrgs = $this->GetUserOrgs($oUser, $sClass);
|
$aUserOrgs = $this->GetUserOrgs($oUser, $sClass);
|
||||||
@@ -834,7 +834,7 @@ class UserRightsProfile extends UserRightsAddOnAPI
|
|||||||
// But currently we are checking wether the objects might be written...
|
// But currently we are checking wether the objects might be written...
|
||||||
// Let's exclude the objects based on the relevant criteria
|
// Let's exclude the objects based on the relevant criteria
|
||||||
|
|
||||||
$sOrgAttCode = self::GetOwnerOrganizationAttCode($sClass);
|
$sOrgAttCode = UserRights::GetOwnerOrganizationAttCode($sClass);
|
||||||
if (!is_null($sOrgAttCode))
|
if (!is_null($sOrgAttCode))
|
||||||
{
|
{
|
||||||
$aUserOrgs = $this->GetUserOrgs($oUser, $sClass);
|
$aUserOrgs = $this->GetUserOrgs($oUser, $sClass);
|
||||||
|
|||||||
@@ -778,7 +778,7 @@ exit;
|
|||||||
|
|
||||||
// Determine how to position the objects of this class
|
// Determine how to position the objects of this class
|
||||||
//
|
//
|
||||||
$sAttCode = self::GetOwnerOrganizationAttCode($sClass);
|
$sAttCode = UserRights::GetOwnerOrganizationAttCode($sClass);
|
||||||
if (is_null($sAttCode))
|
if (is_null($sAttCode))
|
||||||
{
|
{
|
||||||
// No filtering for this object
|
// No filtering for this object
|
||||||
@@ -909,7 +909,7 @@ exit;
|
|||||||
// But currently we are checking wether the objects might be written...
|
// But currently we are checking wether the objects might be written...
|
||||||
// Let's exclude the objects based on the relevant criteria
|
// Let's exclude the objects based on the relevant criteria
|
||||||
|
|
||||||
$sOrgAttCode = self::GetOwnerOrganizationAttCode($sClass);
|
$sOrgAttCode = UserRights::GetOwnerOrganizationAttCode($sClass);
|
||||||
if (!is_null($sOrgAttCode))
|
if (!is_null($sOrgAttCode))
|
||||||
{
|
{
|
||||||
$aUserOrgs = $this->GetUserOrgs($oUser, $sClass);
|
$aUserOrgs = $this->GetUserOrgs($oUser, $sClass);
|
||||||
@@ -1015,28 +1015,7 @@ exit;
|
|||||||
*/
|
*/
|
||||||
public static function GetOwnerOrganizationAttCode($sClass)
|
public static function GetOwnerOrganizationAttCode($sClass)
|
||||||
{
|
{
|
||||||
$sAttCode = null;
|
return UserRights::GetOwnerOrganizationAttCode($sClass);;
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -140,10 +140,12 @@ class InlineImage extends DBObject
|
|||||||
*/
|
*/
|
||||||
public function SetDefaultOrgId()
|
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')))) {
|
if (is_null(UserRights::GetOwnerOrganizationAttCode( $this->Get('item_class')))) {
|
||||||
// No need for silos
|
// No need for silos
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// get organization attribute code for the person class
|
||||||
$sOrgAttrCodeForPerson = UserRights::GetOwnerOrganizationAttCode('Person');
|
$sOrgAttrCodeForPerson = UserRights::GetOwnerOrganizationAttCode('Person');
|
||||||
if (is_null($sOrgAttrCodeForPerson)) {
|
if (is_null($sOrgAttrCodeForPerson)) {
|
||||||
// No need for silos
|
// No need for silos
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ if (!class_exists('StructureInstaller'))
|
|||||||
|
|
||||||
$sPersonClass = 'Person';
|
$sPersonClass = 'Person';
|
||||||
$sPersonStateAttCode = MetaModel::GetStateAttributeCode($sPersonClass);
|
$sPersonStateAttCode = MetaModel::GetStateAttributeCode($sPersonClass);
|
||||||
$sPersonOwnerOrgAttCode = UserRightsProfile::GetOwnerOrganizationAttCode($sPersonClass);
|
$sPersonOwnerOrgAttCode = UserRights::GetOwnerOrganizationAttCode($sPersonClass);
|
||||||
|
|
||||||
$iClassesWithLogCount = 0;
|
$iClassesWithLogCount = 0;
|
||||||
$aCreatedTriggerIds = [];
|
$aCreatedTriggerIds = [];
|
||||||
@@ -177,7 +177,7 @@ if (!class_exists('StructureInstaller'))
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Filter on class owner org. if any
|
// Filter on class owner org. if any
|
||||||
$sClassOwnerOrgAttCode = UserRightsProfile::GetOwnerOrganizationAttCode($sClass);
|
$sClassOwnerOrgAttCode = UserRights::GetOwnerOrganizationAttCode($sClass);
|
||||||
$oOwnerOrgExpr = empty($sClassOwnerOrgAttCode) ? null : new BinaryExpression(
|
$oOwnerOrgExpr = empty($sClassOwnerOrgAttCode) ? null : new BinaryExpression(
|
||||||
new FieldExpression($sPersonOwnerOrgAttCode),
|
new FieldExpression($sPersonOwnerOrgAttCode),
|
||||||
'=',
|
'=',
|
||||||
|
|||||||
Reference in New Issue
Block a user