diff options
Diffstat (limited to 'program/steps/addressbook')
-rw-r--r-- | program/steps/addressbook/delete.inc | 39 | ||||
-rw-r--r-- | program/steps/addressbook/groups.inc | 32 |
2 files changed, 39 insertions, 32 deletions
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc index bb0457be7..a41065f7b 100644 --- a/program/steps/addressbook/delete.inc +++ b/program/steps/addressbook/delete.inc @@ -23,30 +23,33 @@ if ($OUTPUT->ajax_call && ($cid = get_input_value('_cid', RCUBE_INPUT_POST)) && preg_match('/^[a-zA-Z0-9\+\/=_-]+(,[a-zA-Z0-9\+\/=_-]+)*$/', $cid) ) { - $plugin = $RCMAIL->plugins->exec_hook('contact_delete', array( - 'id' => $cid, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); + $plugin = $RCMAIL->plugins->exec_hook('contact_delete', array( + 'id' => $cid, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); - $deleted = !$plugin['abort'] ? $CONTACTS->delete($cid) : $plugin['result']; + $deleted = !$plugin['abort'] ? $CONTACTS->delete($cid) : $plugin['result']; - if (!$deleted) { - // send error message - exit; - } + if (!$deleted) { + $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'contactdelerror', 'error'); + $OUTPUT->command('list_contacts'); + } + else { + $OUTPUT->show_message('contactdeleted', 'confirmation'); - // count contacts for this user - $result = $CONTACTS->count(); + // count contacts for this user + $result = $CONTACTS->count(); - // update message count display - $OUTPUT->set_env('pagecount', ceil($result->count / $CONTACTS->page_size)); - $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result->count)); + // update message count display + $OUTPUT->set_env('pagecount', ceil($result->count / $CONTACTS->page_size)); + $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result->count)); - // add new rows from next page (if any) - $pages = ceil(($result->count + $deleted) / $CONTACTS->page_size); - if ($_GET['_from'] != 'show' && $pages > 1 && $CONTACTS->list_page < $pages) - rcmail_js_contacts_list($CONTACTS->list_records(null, -$deleted)); + // add new rows from next page (if any) + $pages = ceil(($result->count + $deleted) / $CONTACTS->page_size); + if ($_GET['_from'] != 'show' && $pages > 1 && $CONTACTS->list_page < $pages) + rcmail_js_contacts_list($CONTACTS->list_records(null, -$deleted)); + } - // send response - $OUTPUT->send(); + // send response + $OUTPUT->send(); } exit; diff --git a/program/steps/addressbook/groups.inc b/program/steps/addressbook/groups.inc index 66619fa7d..f8bd0d7f2 100644 --- a/program/steps/addressbook/groups.inc +++ b/program/steps/addressbook/groups.inc @@ -29,10 +29,10 @@ $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_addmembers', array('group_id' => $gid, 'ids' => $ids, 'source' => $source)); - + $CONTACTS->set_group($gid); $num2add = count(explode(',', $plugin['ids'])); - + if (!$plugin['abort']) { if (($maxnum = $RCMAIL->config->get('max_group_members', 0)) && ($CONTACTS->count()->count + $num2add > $maxnum)) { $OUTPUT->show_message('maxgroupmembersreached', 'warning', array('max' => $maxnum)); @@ -44,26 +44,26 @@ if ($RCMAIL->action == 'group-addmembers') { $result = $plugin['result']; } - if ($result) + if ($result) $OUTPUT->show_message('contactaddedtogroup'); - else if ($plugin['message']) - $OUTPUT->show_message($plugin['message'], 'warning'); + else + $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); } } 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)); - + if (!$plugin['abort']) $result = $CONTACTS->remove_from_group($gid, $plugin['ids']); else $result = $plugin['result']; - if ($result) + if ($result) $OUTPUT->show_message('contactremovedfromgroup'); - else if ($plugin['message']) - $OUTPUT->show_message($plugin['message'], 'warning'); + else + $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); } } @@ -76,10 +76,10 @@ else if ($RCMAIL->action == 'group-create') { else $created = $plugin['result']; } - + if ($created && $OUTPUT->ajax_call) { - $created['source'] = $source; - $OUTPUT->command('insert_contact_group', $created); + $OUTPUT->show_message('groupcreated', 'confirmation'); + $OUTPUT->command('insert_contact_group', array('source' => $created)); } else if (!$created) { $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); @@ -96,8 +96,10 @@ else if ($RCMAIL->action == 'group-rename') { $newname = $plugin['result']; } - if ($newname && $OUTPUT->ajax_call) + if ($newname && $OUTPUT->ajax_call) { + $OUTPUT->show_message('grouprenamed', 'confirmation'); $OUTPUT->command('update_contact_group', array('source' => $source, 'id' => $gid, 'name' => $newname)); + } else if (!$newname) $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); } @@ -112,8 +114,10 @@ else if ($RCMAIL->action == 'group-delete') { $deleted = $plugin['result']; } - if ($deleted) + if ($deleted) { + $OUTPUT->show_message('groupdeleted', 'confirmation'); $OUTPUT->command('remove_group_item', array('source' => $source, 'id' => $gid)); + } else $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); } |