diff --git a/application/application.inc.php b/application/application.inc.php index 86f381396..d15464c19 100644 --- a/application/application.inc.php +++ b/application/application.inc.php @@ -9,4 +9,8 @@ require_once('../application/audit.category.class.inc.php'); require_once('../application/audit.rule.class.inc.php'); //require_once('../application/menunode.class.inc.php'); require_once('../application/utils.inc.php'); + +class ApplicationException extends CoreException +{ +} ?> diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index f95a03eab..59dd5a48b 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -51,6 +51,12 @@ abstract class cmdbAbstractObject extends CMDBObject $sHint = htmlentities("$sObjClass::$sObjKey"); return "GetForLink()."\" title=\"$sHint\">$sLabel"; } + + public function GetHyperlink() + { + $aAvailableFields[MetaModel::GetNameAttributeCode(get_class($this))] = $this->GetName(); + return $this->MakeHyperLink(get_class($this), $this->GetKey(), $aAvailableFields); + } public function GetDisplayValue($sAttCode) { @@ -213,13 +219,37 @@ abstract class cmdbAbstractObject extends CMDBObject // Comment by Rom: this helper may be used to display objects of class DBObject // -> I am using this to display the changes history - public static function DisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true) + public static function DisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true, $bSelectMode = false, $iObjectId = 0) { - $oPage->add(self::GetDisplaySet($oPage, $oSet, $sLinkageAttribute, $bDisplayMenu)); + $oPage->add(self::GetDisplaySet($oPage, $oSet, array( 'link_attr' => $sLinkageAttribute, 'object_id' => $iObjectId, 'menu' => $bDisplayMenu, 'selection_mode' => $bSelectMode))); } - public static function GetDisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true) + //public static function GetDisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true, $bSelectMode = false) + public static function GetDisplaySet(web_page $oPage, CMDBObjectSet $oSet, $aExtraParams = array()) { + static $iListId = 0; + $iListId++; + + // Initialize and check the parameters + $sLinkageAttribute = isset($aExtraParams['link_attr']) ? $aExtraParams['link_attr'] : ''; + $iLinkedObjectId = isset($aExtraParams['object_id']) ? $aExtraParams['object_id'] : 0; + $sTargetAttr = isset($aExtraParams['target_attr']) ? $aExtraParams['target_attr'] : ''; + if (!empty($sLinkageAttribute)) + { + if($iLinkedObjectId == 0) + { + // if 'links' mode is requested the d of the object to link to must be specified + throw new ApplicationException("Parameter object_id is mandatory when link_attr is specified. Check the definition of the display template."); + } + if($sTargetAttr == '') + { + // if 'links' mode is requested the d of the object to link to must be specified + throw new ApplicationException("Parameter target_attr is mandatory when link_attr is specified. Check the definition of the display template."); + } + } + $bDisplayMenu = isset($aExtraParams['menu']) ? $aExtraParams['menu'] == true : true; + $bSelectMode = isset($aExtraParams['selection_mode']) ? $aExtraParams['selection_mode'] == true : false; + $sHtml = ''; $oAppContext = new ApplicationContext(); $sClassName = $oSet->GetFilter()->GetClass(); @@ -260,6 +290,10 @@ abstract class cmdbAbstractObject extends CMDBObject } foreach($aList as $sAttCode) { + if ($bSelectMode) + { + $aAttribs['form::select'] = array('label' => "", 'description' => 'Select / Deselect All'); + } $aAttribs['key'] = array('label' => '', 'description' => 'Click to display'); $aAttribs[$sAttCode] = array('label' => MetaModel::GetLabel($sClassName, $sAttCode), 'description' => MetaModel::GetDescription($sClassName, $sAttCode)); } @@ -267,6 +301,11 @@ abstract class cmdbAbstractObject extends CMDBObject $oSet->Seek(0); while ($oObj = $oSet->Fetch()) { + $aRow['key'] = $oObj->GetKey(); + if ($bSelectMode) + { + $aRow['form::select'] = "GetKey()."\">"; + } $aRow['key'] = $oObj->GetKey(); foreach($aList as $sAttCode) { @@ -280,8 +319,14 @@ abstract class cmdbAbstractObject extends CMDBObject if ($bDisplayMenu) { $sColspan = 'colspan="2"'; + $aMenuExtraParams = array(); + if (!empty($sLinkageAttribute)) + { + //$aMenuExtraParams['linkage'] = $sLinkageAttribute; + $aMenuExtraParams = $aExtraParams; + } $sHtml .= '