summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-04-15 13:31:53 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-04-15 13:31:53 (GMT)
commiteaca5181d46f5176b2215885a2dd611667d36b07 (patch)
treef15d47ac6319c4c0547b304bb2a0fdb0b4dc741b
parent1427f5ff20b9a35b6ba854d1e4c4c0b505470e4b (diff)
downloadkolab-wap-eaca5181d46f5176b2215885a2dd611667d36b07.tar.gz
Added user autocompletion in imap acl widget
-rw-r--r--lib/api/kolab_api_service_form_value.php20
-rw-r--r--public_html/js/kolab_admin.js35
2 files changed, 40 insertions, 15 deletions
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index e013285..f5e7ca5 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -1323,19 +1323,27 @@ class kolab_api_service_form_value extends kolab_api_service
$data['attributes'] = array('displayname', 'mail');
- $service = $this->controller->get_service('users');
- $result = $service->users_list(null, $data);
- $list = $result['list'];
+ $service = $this->controller->get_service('users');
+ $result = $service->users_list(null, $data);
+ $list = $result['list'];
+ $result = array();
+ $result_key = $postdata['result_key'] ?: 'entrydn';
// convert to key=>value array
foreach ($list as $idx => $value) {
- $list[$idx] = $value['displayname'];
+ $ret = $value['displayname'];
if (!empty($value['mail'])) {
- $list[$idx] .= ' <' . $value['mail'] . '>';
+ $ret .= ' <' . $value['mail'] . '>';
}
+
+ if ($result_key != 'entrydn') {
+ $idx = $value[$result_key];
+ }
+
+ $result[$idx] = $ret;
}
- return $list;
+ return $result;
}
private function _list_options_resources($postdata, $attribs = array())
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index d7167c4..c7a803b 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -473,6 +473,17 @@ function kolab_admin()
this.ac_init = function(obj, props)
{
+ if (props && props.form) {
+ if (i = $('[name="type_id"]', props.form).val())
+ props.type_id = i;
+ if (i = $('[name="object_type"]', props.form).val())
+ props.object_type = i;
+ if (i = $('[name="id"]', props.form).val())
+ props.id = i;
+
+ delete props['form'];
+ }
+
obj.keydown(function(e) { return kadm.ac_keydown(e, props); })
.attr('autocomplete', 'off');
};
@@ -877,14 +888,11 @@ function kolab_admin()
}, -1);
// Initialize autocompletion
- var props = {attribute: form_element.name, oninsert: this.form_element_oninsert};
- if (i = $('[name="type_id"]', form).val())
- props.type_id = i;
- if (i = $('[name="object_type"]', form).val())
- props.object_type = i;
- if (i = $('[name="id"]', form).val())
- props.id = i;
- this.ac_init(elem, props);
+ this.ac_init(elem, {
+ form: form,
+ attribute: form_element.name,
+ oninsert: this.form_element_oninsert
+ });
elem.appendTo(area);
area.addClass('autocomplete');
@@ -1886,7 +1894,7 @@ function kolab_admin()
this.trigger_event('form-load', 'acl-form');
// reset form elements
- subject_select.val(acl.subject).change();
+ subject_select.val(acl.subject.match(/^(anyone|anonymous)$/i) ? acl.subject : 'user').change();
subject_input.val(subject_select.val() == 'user' ? acl.subject : '');
epoch_input.val(this.unix_to_date(acl.epoch, true));
epoch_input.datetimepicker({
@@ -1900,6 +1908,15 @@ function kolab_admin()
$('input[value="' + this + '"]', rights_div).prop('checked', v == 'custom' && acl.rights && acl.rights.indexOf(this) > -1);
});
+ // Initialize autocompletion
+ this.ac_init(subject_input, {
+ action: 'form_value.list_options',
+ attribute: 'owner',
+ result_key: 'mail',
+ oninsert: function(key, val) { $(this.ac_input).val(key); },
+ form: $('textarea[name="' + this.acl_dialog_name + '"]').parents('form')
+ });
+
return dialog.show();
};