function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
// Mandatory, to get the other tabs displayed as well
parent::DisplayBareRelations($oPage, $bEditMode);
// If the UserRequest is in Read mode
// and the KnownError option has been selected at iTop setup
if ((!$bEditMode) && (MetaModel::IsValidClass('KnownError')))
{
//Search for known errors related to FunctionalCI
// ...linked to current UserRequest
$iTicketID = $this->GetKey();
// We create a Search (definition) with an OQL
// Note {$iTicketID} in the OQL will be replaced by the true value
$oSearch = new DBObjectSearch::FromOQL("
SELECT KnownError AS ke
JOIN lnkErrorToFunctionalCI AS l1 ON l1.error_id=ke.id
JOIN FunctionalCI AS ci ON l1.functionalci_id=ci.id
JOIN lnkFunctionalCIToTicket AS l2 ON l2.functionalci_id=ci.id
WHERE l2.ticket_id={$iTicketID}");
// We get a set of Known Error objects, using the above Search
$oKnownErrorSet = new CMDBObjectSet($oSearch);
// Now that we have the Set we can count them
$iNumberKE = $oKnownErrorSet->();
// Here we have decided to always create a new Known Error tab
// but you could decide to display the tab only if there are some Known
Errors
if ($iNumberKE > 0)
{ // here we use the standard iTop way to display tab with data inside
$oPage->SetCurrentTab(Dict::S('Class:UserRequest:KnownErrorList') . "
({$iNumberKE})");
} else { // or without data inside with no brackets and no count
$oPage->SetCurrentTab(Dict::S('Class:UserRequest:KnownErrorList'));
}
// We create a Block made of the Known Error in a 'list' mode
// The Block just need a DBObjectSearch and not the Set itself
// GetFilter() retrieve that Search from the Set
$oBlock = new DisplayBlock($oKnownErrorSet->GetFilter(), 'list', false);
// 'menu' says if the list will offer a menu
// 'display_limit' says if we display in page mode or all objects at once
$aExtraParam = ('menu' => true, 'display_limit' => false);
// Display the block in the page with a Title (optional), and extra params
$oBlock->Display($oPage, Dict::S('Class:UserRequest:KnownErrorList'),
$aExtraParam);
}
}