Add server-side plugin hooks to address group functions + better action names

release-0.6
thomascube 15 years ago
parent cbde304b98
commit aa12df20e4

@ -221,8 +221,8 @@ $action_map = array(
'group-create' => 'groups.inc', 'group-create' => 'groups.inc',
'group-rename' => 'groups.inc', 'group-rename' => 'groups.inc',
'group-delete' => 'groups.inc', 'group-delete' => 'groups.inc',
'group-addmember' => 'groups.inc', 'group-addmembers' => 'groups.inc',
'group-delmenber' => 'groups.inc', 'group-delmembers' => 'groups.inc',
), ),
'settings' => array( 'settings' => array(

@ -3238,11 +3238,9 @@ function rcube_webmail()
var insert = ''; var insert = '';
// insert all members of a group // insert all members of a group
if (typeof this.env.contacts[id] == 'object' && this.env.contacts[id].id) { if (typeof this.env.contacts[id] == 'object' && this.env.contacts[id].members) {
insert += this.env.contacts[id].name + ', '; for (var i=0; i < this.env.contacts[id].members.length; i++)
this.group2expand = $.extend({}, this.env.contacts[id]); insert += this.env.contacts[id].members[i] + ', ';
this.group2expand.input = this.ksearch_input;
this.http_request('group-expand', '_source='+urlencode(this.env.contacts[id].source)+'&_gid='+urlencode(this.env.contacts[id].id), false);
} }
else if (typeof this.env.contacts[id] == 'string') else if (typeof this.env.contacts[id] == 'string')
insert = this.env.contacts[id] + ', '; insert = this.env.contacts[id] + ', ';
@ -3255,14 +3253,6 @@ function rcube_webmail()
this.ksearch_input.setSelectionRange(cpos, cpos); this.ksearch_input.setSelectionRange(cpos, cpos);
}; };
this.replace_group_recipients = function(id, recipients)
{
if (this.group2expand && this.group2expand.id == id) {
this.group2expand.input.value = this.group2expand.input.value.replace(this.group2expand.name, recipients);
this.group2expand = null;
}
};
// address search processor // address search processor
this.ksearch_get_results = function() this.ksearch_get_results = function()
{ {
@ -3519,7 +3509,7 @@ function rcube_webmail()
cid = this.contact_list.get_selection().join(','); cid = this.contact_list.get_selection().join(',');
if (to.type == 'group') if (to.type == 'group')
this.http_post('group-addmember', '_cid='+urlencode(cid)+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(to.id)); this.http_post('group-addmembers', '_cid='+urlencode(cid)+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(to.id));
else if (to.id != this.env.source && cid && this.env.address_sources[to.id] && !this.env.address_sources[to.id].readonly) else if (to.id != this.env.source && cid && this.env.address_sources[to.id] && !this.env.address_sources[to.id].readonly)
this.http_post('copy', '_cid='+urlencode(cid)+'&_source='+urlencode(this.env.source)+'&_to='+urlencode(to.id)); this.http_post('copy', '_cid='+urlencode(cid)+'&_source='+urlencode(this.env.source)+'&_to='+urlencode(to.id));
}; };
@ -3558,7 +3548,7 @@ function rcube_webmail()
// send request to server // send request to server
if (this.env.group) if (this.env.group)
this.http_post('group-delmember', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group)+qs); this.http_post('group-delmembers', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group)+qs);
else else
this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs); this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs);

@ -97,6 +97,7 @@ $messages['selectimportfile'] = 'Please select a file to upload';
$messages['addresswriterror'] = 'The selected address book is not writeable'; $messages['addresswriterror'] = 'The selected address book is not writeable';
$messages['contactaddedtogroup'] = 'Successfully added the contacts to this group'; $messages['contactaddedtogroup'] = 'Successfully added the contacts to this group';
$messages['contactremovedfromgroup'] = 'Successfully remove contacts from this group'; $messages['contactremovedfromgroup'] = 'Successfully remove contacts from this group';
$messages['importwait'] = 'Importing, please wait...'; $messages['importwait'] = 'Importing, please wait...';
$messages['importerror'] = 'Import failed! The uploaded file is not a valid vCard file.'; $messages['importerror'] = 'Import failed! The uploaded file is not a valid vCard file.';
$messages['importconfirm'] = '<b>Successfully imported $inserted contacts, $skipped existing entries skipped</b>:<p><em>$names</em></p>'; $messages['importconfirm'] = '<b>Successfully imported $inserted contacts, $skipped existing entries skipped</b>:<p><em>$names</em></p>';

