if ($aValues['open_editor']) { $oPage->add_ready_script("window.location.href='" . addslashes(utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?c[menu]=' . urlencode($sMenuId)) . "&edit=1';"); // reloads the page, doing a GET even if we arrived via a POST } } break; case 'shortcut_list_dlg': $sOQL = utils::ReadParam('oql', '', false, 'raw_data'); $sTableSettings = utils::ReadParam('table_settings', '', false, 'raw_data'); ShortcutOQL::GetCreationDlgFromOQL($oPage, $sOQL, $sTableSettings); break; case 'shortcut_list_create': $oForm = ShortcutOQL::GetCreationForm(); $aValues = $oForm->ReadParams(); $oAppContext = new ApplicationContext(); $aContext = $oAppContext->GetAsHash(); $sContext = serialize($aContext); $oShortcut = MetaModel::NewObject("ShortcutOQL"); $oShortcut->Set('user_id', UserRights::GetUserId()); $oShortcut->Set("context", $sContext); $oShortcut->Set("name", $aValues['name']); $oShortcut->Set("oql", $aValues['oql']); $iAutoReload = (int) $aValues['auto_reload_sec']; if ($aValues['auto_reload'] && $iAutoReload > 0) { $oShortcut->Set("auto_reload_sec", max(5, $iAutoReload)); $oShortcut->Set("auto_reload", 'custom'); } $iId = $oShortcut->DBInsertNoReload(); $oShortcut->CloneTableSettings($aValues['table_settings']); // Add the menu node in the right place //
// Second part: advanced search form: if (!empty($sFilter)) { $oFilter = CMDBSearchFilter::unserialize($sFilter); } else { if (!empty($sClass)) { $oFilter = new CMDBSearchFilter($sClass); } } } } catch (CoreException $e) { $oFilter = new CMDBSearchFilter($sClass); $oP->P("<b>" . Dict::Format('UI:UniversalSearch:Error', $e->getHtmlDesc()) . "</b>"); } if ($oFilter != null) { $oSet = new CMDBObjectSet($oFilter); $oBlock = new DisplayBlock($oFilter, 'search', false); $aExtraParams = $oAppContext->GetAsHash(); $aExtraParams['open'] = true; $aExtraParams['baseClass'] = $sBaseClass; $aExtraParams['action'] = utils::GetAbsoluteUrlAppRoot() . 'pages/UniversalSearch.php'; //$aExtraParams['class'] = $sClassName; $oBlock->Display($oP, 0, $aExtraParams); // Search results $oResultBlock = new DisplayBlock($oFilter, 'list', false); $oResultBlock->Display($oP, 1); // Menu node $sFilter = $oFilter->ToOQL(); $oP->add("\n<!-- {$sFilter} -->\n"); } $oP->add("</div>\n"); $oP->output();
public function DisplayMenu() { // Display the menu $oAppContext = new ApplicationContext(); $iAccordionIndex = 0; ApplicationMenu::DisplayMenu($this, $oAppContext->GetAsHash()); }
/** * Merge standard menu items with plugin provided menus items */ public static function GetPopupMenuItems($oPage, $iMenuId, $param, &$aActions, $sTableId = null, $sDataTableId = null) { // 1st - add standard built-in menu items // switch ($iMenuId) { case iPopupMenuExtension::MENU_OBJLIST_TOOLKIT: // $param is a DBObjectSet $oAppContext = new ApplicationContext(); $sContext = $oAppContext->GetForLink(); $sDataTableId = is_null($sDataTableId) ? '' : $sDataTableId; $sUIPage = cmdbAbstractObject::ComputeStandardUIPage($param->GetFilter()->GetClass()); $sOQL = addslashes($param->GetFilter()->ToOQL(true)); $sFilter = urlencode($param->GetFilter()->serialize()); $sUrl = utils::GetAbsoluteUrlAppRoot() . "pages/{$sUIPage}?operation=search&filter=" . $sFilter . "&{$sContext}"; $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/tabularfieldsselector.js'); $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.dragtable.js'); $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/dragtable.css'); $aResult = array(new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:Menu:EMail', Dict::S('UI:Menu:EMail'), "mailto:?body=" . urlencode($sUrl) . ' ')); if (UserRights::IsActionAllowed($param->GetFilter()->GetClass(), UR_ACTION_BULK_READ, $param) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) { // Bulk export actions $aResult[] = new JSPopupMenuItem('UI:Menu:CSVExport', Dict::S('UI:Menu:CSVExport'), "ExportListDlg('{$sOQL}', '{$sDataTableId}', 'csv', " . json_encode(Dict::S('UI:Menu:CSVExport')) . ")"); $aResult[] = new JSPopupMenuItem('UI:Menu:ExportXLSX', Dict::S('ExcelExporter:ExportMenu'), "ExportListDlg('{$sOQL}', '{$sDataTableId}', 'xlsx', " . json_encode(Dict::S('ExcelExporter:ExportMenu')) . ")"); $aResult[] = new JSPopupMenuItem('UI:Menu:ExportPDF', Dict::S('UI:Menu:ExportPDF'), "ExportListDlg('{$sOQL}', '{$sDataTableId}', 'pdf', " . json_encode(Dict::S('UI:Menu:ExportPDF')) . ")"); } $aResult[] = new JSPopupMenuItem('UI:Menu:AddToDashboard', Dict::S('UI:Menu:AddToDashboard'), "DashletCreationDlg('{$sOQL}')"); $aResult[] = new JSPopupMenuItem('UI:Menu:ShortcutList', Dict::S('UI:Menu:ShortcutList'), "ShortcutListDlg('{$sOQL}', '{$sDataTableId}', '{$sContext}')"); break; case iPopupMenuExtension::MENU_OBJDETAILS_ACTIONS: // $param is a DBObject $oObj = $param; $sOQL = "SELECT " . get_class($oObj) . " WHERE id=" . $oObj->GetKey(); $oFilter = DBObjectSearch::FromOQL($sOQL); $sFilter = $oFilter->serialize(); $sUrl = ApplicationContext::MakeObjectUrl(get_class($oObj), $oObj->GetKey()); $sUIPage = cmdbAbstractObject::ComputeStandardUIPage(get_class($oObj)); $oAppContext = new ApplicationContext(); $sContext = $oAppContext->GetForLink(); $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/tabularfieldsselector.js'); $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.dragtable.js'); $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/dragtable.css'); $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/tabularfieldsselector.js'); $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/jquery.dragtable.js'); $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot() . 'css/dragtable.css'); $aResult = array(new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:Menu:EMail', Dict::S('UI:Menu:EMail'), "mailto:?subject=" . urlencode($oObj->GetRawName()) . "&body=" . urlencode($sUrl) . ' '), new JSPopupMenuItem('UI:Menu:CSVExport', Dict::S('UI:Menu:CSVExport'), "ExportListDlg('{$sOQL}', '', 'csv', " . json_encode(Dict::S('UI:Menu:CSVExport')) . ")"), new JSPopupMenuItem('UI:Menu:ExportXLSX', Dict::S('ExcelExporter:ExportMenu'), "ExportListDlg('{$sOQL}', '', 'xlsx', " . json_encode(Dict::S('ExcelExporter:ExportMenu')) . ")")); break; case iPopupMenuExtension::MENU_DASHBOARD_ACTIONS: // $param is a Dashboard $oAppContext = new ApplicationContext(); $aParams = $oAppContext->GetAsHash(); $sMenuId = ApplicationMenu::GetActiveNodeId(); $sDlgTitle = addslashes(Dict::S('UI:ImportDashboardTitle')); $sDlgText = addslashes(Dict::S('UI:ImportDashboardText')); $sCloseBtn = addslashes(Dict::S('UI:Button:Cancel')); $aResult = array(new SeparatorPopupMenuItem(), new URLPopupMenuItem('UI:ExportDashboard', Dict::S('UI:ExportDashBoard'), utils::GetAbsoluteUrlAppRoot() . 'pages/ajax.render.php?operation=export_dashboard&id=' . $sMenuId), new JSPopupMenuItem('UI:ImportDashboard', Dict::S('UI:ImportDashBoard'), "UploadDashboard({dashboard_id: '{$sMenuId}', title: '{$sDlgTitle}', text: '{$sDlgText}', close_btn: '{$sCloseBtn}' })")); break; default: // Unknown type of menu, do nothing $aResult = array(); } foreach ($aResult as $oMenuItem) { $aActions[$oMenuItem->GetUID()] = $oMenuItem->GetMenuItem(); } // Invoke the plugins // foreach (MetaModel::EnumPlugins('iPopupMenuExtension') as $oExtensionInstance) { if (is_object($param) && !$param instanceof DBObject) { $tmpParam = clone $param; // In case the parameter is an DBObjectSet, clone it to prevent alterations } else { $tmpParam = $param; } foreach ($oExtensionInstance->EnumItems($iMenuId, $tmpParam) as $oMenuItem) { if (is_object($oMenuItem)) { $aActions[$oMenuItem->GetUID()] = $oMenuItem->GetMenuItem(); foreach ($oMenuItem->GetLinkedScripts() as $sLinkedScript) { $oPage->add_linked_script($sLinkedScript); } } } } }