- Better management of (truncated) list of linked objects (Trac #219)

- New type of display block to display some "actions" (New/Search) for a given class of objects.

SVN:trunk[709]
This commit is contained in:
Denis Flaven
2010-08-27 15:34:47 +00:00
parent 88efd37525
commit bd001f8072
2 changed files with 30 additions and 3 deletions

View File

@@ -290,6 +290,11 @@ class DisplayBlock
$bDoSearch = utils::ReadParam('dosearch', false);
if ($this->m_oSet == null)
{
$aQueryParams = array();
if (isset($aExtraParams['query_params']))
{
$aQueryParams = $aExtraParams['query_params'];
}
if ($this->m_sStyle != 'links')
{
$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
@@ -306,7 +311,7 @@ class DisplayBlock
}
}
}
$this->m_oSet = new CMDBObjectSet($this->m_oFilter);
$this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams);
}
switch($this->m_sStyle)
{
@@ -340,8 +345,13 @@ class DisplayBlock
else
{
// Simply count the number of elements in the set
$iCount = $oSet->Count();
$sHtml .= $oPage->GetP(Dict::Format('UI:CountOfObjects', $iCount));
$iCount = $this->m_oSet->Count();
$sFormat = 'UI:CountOfObjects';
if (isset($aExtraParams['format']))
{
$sFormat = $aExtraParams['format'];
}
$sHtml .= $oPage->GetP(Dict::Format($sFormat, $iCount));
}
break;
@@ -542,6 +552,19 @@ class DisplayBlock
}
break;
case 'actions':
$sClass = $this->m_oFilter->GetClass();
$oAppContext = new ApplicationContext();
$sParams = $oAppContext->GetForLink();
$sHtml .= '<p>';
if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY))
{
$sHtml .= "<a href=\"../pages/UI.php?operation=new&class={$sClass}&$sParams\">".Dict::Format('UI:ClickToCreateNew', MetaModel::GetName($sClass))."</a><br/>\n";
}
$sHtml .= "<a href=\"../pages/UI.php?operation=search_form&class={$sClass}&$sParams\">".Dict::Format('UI:SearchFor_Class', MetaModel::GetName($sClass))."</a>\n";
$sHtml .= '</p>';
break;
case 'bare_details':
while($oObj = $this->m_oSet->Fetch())
{