@ -25,54 +25,70 @@ if ($CONTACTS->readonly || !$CONTACTS->groups) {
$OUTPUT->send(); $OUTPUT->send();
} }
if ($RCMAIL->action == 'group-addmember') { $source = get_input_value('_source', RCUBE_INPUT_GPC);
if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST)))
if ($CONTACTS->add_to_group($gid, $ids)) if ($RCMAIL->action == 'group-addmembers') {
if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST))) {
$plugin = $RCMAIL->plugins->exec_hook('group_addmember', array('group_id' => $gid, 'ids' => $ids, 'source' => $source));
if (!$plugin['abort'] && $CONTACTS->add_to_group($gid, $plugin['ids']))
$OUTPUT->show_message('contactaddedtogroup'); $OUTPUT->show_message('contactaddedtogroup');
//else else if ($plugin['message'])
// $OUTPUT->show_message('erroraddingcontact', 'warning'); $OUTPUT->show_message($plugin['message'], 'warning');
} }
}
else if ($RCMAIL->action == 'group-delmembers') {
if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST))) {
$plugin = $RCMAIL->plugins->exec_hook('group_delmembers', array('group_id' => $gid, 'ids' => $ids, 'source' => $source));
$ids = $plugin['ids'];
else if ($RCMAIL->action == 'group-delmember') { if (!$plugin['abort'] && $CONTACTS->remove_from_group($gid, $ids))
if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST)))
if ($CONTACTS->remove_from_group($gid, $ids))
$OUTPUT->show_message('contactremovedfromgroup'); $OUTPUT->show_message('contactremovedfromgroup');
//else else if ($plugin['message'])
// $OUTPUT->show_message('erroraddingcontact', 'warning'); $OUTPUT->show_message($plugin['message'], 'warning');
}
} }
else if ($RCMAIL->action == 'group-create') { else if ($RCMAIL->action == 'group-create') {
if (!empty($_POST['_name'])) { if ($name = trim(get_input_value('_name', RCUBE_INPUT_POST))) {
$name = trim(get_input_value('_name', RCUBE_INPUT_POST)); $plugin = $RCMAIL->plugins->exec_hook('group_create', array('name' => $name, 'source' => $source));
$created = $CONTACTS->create_group($name); if (!$plugin['abort'])
$created = $CONTACTS->create_group($plugin['name']);
} }
if ($created && $OUTPUT->ajax_call) { if ($created && $OUTPUT->ajax_call) {
$OUTPUT->command('insert_contact_group', $created); $OUTPUT->command('insert_contact_group', $created);
} }
else if (!$create) { else if (!$created) {
$OUTPUT->show_message('errorsaving', 'error'); $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
} }
} }
else if ($RCMAIL->action == 'group-rename') { else if ($RCMAIL->action == 'group-rename') {
if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($name = trim(get_input_value('_name', RCUBE_INPUT_POST)))) if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($name = trim(get_input_value('_name', RCUBE_INPUT_POST)))) {
$newname = $CONTACTS->rename_group($gid, $name); $plugin = $RCMAIL->plugins->exec_hook('group_rename', array('group_id' => $gid, 'name' => $name, 'source' => $source));
if (!$plugin['abort'])
$newname = $CONTACTS->rename_group($gid, $plugin['name']);
}
if ($newname && $OUTPUT->ajax_call) if ($newname && $OUTPUT->ajax_call)
$OUTPUT->command('update_contact_group', $gid, $newname); $OUTPUT->command('update_contact_group', $gid, $newname);
else if (!$newname) else if (!$newname)
$OUTPUT->show_message('errorsaving', 'error'); $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
} }
else if ($RCMAIL->action == 'group-delete') { else if ($RCMAIL->action == 'group-delete') {
if ($gid = get_input_value('_gid', RCUBE_INPUT_POST)) if ($gid = get_input_value('_gid', RCUBE_INPUT_POST)) {
$plugin = $RCMAIL->plugins->exec_hook('group_delete', array('group_id' => $gid, 'source' => $source));
if (!$plugin['abort'])
$deleted = $CONTACTS->delete_group($gid); $deleted = $CONTACTS->delete_group($gid);
}
if ($deleted) if ($deleted)
$OUTPUT->command('remove_group_item', $gid); $OUTPUT->command('remove_group_item', $gid);
else else
$OUTPUT->show_message('errorsaving', 'error'); $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
} }
// send response // send response

Loading…
Cancel
Save