ui.linkswidget.class.inc.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * Class UILinksWidget
  18. *
  19. * @author Erwan Taloc <erwan.taloc@combodo.com>
  20. * @author Romain Quetiez <romain.quetiez@combodo.com>
  21. * @author Denis Flaven <denis.flaven@combodo.com>
  22. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  23. */
  24. require_once('../application/webpage.class.inc.php');
  25. require_once('../application/displayblock.class.inc.php');
  26. class UILinksWidget
  27. {
  28. protected $m_sClass;
  29. protected $m_sAttCode;
  30. protected $m_sNameSuffix;
  31. protected $m_iInputId;
  32. protected $m_aAttributes;
  33. protected $m_sExtKeyToRemote;
  34. protected $m_sLinkedClass;
  35. protected $m_sRemoteClass;
  36. protected static $iWidgetIndex = 0;
  37. public function __construct($sClass, $sAttCode, $iInputId, $sNameSuffix = '')
  38. {
  39. $this->m_sClass = $sClass;
  40. $this->m_sAttCode = $sAttCode;
  41. $this->m_sNameSuffix = $sNameSuffix;
  42. $this->m_iInputId = $iInputId;
  43. $this->m_aEditableFields = array();
  44. self::$iWidgetIndex++;
  45. $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sAttCode);
  46. $this->m_sLinkedClass = $oAttDef->GetLinkedClass();
  47. $this->m_sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
  48. $oLinkingAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $this->m_sExtKeyToRemote);
  49. $this->m_sRemoteClass = $oLinkingAttDef->GetTargetClass();
  50. $sExtKeyToMe = $oAttDef->GetExtKeyToMe();
  51. $sStateAttCode = MetaModel::GetStateAttributeCode($this->m_sClass);
  52. $sDefaultState = MetaModel::GetDefaultState($this->m_sClass);
  53. $this->m_aEditableFields = array();
  54. $this->m_aTableConfig = array();
  55. $this->m_aTableConfig['form::checkbox'] = array( 'label' => "<input class=\"select_all\" type=\"checkbox\" value=\"1\" onChange=\"var value = this.checked; $('#linkedset_{$this->m_sAttCode}{$this->m_sNameSuffix} .selection').each( function() { this.checked = value; } ); oWidget".self::$iWidgetIndex.".OnSelectChange();\">", 'description' => Dict::S('UI:SelectAllToggle+'));
  56. foreach(MetaModel::ListAttributeDefs($this->m_sLinkedClass) as $sAttCode=>$oAttDef)
  57. {
  58. if ($sStateAttCode == $sAttCode)
  59. {
  60. // State attribute is always hidden from the UI
  61. }
  62. else if (!$oAttDef->IsExternalField() && ($sAttCode != $sExtKeyToMe) && ($sAttCode != $this->m_sExtKeyToRemote) && ($sAttCode != 'finalclass'))
  63. {
  64. $iFlags = MetaModel::GetAttributeFlags($this->m_sLinkedClass, $sDefaultState, $sAttCode);
  65. if ( !($iFlags & OPT_ATT_HIDDEN) && !($iFlags & OPT_ATT_READONLY) )
  66. {
  67. $this->m_aEditableFields[] = $sAttCode;
  68. $this->m_aTableConfig[$sAttCode] = array( 'label' => $oAttDef->GetLabel(), 'description' => $oAttDef->GetDescription());
  69. }
  70. }
  71. }
  72. foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
  73. {
  74. // TO DO: check the state of the attribute: hidden or visible ?
  75. if ($sFieldCode != 'finalclass')
  76. {
  77. $oAttDef = MetaModel::GetAttributeDef($this->m_sRemoteClass, $sFieldCode);
  78. $this->m_aTableConfig['static::'.$sFieldCode] = array( 'label' => $oAttDef->GetLabel(), 'description' => $oAttDef->GetDescription());
  79. }
  80. }
  81. }
  82. /**
  83. * A one-row form for editing a link record
  84. * @param WebPage $oP Web page used for the ouput
  85. * @param DBObject $oLinkedObj The object to which all the elements of the linked set refer to
  86. * @param mixed $linkObjOrId Either the object linked or a unique number for new link records to add
  87. * @param Hash $aArgs Extra context arguments
  88. * @return string The HTML fragment of the one-row form
  89. */
  90. protected function GetFormRow(WebPage $oP, DBObject $oLinkedObj, $linkObjOrId = null, $aArgs = array() )
  91. {
  92. $sPrefix = "$this->m_sAttCode{$this->m_sNameSuffix}";
  93. $aRow = array();
  94. if(is_object($linkObjOrId))
  95. {
  96. $key = $linkObjOrId->GetKey();
  97. $sPrefix .= "[$key][";
  98. $sNameSuffix = "]"; // To make a tabular form
  99. $aArgs['prefix'] = $sPrefix;
  100. $aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onChange=\"oWidget".self::$iWidgetIndex.".OnSelectChange();\" value=\"$key\">";
  101. foreach($this->m_aEditableFields as $sFieldCode)
  102. {
  103. $oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
  104. $aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $linkObjOrId->Get($sFieldCode), '' /* DisplayValue */, $key, $sNameSuffix, 0, $aArgs);
  105. }
  106. }
  107. else
  108. {
  109. // form for creating a new record
  110. $sPrefix .= "[$linkObjOrId][";
  111. $sNameSuffix = "]"; // To make a tabular form
  112. $aArgs['prefix'] = $sPrefix;
  113. $aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onChange=\"oWidget".self::$iWidgetIndex.".OnSelectChange();\" value=\"$linkObjOrId\">";
  114. $aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_attr_{$sPrefix}id{$sNameSuffix}\" value=\"\">";
  115. foreach($this->m_aEditableFields as $sFieldCode)
  116. {
  117. $oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
  118. $aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, '' /* TO DO/ call GetDefaultValue($oObject->ToArgs()) */, '' /* DisplayValue */, '' /* id */, $sNameSuffix, 0, $aArgs);
  119. }
  120. }
  121. foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
  122. {
  123. $aRow['static::'.$sFieldCode] = $oLinkedObj->GetAsHTML($sFieldCode);
  124. }
  125. return $aRow;
  126. }
  127. /**
  128. * Display one row of the whole form
  129. * @return none
  130. */
  131. protected function DisplayFormRow(WebPage $oP, $aConfig, $aRow, $iRowId)
  132. {
  133. $sHtml = '';
  134. $sHtml .= "<tr id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_row_$iRowId\">\n";
  135. foreach($aConfig as $sName=>$void)
  136. {
  137. $sHtml .= "<td>".$aRow[$sName]."</td>\n";
  138. }
  139. $sHtml .= "</tr>\n";
  140. return $sHtml;
  141. }
  142. /**
  143. * Display the table with the form for editing all the links at once
  144. * @param WebPage $oP The web page used for the output
  145. * @param Hash $aConfig The table's header configuration
  146. * @param Hash $aData The tabular data to be displayed
  147. * @return string Html fragment representing the form table
  148. */
  149. protected function DisplayFormTable(WebPage $oP, $aConfig, $aData)
  150. {
  151. $sHtml = '';
  152. $sHtml .= "<table class=\"listResults\">\n";
  153. // Header
  154. $sHtml .= "<thead>\n";
  155. $sHtml .= "<tr>\n";
  156. foreach($aConfig as $sName=>$aDef)
  157. {
  158. $sHtml .= "<th title=\"".$aDef['description']."\">".$aDef['label']."</th>\n";
  159. }
  160. $sHtml .= "</tr>\n";
  161. $sHtml .= "</thead>\n";
  162. // Content
  163. $sHtml .= "</tbody>\n";
  164. if (count($aData) == 0)
  165. {
  166. $sHtml .= "<tr id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_empty_row\"><td colspan=\"".count($aConfig)."\" style=\"text-align:center;\">".Dict::S('UI:Message:EmptyList:UseAdd')."<input type=\"hidden\" name=\"attr_{$this->m_sAttCode}{$this->m_sNameSuffix}\" value=\"\"></td></td>";
  167. }
  168. else
  169. {
  170. foreach($aData as $iRowId => $aRow)
  171. {
  172. $sHtml .= $this->DisplayFormRow($oP, $aConfig, $aRow, $iRowId);
  173. }
  174. }
  175. $sHtml .= "</tbody>\n";
  176. // Footer
  177. $sHtml .= "</table>\n";
  178. return $sHtml;
  179. }
  180. /**
  181. * Get the HTML fragment corresponding to the linkset editing widget
  182. * @param WebPage $oP The web page used for all the output
  183. * @param DBObjectSet The initial value of the linked set
  184. * @param Hash $aArgs Extra context arguments
  185. * @return string The HTML fragment to be inserted into the page
  186. */
  187. public function Display(WebPage $oPage, DBObjectSet $oValue, $aArgs = array())
  188. {
  189. $iWidgetIndex = self::$iWidgetIndex;
  190. $sHtmlValue = '';
  191. $sTargetClass = self::GetTargetClass($this->m_sClass, $this->m_sAttCode);
  192. $sHtmlValue .= "<div id=\"linkedset_{$this->m_sAttCode}{$this->m_sNameSuffix}\">\n";
  193. $oValue->Rewind();
  194. $aForm = array();
  195. $oContext = new UserContext();
  196. while($oCurrentLink = $oValue->Fetch())
  197. {
  198. $aRow = array();
  199. $key = $oCurrentLink->GetKey();
  200. $oLinkedObj = $oContext->GetObject($this->m_sRemoteClass, $oCurrentLink->Get($this->m_sExtKeyToRemote));
  201. $aForm[$key] = $this->GetFormRow($oPage, $oLinkedObj, $oCurrentLink, $aArgs);
  202. }
  203. $sHtmlValue .= $this->DisplayFormTable($oPage, $this->m_aTableConfig, $aForm);
  204. $oPage->add_ready_script(<<<EOF
  205. oWidget$iWidgetIndex = new LinksWidget('{$this->m_sAttCode}{$this->m_sNameSuffix}', '{$this->m_sClass}', '{$this->m_sAttCode}', '{$this->m_iInputId}', '{$this->m_sNameSuffix}');
  206. oWidget$iWidgetIndex.Init();
  207. EOF
  208. );
  209. $sHtmlValue .= "<span style=\"float:left;\">&nbsp;&nbsp;&nbsp;<img src=\"../images/tv-item-last.gif\">&nbsp;&nbsp;<input id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_btnRemove\" type=\"button\" value=\"".Dict::S('UI:RemoveLinkedObjectsOf_Class')."\" onClick=\"oWidget$iWidgetIndex.RemoveSelected();\" >";
  210. $sHtmlValue .= "&nbsp;&nbsp;&nbsp;<input id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_btnAdd\" type=\"button\" value=\"".Dict::Format('UI:AddLinkedObjectsOf_Class', MetaModel::GetName($this->m_sRemoteClass))."\" onClick=\"oWidget$iWidgetIndex.AddObjects();\"></span>\n";
  211. $sHtmlValue .= "<span style=\"clear:both;\"><p>&nbsp;</p></span>\n";
  212. $sHtmlValue .= "</div>\n";
  213. $oPage->add_at_the_end($this->GetObjectPickerDialog($oPage)); // To prevent adding forms inside the main form
  214. return $sHtmlValue;
  215. }
  216. /**
  217. * This static function is called by the Ajax Page when there is a need to fill an autocomplete combo
  218. * @param $oPage WebPage The ajax page used for the output (sent back to the browser)
  219. * @param $oContext UserContext The context of the user (for limiting the search)
  220. * @param $sClass string The name of the class of the current object being edited
  221. * @param $sAttCode string The name of the attribute being edited
  222. * @param $sName string The partial name that was typed by the user
  223. * @param $iMaxCount integer The maximum number of items to return
  224. * @return void
  225. */
  226. static public function Autocomplete(WebPage $oPage, UserContext $oContext, $sClass, $sAttCode, $sName, $iMaxCount)
  227. {
  228. // #@# todo - add context information, otherwise any value will be authorized for external keys
  229. $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array() /* $aArgs */, $sName);
  230. if ($aAllowedValues != null)
  231. {
  232. $iCount = $iMaxCount;
  233. foreach($aAllowedValues as $key => $value)
  234. {
  235. $oPage->add($value."|".$key."\n");
  236. $iCount--;
  237. if ($iCount == 0) break;
  238. }
  239. }
  240. else // No limitation to the allowed values
  241. {
  242. // Search for all the object of the linked class
  243. $oAttDef = $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
  244. $sLinkedClass = $oAttDef->GetLinkedClass();
  245. $sSearchClass = self::GetTargetClass($sClass, $sAttCode);
  246. $oFilter = $oContext->NewFilter($sSearchClass);
  247. $sSearchAttCode = MetaModel::GetNameAttributeCode($sSearchClass);
  248. $oFilter->AddCondition($sSearchAttCode, $sName, 'Begins with');
  249. $oSet = new CMDBObjectSet($oFilter, array($sSearchAttCode => true));
  250. $iCount = 0;
  251. while( ($iCount < $iMaxCount) && ($oObj = $oSet->fetch()) )
  252. {
  253. $oPage->add($oObj->GetName()."|".$oObj->GetKey()."\n");
  254. $iCount++;
  255. }
  256. }
  257. }
  258. /**
  259. * This static function is called by the Ajax Page display a set of objects being linked
  260. * to the object being created
  261. * @param $oPage WebPage The ajax page used for the put^put (sent back to the browser
  262. * @param $sClass string The name of the 'linking class' which is the class of the objects to display
  263. * @param $sSet JSON serialized set of objects
  264. * @param $sExtKeyToMe Name of the attribute in sClass that is pointing to a given object
  265. * @param $iObjectId The id of the object $sExtKeyToMe is pointing to
  266. * @return void
  267. */
  268. static public function RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe, $sExtKeyToRemote, $iObjectId)
  269. {
  270. $aSet = json_decode($sJSONSet, true); // true means hash array instead of object
  271. $oSet = CMDBObjectSet::FromScratch($sClass);
  272. foreach($aSet as $aObject)
  273. {
  274. $oObj = MetaModel::NewObject($sClass);
  275. foreach($aObject as $sAttCode => $value)
  276. {
  277. $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
  278. if ($oAttDef->IsExternalKey() && ($value != 0))
  279. {
  280. $oTargetObj = MetaModel::GetObject($oAttDef->GetTargetClass(), $value); // @@ optimization, don't do & query per object in the set !
  281. $oObj->Set($sAttCode, $oTargetObj);
  282. }
  283. else
  284. {
  285. $oObj->Set($sAttCode, $value);
  286. }
  287. }
  288. $oSet->AddObject($oObj);
  289. }
  290. $aExtraParams = array();
  291. $aExtraParams['link_attr'] = $sExtKeyToMe;
  292. $aExtraParams['object_id'] = $iObjectId;
  293. $aExtraParams['target_attr'] = $sExtKeyToRemote;
  294. $aExtraParams['menu'] = false;
  295. $aExtraParams['select'] = false;
  296. $aExtraParams['view_link'] = false;
  297. cmdbAbstractObject::DisplaySet($oPage, $oSet, $aExtraParams);
  298. }
  299. protected static function GetTargetClass($sClass, $sAttCode)
  300. {
  301. $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
  302. $sLinkedClass = $oAttDef->GetLinkedClass();
  303. switch(get_class($oAttDef))
  304. {
  305. case 'AttributeLinkedSetIndirect':
  306. $oLinkingAttDef = MetaModel::GetAttributeDef($sLinkedClass, $oAttDef->GetExtKeyToRemote());
  307. $sTargetClass = $oLinkingAttDef->GetTargetClass();
  308. break;
  309. case 'AttributeLinkedSet':
  310. $sTargetClass = $sLinkedClass;
  311. break;
  312. }
  313. return $sTargetClass;
  314. }
  315. protected function GetObjectPickerDialog($oPage)
  316. {
  317. $sHtml = "<div id=\"dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}\">";
  318. //$oTargetObj = $oContext->GetObject($sTargetClass, $this->m_iObjectId);
  319. $sHtml .= "<div class=\"wizContainer\">\n";
  320. //$sHtml .= "<div class=\"page_header\">\n");
  321. //$sHtml .= "<h1>".Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class_Instance', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName(get_class($oTargetObj)), "<span class=\"hilite\">".$oTargetObj->GetHyperlink()."</span>")."</h1>\n");
  322. //$sHtml .= "</div>\n");
  323. $oContext = new UserContext();
  324. $iWidgetIndex = self::$iWidgetIndex;
  325. $oFilter = $oContext->NewFilter($this->m_sRemoteClass);
  326. $oSet = new CMDBObjectSet($oFilter);
  327. $oBlock = new DisplayBlock($oFilter, 'search', false);
  328. $sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}", array('open' => true));
  329. $sHtml .= "<form id=\"ObjectsAddForm_{$this->m_sAttCode}{$this->m_sNameSuffix}\" OnSubmit=\"return oWidget$iWidgetIndex.DoAddObjects(this.id);\">\n";
  330. $sHtml .= "<div id=\"SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}\">\n";
  331. $sHtml .= "<div style=\"height: 100px; background: #fff;border-color:#F6F6F1 #E6E6E1 #E6E6E1 #F6F6F1; border-style:solid; border-width:3px; text-align: center; vertical-align: center;\"><p>".Dict::S('UI:Message:EmptyList:UseSearchForm')."</p></div>\n";
  332. $sHtml .= "</div>\n";
  333. $sHtml .= "<input type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('close');\">&nbsp;&nbsp;<input type=\"submit\" value=\"".Dict::S('UI:Button:Add')."\">";
  334. $sHtml .= "</div>\n";
  335. $sHtml .= "</form>\n";
  336. $sHtml .= "</div>\n";
  337. $oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog({ autoOpen: false, modal: true });");
  338. $oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('option', {title:'".Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class_Instance', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName($this->m_sClass), "<span class=\"hilite\"> ZZZZ </span>")."'});");
  339. $oPage->add_ready_script("$('#SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix} form').bind('submit.uilinksWizard', oWidget$iWidgetIndex.SearchObjectsToAdd);");
  340. return $sHtml;
  341. }
  342. /**
  343. * Search for objects to be linked to the current object (i.e "remote" objects)
  344. * @param WebPage $oP The page used for the output (usually an AjaxWebPage)
  345. * @param UserContext $oContext User context to limit the search...
  346. * @param string $sRemoteClass Name of the "remote" class to perform the search on, must be a derived class of m_sRemoteClass
  347. * @param Array $aAlreadyLinkedIds List of IDs of objects of "remote" class already linked, to be filtered out of the search
  348. */
  349. public function SearchObjectsToAdd(WebPage $oP, UserContext $oContext, $sRemoteClass = '', $aAlreadyLinkedIds = array())
  350. {
  351. if ($sRemoteClass != '')
  352. {
  353. // assert(MetaModel::IsParentClass($this->m_sRemoteClass, $sRemoteClass));
  354. $oFilter = $oContext->NewFilter($sRemoteClass);
  355. }
  356. else
  357. {
  358. // No remote class specified use the one defined in the linkedset
  359. $oFilter = $oContext->NewFilter($this->m_sRemoteClass);
  360. }
  361. if (count($aAlreadyLinkedIds) > 0)
  362. {
  363. // Positive IDs correspond to existing link records
  364. // negative IDs correspond to "remote" objects to be linked
  365. $aLinkIds = array();
  366. $aRemoteObjIds = array();
  367. foreach($aAlreadyLinkedIds as $iId)
  368. {
  369. if ($iId > 0)
  370. {
  371. $aLinkIds[] = $iId;
  372. }
  373. else
  374. {
  375. $aRemoteObjIds[] = -$iId;
  376. }
  377. }
  378. if (count($aLinkIds) >0)
  379. {
  380. // Search for the links to find to which "remote" object they are linked
  381. $oLinkFilter = $oContext->NewFilter($this->m_sLinkedClass);
  382. $oLinkFilter->AddCondition('id', $aLinkIds, 'IN');
  383. $oLinkSet = new CMDBObjectSet($oLinkFilter);
  384. while($oLink = $oLinkSet->Fetch())
  385. {
  386. $aRemoteObjIds[] = $oLink->Get($this->m_sExtKeyToRemote);
  387. }
  388. }
  389. $oFilter->AddCondition('id', $aRemoteObjIds, 'NOTIN');
  390. }
  391. $oSet = new CMDBObjectSet($oFilter);
  392. $oBlock = new DisplayBlock($oFilter, 'list', false);
  393. $oBlock->Display($oP, 'ResultsToAdd', array('menu' => false, 'selection_mode' => true, 'display_limit' => false)); // Don't display the 'Actions' menu on the results
  394. }
  395. public function DoAddObjects(WebPage $oP, UserContext $oContext, $aLinkedObjectIds = array())
  396. {
  397. $aTable = array();
  398. foreach($aLinkedObjectIds as $iObjectId)
  399. {
  400. $oLinkedObj = $oContext->GetObject($this->m_sRemoteClass, $iObjectId);
  401. if (is_object($oLinkedObj))
  402. {
  403. $aRow = $this->GetFormRow($oP, $oLinkedObj, -$iObjectId ); // Not yet created link get negative Ids
  404. $oP->add($this->DisplayFormRow($oP, $this->m_aTableConfig, $aRow, -$iObjectId));
  405. }
  406. else
  407. {
  408. $oP->p(Dict::Format('UI:Error:Object_Class_Id_NotFound', $this->m_sLinkedClass, $iObjectId));
  409. }
  410. }
  411. }
  412. }
  413. ?>