From 01e339815f4619d2b7134c394f12b781845419bb Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 27 Mar 2015 16:32:51 +0000 Subject: [PATCH] Fix customfields options with multiple negated fields and single custom field --- ...lass.etemplate_widget_customfields.inc.php | 19 +++++++++++-------- etemplate/js/et2_extension_customfields.js | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_customfields.inc.php b/etemplate/inc/class.etemplate_widget_customfields.inc.php index f8bfd3b5a1..61473fb6e3 100644 --- a/etemplate/inc/class.etemplate_widget_customfields.inc.php +++ b/etemplate/inc/class.etemplate_widget_customfields.inc.php @@ -135,17 +135,21 @@ class etemplate_widget_customfields extends etemplate_widget_transformer // app changed $customfields =& egw_customfields::get($app); } - // Filter fields if($this->attrs['field-names']) { - if($this->attrs['field-names'][0] == '!') + $fields_name = explode(',', $this->attrs['field-names']); + foreach($fields_name as &$f) { - $negate_field_filter = true; - $this->attrs['field-names'] = substr($this->attrs['field-names'],1); + if ($f[0] == "!") + { + $f= substr($f,1); + $negate_fields[]= $f; + } + $field_filters []= $f; } - $field_filter = explode(',', $this->attrs['field-names']); } + $fields = $customfields; $use_private = self::expand_name($this->attrs['use-private'],0,0,'','',self::$cont); @@ -160,8 +164,7 @@ class etemplate_widget_customfields extends etemplate_widget_transformer } // Remove filtered fields - if($field_filter && (!$negate_field_filter && !in_array($key, $field_filter) || - $negate_field_filter && in_array($key, $field_filter))) + if($field_filters && in_array($key, $negate_fields) && in_array($key, $field_filters)) { unset($fields[$key]); } @@ -173,7 +176,7 @@ class etemplate_widget_customfields extends etemplate_widget_transformer { $fields = array($name => $fields[$name]); $value = array(self::$prefix.$name => $value); - $form_name = substr($form_name,0,-strlen('['.self::$prefix.$name.']')); + $form_name = self::$prefix.$name; } if(!is_array($fields)) $fields = array(); diff --git a/etemplate/js/et2_extension_customfields.js b/etemplate/js/et2_extension_customfields.js index f01a7a8c16..50e9472e0b 100644 --- a/etemplate/js/et2_extension_customfields.js +++ b/etemplate/js/et2_extension_customfields.js @@ -53,7 +53,7 @@ var et2_customfields_list = et2_valueWidget.extend([et2_IDetachedDOM, et2_IInput } }, - legacyOptions: ["type_filter","private"], // Field restriction & private done server-side + legacyOptions: ["type_filter","private", "fields"], // Field restriction & private done server-side prefix: '#',