diff --git a/pages/preferences.php b/pages/preferences.php index 9380b981c..bcbfce151 100644 --- a/pages/preferences.php +++ b/pages/preferences.php @@ -36,26 +36,31 @@ function DisplayPreferences($oP) { $oAppContext = new ApplicationContext(); + $oP->add('\n"); + $oP->add('
'); + + ////////////////////////////////////////////////////////////////////////// + // + // Favorite Organizations + // + ////////////////////////////////////////////////////////////////////////// + + $oP->add('
'.Dict::S('UI:FavoriteOrganizations').''); + $oP->p(Dict::S('UI:FavoriteOrganizations+')); + $oP->add('
'); // Favorite organizations: the organizations listed in the drop-down menu $sOQL = ApplicationMenu::GetFavoriteSiloQuery(); $oFilter = DBObjectSearch::FromOQL($sOQL); $oBlock = new DisplayBlock($oFilter, 'list', false); - - $oP->add('\n"); - $oP->add('
'); - $oP->add('
'.Dict::S('UI:FavoriteOrganizations').''); - $oP->p(Dict::S('UI:FavoriteOrganizations+')); - $oP->add(''); - $oBlock->Display($oP, 1, array('menu' => false, 'selection_mode' => true, 'selection_type' => 'multiple', 'cssCount'=> '.selectedCount')); + $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(''); - $oP->add('
'); - $sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php'; + $sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?'.$oAppContext->GetForLink(); $oP->add('

'); $oP->add('  '); $oP->add('

'); $oP->add(''); - $oP->add('
'); + $oP->add('
'); $aFavoriteOrgs = appUserPreferences::GetPref('favorite_orgs', null); if ($aFavoriteOrgs == null) @@ -73,10 +78,11 @@ function DisplayPreferences($oP) } else { - CheckAll('#user_prefs .listResults :checkbox:not(:disabled)', true); + $('#user_prefs table.listResults').trigger('check_all'); } EOF ); + } else { @@ -109,7 +115,81 @@ EOF } EOF ); - }} + } + + ////////////////////////////////////////////////////////////////////////// + // + // User Language selection + // + ////////////////////////////////////////////////////////////////////////// + + $oP->add('
'.Dict::S('UI:FavoriteLanguage').''); + $oP->add('
'); + $aLanguages = Dict::GetLanguages(); + $aSortedlang = array(); + foreach($aLanguages as $sCode => $aLang) + { + $aSortedlang[$aLang['description']] = $sCode; + } + ksort($aSortedlang); + $oP->add('

'.Dict::S('UI:Favorites:SelectYourLanguage').'

'); + $oP->add(''); + $oP->add($oAppContext->GetForForm()); + $oP->add('

'); + $oP->add('  '); + $oP->add('

'); + $oP->add('
'); + $oP->add('
'); + + ////////////////////////////////////////////////////////////////////////// + // + // Other (miscellaneous) settings + // + ////////////////////////////////////////////////////////////////////////// + + $oP->add('
'.Dict::S('UI:FavoriteOtherSettings').''); + $oP->add('
'); + $iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit()); + $oP->add('

'.Dict::Format('UI:Favorites:Default_X_ItemsPerPage', '').'

'); + $oP->add(''); + $oP->add($oAppContext->GetForForm()); + $oP->add('

'); + $oP->add('  '); + $oP->add('

'); + $oP->add('
'); + $oP->add('
'); + + $oP->add_script( +<< 0)) + { + $('#v_default_page_size').html(''); + $('#other_submit').removeAttr('disabled'); + return true; + } + else + { + $('#v_default_page_size').html(''); + $('#other_submit').attr('disabled', 'disabled'); + return false; + } +} +EOF + ); + + $oP->add('
'); + $oP->add_ready_script("$('#fav_page_length').bind('keyup change', function(){ ValidateOtherSettings(); })"); +} ///////////////////////////////////////////////////////////////////////////// // @@ -148,6 +228,30 @@ try DisplayPreferences($oPage); break; + case 'apply_language': + $sLangCode = utils::ReadParam('language', 'EN US'); + $oUser = UserRights::GetUserObject(); + $oUser->Set('language', $sLangCode); + $oMyChange = MetaModel::NewObject("CMDBChange"); + $oMyChange->Set("date", time()); + $sUserString = CMDBChange::GetCurrentUserName(); + $oMyChange->Set("userinfo", $sUserString); + $iChangeId = $oMyChange->DBInsert(); + $oUser->DBUpdateTracked($oMyChange); + // Redirect to force a reload/display of the page with the new language + $oAppContext = new ApplicationContext(); + $sURL = utils::GetAbsoluteUrlAppRoot().'pages/preferences.php?'.$oAppContext->GetForLink(); + $oPage->add_header('Location: '.$sURL); + break; + case 'apply_others': + $iDefaultPageSize = (int)utils::ReadParam('default_page_size', -1); + if ($iDefaultPageSize > 0) + { + appUserPreferences::SetPref('default_page_size', $iDefaultPageSize); + } + DisplayPreferences($oPage); + break; + case 'display': default: DisplayPreferences($oPage);