mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
N°3294 - Introduce counters in OQL menu entries
This commit is contained in:
@@ -1157,8 +1157,33 @@ class OQLMenuNode extends MenuNode
|
||||
public function GetEntriesCount()
|
||||
{
|
||||
// Count the entries up to 99
|
||||
$oFilter = DBSearch::FromOQL($this->sOQL);
|
||||
$oAppContext = new ApplicationContext();
|
||||
$iCurrentOrganization = $oAppContext->GetCurrentValue('org_id');
|
||||
|
||||
$oSet = new DBObjectSet(DBSearch::FromOQL($this->sOQL));
|
||||
if( isset($iCurrentOrganization) && $iCurrentOrganization!="" ) {
|
||||
$aAllowedOrgs[] = intval( $iCurrentOrganization);
|
||||
$aSettings['bSearchMode'] = true;
|
||||
$aSelectedClasses = $oFilter->GetSelectedClasses();
|
||||
foreach ($aSelectedClasses as $sClassAlias => $sClass) {
|
||||
//MakeSelectFilter($sClass, $aAllowedOrgs, $aSettings = array(), $sAttCode = null)
|
||||
$sAttCode = $sClass::MapContextParam('org_id');
|
||||
if(!is_null($sAttCode) && MetaModel::IsValidAttCode($sClass,$sAttCode)) {
|
||||
$oVisibleObjects = UserRights::MakeSelectFilter($sClass, $aAllowedOrgs, $aSettings, $sAttCode);
|
||||
if ($oVisibleObjects === false) {
|
||||
// Make sure this is a valid search object, saying NO for all
|
||||
$oVisibleObjects = DBObjectSearch::FromEmptySet($sClass);
|
||||
}
|
||||
if (is_object($oVisibleObjects)) {
|
||||
$oVisibleObjects->AllowAllData();
|
||||
$oFilter = $oFilter->Filter($sClassAlias, $oVisibleObjects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$oSet = new DBObjectSet($oFilter);
|
||||
$iCount = $oSet->CountWithLimit(99);
|
||||
if ($iCount > 99) {
|
||||
$iCount = "99+";
|
||||
|
||||
@@ -27,6 +27,7 @@ $(function()
|
||||
active_menu_group: null,
|
||||
display_counts: false,
|
||||
filter_keyup_throttle: 200, // In milliseconds
|
||||
org_id:''
|
||||
},
|
||||
css_classes:
|
||||
{
|
||||
@@ -362,7 +363,8 @@ $(function()
|
||||
method: "POST",
|
||||
url: GetAbsoluteUrlAppRoot() + 'pages/ajax.render.php',
|
||||
data: {
|
||||
operation: "get_menus_count"
|
||||
operation: "get_menus_count",
|
||||
c: { org_id: me.options.org_id }
|
||||
},
|
||||
dataType: "json"
|
||||
})
|
||||
|
||||
@@ -423,5 +423,15 @@ JS;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetOrgId(){
|
||||
$oAppContext = new ApplicationContext();
|
||||
$iCurrentOrganization = $oAppContext->GetCurrentValue('org_id');
|
||||
|
||||
if(!empty($iCurrentOrganization)) {
|
||||
return $iCurrentOrganization;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
$('#{{ oUIBlock.GetId() }}').navigation_menu({
|
||||
display_counts: {% if get_config_parameter('display_menus_count') %} true {% else %} false {% endif %}
|
||||
{%if oUIBlock.GetOrgId()%}, org_id: {{ oUIBlock.GetOrgId()}} {% endif %}
|
||||
});
|
||||
|
||||
$('#{{ oUIBlock.GetId() }}').navigation_menu('refreshCounts', null);
|
||||
|
||||
Reference in New Issue
Block a user