mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-01 15:14:11 +01:00
N°3203 - Datamodel: Add semantic for image & state attributes Part. II
This commit is contained in:
@@ -834,7 +834,7 @@ EOF
|
|||||||
if ((!$oAttDef->IsLinkSet()) && (($iFlags & OPT_ATT_HIDDEN) == 0) && !($oAttDef instanceof AttributeDashboard)) {
|
if ((!$oAttDef->IsLinkSet()) && (($iFlags & OPT_ATT_HIDDEN) == 0) && !($oAttDef instanceof AttributeDashboard)) {
|
||||||
$sInputId = $this->m_iFormId.'_'.$sAttCode;
|
$sInputId = $this->m_iFormId.'_'.$sAttCode;
|
||||||
if ($oAttDef->IsWritable()) {
|
if ($oAttDef->IsWritable()) {
|
||||||
if ($sStateAttCode == $sAttCode) {
|
if (($sStateAttCode === $sAttCode) && (MetaModel::HasLifecycle($sClass))) {
|
||||||
// State attribute is always read-only from the UI
|
// State attribute is always read-only from the UI
|
||||||
$sHTMLValue = $this->GetStateLabel();
|
$sHTMLValue = $this->GetStateLabel();
|
||||||
$val = array(
|
$val = array(
|
||||||
@@ -4565,7 +4565,7 @@ HTML
|
|||||||
//echo "<p>current value for $sAttCode : $currValue</p>";
|
//echo "<p>current value for $sAttCode : $currValue</p>";
|
||||||
$oDummyObj->Set($sAttCode, $currValue);
|
$oDummyObj->Set($sAttCode, $currValue);
|
||||||
$aComments[$sAttCode] = '';
|
$aComments[$sAttCode] = '';
|
||||||
if ($sAttCode != MetaModel::GetStateAttributeCode($sClass))
|
if ($sAttCode != MetaModel::GetStateAttributeCode($sClass) || !MetaModel::HasLifecycle($sClass))
|
||||||
{
|
{
|
||||||
$aComments[$sAttCode] .= '<input type="checkbox" checked id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToggleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
$aComments[$sAttCode] .= '<input type="checkbox" checked id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToggleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
||||||
}
|
}
|
||||||
@@ -4625,7 +4625,7 @@ HTML
|
|||||||
$oDummyObj->Set($sAttCode, null);
|
$oDummyObj->Set($sAttCode, null);
|
||||||
}
|
}
|
||||||
$aComments[$sAttCode] = '';
|
$aComments[$sAttCode] = '';
|
||||||
if ($sAttCode != MetaModel::GetStateAttributeCode($sClass))
|
if ($sAttCode != MetaModel::GetStateAttributeCode($sClass) || !MetaModel::HasLifecycle($sClass))
|
||||||
{
|
{
|
||||||
$aComments[$sAttCode] .= '<input type="checkbox" id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToggleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
$aComments[$sAttCode] .= '<input type="checkbox" id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToggleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
||||||
}
|
}
|
||||||
@@ -4636,11 +4636,11 @@ HTML
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
if (MetaModel::HasLifecycle($sClass) && ($oDummyObj->GetState() == ''))
|
||||||
if (($sStateAttCode != '') && ($oDummyObj->GetState() == ''))
|
|
||||||
{
|
{
|
||||||
// Hmmm, it's not gonna work like this ! Set a default value for the "state"
|
// Hmmm, it's not gonna work like this ! Set a default value for the "state"
|
||||||
// Maybe we should use the "state" that is the most common among the objects...
|
// Maybe we should use the "state" that is the most common among the objects...
|
||||||
|
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
||||||
$aMultiValues = $aValues[$sStateAttCode];
|
$aMultiValues = $aValues[$sStateAttCode];
|
||||||
uasort($aMultiValues, 'MyComparison');
|
uasort($aMultiValues, 'MyComparison');
|
||||||
foreach($aMultiValues as $sCurrValue => $aVal)
|
foreach($aMultiValues as $sCurrValue => $aVal)
|
||||||
|
|||||||
@@ -1673,6 +1673,7 @@ abstract class DBObject implements iDisplay
|
|||||||
public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '')
|
public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '')
|
||||||
{
|
{
|
||||||
$iFlags = 0; // By default (if no life cycle) no flag at all
|
$iFlags = 0; // By default (if no life cycle) no flag at all
|
||||||
|
$sClass = get_class($this);
|
||||||
|
|
||||||
$aReadOnlyAtts = $this->GetReadOnlyAttributes();
|
$aReadOnlyAtts = $this->GetReadOnlyAttributes();
|
||||||
if (($aReadOnlyAtts != null) && (in_array($sAttCode, $aReadOnlyAtts)))
|
if (($aReadOnlyAtts != null) && (in_array($sAttCode, $aReadOnlyAtts)))
|
||||||
@@ -1680,16 +1681,16 @@ abstract class DBObject implements iDisplay
|
|||||||
return OPT_ATT_READONLY;
|
return OPT_ATT_READONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
|
if (MetaModel::HasLifecycle($sClass))
|
||||||
if (!empty($sStateAttCode))
|
|
||||||
{
|
{
|
||||||
if ($sTargetState != '')
|
if ($sTargetState != '')
|
||||||
{
|
{
|
||||||
$iFlags = MetaModel::GetAttributeFlags(get_class($this), $sTargetState, $sAttCode);
|
$iFlags = MetaModel::GetAttributeFlags($sClass, $sTargetState, $sAttCode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$iFlags = MetaModel::GetAttributeFlags(get_class($this), $this->Get($sStateAttCode), $sAttCode);
|
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
||||||
|
$iFlags = MetaModel::GetAttributeFlags($sClass, $this->Get($sStateAttCode), $sAttCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$aReasons = array();
|
$aReasons = array();
|
||||||
@@ -1742,10 +1743,10 @@ abstract class DBObject implements iDisplay
|
|||||||
public function GetTransitionFlags($sAttCode, $sStimulus, &$aReasons = array(), $sOriginState = '')
|
public function GetTransitionFlags($sAttCode, $sStimulus, &$aReasons = array(), $sOriginState = '')
|
||||||
{
|
{
|
||||||
$iFlags = 0; // By default (if no lifecycle) no flag at all
|
$iFlags = 0; // By default (if no lifecycle) no flag at all
|
||||||
|
$sClass = get_class($this);
|
||||||
|
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
|
|
||||||
// If no state attribute, there is no lifecycle
|
// If no state attribute, there is no lifecycle
|
||||||
if (empty($sStateAttCode))
|
if (!MetaModel::HasLifecycle($sClass))
|
||||||
{
|
{
|
||||||
return $iFlags;
|
return $iFlags;
|
||||||
}
|
}
|
||||||
@@ -1753,6 +1754,7 @@ abstract class DBObject implements iDisplay
|
|||||||
// Retrieving current state if necessary
|
// Retrieving current state if necessary
|
||||||
if ($sOriginState === '')
|
if ($sOriginState === '')
|
||||||
{
|
{
|
||||||
|
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
||||||
$sOriginState = $this->Get($sStateAttCode);
|
$sOriginState = $this->Get($sStateAttCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1760,7 +1762,7 @@ abstract class DBObject implements iDisplay
|
|||||||
$iAttributeFlags = $this->GetAttributeFlags($sAttCode, $aReasons, $sOriginState);
|
$iAttributeFlags = $this->GetAttributeFlags($sAttCode, $aReasons, $sOriginState);
|
||||||
|
|
||||||
// Retrieving transition flags
|
// Retrieving transition flags
|
||||||
$iTransitionFlags = MetaModel::GetTransitionFlags(get_class($this), $sOriginState, $sStimulus, $sAttCode);
|
$iTransitionFlags = MetaModel::GetTransitionFlags($sClass, $sOriginState, $sStimulus, $sAttCode);
|
||||||
|
|
||||||
// Merging transition flags with attribute flags
|
// Merging transition flags with attribute flags
|
||||||
$iFlags = $iTransitionFlags | $iAttributeFlags;
|
$iFlags = $iTransitionFlags | $iAttributeFlags;
|
||||||
@@ -1811,10 +1813,12 @@ abstract class DBObject implements iDisplay
|
|||||||
public function GetInitialStateAttributeFlags($sAttCode, &$aReasons = array())
|
public function GetInitialStateAttributeFlags($sAttCode, &$aReasons = array())
|
||||||
{
|
{
|
||||||
$iFlags = 0;
|
$iFlags = 0;
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
|
$sClass = get_class($this);
|
||||||
if (!empty($sStateAttCode))
|
|
||||||
|
if (MetaModel::HasLifecycle($sClass))
|
||||||
{
|
{
|
||||||
$iFlags = MetaModel::GetInitialStateAttributeFlags(get_class($this), $this->Get($sStateAttCode), $sAttCode);
|
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
||||||
|
$iFlags = MetaModel::GetInitialStateAttributeFlags($sClass, $this->Get($sStateAttCode), $sAttCode);
|
||||||
}
|
}
|
||||||
return $iFlags; // No need to care about the synchro flags since we'll be creating a new object anyway
|
return $iFlags; // No need to care about the synchro flags since we'll be creating a new object anyway
|
||||||
}
|
}
|
||||||
@@ -3631,11 +3635,12 @@ abstract class DBObject implements iDisplay
|
|||||||
*/
|
*/
|
||||||
public function EnumTransitions()
|
public function EnumTransitions()
|
||||||
{
|
{
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
|
$sClass = get_class($this);
|
||||||
if (empty($sStateAttCode)) return array();
|
if (!MetaModel::HasLifecycle($sClass)) return array();
|
||||||
|
|
||||||
|
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
||||||
$sState = $this->Get($sStateAttCode);
|
$sState = $this->Get($sStateAttCode);
|
||||||
return MetaModel::EnumTransitions(get_class($this), $sState);
|
return MetaModel::EnumTransitions($sClass, $sState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3681,14 +3686,14 @@ abstract class DBObject implements iDisplay
|
|||||||
public function ApplyStimulus($sStimulusCode, $bDoNotWrite = false)
|
public function ApplyStimulus($sStimulusCode, $bDoNotWrite = false)
|
||||||
{
|
{
|
||||||
$sClass = get_class($this);
|
$sClass = get_class($this);
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
if (!MetaModel::HasLifecycle($sClass))
|
||||||
if (empty($sStateAttCode))
|
|
||||||
{
|
{
|
||||||
throw new CoreException('No lifecycle for the class '.$sClass);
|
throw new CoreException('No lifecycle for the class '.$sClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
MyHelpers::CheckKeyInArray('object lifecycle stimulus', $sStimulusCode, MetaModel::EnumStimuli($sClass));
|
MyHelpers::CheckKeyInArray('object lifecycle stimulus', $sStimulusCode, MetaModel::EnumStimuli($sClass));
|
||||||
|
|
||||||
|
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
||||||
$aStateTransitions = $this->EnumTransitions();
|
$aStateTransitions = $this->EnumTransitions();
|
||||||
if (!array_key_exists($sStimulusCode, $aStateTransitions))
|
if (!array_key_exists($sStimulusCode, $aStateTransitions))
|
||||||
{
|
{
|
||||||
@@ -5338,10 +5343,10 @@ abstract class DBObject implements iDisplay
|
|||||||
*/
|
*/
|
||||||
public static function MakeDefaultInstance($sClass)
|
public static function MakeDefaultInstance($sClass)
|
||||||
{
|
{
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
|
||||||
$oObj = MetaModel::NewObject($sClass);
|
$oObj = MetaModel::NewObject($sClass);
|
||||||
if (!empty($sStateAttCode))
|
if (MetaModel::HasLifecycle($sClass))
|
||||||
{
|
{
|
||||||
|
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
||||||
$sTargetState = MetaModel::GetDefaultState($sClass);
|
$sTargetState = MetaModel::GetDefaultState($sClass);
|
||||||
$oObj->Set($sStateAttCode, $sTargetState);
|
$oObj->Set($sStateAttCode, $sTargetState);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -853,8 +853,13 @@ abstract class MetaModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the $sClass has a state attribute defined
|
* Return true if the $sClass has a state attribute defined.
|
||||||
*
|
*
|
||||||
|
* Note that having a state attribute does NOT mean having a lifecycle!
|
||||||
|
* - A Person with active/inactive state won't have transitions and therefore no lifecycle
|
||||||
|
* - A UserRequest will have transitions between its states and so a lifecycle
|
||||||
|
*
|
||||||
|
* @see self::HasLifecycle($sClass)
|
||||||
* @param string $sClass Datamodel class to check
|
* @param string $sClass Datamodel class to check
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -2372,6 +2377,22 @@ abstract class MetaModel
|
|||||||
{
|
{
|
||||||
return self::$m_aStates[$sClass];
|
return self::$m_aStates[$sClass];
|
||||||
}
|
}
|
||||||
|
elseif (self::HasStateAttributeCode($sClass))
|
||||||
|
{
|
||||||
|
$sStateAttCode = self::GetStateAttributeCode($sClass);
|
||||||
|
$oAttDef = self::GetAttributeDef($sClass, $sStateAttCode);
|
||||||
|
|
||||||
|
$aStates = [];
|
||||||
|
foreach($oAttDef->GetAllowedValues() as $sStateCode => $sStateLabel)
|
||||||
|
{
|
||||||
|
$aStates[$sStateCode] = [
|
||||||
|
'attribute_inherit' => '',
|
||||||
|
'attribute_list' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $aStates;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
@@ -2429,6 +2450,21 @@ abstract class MetaModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if $sClass has a lifecycle, which means that it has a state attribute AND stimuli
|
||||||
|
*
|
||||||
|
* @param string $sClass
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
* @throws \CoreException
|
||||||
|
* @since 3.0.0
|
||||||
|
* @see self::HasStateAttributeCode($sClass)
|
||||||
|
*/
|
||||||
|
public static function HasLifecycle(string $sClass)
|
||||||
|
{
|
||||||
|
return self::HasStateAttributeCode($sClass) && !empty(self::EnumStimuli($sClass));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $sClass
|
* @param string $sClass
|
||||||
* @param string $sStateValue
|
* @param string $sStateValue
|
||||||
@@ -2517,17 +2553,13 @@ abstract class MetaModel
|
|||||||
public static function GetAttributeFlags($sClass, $sState, $sAttCode)
|
public static function GetAttributeFlags($sClass, $sState, $sAttCode)
|
||||||
{
|
{
|
||||||
$iFlags = 0; // By default (if no life cycle) no flag at all
|
$iFlags = 0; // By default (if no life cycle) no flag at all
|
||||||
$sStateAttCode = self::GetStateAttributeCode($sClass);
|
if (self::HasLifecycle($sClass)) {
|
||||||
if (!empty($sStateAttCode))
|
|
||||||
{
|
|
||||||
$aStates = MetaModel::EnumStates($sClass);
|
$aStates = MetaModel::EnumStates($sClass);
|
||||||
if (!array_key_exists($sState, $aStates))
|
if (!array_key_exists($sState, $aStates)) {
|
||||||
{
|
|
||||||
throw new CoreException("Invalid state '$sState' for class '$sClass', expecting a value in {".implode(', ', array_keys($aStates))."}");
|
throw new CoreException("Invalid state '$sState' for class '$sClass', expecting a value in {".implode(', ', array_keys($aStates))."}");
|
||||||
}
|
}
|
||||||
$aCurrentState = $aStates[$sState];
|
$aCurrentState = $aStates[$sState];
|
||||||
if ((array_key_exists('attribute_list', $aCurrentState)) && (array_key_exists($sAttCode, $aCurrentState['attribute_list'])))
|
if ((array_key_exists('attribute_list', $aCurrentState)) && (array_key_exists($sAttCode, $aCurrentState['attribute_list']))) {
|
||||||
{
|
|
||||||
$iFlags = $aCurrentState['attribute_list'][$sAttCode];
|
$iFlags = $aCurrentState['attribute_list'][$sAttCode];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2547,18 +2579,14 @@ abstract class MetaModel
|
|||||||
public static function GetTransitionFlags($sClass, $sState, $sStimulus, $sAttCode)
|
public static function GetTransitionFlags($sClass, $sState, $sStimulus, $sAttCode)
|
||||||
{
|
{
|
||||||
$iFlags = 0; // By default (if no lifecycle) no flag at all
|
$iFlags = 0; // By default (if no lifecycle) no flag at all
|
||||||
$sStateAttCode = self::GetStateAttributeCode($sClass);
|
if (self::HasLifecycle($sClass)) {
|
||||||
if (!empty($sStateAttCode))
|
|
||||||
{
|
|
||||||
$aTransitions = MetaModel::EnumTransitions($sClass, $sState);
|
$aTransitions = MetaModel::EnumTransitions($sClass, $sState);
|
||||||
if (!array_key_exists($sStimulus, $aTransitions))
|
if (!array_key_exists($sStimulus, $aTransitions)) {
|
||||||
{
|
|
||||||
throw new CoreException("Invalid transition '$sStimulus' for class '$sClass', expecting a value in {".implode(', ', array_keys($aTransitions))."}");
|
throw new CoreException("Invalid transition '$sStimulus' for class '$sClass', expecting a value in {".implode(', ', array_keys($aTransitions))."}");
|
||||||
}
|
}
|
||||||
|
|
||||||
$aCurrentTransition = $aTransitions[$sStimulus];
|
$aCurrentTransition = $aTransitions[$sStimulus];
|
||||||
if ((array_key_exists('attribute_list', $aCurrentTransition)) && (array_key_exists($sAttCode, $aCurrentTransition['attribute_list'])))
|
if ((array_key_exists('attribute_list', $aCurrentTransition)) && (array_key_exists($sAttCode, $aCurrentTransition['attribute_list']))) {
|
||||||
{
|
|
||||||
$iFlags = $aCurrentTransition['attribute_list'][$sAttCode];
|
$iFlags = $aCurrentTransition['attribute_list'][$sAttCode];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2637,37 +2665,30 @@ abstract class MetaModel
|
|||||||
public static function GetInitialStateAttributeFlags($sClass, $sState, $sAttCode)
|
public static function GetInitialStateAttributeFlags($sClass, $sState, $sAttCode)
|
||||||
{
|
{
|
||||||
$iFlags = self::GetAttributeFlags($sClass, $sState, $sAttCode); // Be default set the same flags as the 'target' state
|
$iFlags = self::GetAttributeFlags($sClass, $sState, $sAttCode); // Be default set the same flags as the 'target' state
|
||||||
$sStateAttCode = self::GetStateAttributeCode($sClass);
|
if (self::HasLifecycle($sClass)) {
|
||||||
if (!empty($sStateAttCode))
|
|
||||||
{
|
|
||||||
$aStates = MetaModel::EnumInitialStates($sClass);
|
$aStates = MetaModel::EnumInitialStates($sClass);
|
||||||
if (array_key_exists($sState, $aStates))
|
if (array_key_exists($sState, $aStates)) {
|
||||||
{
|
|
||||||
$bReadOnly = (($iFlags & OPT_ATT_READONLY) == OPT_ATT_READONLY);
|
$bReadOnly = (($iFlags & OPT_ATT_READONLY) == OPT_ATT_READONLY);
|
||||||
$bHidden = (($iFlags & OPT_ATT_HIDDEN) == OPT_ATT_HIDDEN);
|
$bHidden = (($iFlags & OPT_ATT_HIDDEN) == OPT_ATT_HIDDEN);
|
||||||
foreach($aStates[$sState] as $sPrevState)
|
foreach($aStates[$sState] as $sPrevState) {
|
||||||
{
|
|
||||||
$iPrevFlags = self::GetAttributeFlags($sClass, $sPrevState, $sAttCode);
|
$iPrevFlags = self::GetAttributeFlags($sClass, $sPrevState, $sAttCode);
|
||||||
if (($iPrevFlags & OPT_ATT_HIDDEN) != OPT_ATT_HIDDEN)
|
if (($iPrevFlags & OPT_ATT_HIDDEN) != OPT_ATT_HIDDEN) {
|
||||||
{
|
|
||||||
$bReadOnly = $bReadOnly && (($iPrevFlags & OPT_ATT_READONLY) == OPT_ATT_READONLY); // if it is/was not readonly => then it's not
|
$bReadOnly = $bReadOnly && (($iPrevFlags & OPT_ATT_READONLY) == OPT_ATT_READONLY); // if it is/was not readonly => then it's not
|
||||||
}
|
}
|
||||||
$bHidden = $bHidden && (($iPrevFlags & OPT_ATT_HIDDEN) == OPT_ATT_HIDDEN); // if it is/was not hidden => then it's not
|
$bHidden = $bHidden && (($iPrevFlags & OPT_ATT_HIDDEN) == OPT_ATT_HIDDEN); // if it is/was not hidden => then it's not
|
||||||
}
|
}
|
||||||
if ($bReadOnly)
|
|
||||||
{
|
if ($bReadOnly) {
|
||||||
$iFlags = $iFlags | OPT_ATT_READONLY;
|
$iFlags = $iFlags | OPT_ATT_READONLY;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$iFlags = $iFlags & ~OPT_ATT_READONLY;
|
$iFlags = $iFlags & ~OPT_ATT_READONLY;
|
||||||
}
|
}
|
||||||
if ($bHidden)
|
|
||||||
{
|
if ($bHidden) {
|
||||||
$iFlags = $iFlags | OPT_ATT_HIDDEN;
|
$iFlags = $iFlags | OPT_ATT_HIDDEN;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$iFlags = $iFlags & ~OPT_ATT_HIDDEN;
|
$iFlags = $iFlags & ~OPT_ATT_HIDDEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2877,6 +2898,25 @@ abstract class MetaModel
|
|||||||
}
|
}
|
||||||
self::$m_aClassParams[$sPHPClass]['obsolescence_expression'] = $sObsolescence;
|
self::$m_aClassParams[$sPHPClass]['obsolescence_expression'] = $sObsolescence;
|
||||||
|
|
||||||
|
// Inherit fields semantic
|
||||||
|
// - State attribute
|
||||||
|
$bParentHasStateAttribute = (isset(self::$m_aClassParams[$sParent]['state_attcode']) && !empty(self::$m_aClassParams[$sParent]['state_attcode']));
|
||||||
|
$bHasStateAttribute = (isset(self::$m_aClassParams[$sPHPClass]['state_attcode']) && !empty(self::$m_aClassParams[$sPHPClass]['state_attcode']));
|
||||||
|
if($bParentHasStateAttribute && !$bHasStateAttribute) {
|
||||||
|
// Set attribute code
|
||||||
|
self::$m_aClassParams[$sPHPClass]['state_attcode'] = self::$m_aClassParams[$sParent]['state_attcode'];
|
||||||
|
|
||||||
|
// Set states
|
||||||
|
self::$m_aStates[$sPHPClass] = self::$m_aStates[$sParent];
|
||||||
|
}
|
||||||
|
// - Image attribute
|
||||||
|
$bParentHasImageAttribute = (isset(self::$m_aClassParams[$sParent]['image_attcode']) && !empty(self::$m_aClassParams[$sParent]['image_attcode']));
|
||||||
|
$bHasImageAttribute = (isset(self::$m_aClassParams[$sPHPClass]['image_attcode']) && !empty(self::$m_aClassParams[$sPHPClass]['image_attcode']));
|
||||||
|
if($bParentHasImageAttribute && !$bHasImageAttribute) {
|
||||||
|
// Set attribute code
|
||||||
|
self::$m_aClassParams[$sPHPClass]['image_attcode'] = self::$m_aClassParams[$sParent]['image_attcode'];
|
||||||
|
}
|
||||||
|
|
||||||
foreach(MetaModel::EnumPlugins('iOnClassInitialization') as $sPluginClass => $oClassInit)
|
foreach(MetaModel::EnumPlugins('iOnClassInitialization') as $sPluginClass => $oClassInit)
|
||||||
{
|
{
|
||||||
$oClassInit->OnAfterClassInitialization($sPHPClass);
|
$oClassInit->OnAfterClassInitialization($sPHPClass);
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<attribute id="ref"/>
|
<attribute id="ref"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/change.png</icon>
|
<icon>images/change.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -199,7 +202,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</fields>
|
</fields>
|
||||||
<lifecycle>
|
<lifecycle>
|
||||||
<attribute>status</attribute>
|
|
||||||
<highlight_scale>
|
<highlight_scale>
|
||||||
<item id="approved">
|
<item id="approved">
|
||||||
<rank>1</rank>
|
<rank>1</rank>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<attribute id="ref"/>
|
<attribute id="ref"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/change.png</icon>
|
<icon>images/change.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -160,7 +163,6 @@
|
|||||||
<icon>images/change-closed.png</icon>
|
<icon>images/change-closed.png</icon>
|
||||||
</item>
|
</item>
|
||||||
</highlight_scale>
|
</highlight_scale>
|
||||||
<attribute>status</attribute>
|
|
||||||
<stimuli>
|
<stimuli>
|
||||||
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
||||||
<stimulus id="ev_plan" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_plan" xsi:type="StimulusUserAction"/>
|
||||||
|
|||||||
@@ -256,6 +256,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/server.png</icon>
|
<icon>images/server.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -1516,6 +1519,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/solution.png</icon>
|
<icon>images/solution.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -1657,6 +1663,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/business-process.png</icon>
|
<icon>images/business-process.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -1768,6 +1777,9 @@
|
|||||||
<attribute id="system_name"/>
|
<attribute id="system_name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/application.png</icon>
|
<icon>images/application.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -5972,6 +5984,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/group.png</icon>
|
<icon>images/group.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<attribute id="ref"/>
|
<attribute id="ref"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/incident.png</icon>
|
<icon>images/incident.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -376,7 +379,6 @@
|
|||||||
<icon>images/incident-closed.png</icon>
|
<icon>images/incident-closed.png</icon>
|
||||||
</item>
|
</item>
|
||||||
</highlight_scale>
|
</highlight_scale>
|
||||||
<attribute>status</attribute>
|
|
||||||
<stimuli>
|
<stimuli>
|
||||||
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
||||||
<stimulus id="ev_reassign" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_reassign" xsi:type="StimulusUserAction"/>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<attribute id="ref"/>
|
<attribute id="ref"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/problem.png</icon>
|
<icon>images/problem.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -160,7 +163,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</fields>
|
</fields>
|
||||||
<lifecycle>
|
<lifecycle>
|
||||||
<attribute>status</attribute>
|
|
||||||
<stimuli>
|
<stimuli>
|
||||||
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
||||||
<stimulus id="ev_reassign" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_reassign" xsi:type="StimulusUserAction"/>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<attribute id="ref"/>
|
<attribute id="ref"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/user-request.png</icon>
|
<icon>images/user-request.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -408,7 +411,6 @@
|
|||||||
<icon>images/user-request-closed.png</icon>
|
<icon>images/user-request-closed.png</icon>
|
||||||
</item>
|
</item>
|
||||||
</highlight_scale>
|
</highlight_scale>
|
||||||
<attribute>status</attribute>
|
|
||||||
<stimuli>
|
<stimuli>
|
||||||
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
||||||
<stimulus id="ev_reassign" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_reassign" xsi:type="StimulusUserAction"/>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<attribute id="ref"/>
|
<attribute id="ref"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/user-request.png</icon>
|
<icon>images/user-request.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -412,7 +415,6 @@
|
|||||||
<icon>images/user-request-closed.png</icon>
|
<icon>images/user-request-closed.png</icon>
|
||||||
</item>
|
</item>
|
||||||
</highlight_scale>
|
</highlight_scale>
|
||||||
<attribute>status</attribute>
|
|
||||||
<stimuli>
|
<stimuli>
|
||||||
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
|
||||||
<stimulus id="ev_reassign" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_reassign" xsi:type="StimulusUserAction"/>
|
||||||
|
|||||||
@@ -60,6 +60,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/contract.png</icon>
|
<icon>images/contract.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -984,9 +987,9 @@ public function PrefillSearchForm(&$aContextParam)
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
<semantic>
|
<fields_semantic>
|
||||||
<image_attribute>icon</image_attribute>
|
<image_attribute>icon</image_attribute>
|
||||||
</semantic>
|
</fields_semantic>
|
||||||
<icon>images/service.png</icon>
|
<icon>images/service.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -1069,9 +1072,10 @@ public function PrefillSearchForm(&$aContextParam)
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
<semantic>
|
<fields_semantic>
|
||||||
<image_attribute>icon</image_attribute>
|
<image_attribute>icon</image_attribute>
|
||||||
</semantic>
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/service.png</icon>
|
<icon>images/service.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -1421,6 +1425,9 @@ public function PrefillSearchForm(&$aContextParam)
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/service.png</icon>
|
<icon>images/service.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
|||||||
@@ -60,6 +60,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/contract.png</icon>
|
<icon>images/contract.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -876,9 +879,9 @@ public function PrefillSearchForm(&$aContextParam)
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
<semantic>
|
<fields_semantic>
|
||||||
<image_attribute>icon</image_attribute>
|
<image_attribute>icon</image_attribute>
|
||||||
</semantic>
|
</fields_semantic>
|
||||||
<icon>images/service.png</icon>
|
<icon>images/service.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -961,9 +964,10 @@ public function PrefillSearchForm(&$aContextParam)
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
<semantic>
|
<fields_semantic>
|
||||||
<image_attribute>icon</image_attribute>
|
<image_attribute>icon</image_attribute>
|
||||||
</semantic>
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/service.png</icon>
|
<icon>images/service.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -1335,6 +1339,9 @@ public function PrefillSearchForm(&$aContextParam)
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/service.png</icon>
|
<icon>images/service.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/building.png</icon>
|
<icon>images/building.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -181,6 +184,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/location.png</icon>
|
<icon>images/location.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -347,6 +353,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/team.png</icon>
|
<icon>images/team.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -514,9 +523,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
<semantic>
|
<fields_semantic>
|
||||||
<image_attribute>picture</image_attribute>
|
<image_attribute>picture</image_attribute>
|
||||||
</semantic>
|
</fields_semantic>
|
||||||
<icon>images/person.png</icon>
|
<icon>images/person.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -1099,6 +1108,9 @@
|
|||||||
<naming>
|
<naming>
|
||||||
<attributes/>
|
<attributes/>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/document.png</icon>
|
<icon>images/document.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
|||||||
@@ -475,6 +475,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon>images/workorder.png</icon>
|
<icon>images/workorder.png</icon>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
@@ -557,7 +560,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</fields>
|
</fields>
|
||||||
<lifecycle>
|
<lifecycle>
|
||||||
<attribute>status</attribute>
|
|
||||||
<stimuli>
|
<stimuli>
|
||||||
<stimulus id="ev_close" xsi:type="StimulusUserAction"/>
|
<stimulus id="ev_close" xsi:type="StimulusUserAction"/>
|
||||||
</stimuli>
|
</stimuli>
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
<attribute id="name"/>
|
<attribute id="name"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</naming>
|
</naming>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>status</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
<icon/>
|
<icon/>
|
||||||
<reconciliation>
|
<reconciliation>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
|||||||
@@ -1225,9 +1225,9 @@ HTML
|
|||||||
{
|
{
|
||||||
/** @var \cmdbAbstractObject $oObj */
|
/** @var \cmdbAbstractObject $oObj */
|
||||||
$oObj = MetaModel::NewObject($sClass);
|
$oObj = MetaModel::NewObject($sClass);
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
if (MetaModel::HasLifecycle($sClass))
|
||||||
if (!empty($sStateAttCode))
|
|
||||||
{
|
{
|
||||||
|
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
||||||
$sTargetState = utils::ReadPostedParam('obj_state', '');
|
$sTargetState = utils::ReadPostedParam('obj_state', '');
|
||||||
if ($sTargetState != '')
|
if ($sTargetState != '')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ function GraphvizEscape($s)
|
|||||||
function GraphvizLifecycle($sClass)
|
function GraphvizLifecycle($sClass)
|
||||||
{
|
{
|
||||||
$sDotFileContent = "";
|
$sDotFileContent = "";
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
if (!MetaModel::HasLifecycle($sClass))
|
||||||
if (empty($sStateAttCode))
|
|
||||||
{
|
{
|
||||||
//$oPage->p("no lifecycle for this class");
|
//$oPage->p("no lifecycle for this class");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ function DisplaySubclasses($oPage, $sClass, $sContext)
|
|||||||
*/
|
*/
|
||||||
function DisplayLifecycle($oPage, $sClass)
|
function DisplayLifecycle($oPage, $sClass)
|
||||||
{
|
{
|
||||||
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
if (!MetaModel::HasLifecycle($sClass))
|
||||||
if (empty($sStateAttCode))
|
|
||||||
{
|
{
|
||||||
$oPage->p(Dict::S('UI:Schema:NoLifeCyle'));
|
$oPage->p(Dict::S('UI:Schema:NoLifeCyle'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1029,31 +1029,24 @@ EOF
|
|||||||
// - Default attributes code
|
// - Default attributes code
|
||||||
$sImageAttCode = "";
|
$sImageAttCode = "";
|
||||||
$sStateAttCode = "";
|
$sStateAttCode = "";
|
||||||
// - Parse optional semantic node
|
// - Parse optional fields semantic node
|
||||||
$oSemantic = $oProperties->GetOptionalElement('semantic');
|
$oFieldsSemantic = $oProperties->GetOptionalElement('fields_semantic');
|
||||||
if ($oSemantic) {
|
if ($oFieldsSemantic) {
|
||||||
// Image attribute
|
// Image attribute
|
||||||
$oImageAttribute = $oSemantic->GetOptionalElement('image_attribute');
|
$oImageAttribute = $oFieldsSemantic->GetOptionalElement('image_attribute');
|
||||||
if ($oImageAttribute) {
|
if ($oImageAttribute) {
|
||||||
$sImageAttCode = $oImageAttribute->GetText();
|
$sImageAttCode = $oImageAttribute->GetText();
|
||||||
}
|
}
|
||||||
|
|
||||||
// State attribute, only if not already found from lifecycle
|
// State attribute (for XML v1.7- the lifecycle/attribute node should have been migrated in this one)
|
||||||
// $oStateAttribute = $oSemantic->GetOptionalElement('state_attribute');
|
$oStateAttribute = $oFieldsSemantic->GetOptionalElement('state_attribute');
|
||||||
// if(empty($sStateAttCode) && $oStateAttribute) {
|
if($oStateAttribute) {
|
||||||
// $sStateAttCode = $oStateAttribute->GetText();
|
$sStateAttCode = $oStateAttribute->GetText();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
$aClassParams['image_attcode'] = "'$sImageAttCode'";
|
$aClassParams['image_attcode'] = "'$sImageAttCode'";
|
||||||
$aClassParams['state_attcode'] = "'$sStateAttCode'";
|
$aClassParams['state_attcode'] = "'$sStateAttCode'";
|
||||||
|
|
||||||
// Lifecycle (overload any state attribute defined in the semantic node)
|
|
||||||
$oLifecycle = $oClass->GetOptionalElement('lifecycle');
|
|
||||||
if ($oLifecycle) {
|
|
||||||
$sStateAttCode = $oLifecycle->GetChildText('attribute');
|
|
||||||
$aClassParams['state_attcode'] = "'$sStateAttCode'";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reconcialiation
|
// Reconcialiation
|
||||||
if ($oReconciliation = $oProperties->GetOptionalElement('reconciliation'))
|
if ($oReconciliation = $oProperties->GetOptionalElement('reconciliation'))
|
||||||
{
|
{
|
||||||
@@ -1641,8 +1634,8 @@ EOF
|
|||||||
//
|
//
|
||||||
$sLifecycle = '';
|
$sLifecycle = '';
|
||||||
$sHighlightScale = '';
|
$sHighlightScale = '';
|
||||||
if ($oLifecycle)
|
$oLifecycle = $oClass->GetOptionalElement('lifecycle');
|
||||||
{
|
if ($oLifecycle) {
|
||||||
$sLifecycle .= "\t\t// Lifecycle (status attribute: $sStateAttCode)\n";
|
$sLifecycle .= "\t\t// Lifecycle (status attribute: $sStateAttCode)\n";
|
||||||
$sLifecycle .= "\t\t//\n";
|
$sLifecycle .= "\t\t//\n";
|
||||||
|
|
||||||
@@ -1869,6 +1862,26 @@ EOF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// No "real" lifecycle with stimuli and such but still a state attribute, we need to define states from the enum. values
|
||||||
|
elseif ($oFieldsSemantic && $oStateAttribute) {
|
||||||
|
$sLifecycle .= "\t\t// States but no lifecycle declared in XML (status attribute: $sStateAttCode)\n";
|
||||||
|
$sLifecycle .= "\t\t//\n";
|
||||||
|
|
||||||
|
// Note: We can't use ModelFactory::GetField() as the current clas doesn't seem to be loaded yet.
|
||||||
|
$oField = $this->oFactory->GetNodes('field[@id="'.$sStateAttCode.'"]', $oFields)->item(0);
|
||||||
|
$oValues = $oField->GetUniqueElement('values');
|
||||||
|
$oValueNodes = $oValues->getElementsByTagName('value');
|
||||||
|
foreach($oValueNodes as $oValue)
|
||||||
|
{
|
||||||
|
$sLifecycle .= " MetaModel::Init_DefineState(\n";
|
||||||
|
$sLifecycle .= " \"".$oValue->GetText()."\",\n";
|
||||||
|
$sLifecycle .= " array(\n";
|
||||||
|
$sLifecycle .= " \"attribute_inherit\" => '',\n";
|
||||||
|
$sLifecycle .= " \"attribute_list\" => array()\n";
|
||||||
|
$sLifecycle .= " )\n";
|
||||||
|
$sLifecycle .= " );\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ZLists
|
// ZLists
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class iTopDesignFormat
|
|||||||
'go_to_previous' => 'From18To17',
|
'go_to_previous' => 'From18To17',
|
||||||
'next' => null,
|
'next' => null,
|
||||||
'go_to_next' => null,
|
'go_to_next' => null,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -768,9 +768,35 @@ class iTopDesignFormat
|
|||||||
*/
|
*/
|
||||||
protected function From17To18($oFactory)
|
protected function From17To18($oFactory)
|
||||||
{
|
{
|
||||||
|
$oXPath = new DOMXPath($this->oDocument);
|
||||||
|
|
||||||
// N°3233 - Remove "display template" feature from MetaModel
|
// N°3233 - Remove "display template" feature from MetaModel
|
||||||
$sPath = "/itop_design//class/properties/display_template";
|
$sPath = "/itop_design//class/properties/display_template";
|
||||||
$this->RemoveNodeFromXPath($sPath);
|
$this->RemoveNodeFromXPath($sPath);
|
||||||
|
|
||||||
|
// N°3203 - Datamodel: Add semantic for image & state attributes
|
||||||
|
// - Move lifecycle attribute declaration to the semantic node
|
||||||
|
$oNodeList = $oXPath->query("/itop_design//class/lifecycle/attribute");
|
||||||
|
/** @var \DOMElement $oNode */
|
||||||
|
foreach ($oNodeList as $oNode) {
|
||||||
|
// Find semantic node or create it
|
||||||
|
$oPropertiesNode = $oXPath->query("../../properties", $oNode)->item(0);
|
||||||
|
$oFieldsSemanticNodeList = $oXPath->query("fields_semantic", $oPropertiesNode);
|
||||||
|
if ($oFieldsSemanticNodeList->length > 0) {
|
||||||
|
$oSemanticNode = $oFieldsSemanticNodeList->item(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$oSemanticNode = $oPropertiesNode->ownerDocument->createElement("fields_semantic");
|
||||||
|
$oPropertiesNode->appendChild($oSemanticNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create state_attribute node
|
||||||
|
$oStateNode = $oSemanticNode->ownerDocument->createElement("state_attribute", $oNode->nodeValue);
|
||||||
|
$oSemanticNode->appendChild($oStateNode);
|
||||||
|
|
||||||
|
// Remove current node from lifecycle
|
||||||
|
$this->DeleteNode($oNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -780,6 +806,8 @@ class iTopDesignFormat
|
|||||||
*/
|
*/
|
||||||
protected function From18To17($oFactory)
|
protected function From18To17($oFactory)
|
||||||
{
|
{
|
||||||
|
$oXPath = new DOMXPath($this->oDocument);
|
||||||
|
|
||||||
// N°3182 - Remove style node from MenuGroup
|
// N°3182 - Remove style node from MenuGroup
|
||||||
$sPath = "/itop_design/menus/menu[@xsi:type='MenuGroup']/style";
|
$sPath = "/itop_design/menus/menu[@xsi:type='MenuGroup']/style";
|
||||||
$this->RemoveNodeFromXPath($sPath);
|
$this->RemoveNodeFromXPath($sPath);
|
||||||
@@ -791,6 +819,27 @@ class iTopDesignFormat
|
|||||||
// N°2982 - Speed up SCSS themes compilation during setup
|
// N°2982 - Speed up SCSS themes compilation during setup
|
||||||
$sPath = "/itop_design/branding/themes/theme/precompiled_stylesheet";
|
$sPath = "/itop_design/branding/themes/theme/precompiled_stylesheet";
|
||||||
$this->RemoveNodeFromXPath($sPath);
|
$this->RemoveNodeFromXPath($sPath);
|
||||||
|
|
||||||
|
// N°3203 - Datamodel: Add semantic for image & state attributes
|
||||||
|
// - Move state_attribute back to the lifecycle node if it has one
|
||||||
|
$oNodeList = $oXPath->query("/itop_design//class/properties/fields_semantic/state_attribute");
|
||||||
|
/** @var \DOMElement $oNode */
|
||||||
|
foreach ($oNodeList as $oNode) {
|
||||||
|
// Move node under lifecycle only if there is such a node
|
||||||
|
$oLifecycleNode = $oXPath->query("../../../lifecycle", $oNode)->item(0);
|
||||||
|
if($oLifecycleNode !== null)
|
||||||
|
{
|
||||||
|
// Create attribute node
|
||||||
|
$oAttributeNode = $oLifecycleNode->ownerDocument->createElement("attribute", $oNode->nodeValue);
|
||||||
|
$oLifecycleNode->appendChild($oAttributeNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove current node from semantic in all cases
|
||||||
|
$this->DeleteNode($oNode);
|
||||||
|
}
|
||||||
|
// - Remove semantic node
|
||||||
|
$sPath = "/itop_design//class/properties/fields_semantic";
|
||||||
|
$this->RemoveNodeFromXPath($sPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ class TitleFactory
|
|||||||
$oTitle->SetIcon($sObjIconUrl, $sIconCoverMethod);
|
$oTitle->SetIcon($sObjIconUrl, $sIconCoverMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sStatusAttCode = MetaModel::GetStateAttributeCode($sObjClass);
|
if (MetaModel::HasStateAttributeCode($sObjClass)) {
|
||||||
if (!empty($sStatusAttCode)) {
|
$sStatusAttCode = MetaModel::GetStateAttributeCode($sObjClass);
|
||||||
$sStateCode = $oObject->GetState();
|
$sStateCode = $oObject->GetState();
|
||||||
$sStatusLabel = $oObject->GetStateLabel();
|
$sStatusLabel = $oObject->GetStateLabel();
|
||||||
$sStatusColor = UIHelper::GetColorFromStatus(get_class($oObject), $sStateCode);
|
$sStatusColor = UIHelper::GetColorFromStatus(get_class($oObject), $sStateCode);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class CMDBChangeOpSetAttributeScalarFactory extends CMDBChangeOpSetAttributeFact
|
|||||||
$sAttCode = $oChangeOp->Get('attcode');
|
$sAttCode = $oChangeOp->Get('attcode');
|
||||||
|
|
||||||
// Specific ActivityEntry for transition, otherwise just a regular EditsEntry
|
// Specific ActivityEntry for transition, otherwise just a regular EditsEntry
|
||||||
if($sAttCode === MetaModel::GetStateAttributeCode($sHostObjectClass))
|
if(MetaModel::HasLifecycle($sHostObjectClass) && ($sAttCode === MetaModel::GetStateAttributeCode($sHostObjectClass)))
|
||||||
{
|
{
|
||||||
$oDateTime = DateTime::createFromFormat(AttributeDateTime::GetInternalFormat(), $oChangeOp->Get('date'));
|
$oDateTime = DateTime::createFromFormat(AttributeDateTime::GetInternalFormat(), $oChangeOp->Get('date'));
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ class ObjectDetails extends Panel
|
|||||||
$this->sName = $oObject->GetRawName();
|
$this->sName = $oObject->GetRawName();
|
||||||
$this->sIconUrl = $oObject->GetIcon(false);
|
$this->sIconUrl = $oObject->GetIcon(false);
|
||||||
|
|
||||||
$sStatusAttCode = MetaModel::GetStateAttributeCode($this->sClassName);
|
if(MetaModel::HasStateAttributeCode($this->sClassName)) {
|
||||||
if(!empty($sStatusAttCode)) {
|
|
||||||
$this->sStatusCode = $oObject->GetState();
|
$this->sStatusCode = $oObject->GetState();
|
||||||
$this->sStatusLabel = $oObject->GetStateLabel();
|
$this->sStatusLabel = $oObject->GetStateLabel();
|
||||||
$this->sStatusColor = UIHelper::GetColorFromStatus($this->sClassName, $this->sStatusCode);
|
$this->sStatusColor = UIHelper::GetColorFromStatus($this->sClassName, $this->sStatusCode);
|
||||||
|
|||||||
14
test/setup/iTopDesignFormat/1.7_to_1.8.expected.xml
Normal file
14
test/setup/iTopDesignFormat/1.7_to_1.8.expected.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.8">
|
||||||
|
<classes>
|
||||||
|
<class id="ClassWithLifecycle">
|
||||||
|
<properties>
|
||||||
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>foo</state_attribute>
|
||||||
|
</fields_semantic>
|
||||||
|
</properties>
|
||||||
|
<lifecycle/>
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
</itop_design>
|
||||||
13
test/setup/iTopDesignFormat/1.7_to_1.8.input.xml
Normal file
13
test/setup/iTopDesignFormat/1.7_to_1.8.input.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
|
||||||
|
<classes>
|
||||||
|
<class id="ClassWithLifecycle">
|
||||||
|
<properties>
|
||||||
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
|
</properties>
|
||||||
|
<lifecycle>
|
||||||
|
<attribute>foo</attribute>
|
||||||
|
</lifecycle>
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
</itop_design>
|
||||||
@@ -1,5 +1,30 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
|
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
|
||||||
|
<classes>
|
||||||
|
<class id="ClassWithStateButNoLifecycle">
|
||||||
|
<properties>
|
||||||
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
|
</properties>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithStateAndLifecycle">
|
||||||
|
<properties>
|
||||||
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
|
</properties>
|
||||||
|
<lifecycle>
|
||||||
|
<attribute>foo</attribute>
|
||||||
|
</lifecycle>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithStateAndImage">
|
||||||
|
<properties>
|
||||||
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
|
</properties>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithImageOnly">
|
||||||
|
<properties>
|
||||||
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
|
</properties>
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
<menus>
|
<menus>
|
||||||
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
|
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
|
||||||
<rank>100</rank>
|
<rank>100</rank>
|
||||||
|
|||||||
@@ -1,22 +1,58 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.8">
|
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.8">
|
||||||
<menus>
|
<classes>
|
||||||
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
|
<class id="ClassWithStateButNoLifecycle">
|
||||||
<rank>100</rank>
|
<properties>
|
||||||
<parent>WelcomeMenu</parent>
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
<url>$$http://fr.wikipedia.org/</url>
|
<fields_semantic>
|
||||||
<in_new_window>true</in_new_window>
|
<state_attribute>foo</state_attribute>
|
||||||
</menu>
|
</fields_semantic>
|
||||||
<menu id="RequestManagement" xsi:type="MenuGroup" _delta="define">
|
</properties>
|
||||||
<rank>30</rank>
|
</class>
|
||||||
<enable_stimulus/>
|
<class id="ClassWithStateAndLifecycle">
|
||||||
<style>
|
<properties>
|
||||||
<decoration_classes>fas fa-comment-alt</decoration_classes>
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
</style>
|
<fields_semantic>
|
||||||
</menu>
|
<state_attribute>foo</state_attribute>
|
||||||
</menus>
|
</fields_semantic>
|
||||||
<branding>
|
</properties>
|
||||||
<main_logo _delta="define">images/itop-logo.png</main_logo>
|
<lifecycle/>
|
||||||
<main_logo_compact _delta="define">images/itop-logo-square.png</main_logo_compact>
|
</class>
|
||||||
</branding>
|
<class id="ClassWithStateAndImage">
|
||||||
|
<properties>
|
||||||
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
|
<fields_semantic>
|
||||||
|
<state_attribute>foo</state_attribute>
|
||||||
|
<image_attribute>bar</image_attribute>
|
||||||
|
</fields_semantic>
|
||||||
|
</properties>
|
||||||
|
</class>
|
||||||
|
<class id="ClassWithImageOnly">
|
||||||
|
<properties>
|
||||||
|
<icon>images/class-with-lifecycle.png</icon>
|
||||||
|
<fields_semantic>
|
||||||
|
<image_attribute>bar</image_attribute>
|
||||||
|
</fields_semantic>
|
||||||
|
</properties>
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
<menus>
|
||||||
|
<menu id="WelcomeMenuLink1" xsi:type="WebPageMenuNode" _delta="define">
|
||||||
|
<rank>100</rank>
|
||||||
|
<parent>WelcomeMenu</parent>
|
||||||
|
<url>$$http://fr.wikipedia.org/</url>
|
||||||
|
<in_new_window>true</in_new_window>
|
||||||
|
</menu>
|
||||||
|
<menu id="RequestManagement" xsi:type="MenuGroup" _delta="define">
|
||||||
|
<rank>30</rank>
|
||||||
|
<enable_stimulus/>
|
||||||
|
<style>
|
||||||
|
<decoration_classes>fas fa-comment-alt</decoration_classes>
|
||||||
|
</style>
|
||||||
|
</menu>
|
||||||
|
</menus>
|
||||||
|
<branding>
|
||||||
|
<main_logo _delta="define">images/itop-logo.png</main_logo>
|
||||||
|
<main_logo_compact _delta="define">images/itop-logo-square.png</main_logo_compact>
|
||||||
|
</branding>
|
||||||
</itop_design>
|
</itop_design>
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class TestForITopDesignFormatClass extends ItopTestCase
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'1.7 to 1.6' => array('1.6', '1.7_to_1.6.input', '1.7_to_1.6.expected'),
|
'1.7 to 1.6' => array('1.6', '1.7_to_1.6.input', '1.7_to_1.6.expected'),
|
||||||
|
'1.7 to 1.8' => array('1.8', '1.7_to_1.8.input', '1.7_to_1.8.expected'),
|
||||||
'1.8 to 1.7' => array('1.7', '1.8_to_1.7.input', '1.8_to_1.7.expected'),
|
'1.8 to 1.7' => array('1.7', '1.8_to_1.7.input', '1.8_to_1.7.expected'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user