diff options
author | Aleksander Machniak <machniak@kolabsys.com> | 2014-11-06 10:49:27 (GMT) |
---|---|---|
committer | Aleksander Machniak <machniak@kolabsys.com> | 2014-11-06 10:49:27 (GMT) |
commit | 02549fda15a1ba7ebfbacb7b128cab8b528c4f88 (patch) | |
tree | d63db229f337bcd35d0e5b58c7b3f51ad506645e | |
parent | e561788b5c9bc243e332c09d86506489deeee796 (diff) | |
download | kolab-wap-02549fda15a1ba7ebfbacb7b128cab8b528c4f88.tar.gz |
Fix re-generating read-only fields on object type change (#2980)kolab-webadmin-3.2.3
-rw-r--r-- | lib/kolab_client_task.php | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php index da0acf5..b784856 100644 --- a/lib/kolab_client_task.php +++ b/lib/kolab_client_task.php @@ -1070,25 +1070,11 @@ class kolab_client_task $extra_fields[$idx] = true; - // build auto_attribs and event_fields lists - $is_data = 0; + // build event_fields list if (!empty($field['data'])) { - foreach ($field['data'] as $fd) { - $event_fields[$fd][] = $idx; - if (isset($data[$fd])) { - $is_data++; - } - } - if (count($field['data']) == $is_data) { - $auto_attribs[] = $idx; - } - } - else { - //console("\$field['data'] is empty for \$auto_fields[\$idx] (idx: $idx)"); - $auto_attribs[] = $idx; - // Unset the $auto_field array key to prevent the form field from - // becoming disabled/readonly - unset($auto_fields[$idx]); + foreach ($field['data'] as $fd) { + $event_fields[$fd][] = $idx; + } } } @@ -1112,6 +1098,33 @@ class kolab_client_task } } + // Re-parse auto_fields again, to get attributes for auto-generation + // Need to do this after form_fields have been initialized (#2980) + foreach ($auto_fields as $idx => $field) { + // build auto_attribs and event_fields lists + if (!empty($field['data'])) { + $is_data = 0; + foreach ($field['data'] as $fd) { + if (!isset($data[$fd]) && isset($fields[$fd]['value'])) { + $data[$fd] = $fields[$fd]['value']; + } + if (isset($data[$fd])) { + $is_data++; + } + } + + if (count($field['data']) == $is_data) { + $auto_attribs[] = $idx; + } + } + else { + $auto_attribs[] = $idx; + // Unset the $auto_fields array key to prevent the form field from + // becoming disabled/readonly + unset($auto_fields[$idx]); + } + } + // Get the rights on the entry and attribute level $data['effective_rights'] = $this->effective_rights($name, $data['id']); $attribute_rights = (array) $data['effective_rights']['attribute']; |