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