Mercurial > hg > rc2
comparison program/steps/addressbook/list.inc @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:52:31 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4681f974d28b |
---|---|
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-2012, The Roundcube Dev Team | | |
9 | | | |
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. | | |
13 | | | |
14 | PURPOSE: | | |
15 | Send contacts list to client (as remote response) | | |
16 | | | |
17 +-----------------------------------------------------------------------+ | |
18 | Author: Thomas Bruederli <roundcube@gmail.com> | | |
19 +-----------------------------------------------------------------------+ | |
20 */ | |
21 | |
22 if (!empty($_GET['_page'])) | |
23 $page = intval($_GET['_page']); | |
24 else | |
25 $page = $_SESSION['page'] ?: 1; | |
26 | |
27 $_SESSION['page'] = $page; | |
28 | |
29 // Use search result | |
30 if (($records = rcmail_search_update(true)) !== false) { | |
31 // sort the records | |
32 ksort($records, SORT_LOCALE_STRING); | |
33 | |
34 // create resultset object | |
35 $count = count($records); | |
36 $first = ($page-1) * $PAGE_SIZE; | |
37 $result = new rcube_result_set($count, $first); | |
38 | |
39 // we need only records for current page | |
40 if ($PAGE_SIZE < $count) { | |
41 $records = array_slice($records, $first, $PAGE_SIZE); | |
42 } | |
43 | |
44 $result->records = array_values($records); | |
45 } | |
46 // List selected directory | |
47 else { | |
48 $afields = $RCMAIL->config->get('contactlist_fields'); | |
49 $CONTACTS = rcmail_contact_source(null, true); | |
50 | |
51 // get contacts for this user | |
52 $result = $CONTACTS->list_records($afields); | |
53 | |
54 if (!$result->count && $result->searchonly) { | |
55 $OUTPUT->show_message('contactsearchonly', 'notice'); | |
56 $OUTPUT->command('command', 'advanced-search'); | |
57 } | |
58 | |
59 if ($CONTACTS->group_id) { | |
60 $group_data = array('ID' => $CONTACTS->group_id) | |
61 + array_intersect_key((array)$CONTACTS->get_group($CONTACTS->group_id), array('name'=>1,'email'=>1)); | |
62 } | |
63 } | |
64 | |
65 $OUTPUT->command('set_group_prop', $group_data); | |
66 | |
67 // update message count display | |
68 $OUTPUT->set_env('pagecount', ceil($result->count / $PAGE_SIZE)); | |
69 $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result)); | |
70 | |
71 // create javascript list | |
72 rcmail_js_contacts_list($result); | |
73 | |
74 // send response | |
75 $OUTPUT->send(); |