Пример #1
0
 /**
  * Adjust preferences and persist them
  *
  * @see Form::onSuccess()
  */
 public function onSuccess()
 {
     $this->preferences = new Preferences($this->store ? $this->store->load() : array());
     $webPreferences = $this->preferences->get('icingaweb', array());
     foreach ($this->getValues() as $key => $value) {
         if ($value === null || $value === 'autodetect') {
             if (isset($webPreferences[$key])) {
                 unset($webPreferences[$key]);
             }
         } else {
             $webPreferences[$key] = $value;
         }
     }
     $this->preferences->icingaweb = $webPreferences;
     Session::getSession()->user->setPreferences($this->preferences);
     try {
         if ($this->store && $this->getElement('btn_submit_preferences')->isChecked()) {
             $this->save();
             Notification::success($this->translate('Preferences successfully saved'));
         } else {
             Notification::success($this->translate('Preferences successfully saved for the current session'));
         }
     } catch (Exception $e) {
         Logger::error($e);
         Notification::error($e->getMessage());
     }
 }
Пример #2
0
 /**
  * Adjust preferences and persist them
  *
  * @see Form::onSuccess()
  */
 public function onSuccess()
 {
     $this->preferences = new Preferences($this->store ? $this->store->load() : array());
     $oldTheme = $this->preferences->getValue('icingaweb', 'theme');
     $webPreferences = $this->preferences->get('icingaweb', array());
     foreach ($this->getValues() as $key => $value) {
         if ($value === '' || $value === 'autodetect' || $key === 'theme' && $value === Config::app()->get('themes', 'default', StyleSheet::DEFAULT_THEME)) {
             if (isset($webPreferences[$key])) {
                 unset($webPreferences[$key]);
             }
         } else {
             $webPreferences[$key] = $value;
         }
     }
     $this->preferences->icingaweb = $webPreferences;
     Session::getSession()->user->setPreferences($this->preferences);
     if (($theme = $this->getElement('theme')) !== null && ($theme = $theme->getValue()) !== $oldTheme) {
         $this->getResponse()->setReloadCss(true);
     }
     try {
         if ($this->store && $this->getElement('btn_submit_preferences')->isChecked()) {
             $this->save();
             Notification::success($this->translate('Preferences successfully saved'));
         } else {
             Notification::success($this->translate('Preferences successfully saved for the current session'));
         }
     } catch (Exception $e) {
         Logger::error($e);
         Notification::error($e->getMessage());
     }
 }