Fix up column selection pref / default / forced to update session & indicate to admin that preference has been forced

This commit is contained in:
Nathan Gray 2013-06-11 22:50:05 +00:00
parent 3300e82b27
commit d2b9501208
2 changed files with 10 additions and 5 deletions

View File

@ -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']);

View File

@ -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();