4 +-----------------------------------------------------------------------+
5 | program/steps/addressbook/delete.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Delete the submitted contacts (CIDs) from the users address book |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: delete.inc 429 2006-12-22 22:26:24Z thomasb $
22 $REMOTE_REQUEST = TRUE;
24 if ($_GET['_cid'] && preg_match('/^[0-9]+(,[0-9]+)*$/',$_GET['_cid']))
26 $DB->query("UPDATE ".get_table_name('contacts')."
29 AND contact_id IN (".$_GET['_cid'].")",
30 $_SESSION['user_id']);
32 $count = $DB->affected_rows();
40 // count contacts for this user
41 $sql_result = $DB->query("SELECT COUNT(contact_id) AS rows
42 FROM ".get_table_name('contacts')."
45 $_SESSION['user_id']);
47 $sql_arr = $DB->fetch_assoc($sql_result);
48 $rowcount = $sql_arr['rows'];
50 // update message count display
51 $pages = ceil($rowcount/$CONFIG['pagesize']);
52 $commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_rowcount_text($rowcount));
53 $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
56 // add new rows from next page (if any)
57 if ($_GET['_from']!='show' && $pages>1 && $_SESSION['page'] < $pages)
59 $start_row = ($_SESSION['page'] * $CONFIG['pagesize']) - $count;
61 // get contacts from DB
62 $sql_result = $DB->limitquery("SELECT * FROM ".get_table_name('contacts')."
68 $_SESSION['user_id']);
70 $commands .= rcmail_js_contacts_list($sql_result);
73 // define list of cols to be displayed
74 $a_show_cols = array('name', 'email');
76 while ($sql_arr = $DB->fetch_assoc($sql_result))
78 $a_row_cols = array();
81 foreach ($a_show_cols as $col)
83 $cont = rep_specialchars_output($sql_arr[$col]);
84 $a_row_cols[$col] = $cont;
87 $commands .= sprintf("this.add_contact_row(%s, %s);\n",
88 $sql_arr['contact_id'],
89 array2js($a_row_cols));
95 rcube_remote_response($commands);