| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /* |
|---|
| 4 | +-----------------------------------------------------------------------+ |
|---|
| 5 | | program/steps/addressbook/list.inc | |
|---|
| 6 | | | |
|---|
| 7 | | This file is part of the RoundCube Webmail client | |
|---|
| 8 | | Copyright (C) 2005, RoundCube Dev. - Switzerland | |
|---|
| 9 | | All rights reserved. | |
|---|
| 10 | | | |
|---|
| 11 | | PURPOSE: | |
|---|
| 12 | | Send contacts list to client (as remote response) | |
|---|
| 13 | | | |
|---|
| 14 | +-----------------------------------------------------------------------+ |
|---|
| 15 | | Author: Thomas Bruederli <roundcube@gmail.com> | |
|---|
| 16 | +-----------------------------------------------------------------------+ |
|---|
| 17 | |
|---|
| 18 | $Id$ |
|---|
| 19 | |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | $REMOTE_REQUEST = TRUE; |
|---|
| 23 | |
|---|
| 24 | // count contacts for this user |
|---|
| 25 | $sql_result = $DB->query(sprintf("SELECT COUNT(contact_id) AS rows |
|---|
| 26 | FROM %s |
|---|
| 27 | WHERE del!='1' |
|---|
| 28 | AND user_id=%d", |
|---|
| 29 | get_table_name('contacts'), |
|---|
| 30 | $_SESSION['user_id'])); |
|---|
| 31 | |
|---|
| 32 | $sql_arr = $DB->fetch_assoc($sql_result); |
|---|
| 33 | $rowcount = $sql_arr['rows']; |
|---|
| 34 | |
|---|
| 35 | // update message count display |
|---|
| 36 | $pages = ceil($rowcount/$CONFIG['pagesize']); |
|---|
| 37 | $commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_rowcount_text($rowcount)); |
|---|
| 38 | $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages); |
|---|
| 39 | |
|---|
| 40 | $start_row = ($CONTACTS_LIST['page']-1) * $CONFIG['pagesize']; |
|---|
| 41 | |
|---|
| 42 | // get contacts from DB |
|---|
| 43 | $sql_result = $DB->query(sprintf("SELECT * FROM %s |
|---|
| 44 | WHERE del!='1' |
|---|
| 45 | AND user_id=%d |
|---|
| 46 | ORDER BY name |
|---|
| 47 | LIMIT %d, %d", |
|---|
| 48 | get_table_name('contacts'), |
|---|
| 49 | $_SESSION['user_id'], |
|---|
| 50 | $start_row, |
|---|
| 51 | $CONFIG['pagesize'])); |
|---|
| 52 | |
|---|
| 53 | $commands .= rcmail_js_contacts_list($sql_result); |
|---|
| 54 | |
|---|
| 55 | // send response |
|---|
| 56 | rcube_remote_response($commands); |
|---|
| 57 | |
|---|
| 58 | exit; |
|---|
| 59 | ?> |
|---|