/** * Displays a popup welcome message, once per session at maximum * until the user unchecks the "Display welcome at startup" * @param WebPage $oP The current web page for the display * @return void */ function DisplayWelcomePopup(WebPage $oP) { if (!isset($_SESSION['welcome'])) { // Check, only once per session, if the popup should be displayed... // If the user did not already ask for hiding it forever $bPopup = appUserPreferences::GetPref('welcome_popup', true); if ($bPopup) { $sTemplate = @file_get_contents('../application/templates/welcome_popup.html'); if ($sTemplate !== false) { $oTemplate = new DisplayTemplate($sTemplate); $oP->add("<div id=\"welcome_popup\">"); $oTemplate->Render($oP, array()); $oP->add("<p style=\"float:left\"><input type=\"checkbox\" checked id=\"display_welcome_popup\"/><label for=\"display_welcome_popup\"> " . Dict::S('UI:DisplayThisMessageAtStartup') . "</label></p>\n"); $oP->add("<p style=\"float:right\"><input type=\"button\" value=\"" . Dict::S('UI:Button:Ok') . "\" onClick=\"\$('#welcome_popup').dialog('close');\"/>\n"); $oP->add("</div>\n"); $sTitle = addslashes(Dict::S('UI:WelcomeMenu:Title')); $oP->add_ready_script(<<<EOF \t\$('#welcome_popup').dialog( { width:'80%', height: 'auto', title: '{$sTitle}', autoOpen: true, modal:true, \t\t\t\t\t\t\t\t close: function() { \t\t\t\t\t\t\t\t \tvar bDisplay = \$('#display_welcome_popup:checked').length; \t\t\t\t\t\t\t\t \tSetUserPreference('welcome_popup', bDisplay, true); \t\t\t\t\t\t\t\t } \t\t\t\t\t\t\t\t }); \tif (\$('#welcome_popup').height() > (\$(window).height()-70)) \t{ \t\t\$('#welcome_popup').height(\$(window).height()-70); \t} EOF ); $_SESSION['welcome'] = 'ok'; } } } }
public static function GetDisplayExtendedSet(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array()) { if (empty($aExtraParams['currentId'])) { $iListId = $oPage->GetUniqueId(); // Works only if not in an Ajax page !! } else { $iListId = $aExtraParams['currentId']; } $aList = array(); // Initialize and check the parameters $bViewLink = isset($aExtraParams['view_link']) ? $aExtraParams['view_link'] : true; $bDisplayMenu = isset($aExtraParams['menu']) ? $aExtraParams['menu'] == true : true; // Check if there is a list of aliases to limit the display to... $aDisplayAliases = isset($aExtraParams['display_aliases']) ? explode(',', $aExtraParams['display_aliases']) : array(); $sZListName = isset($aExtraParams['zlist']) ? $aExtraParams['zlist'] : 'list'; $aExtraFieldsRaw = isset($aExtraParams['extra_fields']) ? explode(',', trim($aExtraParams['extra_fields'])) : array(); $aExtraFields = array(); foreach ($aExtraFieldsRaw as $sFieldName) { // Ignore attributes not of the main queried class if (preg_match('/^(.*)\\.(.*)$/', $sFieldName, $aMatches)) { $sClassAlias = $aMatches[1]; $sAttCode = $aMatches[2]; if (array_key_exists($sClassAlias, $oSet->GetSelectedClasses())) { $aExtraFields[$sClassAlias][] = $sAttCode; } } else { $aExtraFields['*'] = $sAttCode; } } $sHtml = ''; $oAppContext = new ApplicationContext(); $aClasses = $oSet->GetFilter()->GetSelectedClasses(); $aAuthorizedClasses = array(); foreach ($aClasses as $sAlias => $sClassName) { if (UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS) && (count($aDisplayAliases) == 0 || in_array($sAlias, $aDisplayAliases))) { $aAuthorizedClasses[$sAlias] = $sClassName; } } $aAttribs = array(); foreach ($aAuthorizedClasses as $sAlias => $sClassName) { if (array_key_exists($sAlias, $aExtraFields)) { $aList[$sAlias] = $aExtraFields[$sAlias]; } else { $aList[$sAlias] = array(); } if ($sZListName !== false) { $aDefaultList = self::FlattenZList(MetaModel::GetZListItems($sClassName, $sZListName)); $aList[$sAlias] = array_merge($aDefaultList, $aList[$sAlias]); } // Filter the list to removed linked set since we are not able to display them here foreach ($aList[$sAlias] as $index => $sAttCode) { $oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttCode); if ($oAttDef instanceof AttributeLinkedSet) { // Removed from the display list unset($aList[$sAlias][$index]); } } } $sSelectMode = 'none'; $sClassAlias = $oSet->GetClassAlias(); $oDataTable = new DataTable($iListId, $oSet, $aAuthorizedClasses); $oSettings = DataTableSettings::GetDataModelSettings($aAuthorizedClasses, $bViewLink, $aList); $bDisplayLimit = isset($aExtraParams['display_limit']) ? $aExtraParams['display_limit'] : true; if ($bDisplayLimit) { $iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit()); $oSettings->iDefaultPageSize = $iDefaultPageSize; } $oSettings->aSortOrder = MetaModel::GetOrderByDefault($sClassName); return $oDataTable->Display($oPage, $oSettings, $bDisplayMenu, $sSelectMode, $bViewLink, $aExtraParams); }
$currentId = utils::ReadParam('currentId', ''); $sTableId = utils::ReadParam('_table_id_', null, false, 'raw_data'); $sAction = utils::ReadParam('action', ''); $oFilter = new DBObjectSearch($sClass); $oSet = new CMDBObjectSet($oFilter); $sHtml = cmdbAbstractObject::GetSearchForm($oPage, $oSet, array('currentId' => $currentId, 'baseClass' => $sRootClass, 'action' => $sAction, 'table_id' => $sTableId)); $oPage->add($sHtml); break; case 'set_pref': $sCode = utils::ReadPostedParam('code', ''); $sValue = utils::ReadPostedParam('value', '', 'raw_data'); appUserPreferences::SetPref($sCode, $sValue); break; case 'erase_all_pref': // Can be useful in case a user got some corrupted prefs... appUserPreferences::ClearPreferences(); break; case 'on_form_cancel': // Called when a creation/modification form is cancelled by the end-user // Let's take this opportunity to inform the plug-ins so that they can perform some cleanup $iTransactionId = utils::ReadParam('transaction_id', 0); $sTempId = session_id() . '_' . $iTransactionId; foreach (MetaModel::EnumPlugins('iApplicationUIExtension') as $oExtensionInstance) { $oExtensionInstance->OnFormCancel($sTempId); } break; case 'reload_dashboard': $oPage->SetContentType('text/html'); $sDashboardId = utils::ReadParam('dashboard_id', '', false, 'raw_data'); $aExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data'); ApplicationMenu::LoadAdditionalMenus();
public function GetSiloSelectionForm() { // List of visible Organizations $iCount = 0; $oSet = null; if (MetaModel::IsValidClass('Organization')) { // Display the list of *favorite* organizations... but keeping in mind what is the real number of organizations $aFavoriteOrgs = appUserPreferences::GetPref('favorite_orgs', null); $oSearchFilter = new DBObjectSearch('Organization'); $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true); $oSet = new CMDBObjectSet($oSearchFilter); $iCount = $oSet->Count(); // total number of existing Orgs // Now get the list of Orgs to be displayed in the menu $oSearchFilter = DBObjectSearch::FromOQL(ApplicationMenu::GetFavoriteSiloQuery()); $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true); if (!empty($aFavoriteOrgs)) { $oSearchFilter->AddCondition('id', $aFavoriteOrgs, 'IN'); } $oSet = new CMDBObjectSet($oSearchFilter); // List of favorite orgs } switch ($iCount) { case 0: // No such dimension/silo => nothing to select $sHtml = '<div id="SiloSelection"><!-- nothing to select --></div>'; break; case 1: // Only one possible choice... no selection, but display the value $oOrg = $oSet->Fetch(); $sHtml = '<div id="SiloSelection">' . $oOrg->GetName() . '</div>'; $sHtml .= ''; break; default: $sHtml = ''; $oAppContext = new ApplicationContext(); $iCurrentOrganization = $oAppContext->GetCurrentValue('org_id'); $sHtml = '<div id="SiloSelection">'; $sHtml .= '<form style="display:inline" action="' . utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php">'; //<select class="org_combo" name="c[org_id]" title="Pick an organization" onChange="this.form.submit();">'; $sFavoriteOrgs = ''; $oWidget = new UIExtKeyWidget('Organization', 'org_id', '', true); $sHtml .= $oWidget->Display($this, 50, false, '', $oSet, $iCurrentOrganization, 'org_id', false, 'c[org_id]', '', array('iFieldSize' => 20, 'iMinChars' => MetaModel::GetConfig()->Get('min_autocomplete_chars'), 'sDefaultValue' => Dict::S('UI:AllOrganizations')), null, 'select', false); $this->add_ready_script('$("#org_id").bind("extkeychange", function() { $("#SiloSelection form").submit(); } )'); $this->add_ready_script("\$('#label_org_id').click( function() { \$(this).val(''); \$('#org_id').val(''); return true; } );\n"); // Add other dimensions/context information to this form $oAppContext->Reset('org_id'); // org_id is handled above and we want to be able to change it here ! $oAppContext->Reset('menu'); // don't pass the menu, since a menu may expect more parameters $sHtml .= $oAppContext->GetForForm(); // Pass what remains, if anything... $sHtml .= '</form>'; $sHtml .= '</div>'; } return $sHtml; }
/** * Clear the preferences for this particular table * @param $bResetAll boolean If true,the settings for all tables of the same class(es)/alias(es) are reset */ public function ResetToDefault($bResetAll) { if ($this->sTableId == null && !$bResetAll) { return false; } // Cannot reset, the table is not identified, use force $bResetAll instead if ($bResetAll) { // Turn the key into a suitable PCRE pattern $sKey = $this->GetPrefsKey(null); $sPattern = str_replace(array('|'), array('\\|'), $sKey); // escape the | character $sPattern = '#^' . str_replace(array('*'), array('.*'), $sPattern) . '$#'; // Don't use slash as the delimiter since it's used in our key to delimit aliases appUserPreferences::UnsetPref($sPattern, true); } else { appUserPreferences::UnsetPref($this->GetPrefsKey($this->sTableId), false); } return true; }
/** * Loads the preferences for the current user, creating the record in the database * if needed */ protected static function Load() { if (self::$oUserPrefs != null) { return; } $oSearch = new DBObjectSearch('appUserPreferences'); $oSearch->AddCondition('userid', UserRights::GetUserId(), '='); $oSet = new DBObjectSet($oSearch); $oObj = $oSet->Fetch(); if ($oObj == null) { // No prefs (yet) for this user, create the object $oObj = new appUserPreferences(); $oObj->Set('userid', UserRights::GetUserId()); $oObj->Set('preferences', array()); // Default preferences: an empty array try { $oObj->DBInsert(); } catch (Exception $e) { // Ignore errors } } self::$oUserPrefs = $oObj; }
/** * Display the history of bulk imports */ static function DisplayImportHistory(WebPage $oPage, $bFromAjax = false, $bShowAll = false) { $sAjaxDivId = "CSVImportHistory"; if (!$bFromAjax) { $oPage->add('<div id="' . $sAjaxDivId . '">'); } $oPage->p(Dict::S('UI:History:BulkImports+') . ' <span id="csv_history_reload"></span>'); $oBulkChangeSearch = DBObjectSearch::FromOQL("SELECT CMDBChange WHERE origin IN ('csv-interactive', 'csv-import.php')"); $iQueryLimit = $bShowAll ? 0 : appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit()); $oBulkChanges = new DBObjectSet($oBulkChangeSearch, array('date' => false), array(), null, $iQueryLimit); $oAppContext = new ApplicationContext(); $bLimitExceeded = false; if ($oBulkChanges->Count() > appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit())) { $bLimitExceeded = true; if (!$bShowAll) { $iMaxObjects = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit()); $oBulkChanges->SetLimit($iMaxObjects); } } $oBulkChanges->Seek(0); $aDetails = array(); while ($oChange = $oBulkChanges->Fetch()) { $sDate = '<a href="csvimport.php?step=10&changeid=' . $oChange->GetKey() . '&' . $oAppContext->GetForLink() . '">' . $oChange->Get('date') . '</a>'; $sUser = $oChange->GetUserName(); if (preg_match('/^(.*)\\(CSV\\)$/i', $oChange->Get('userinfo'), $aMatches)) { $sUser = $aMatches[1]; } else { $sUser = $oChange->Get('userinfo'); } $oOpSearch = DBObjectSearch::FromOQL("SELECT CMDBChangeOpCreate WHERE change = :change_id"); $oOpSet = new DBObjectSet($oOpSearch, array(), array('change_id' => $oChange->GetKey())); $iCreated = $oOpSet->Count(); // Get the class from the first item found (assumption: a CSV load is done for a single class) if ($oCreateOp = $oOpSet->Fetch()) { $sClass = $oCreateOp->Get('objclass'); } $oOpSearch = DBObjectSearch::FromOQL("SELECT CMDBChangeOpSetAttribute WHERE change = :change_id"); $oOpSet = new DBObjectSet($oOpSearch, array(), array('change_id' => $oChange->GetKey())); $aModified = array(); $aAttList = array(); while ($oModified = $oOpSet->Fetch()) { // Get the class (if not done earlier on object creation) $sClass = $oModified->Get('objclass'); $iKey = $oModified->Get('objkey'); $sAttCode = $oModified->Get('attcode'); $aAttList[$sClass][$sAttCode] = true; $aModified["{$sClass}::{$iKey}"] = true; } $iModified = count($aModified); // Assumption: there is only one class of objects being loaded // Then the last class found gives us the class for every object if ($iModified > 0 || $iCreated > 0) { $aDetails[] = array('date' => $sDate, 'user' => $sUser, 'class' => $sClass, 'created' => $iCreated, 'modified' => $iModified); } } $aConfig = array('date' => array('label' => Dict::S('UI:History:Date'), 'description' => Dict::S('UI:History:Date+')), 'user' => array('label' => Dict::S('UI:History:User'), 'description' => Dict::S('UI:History:User+')), 'class' => array('label' => Dict::S('Core:AttributeClass'), 'description' => Dict::S('Core:AttributeClass+')), 'created' => array('label' => Dict::S('UI:History:StatsCreations'), 'description' => Dict::S('UI:History:StatsCreations+')), 'modified' => array('label' => Dict::S('UI:History:StatsModifs'), 'description' => Dict::S('UI:History:StatsModifs+'))); if ($bLimitExceeded) { if ($bShowAll) { // Collapsible list $oPage->add('<p>' . Dict::Format('UI:CountOfResults', $oBulkChanges->Count()) . ' <a class="truncated" onclick="OnTruncatedHistoryToggle(false);">' . Dict::S('UI:CollapseList') . '</a></p>'); } else { // Truncated list $iMinDisplayLimit = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit()); $sCollapsedLabel = Dict::Format('UI:TruncatedResults', $iMinDisplayLimit, $oBulkChanges->Count()); $sLinkLabel = Dict::S('UI:DisplayAll'); $oPage->add('<p>' . $sCollapsedLabel . ' <a class="truncated" onclick="OnTruncatedHistoryToggle(true);">' . $sLinkLabel . '</p>'); $oPage->add_ready_script(<<<EOF \t\$('#{$sAjaxDivId} table.listResults').addClass('truncated'); \t\$('#{$sAjaxDivId} table.listResults tr:last td').addClass('truncated'); EOF ); $sAppContext = $oAppContext->GetForLink(); $oPage->add_script(<<<EOF \tfunction OnTruncatedHistoryToggle(bShowAll) \t{ \t\t\$('#csv_history_reload').html('<img src="../images/indicator.gif"/>'); \t\t\$.get(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?{$sAppContext}', {operation: 'displayCSVHistory', showall: bShowAll}, function(data) \t\t\t{ \t\t\t\t\$('#{$sAjaxDivId}').html(data); \t\t\t\tvar table = \$('#{$sAjaxDivId} .listResults'); \t\t\t\ttable.tableHover(); // hover tables \t\t\t\ttable.tablesorter( { widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables \t\t\t} \t\t); \t} EOF ); } } else { // Normal display - full list without any decoration } $oPage->table($aConfig, $aDetails); if (!$bFromAjax) { $oPage->add('</div>'); } }
/** * Displays the user's changeable preferences * @param $oP WebPage The web page used for the output */ function DisplayPreferences($oP) { $oAppContext = new ApplicationContext(); $sURL = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?' . $oAppContext->GetForLink(); $oP->add('<div class="page_header"><h1><img style="vertical-align:middle" src="../images/preferences.png"/> ' . Dict::S('UI:Preferences') . "</h1></div>\n"); $oP->add('<div id="user_prefs" style="max-width:800px; min-width:400px;">'); ////////////////////////////////////////////////////////////////////////// // // User Language selection // ////////////////////////////////////////////////////////////////////////// $oP->add('<fieldset><legend>' . Dict::S('UI:FavoriteLanguage') . '</legend>'); $oP->add('<form method="post">'); $aLanguages = Dict::GetLanguages(); $aSortedlang = array(); foreach ($aLanguages as $sCode => $aLang) { if (MetaModel::GetConfig()->Get('demo_mode')) { if ($sCode != Dict::GetUserLanguage()) { // Demo mode: only the current user language is listed in the available choices continue; } } $aSortedlang[$aLang['description']] = $sCode; } ksort($aSortedlang); $oP->add('<p>' . Dict::S('UI:Favorites:SelectYourLanguage') . ' <select name="language">'); foreach ($aSortedlang as $sCode) { $sSelected = $sCode == Dict::GetUserLanguage() ? 'selected' : ''; $oP->add('<option value="' . $sCode . '" ' . $sSelected . '/>' . $aLanguages[$sCode]['description'] . ' (' . $aLanguages[$sCode]['localized_description'] . ')</option>'); } $oP->add('</select></p>'); $oP->add('<input type="hidden" name="operation" value="apply_language"/>'); $oP->add($oAppContext->GetForForm()); $oP->add('<p><input type="button" onClick="window.location.href=\'' . $sURL . '\'" value="' . Dict::S('UI:Button:Cancel') . '"/>'); $oP->add(' '); $oP->add('<input type="submit" value="' . Dict::S('UI:Button:Apply') . '"/></p>'); $oP->add('</form>'); $oP->add('</fieldset>'); ////////////////////////////////////////////////////////////////////////// // // Other (miscellaneous) settings // ////////////////////////////////////////////////////////////////////////// $oP->add('<fieldset><legend>' . Dict::S('UI:FavoriteOtherSettings') . '</legend>'); $oP->add('<form method="post" onsubmit="return ValidateOtherSettings()">'); $iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit()); $oP->add('<p>' . Dict::Format('UI:Favorites:Default_X_ItemsPerPage', '<input id="default_page_size" name="default_page_size" type="text" size="3" value="' . $iDefaultPageSize . '"/><span id="v_default_page_size"></span>') . '</p>'); $oP->add('<input type="hidden" name="operation" value="apply_others"/>'); $oP->add($oAppContext->GetForForm()); $oP->add('<p><input type="button" onClick="window.location.href=\'' . $sURL . '\'" value="' . Dict::S('UI:Button:Cancel') . '"/>'); $oP->add(' '); $oP->add('<input id="other_submit" type="submit" value="' . Dict::S('UI:Button:Apply') . '"/></p>'); $oP->add('</form>'); $oP->add('</fieldset>'); $oP->add_script(<<<EOF function ValidateOtherSettings() { \tvar sPageLength = \$('#default_page_size').val(); \tvar iPageLength = parseInt(sPageLength , 10); \tif (/^[0-9]+\$/.test(sPageLength) && (iPageLength > 0)) \t{ \t\t\$('#v_default_page_size').html(''); \t\t\$('#other_submit').removeAttr('disabled'); \t\treturn true; \t} \telse \t{ \t\t\$('#v_default_page_size').html('<img src="../images/validation_error.png"/>'); \t\t\$('#other_submit').attr('disabled', 'disabled'); \t\treturn false; \t} } EOF ); ////////////////////////////////////////////////////////////////////////// // // Favorite Organizations // ////////////////////////////////////////////////////////////////////////// $oP->add('<fieldset><legend>' . Dict::S('UI:FavoriteOrganizations') . '</legend>'); $oP->p(Dict::S('UI:FavoriteOrganizations+')); $oP->add('<form method="post">'); // Favorite organizations: the organizations listed in the drop-down menu $sOQL = ApplicationMenu::GetFavoriteSiloQuery(); $oFilter = DBObjectSearch::FromOQL($sOQL); $oBlock = new DisplayBlock($oFilter, 'list', false); $oBlock->Display($oP, 1, array('menu' => false, 'selection_mode' => true, 'selection_type' => 'multiple', 'cssCount' => '.selectedCount', 'table_id' => 'user_prefs')); $oP->add($oAppContext->GetForForm()); $oP->add('<input type="hidden" name="operation" value="apply"/>'); $oP->add('<p><input type="button" onClick="window.location.href=\'' . $sURL . '\'" value="' . Dict::S('UI:Button:Cancel') . '"/>'); $oP->add(' '); $oP->add('<input type="submit" value="' . Dict::S('UI:Button:Apply') . '"/></p>'); $oP->add('</form>'); $oP->add('</fieldset>'); $aFavoriteOrgs = appUserPreferences::GetPref('favorite_orgs', null); if ($aFavoriteOrgs == null) { // All checked $oP->add_ready_script(<<<EOF \tif (\$('#user_prefs table.pagination').length > 0) \t{ \t\t// paginated display, restore the selection \t\tvar pager = \$('#user_prefs form .pager'); \t\t\$(':input[name=selectionMode]', pager).val('negative'); \t\t\$('#user_prefs table.listResults').trigger('load_selection'); \t} \telse \t{ \t\t\$('#user_prefs table.listResults').trigger('check_all'); \t} EOF ); } else { $sChecked = implode('","', $aFavoriteOrgs); $oP->add_ready_script(<<<EOF \tvar aChecked = ["{$sChecked}"]; \tif (\$('#user_prefs table.pagination').length > 0) \t{ \t\t// paginated display, restore the selection \t\tvar pager = \$('#user_prefs form .pager'); \t\t\$(':input[name=selectionMode]', pager).val('positive'); \t\tfor (i=0; i<aChecked.length; i++) \t\t{ \t\t\tpager.append('<input type="hidden" name="storedSelection[]" id="'+aChecked[i]+'" value="'+aChecked[i]+'"/>'); \t\t} \t\t\$('#user_prefs table.listResults').trigger('load_selection'); \t\t \t} \telse \t{ \t\t\$('#user_prefs form :checkbox[name^=selectObject]').each( function() \t\t\t{ \t\t\t\tif (\$.inArray(\$(this).val(), aChecked) > -1) \t\t\t\t{ \t\t\t\t\t\$(this).attr('checked', true); \t\t\t\t\t\$(this).trigger('change'); \t\t\t\t} \t\t\t}); \t} EOF ); } ////////////////////////////////////////////////////////////////////////// // // Shortcuts // ////////////////////////////////////////////////////////////////////////// $oP->add('<fieldset><legend>' . Dict::S('Menu:MyShortcuts') . '</legend>'); //$oP->p(Dict::S('UI:Menu:MyShortcuts+')); $oBMSearch = new DBObjectSearch('Shortcut'); $oBMSearch->AddCondition('user_id', UserRights::GetUserId(), '='); //$aExtraParams = array('menu' => false, 'toolkit_menu' => false, 'display_limit' => false, 'localize_values' => $bLocalize, 'zlist' => 'details'); $aExtraParams = array(); $oBlock = new DisplayBlock($oBMSearch, 'list', false, $aExtraParams); $oBlock->Display($oP, 'shortcut_list', array('view_link' => false, 'menu' => false, 'toolkit_menu' => false, 'selection_mode' => true, 'selection_type' => 'multiple', 'cssCount' => '#shortcut_selection_count', 'table_id' => 'user_prefs_shortcuts')); $oP->add('<p>'); $oSet = new DBObjectSet($oBMSearch); if ($oSet->Count() > 0) { $sButtons = '<img src="../images/tv-item-last.gif">'; $sButtons .= ' '; $sButtons .= '<button id="shortcut_btn_rename">' . Dict::S('UI:Button:Rename') . '</button>'; $sButtons .= ' '; $sButtons .= '<button id="shortcut_btn_delete">' . Dict::S('UI:Button:Delete') . '</button>'; // Selection count updated by the pager, and used to enable buttons $oP->add('<input type="hidden" id="shortcut_selection_count"/>'); $oP->add('</fieldset>'); $sConfirmDelete = addslashes(Dict::S('UI:ShortcutDelete:Confirm')); $oP->add_ready_script(<<<EOF function OnShortcutBtnRename() { \tvar oParams = \$('#datatable_shortcut_list').datatable('GetMultipleSelectionParams'); \toParams.operation = 'shortcut_rename_dlg'; \t\$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data){ \t\t\$('body').append(data); \t}); \treturn false; } function OnShortcutBtnDelete() { \tif (confirm('{$sConfirmDelete}')) \t{ \t\tvar oParams = \$('#datatable_shortcut_list').datatable('GetMultipleSelectionParams'); \t\toParams.operation = 'shortcut_delete_go'; \t\t\$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data){ \t\t\t\$('body').append(data); \t\t}); \t} \treturn false; } function OnSelectionCountChange() { \tvar iCountSelected = \$("#shortcut_selection_count").val(); \tif (iCountSelected == 0) \t{ \t\t\$('#shortcut_btn_rename').attr('disabled', 'disabled'); \t\t\$('#shortcut_btn_delete').attr('disabled', 'disabled'); \t} \telse if (iCountSelected == 1) \t{ \t\t\$('#shortcut_btn_rename').removeAttr('disabled'); \t\t\$('#shortcut_btn_delete').removeAttr('disabled'); \t} \telse \t{ \t\t\$('#shortcut_btn_rename').attr('disabled', 'disabled'); \t\t\$('#shortcut_btn_delete').removeAttr('disabled'); \t} } var oUpperCheckBox = \$('#datatable_shortcut_list .checkAll').first(); oUpperCheckBox.parent().width(oUpperCheckBox.width() + 2); \$('#datatable_shortcut_list').append('<tr><td colspan="2"> {$sButtons}</td></tr>'); \$('#shortcut_selection_count').bind('change', OnSelectionCountChange); \$('#shortcut_btn_rename').bind('click', OnShortcutBtnRename); \$('#shortcut_btn_delete').bind('click', OnShortcutBtnDelete); OnSelectionCountChange(); EOF ); } // if count > 0 ////////////////////////////////////////////////////////////////////////// // // Footer // $oP->add('</div>'); $oP->add_ready_script("\$('#fav_page_length').bind('keyup change', function(){ ValidateOtherSettings(); })"); }