allow to unset default info_des from sub_excludefields

This commit is contained in:
Ralf Becker 2012-02-24 10:31:43 +00:00
parent 3015287833
commit 3e5e2156c1
2 changed files with 18 additions and 7 deletions

View File

@ -70,7 +70,13 @@ class infolog_bo
*
* @var array
*/
var $sub_excludefields = array('info_des','info_id', 'info_uid', 'info_etag', 'caldav_name', 'info_created', 'info_creator', 'info_datemodified', 'info_modifier');
var $sub_excludefields = array('info_id', 'info_uid', 'info_etag', 'caldav_name', 'info_created', 'info_creator', 'info_datemodified', 'info_modifier');
/**
* Additional fields to $sub_excludefields to exclude, if no config stored
*
* @var array
*/
var $default_sub_excludefields = array('info_des');
/**
* implicit ACL rights of the responsible user: read or edit
*
@ -244,9 +250,12 @@ class infolog_bo
}
if (is_array($config_data['sub_excludefields']) && $config_data['sub_excludefields'])
{
if (($k = array_search('info_des',$this->sub_excludefields))) unset($this->sub_excludefields[$k]);
$this->sub_excludefields = array_merge($this->sub_excludefields,$config_data['sub_excludefields']);
}
else
{
$this->sub_excludefields = array_merge($this->sub_excludefields,$this->default_sub_excludefields);
}
if ($config_data['implicit_rights'] == 'edit')
{
$this->implicit_rights = 'edit';

View File

@ -2172,15 +2172,17 @@ class infolog_ui
foreach(array('copy_excludefields','sub_excludefields') as $name)
{
$efs = array_keys($name == 'sub_excludefields' ? $sub_excludefields : $excludefields);
$this->bo->$name = array_diff($this->bo->$name, $efs); // restore default from bo
$this->bo->$name = array_unique(array_diff($this->bo->$name, $efs, // restore default from bo
$name == 'sub_excludefields' ? $this->bo->default_sub_excludefields : array()));
if ($_POST[$name])
{
if ($name == 'sub_excludefields') // remove default info_des, to be able to unselect it!
{
$this->bo->sub_excludefields = array_diff($this->bo->sub_excludefields,array('info_des'));
}
$this->bo->$name = array_merge($this->bo->$name, array_intersect((array)$_POST[$name], $efs));
}
elseif ($name == 'sub_excludefields' && !in_array('explicit-set',$this->bo->sub_excludefields))
{
$this->bo->sub_excludefields[] = 'explicit-set'; // otherwise we can NOT unset default info_des
}
}
config::save_value('copy_excludefields',$this->bo->copy_excludefields,'infolog');
config::save_value('sub_excludefields',$this->bo->sub_excludefields,'infolog');