summaryrefslogtreecommitdiff
path: root/program/steps/addressbook
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2010-04-01 06:39:06 +0000
committerthomascube <thomas@roundcube.net>2010-04-01 06:39:06 +0000
commitaa12df20e46ae72467f8d4dc01784a500eb83f0c (patch)
treef1ff109b8d0c9850ad19498067a87767da417894 /program/steps/addressbook
parentcbde304b98e4e0fc2ff33fd84068d63ae3e86c45 (diff)
Add server-side plugin hooks to address group functions + better action names
Diffstat (limited to 'program/steps/addressbook')
-rw-r--r--program/steps/addressbook/groups.inc62
1 files changed, 39 insertions, 23 deletions
diff --git a/program/steps/addressbook/groups.inc b/program/steps/addressbook/groups.inc
index 014192676..f69501b0d 100644
--- a/program/steps/addressbook/groups.inc
+++ b/program/steps/addressbook/groups.inc
@@ -25,54 +25,70 @@ if ($CONTACTS->readonly || !$CONTACTS->groups) {
$OUTPUT->send();
}
-if ($RCMAIL->action == 'group-addmember') {
- if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST)))
- if ($CONTACTS->add_to_group($gid, $ids))
- $OUTPUT->show_message('contactaddedtogroup');
- //else
- // $OUTPUT->show_message('erroraddingcontact', 'warning');
+$source = get_input_value('_source', RCUBE_INPUT_GPC);
+
+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');
+ else if ($plugin['message'])
+ $OUTPUT->show_message($plugin['message'], 'warning');
+ }
}
-else if ($RCMAIL->action == 'group-delmember') {
- 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');
- //else
- // $OUTPUT->show_message('erroraddingcontact', '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'];
+
+ if (!$plugin['abort'] && $CONTACTS->remove_from_group($gid, $ids))
+ $OUTPUT->show_message('contactremovedfromgroup');
+ else if ($plugin['message'])
+ $OUTPUT->show_message($plugin['message'], 'warning');
+ }
}
else if ($RCMAIL->action == 'group-create') {
- if (!empty($_POST['_name'])) {
- $name = trim(get_input_value('_name', RCUBE_INPUT_POST));
- $created = $CONTACTS->create_group($name);
+ if ($name = trim(get_input_value('_name', RCUBE_INPUT_POST))) {
+ $plugin = $RCMAIL->plugins->exec_hook('group_create', array('name' => $name, 'source' => $source));
+ if (!$plugin['abort'])
+ $created = $CONTACTS->create_group($plugin['name']);
}
if ($created && $OUTPUT->ajax_call) {
$OUTPUT->command('insert_contact_group', $created);
}
- else if (!$create) {
- $OUTPUT->show_message('errorsaving', 'error');
+ else if (!$created) {
+ $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
}
}
else if ($RCMAIL->action == 'group-rename') {
- if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($name = trim(get_input_value('_name', RCUBE_INPUT_POST))))
- $newname = $CONTACTS->rename_group($gid, $name);
+ if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($name = trim(get_input_value('_name', RCUBE_INPUT_POST)))) {
+ $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)
$OUTPUT->command('update_contact_group', $gid, $newname);
else if (!$newname)
- $OUTPUT->show_message('errorsaving', 'error');
+ $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
}
else if ($RCMAIL->action == 'group-delete') {
- if ($gid = get_input_value('_gid', RCUBE_INPUT_POST))
- $deleted = $CONTACTS->delete_group($gid);
+ 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);
+ }
if ($deleted)
$OUTPUT->command('remove_group_item', $gid);
else
- $OUTPUT->show_message('errorsaving', 'error');
+ $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
}
// send response