- Fixed bug #243. OQLMenuNodes can now auto-refresh. I've enabled this by default for the "shortcuts" of Helpdesk, Incident Management and Change Management

SVN:trunk[764]
This commit is contained in:
Denis Flaven
2010-09-05 12:46:47 +00:00
parent 775524824e
commit cb98432f6d
4 changed files with 48 additions and 13 deletions

View File

@@ -448,6 +448,12 @@ class OQLMenuNode extends MenuNode
protected $sOQL;
protected $bSearch;
/**
* Extra parameters to be passed to the display block to fine tune its appearence
*/
protected $m_aParams;
/**
* Create a menu item based on an OQL query and inserts it into the application's main menu
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
@@ -466,12 +472,23 @@ class OQLMenuNode extends MenuNode
$this->sPageTitle = "Menu:$sMenuId+";
$this->sOQL = $sOQL;
$this->bSearch = $bSearch;
$this->m_aParams = array();
// Enhancement: we could set as the "enable" condition that the user has enough rights to "read" the objects
// of the class specified by the OQL...
}
/**
* Set some extra parameters to be passed to the display block to fine tune its appearence
* @param Hash $aParams paramCode => value. See DisplayBlock::GetDisplay for the meaning of the parameters
*/
public function SetParameters($aParams)
{
$this->m_aParams = $aParams;
}
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
$aExtraParams = array_merge($aExtraParams, $this->m_aParams);
try
{
$oSearch = DBObjectSearch::FromOQL($this->sOQL);
@@ -490,10 +507,19 @@ class OQLMenuNode extends MenuNode
<itopblock BlockClass="DisplayBlock" type="search" asynchronous="false" encoding="text/oql">$this->sOQL</itopblock>
EOF;
}
$sParams = '';
if (!empty($this->m_aParams))
{
$sParams = 'parameters="';
foreach($this->m_aParams as $sName => $sValue)
{
$sParams .= $sName.':'.$sValue.';';
}
$sParams .= '"';
}
$sTemplate .= <<<EOF
<p class="page-header">$sIcon<itopstring>$this->sPageTitle</itopstring></p>
<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql">$this->sOQL</itopblock>
<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql" $sParams>$this->sOQL</itopblock>
EOF;
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, $aExtraParams);