commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/addressbook/delete.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
881217
|
8 |
| Copyright (C) 2005-2009, RoundCube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Delete the submitted contacts (CIDs) from the users address book | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
881217
|
22 |
if ($OUTPUT->ajax_call && |
T |
23 |
($cid = get_input_value('_cid', RCUBE_INPUT_POST)) && |
4f9c83
|
24 |
(preg_match('/^[0-9]+(,[0-9]+)*$/', $cid) || |
S |
25 |
preg_match('/^[a-zA-Z0-9=]+(,[a-zA-Z0-9=]+)*$/', $cid)) |
|
26 |
) |
4e17e6
|
27 |
{ |
69f18a
|
28 |
$plugin = $RCMAIL->plugins->exec_hook('delete_contact', array('id' => $cid, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); |
T |
29 |
|
|
30 |
$deleted = !$plugin['abort'] ? $CONTACTS->delete($cid) : false; |
f11541
|
31 |
if (!$deleted) |
4e17e6
|
32 |
{ |
T |
33 |
// send error message |
|
34 |
exit; |
|
35 |
} |
|
36 |
|
|
37 |
// count contacts for this user |
f11541
|
38 |
$result = $CONTACTS->count(); |
4e17e6
|
39 |
|
T |
40 |
// update message count display |
f11541
|
41 |
$OUTPUT->set_env('pagecount', ceil($result->count / $CONTACTS->page_size)); |
T |
42 |
$OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result->count)); |
4e17e6
|
43 |
|
T |
44 |
// add new rows from next page (if any) |
f11541
|
45 |
$pages = ceil(($result->count + $deleted) / $CONTACTS->page_size); |
T |
46 |
if ($_GET['_from'] != 'show' && $pages > 1 && $CONTACTS->list_page < $pages) |
|
47 |
rcmail_js_contacts_list($CONTACTS->list_records(null, -$deleted)); |
4e17e6
|
48 |
|
T |
49 |
// send response |
f11541
|
50 |
$OUTPUT->send(); |
4e17e6
|
51 |
} |
T |
52 |
|
|
53 |
exit; |
ee883a
|
54 |
?> |