commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/addressbook/list.inc | |
|
6 |
| | |
e019f2
|
7 |
| This file is part of the Roundcube Webmail client | |
438753
|
8 |
| Copyright (C) 2005-2012, The Roundcube Dev Team | |
7fe381
|
9 |
| | |
T |
10 |
| Licensed under the GNU General Public License version 3 or | |
|
11 |
| any later version with exceptions for skins & plugins. | |
|
12 |
| See the README file for a full license statement. | |
4e17e6
|
13 |
| | |
T |
14 |
| PURPOSE: | |
|
15 |
| Send contacts list to client (as remote response) | |
|
16 |
| | |
|
17 |
+-----------------------------------------------------------------------+ |
|
18 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
19 |
+-----------------------------------------------------------------------+ |
|
20 |
|
|
21 |
$Id$ |
|
22 |
|
|
23 |
*/ |
|
24 |
|
ecf295
|
25 |
// Use search result |
b896b1
|
26 |
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) |
ecf295
|
27 |
{ |
A |
28 |
$search = (array)$_SESSION['search'][$_REQUEST['_search']]; |
|
29 |
$records = array(); |
b896b1
|
30 |
|
ecf295
|
31 |
if (!empty($_GET['_page'])) |
A |
32 |
$page = intval($_GET['_page']); |
|
33 |
else |
|
34 |
$page = isset($_SESSION['page']) ? $_SESSION['page'] : 1; |
|
35 |
|
|
36 |
$_SESSION['page'] = $page; |
438753
|
37 |
$sort_col = $this->config->get('addressbook_sort_col', 'name'); |
ecf295
|
38 |
|
A |
39 |
// Get records from all sources |
|
40 |
foreach ($search as $s => $set) { |
|
41 |
$source = $RCMAIL->get_address_book($s); |
|
42 |
|
|
43 |
// reset page |
|
44 |
$source->set_page(1); |
|
45 |
$source->set_pagesize(9999); |
|
46 |
$source->set_search_set($set); |
|
47 |
|
|
48 |
// get records |
168e54
|
49 |
$result = $source->list_records(array('name', 'firstname', 'surname', 'email')); |
ecf295
|
50 |
|
A |
51 |
while ($row = $result->next()) { |
|
52 |
$row['sourceid'] = $s; |
0203f1
|
53 |
$key = rcmail_contact_key($row, $sort_col); |
ecf295
|
54 |
$records[$key] = $row; |
A |
55 |
} |
|
56 |
unset($result); |
|
57 |
} |
|
58 |
|
|
59 |
// sort the records |
|
60 |
ksort($records, SORT_LOCALE_STRING); |
|
61 |
|
|
62 |
// create resultset object |
08ffd9
|
63 |
$count = count($records); |
A |
64 |
$first = ($page-1) * $PAGE_SIZE; |
ecf295
|
65 |
$result = new rcube_result_set($count, $first); |
A |
66 |
|
|
67 |
// we need only records for current page |
08ffd9
|
68 |
if ($PAGE_SIZE < $count) { |
A |
69 |
$records = array_slice($records, $first, $PAGE_SIZE); |
ecf295
|
70 |
} |
A |
71 |
|
|
72 |
$result->records = array_values($records); |
|
73 |
} |
|
74 |
// List selected directory |
|
75 |
else { |
|
76 |
$CONTACTS = rcmail_contact_source(null, true); |
|
77 |
|
|
78 |
// get contacts for this user |
168e54
|
79 |
$result = $CONTACTS->list_records(array('name', 'firstname', 'surname', 'email')); |
08ffd9
|
80 |
|
e2a8b4
|
81 |
if (!$result->count && $result->searchonly) { |
2d3e2b
|
82 |
$OUTPUT->show_message('contactsearchonly', 'notice'); |
e2a8b4
|
83 |
$OUTPUT->command('command', 'advanced-search'); |
T |
84 |
} |
ecf295
|
85 |
} |
4e17e6
|
86 |
|
T |
87 |
// update message count display |
08ffd9
|
88 |
$OUTPUT->set_env('pagecount', ceil($result->count / $PAGE_SIZE)); |
ecf295
|
89 |
$OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result)); |
4e17e6
|
90 |
|
f11541
|
91 |
// create javascript list |
T |
92 |
rcmail_js_contacts_list($result); |
e9a9f2
|
93 |
|
4e17e6
|
94 |
// send response |
f11541
|
95 |
$OUTPUT->send(); |