X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=program%2Fsteps%2Faddressbook%2Fdelete.inc;h=20e98ce59a4293204a0bb93cd2acf98cb7534faa;hb=8bb10dbda276f4c5f1050a05786ba5a5a6cc787d;hp=2bec51e8a337e5768b9b3dd1ac532a2ee9ea00c5;hpb=0af63e79917234f76cfa7ec74e9d97b24fbf9b55;p=roundcube.git diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc index 2bec51e..20e98ce 100644 --- a/program/steps/addressbook/delete.inc +++ b/program/steps/addressbook/delete.inc @@ -5,7 +5,7 @@ | program/steps/addressbook/delete.inc | | | | This file is part of the RoundCube Webmail client | - | Copyright (C) 2005, RoundCube Dev. - Switzerland | + | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | | Licensed under the GNU GPL | | | | PURPOSE: | @@ -15,84 +15,33 @@ | Author: Thomas Bruederli | +-----------------------------------------------------------------------+ - $Id: delete.inc 429 2006-12-22 22:26:24Z thomasb $ + $Id: delete.inc 573 2007-05-18 11:29:25Z thomasb $ */ -$REMOTE_REQUEST = TRUE; - -if ($_GET['_cid'] && preg_match('/^[0-9]+(,[0-9]+)*$/',$_GET['_cid'])) +if (($cid = get_input_value('_cid', RCUBE_INPUT_POST)) && preg_match('/^[0-9]+(,[0-9]+)*$/', $cid)) { - $DB->query("UPDATE ".get_table_name('contacts')." - SET del=1 - WHERE user_id=? - AND contact_id IN (".$_GET['_cid'].")", - $_SESSION['user_id']); - - $count = $DB->affected_rows(); - if (!$count) + $deleted = $CONTACTS->delete($cid); + if (!$deleted) { // send error message exit; } - // count contacts for this user - $sql_result = $DB->query("SELECT COUNT(contact_id) AS rows - FROM ".get_table_name('contacts')." - WHERE del<>1 - AND user_id=?", - $_SESSION['user_id']); - - $sql_arr = $DB->fetch_assoc($sql_result); - $rowcount = $sql_arr['rows']; + $result = $CONTACTS->count(); // update message count display - $pages = ceil($rowcount/$CONFIG['pagesize']); - $commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_rowcount_text($rowcount)); - $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages); - + $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) - if ($_GET['_from']!='show' && $pages>1 && $_SESSION['page'] < $pages) - { - $start_row = ($_SESSION['page'] * $CONFIG['pagesize']) - $count; - - // get contacts from DB - $sql_result = $DB->limitquery("SELECT * FROM ".get_table_name('contacts')." - WHERE del<>1 - AND user_id=? - ORDER BY name", - $start_row, - $count, - $_SESSION['user_id']); - - $commands .= rcmail_js_contacts_list($sql_result); - -/* - // define list of cols to be displayed - $a_show_cols = array('name', 'email'); - - while ($sql_arr = $DB->fetch_assoc($sql_result)) - { - $a_row_cols = array(); - - // format each col - foreach ($a_show_cols as $col) - { - $cont = rep_specialchars_output($sql_arr[$col]); - $a_row_cols[$col] = $cont; - } - - $commands .= sprintf("this.add_contact_row(%s, %s);\n", - $sql_arr['contact_id'], - array2js($a_row_cols)); - } -*/ - } + $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 - rcube_remote_response($commands); + $OUTPUT->send(); } exit;