lib/kolab_client_task.php
Aleksander Machniak
machniak at kolabsys.com
Thu Nov 6 11:55:25 CET 2014
lib/kolab_client_task.php | 49 +++++++++++++++++++++++++++++-----------------
1 file changed, 31 insertions(+), 18 deletions(-)
New commits:
commit 02549fda15a1ba7ebfbacb7b128cab8b528c4f88
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Thu Nov 6 05:49:27 2014 -0500
Fix re-generating read-only fields on object type change (#2980)
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'];
More information about the commits
mailing list