fixed not working group preferences using new preferences::get/set_account_id and display group-default also as default for user

This commit is contained in:
Ralf Becker 2013-05-10 17:22:14 +00:00
parent 4ae5eb452b
commit a57ae54e82

View File

@ -79,10 +79,10 @@ class preferences_settings
$prefs = array_merge($prefs, $val); $prefs = array_merge($prefs, $val);
} }
} }
error_log(__METHOD__."() button=$button, content=".array2string($content).' --> prefs='.array2string($prefs));;; //error_log(__METHOD__."() button=$button, content=".array2string($content).' --> prefs='.array2string($prefs));;;
if ($account_id && $account_id != $GLOBALS['egw']->preferences->account_id) if ($account_id && $account_id != $GLOBALS['egw']->preferences->get_account_id())
{ {
$GLOBALS['egw']->preferences->account_id = $account_id; $GLOBALS['egw']->preferences->set_account_id($account_id);
$GLOBALS['egw']->preferences->read_repository(); $GLOBALS['egw']->preferences->read_repository();
} }
$attribute = $type == 'group' ? 'user' : $type; $attribute = $type == 'group' ? 'user' : $type;
@ -100,9 +100,9 @@ class preferences_settings
list($type,$account_id) = explode(':', $content['type']); list($type,$account_id) = explode(':', $content['type']);
//_debug_array($prefs); //_debug_array($prefs);
} }
if ($account_id && $account_id != $GLOBALS['egw']->preferences->account_id) if ($account_id && $account_id != $GLOBALS['egw']->preferences->get_account_id())
{ {
$GLOBALS['egw']->preferences->account_id = $account_id; $GLOBALS['egw']->preferences->set_account_id($account_id);
$GLOBALS['egw']->preferences->read_repository(); $GLOBALS['egw']->preferences->read_repository();
} }
$preserve = array( $preserve = array(
@ -121,7 +121,7 @@ class preferences_settings
{ {
$attribute = $type == 'group' ? 'user' : $type; $attribute = $type == 'group' ? 'user' : $type;
$msg = $this->process_array($GLOBALS['egw']->preferences->$attribute, $msg = $this->process_array($GLOBALS['egw']->preferences->$attribute,
$GLOBALS['egw']->preferences->{$attribute}[$appname], $preserve['types'], $appname, $attribute, true); (array)$GLOBALS['egw']->preferences->{$attribute}[$appname], $preserve['types'], $appname, $attribute, true);
} }
$content['msg'] = $msg; $content['msg'] = $msg;
@ -148,7 +148,6 @@ class preferences_settings
//_debug_array($values);exit; //_debug_array($values);exit;
foreach($values as $var => $value) foreach($values as $var => $value)
{ {
error_log(__METHOD__."() types[var='$var']='{$types[$var]}', value=".array2string($value));
// type specific validation // type specific validation
switch((string)$types[$var]) switch((string)$types[$var])
{ {
@ -262,7 +261,7 @@ class preferences_settings
throw new egw_exception_wrong_parameter("Could not find settings for application: ".$appname); throw new egw_exception_wrong_parameter("Could not find settings for application: ".$appname);
} }
$attribute = $type == 'group' ? 'user' : $type; $attribute = $type == 'group' ? 'user' : $type;
//error_log(__METHOD__."('$appname', '$type' ) attribute='$attribute', preferences->account_id=".$GLOBALS['egw']->preferences->account_id); //error_log(__METHOD__."('$appname', '$type' ) attribute='$attribute', preferences->account_id=".$GLOBALS['egw']->preferences->get_account_id());
//_debug_array($this->settings); exit; //_debug_array($this->settings); exit;
$sel_options = $readonlys = $content = $tabs = array(); $sel_options = $readonlys = $content = $tabs = array();
@ -364,7 +363,10 @@ class preferences_settings
} }
if ($type == 'user') if ($type == 'user')
{ {
$default = $GLOBALS['egw']->preferences->default[$appname][$setting['name']]; $default = $GLOBALS['egw']->preferences->group[$appname][$setting['name']] ?
$GLOBALS['egw']->preferences->group[$appname][$setting['name']] :
$GLOBALS['egw']->preferences->default[$appname][$setting['name']];
if (isset($setting['values']) && (string)$setting['values'][$default] !== '') if (isset($setting['values']) && (string)$setting['values'][$default] !== '')
{ {
$default = $setting['values'][$default]; $default = $setting['values'][$default];
@ -421,9 +423,9 @@ class preferences_settings
if ($GLOBALS['egw_info']['apps']['admin']) if ($GLOBALS['egw_info']['apps']['admin'])
{ {
$content['type'] = $type; $content['type'] = $type;
if ($GLOBALS['egw']->preferences->account_id != $GLOBALS['egw_info']['user']['account_id']) if (($id = $GLOBALS['egw']->preferences->get_account_id()) != $GLOBALS['egw_info']['user']['account_id'])
{ {
$content['type'] .= ':'.$GLOBALS['egw']->preferences->account_id; $content['type'] .= ':'.$id;
$sel_options['type'][$content['type']] = common::grab_owner_name($GLOBALS['egw']->preferences->account_id); $sel_options['type'][$content['type']] = common::grab_owner_name($GLOBALS['egw']->preferences->account_id);
} }
foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups', 'sort' => 'account_lid')) as $account_id => $group) foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups', 'sort' => 'account_lid')) as $account_id => $group)