4 +-----------------------------------------------------------------------+
5 | program/steps/addressbook/list.inc |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2005-2007, The Roundcube Dev Team |
9 | Licensed under the GNU GPL |
12 | Send contacts list to client (as remote response) |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: list.inc 5967 2012-03-05 19:59:07Z alec $
23 if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
25 $search = (array)$_SESSION['search'][$_REQUEST['_search']];
28 if (!empty($_GET['_page']))
29 $page = intval($_GET['_page']);
31 $page = isset($_SESSION['page']) ? $_SESSION['page'] : 1;
33 $_SESSION['page'] = $page;
34 $sort_col = $this->config->get('addressbook_sort_col', 'name');
36 // Get records from all sources
37 foreach ($search as $s => $set) {
38 $source = $RCMAIL->get_address_book($s);
42 $source->set_pagesize(9999);
43 $source->set_search_set($set);
46 $result = $source->list_records(array('name', 'email'));
48 while ($row = $result->next()) {
49 $row['sourceid'] = $s;
50 $key = rcmail_contact_key($row, $sort_col);
51 $records[$key] = $row;
57 ksort($records, SORT_LOCALE_STRING);
59 // create resultset object
60 $count = count($records);
61 $first = ($page-1) * $CONFIG['pagesize'];
62 $result = new rcube_result_set($count, $first);
64 // we need only records for current page
65 if ($CONFIG['pagesize'] < $count) {
66 $records = array_slice($records, $first, $CONFIG['pagesize']);
69 $result->records = array_values($records);
71 // List selected directory
73 $CONTACTS = rcmail_contact_source(null, true);
75 // get contacts for this user
76 $result = $CONTACTS->list_records(array('name'));
78 if (!$result->count && $result->searchonly) {
79 $OUTPUT->show_message('contactsearchonly', 'notice');
80 $OUTPUT->command('command', 'advanced-search');
84 // update message count display
85 $OUTPUT->set_env('pagecount', ceil($result->count / $CONFIG['pagesize']));
86 $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result));
88 // create javascript list
89 rcmail_js_contacts_list($result);