thomascube
2007-11-25 d5342aabcfeddb959cc286befe6de5bf35fe9d76
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                     |
f11541 8  | Copyright (C) 2005-2007, 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
8d0758 22 if (($cid = get_input_value('_cid', RCUBE_INPUT_POST)) && preg_match('/^[0-9]+(,[0-9]+)*$/', $cid))
4e17e6 23   {
f11541 24   $deleted = $CONTACTS->delete($cid);
T 25   if (!$deleted)
4e17e6 26     {
T 27     // send error message
28     exit;
29     }
30
31   // count contacts for this user
f11541 32   $result = $CONTACTS->count();
4e17e6 33
T 34   // update message count display
f11541 35   $OUTPUT->set_env('pagecount', ceil($result->count / $CONTACTS->page_size));
T 36   $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result->count));
4e17e6 37
T 38   // add new rows from next page (if any)
f11541 39   $pages = ceil(($result->count + $deleted) / $CONTACTS->page_size);
T 40   if ($_GET['_from'] != 'show' && $pages > 1 && $CONTACTS->list_page < $pages)
41     rcmail_js_contacts_list($CONTACTS->list_records(null, -$deleted));
4e17e6 42
T 43   // send response
f11541 44   $OUTPUT->send();
4e17e6 45   }
T 46
47 exit;
ee883a 48 ?>