From d2b9501208be7659ec489dc7c3a021789c1a7efa Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 11 Jun 2013 22:50:05 +0000 Subject: [PATCH] Fix up column selection pref / default / forced to update session & indicate to admin that preference has been forced --- .../inc/class.etemplate_widget_nextmatch.inc.php | 12 ++++++++---- etemplate/js/et2_extension_nextmatch.js | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php index cf65ce7400..96763320f3 100644 --- a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php +++ b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php @@ -217,6 +217,8 @@ class etemplate_widget_nextmatch extends etemplate_widget // Need to check admin too, or it will be impossible to turn off !$GLOBALS['egw_info']['user']['apps']['admin'] ); + // Use this flag to indicate to the admin that columns are forced (and that's why they can't change) + $value['columns_forced'] = (boolean)$GLOBALS['egw']->preferences->forced[$app][$pref_name]; // todo: no need to store rows in request, it's enought to send them to client @@ -830,7 +832,7 @@ class etemplate_widget_nextmatch extends etemplate_widget { $GLOBALS['egw']->preferences->delete($app,$pref_name,'forced'); $GLOBALS['egw']->preferences->delete($app,$refresh_pref_name,'forced'); - $GLOBALS['egw']->preferences->save_repository(false,'forced'); + $GLOBALS['egw']->preferences->save_repository(true,'forced'); } // Set columns + refresh as default for all users @@ -841,16 +843,18 @@ class etemplate_widget_nextmatch extends etemplate_widget $GLOBALS['egw']->preferences->add($app,$pref_name,is_array($cols) ? implode(',',$cols) : $cols, $pref_level); // Autorefresh - $refresh = $prefs[$app][$refresh_pref_name]; + $refresh = $value['nm_autorefresh']; $GLOBALS['egw']->preferences->add($app,$refresh_pref_name,(int)$refresh,$pref_level); - $GLOBALS['egw']->preferences->save_repository(false,$pref_level); - $prefs = $GLOBALS['egw']->preferences->read(); + $GLOBALS['egw']->preferences->save_repository(true,$pref_level); + $prefs = $GLOBALS['egw']->preferences->read(true); if($value['nm_col_preference'] == 'reset') { // Clear column + refresh preference so users go back to default $GLOBALS['egw']->preferences->delete_preference($app,$pref_name); + $GLOBALS['egw']->preferences->delete_preference($app,$pref_name.'-size'); + $GLOBALS['egw']->preferences->delete_preference($app,$refresh_pref_name); } } unset($value['nm_col_preference']); diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 2916d37341..7c5a08cf27 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -938,6 +938,7 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], 'reset': {label: 'Reset', title:"Reset all user's column preferences"}, 'force': {label: 'Force', title:'Force column preference so users cannot change it'} }); + defaultCheck.set_value(this.options.settings.columns_forced ? 'force': ''); var okButton = et2_createWidget("buttononly", {}, this); okButton.set_label(this.egw().lang("ok")); @@ -995,7 +996,7 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], // Auto refresh self._set_autorefresh(autoRefresh.get_value()); - // Set default? + // Set default or clear forced? if(defaultCheck.get_value()) { self.getInstanceManager().submit();