mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 23:32:17 +02:00
N°931 TagSet admin updates :
* when modifying tag, code field is read only if tag is used by at least one object * "tag usage" tab : show only parent class
This commit is contained in:
@@ -278,6 +278,19 @@ abstract class TagSetFieldData extends cmdbAbstractObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '')
|
||||||
|
{
|
||||||
|
if ($sAttCode == 'code')
|
||||||
|
{
|
||||||
|
if ((!$this->IsNew()) && ($this->IsCodeUsed($this->Get('code'))))
|
||||||
|
{
|
||||||
|
return OPT_ATT_READONLY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display Tag Usage
|
* Display Tag Usage
|
||||||
*
|
*
|
||||||
@@ -299,37 +312,32 @@ abstract class TagSetFieldData extends cmdbAbstractObject
|
|||||||
$sClass = $this->Get('obj_class');
|
$sClass = $this->Get('obj_class');
|
||||||
$sAttCode = $this->Get('obj_attcode');
|
$sAttCode = $this->Get('obj_attcode');
|
||||||
$sTagCode = $this->Get('code');
|
$sTagCode = $this->Get('code');
|
||||||
|
|
||||||
|
|
||||||
$oFilter = DBSearch::FromOQL("SELECT $sClass WHERE $sAttCode MATCHES '$sTagCode'");
|
$oFilter = DBSearch::FromOQL("SELECT $sClass WHERE $sAttCode MATCHES '$sTagCode'");
|
||||||
$oSet = new DBObjectSet($oFilter);
|
$oSet = new DBObjectSet($oFilter);
|
||||||
$iCount = $oSet->Count();
|
$iCount = $oSet->Count();
|
||||||
$oPage->SetCurrentTab(Dict::Format('Core:TagSetFieldData:WhereIsThisTagTab', $iCount));
|
$oPage->SetCurrentTab(Dict::Format('Core:TagSetFieldData:WhereIsThisTagTab', $iCount));
|
||||||
|
|
||||||
if ($iCount === 0)
|
if ($iCount === 0)
|
||||||
{
|
{
|
||||||
$sNoEntries = Dict::S('Core:TagSetFieldData:NoEntryFound');
|
$sNoEntries = Dict::S('Core:TagSetFieldData:NoEntryFound');
|
||||||
$oPage->add("<p>$sNoEntries</p>");
|
$oPage->add("<p>$sNoEntries</p>");
|
||||||
}
|
|
||||||
else
|
return;
|
||||||
{
|
|
||||||
$aClassLabels = array();
|
|
||||||
foreach(MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL) as $sCurrentClass)
|
|
||||||
{
|
|
||||||
$aClassLabels[$sCurrentClass] = MetaModel::GetName($sCurrentClass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($aClassLabels as $sClass => $sClassLabel)
|
|
||||||
{
|
|
||||||
$oFilter = DBSearch::FromOQL("SELECT $sClass WHERE $sAttCode MATCHES '$sTagCode'");
|
$oFilter = DBSearch::FromOQL("SELECT $sClass WHERE $sAttCode MATCHES '$sTagCode'");
|
||||||
$oSet = new DBObjectSet($oFilter);
|
$oSet = new DBObjectSet($oFilter);
|
||||||
if ($oSet->CountExceeds(0))
|
if ($oSet->CountExceeds(0))
|
||||||
{
|
{
|
||||||
|
$sClassLabel = MetaModel::GetName($sClass);
|
||||||
$oPage->add("<h2>$sClassLabel</h2>");
|
$oPage->add("<h2>$sClassLabel</h2>");
|
||||||
$oResultBlock = new DisplayBlock($oFilter, 'list', false);
|
$oResultBlock = new DisplayBlock($oFilter, 'list', false);
|
||||||
$oResultBlock->Display($oPage, 1);
|
$oResultBlock->Display($oPage, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetClassName($sClass)
|
public static function GetClassName($sClass)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user