diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php
index 929c92778..5e9066840 100644
--- a/addons/userrights/userrightsprofile.class.inc.php
+++ b/addons/userrights/userrightsprofile.class.inc.php
@@ -153,27 +153,29 @@ class URP_Users extends UserRightsBaseClass
$oPage->table($aDisplayConfig, $aDisplayData);
}
- function DisplayBareRelations(WebPage $oPage)
+ function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
- parent::DisplayBareRelations($oPage);
-
- $oPage->SetCurrentTab(Dict::S('UI:UserManagement:GrantMatrix'));
- $this->DoShowGrantSumary($oPage, 'bizmodel');
-
- // debug
- if (false)
+ parent::DisplayBareRelations($oPage, $bEditMode);
+ if (!$bEditMode)
{
- $oPage->SetCurrentTab('More on user rigths (dev only)');
- $oPage->add("
User rights
\n");
- $this->DoShowGrantSumary($oPage, 'addon/userrights');
- $oPage->add("Change log
\n");
- $this->DoShowGrantSumary($oPage, 'core/cmdb');
- $oPage->add("Application
\n");
- $this->DoShowGrantSumary($oPage, 'application');
- $oPage->add("GUI
\n");
- $this->DoShowGrantSumary($oPage, 'gui');
-
- }
+ $oPage->SetCurrentTab(Dict::S('UI:UserManagement:GrantMatrix'));
+ $this->DoShowGrantSumary($oPage, 'bizmodel');
+
+ // debug
+ if (false)
+ {
+ $oPage->SetCurrentTab('More on user rigths (dev only)');
+ $oPage->add("User rights
\n");
+ $this->DoShowGrantSumary($oPage, 'addon/userrights');
+ $oPage->add("Change log
\n");
+ $this->DoShowGrantSumary($oPage, 'core/cmdb');
+ $oPage->add("Application
\n");
+ $this->DoShowGrantSumary($oPage, 'application');
+ $oPage->add("GUI
\n");
+ $this->DoShowGrantSumary($oPage, 'gui');
+
+ }
+ }
}
}
@@ -272,12 +274,14 @@ class URP_Profiles extends UserRightsBaseClass
$oPage->table($aDisplayConfig, $aDisplayData);
}
- function DisplayBareRelations(WebPage $oPage)
+ function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
parent::DisplayBareRelations($oPage);
-
- $oPage->SetCurrentTab(Dict::S('UI:UserManagement:GrantMatrix'));
- $this->DoShowGrantSumary($oPage);
+ if (!$bEditMode)
+ {
+ $oPage->SetCurrentTab(Dict::S('UI:UserManagement:GrantMatrix'));
+ $this->DoShowGrantSumary($oPage);
+ }
}
}
diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php
index e32276e33..1d04420b6 100644
--- a/application/cmdbabstract.class.inc.php
+++ b/application/cmdbabstract.class.inc.php
@@ -33,6 +33,7 @@ require_once('../application/ui.linkswidget.class.inc.php');
abstract class cmdbAbstractObject extends CMDBObject
{
+ protected $m_iFormId; // The ID of the form used to edit the object (when in edition mode !)
public static function GetUIPage()
{
@@ -99,7 +100,7 @@ abstract class cmdbAbstractObject extends CMDBObject
return "GetForLink()."\" title=\"$sHint\">$sLabel";
}
- function DisplayBareHeader(WebPage $oPage)
+ function DisplayBareHeader(WebPage $oPage, $bEditMode = false)
{
// Standard Header with name, actions menu and history block
//
@@ -114,7 +115,7 @@ abstract class cmdbAbstractObject extends CMDBObject
$oPage->add("\n");
}
- function DisplayBareHistory(WebPage $oPage)
+ function DisplayBareHistory(WebPage $oPage, $bEditMode = false)
{
// history block (with as a tab)
$oHistoryFilter = new DBObjectSearch('CMDBChangeOp');
@@ -124,24 +125,64 @@ abstract class cmdbAbstractObject extends CMDBObject
$oBlock->Display($oPage, -1);
}
- function DisplayBareProperties(WebPage $oPage)
+ function DisplayBareProperties(WebPage $oPage, $bEditMode = false)
{
- $oPage->add($this->GetBareProperties($oPage));
+ $oPage->add($this->GetBareProperties($oPage, $bEditMode));
}
- function DisplayBareRelations(WebPage $oPage)
+ function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
// Related objects: display all the linkset attributes, each as a separate tab
- // First in the order described by the 'display' ZList, then the remaining ones
+ // In the order described by the 'display' ZList
$aList = $this->FlattenZList(MetaModel::GetZListItems(get_class($this), 'details'));
- $aList = array_unique(array_merge($aList, array_keys(MetaModel::ListAttributeDefs(get_class($this)))));
+ if (count($aList) == 0)
+ {
+ // Empty ZList defined, display all the linkedset attributes defined
+ $aList = array_keys(MetaModel::ListAttributeDefs(get_class($this)));
+ }
foreach($aList as $sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
- if ($oAttDef->IsLinkset())
+ // Display mode
+ if (!$oAttDef->IsLinkset()) continue; // Process only linkset attributes...
+
+ $oPage->SetCurrentTab($oAttDef->GetLabel());
+ if ($bEditMode)
{
- $oPage->SetCurrentTab($oAttDef->GetLabel());
-
+ $iFlags = $this->GetAttributeFlags($sAttCode);
+ $sClass = get_class($this);
+ if (get_class($oAttDef) == 'AttributeLinkedSet')
+ {
+ // 1:n links
+ $sTargetClass = $oAttDef->GetLinkedClass();
+ $oPage->p("
".$oAttDef->GetDescription());
+
+ $oFilter = new DBObjectSearch($sTargetClass);
+ $oFilter->AddCondition($oAttDef->GetExtKeyToMe(), $this->GetKey());
+
+ $oBlock = new DisplayBlock($oFilter, 'list', false);
+ $oBlock->Display($oPage, 0);
+ }
+ else // get_class($oAttDef) == 'AttributeLinkedSetIndirect'
+ {
+ // n:n links
+ $sLinkedClass = $oAttDef->GetLinkedClass();
+ $oLinkingAttDef = MetaModel::GetAttributeDef($sLinkedClass, $oAttDef->GetExtKeyToRemote());
+ $sTargetClass = $oLinkingAttDef->GetTargetClass();
+ $oPage->p("
".$oAttDef->GetDescription());
+
+ $sValue = $this->Get($sAttCode);
+ $sDisplayValue = $this->GetEditValue($sAttCode);
+ $aArgs = array('this' => $this);
+ $sInputId = $this->m_iFormId.'_'.$sAttCode;
+ $sHTMLValue = "".self::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $sValue, $sDisplayValue, $sInputId, '', $iFlags, $aArgs).'';
+ $aFieldsMap[$sAttCode] = $sInputId;
+ $oPage->add($sHTMLValue);
+ }
+ }
+ else
+ {
+ // Display mode
if (!$oAttDef->IsIndirect())
{
// 1:n links
@@ -176,7 +217,7 @@ abstract class cmdbAbstractObject extends CMDBObject
$oPage->SetCurrentTab('');
}
- function GetBareProperties(WebPage $oPage)
+ function GetBareProperties(WebPage $oPage, $bEditMode = false)
{
$sHtml = '';
$oAppContext = new ApplicationContext();
@@ -223,7 +264,7 @@ abstract class cmdbAbstractObject extends CMDBObject
}
- function DisplayDetails(WebPage $oPage)
+ function DisplayDetails(WebPage $oPage, $bEditMode = false)
{
$sTemplate = Utils::ReadFromFile(MetaModel::GetDisplayTemplate(get_class($this)));
if (!empty($sTemplate))
@@ -238,14 +279,14 @@ abstract class cmdbAbstractObject extends CMDBObject
{
// Object's details
// template not found display the object using the *old style*
- $this->DisplayBareHeader($oPage);
+ $this->DisplayBareHeader($oPage, $bEditMode);
$oPage->AddTabContainer(OBJECT_PROPERTIES_TAB);
$oPage->SetCurrentTabContainer(OBJECT_PROPERTIES_TAB);
$oPage->SetCurrentTab(Dict::S('UI:PropertiesTab'));
- $this->DisplayBareProperties($oPage);
- $this->DisplayBareRelations($oPage);
+ $this->DisplayBareProperties($oPage, $bEditMode);
+ $this->DisplayBareRelations($oPage, $bEditMode);
$oPage->SetCurrentTab(Dict::S('UI:HistoryTab'));
- $this->DisplayBareHistory($oPage);
+ $this->DisplayBareHistory($oPage, $bEditMode);
}
}
@@ -990,28 +1031,29 @@ abstract class cmdbAbstractObject extends CMDBObject
public function DisplayModifyForm(WebPage $oPage, $aExtraParams = array())
{
- static $iFormId = 0;
- $iFormId++;
+ static $iGlobalFormId = 0;
+ $iGlobalFormId++;
+ $this->m_iFormId = $iGlobalFormId;
$sClass = get_class($this);
$oAppContext = new ApplicationContext();
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
$iKey = $this->GetKey();
$aDetails = array();
$aFieldsMap = array();
- $oPage->add("