| | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2011, The Roundcube Dev Team | |
| | | | Copyright (C) 2011, Kolab Systems AG | |
| | | | Licensed under the GNU GPL | |
| | | | | |
| | | | Licensed under the GNU General Public License version 3 or | |
| | | | any later version with exceptions for skins & plugins. | |
| | | | See the README file for a full license statement. | |
| | | | | |
| | | | PURPOSE: | |
| | | | Search action (and form) for address book contacts | |
| | |
| | | |
| | | function rcmail_contact_search() |
| | | { |
| | | global $RCMAIL, $OUTPUT, $CONFIG, $SEARCH_MODS_DEFAULT; |
| | | global $RCMAIL, $OUTPUT, $SEARCH_MODS_DEFAULT, $PAGE_SIZE; |
| | | |
| | | $adv = isset($_POST['_adv']); |
| | | $sid = get_input_value('_sid', RCUBE_INPUT_GET); |
| | |
| | | } |
| | | } |
| | | |
| | | // Values matching mode |
| | | $mode = (int) $RCMAIL->config->get('addressbook_search_mode'); |
| | | |
| | | // get sources list |
| | | $sources = $RCMAIL->get_address_sources(); |
| | | $search_set = array(); |
| | | $records = array(); |
| | | $sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name'); |
| | | |
| | | foreach ($sources as $s) { |
| | | $source = $RCMAIL->get_address_book($s['id']); |
| | |
| | | $source->set_pagesize(9999); |
| | | |
| | | // get contacts count |
| | | $result = $source->search($fields, $search, false, false); |
| | | $result = $source->search($fields, $search, $mode, false); |
| | | |
| | | if (!$result->count) { |
| | | continue; |
| | | } |
| | | |
| | | // get records |
| | | $result = $source->list_records(array('name', 'email')); |
| | | $result = $source->list_records(array('name', 'firstname', 'surname', 'email')); |
| | | |
| | | while ($row = $result->next()) { |
| | | $row['sourceid'] = $s['id']; |
| | | $key = $row['name'] . ':' . $row['sourceid']; |
| | | $key = rcmail_contact_key($row, $sort_col); |
| | | $records[$key] = $row; |
| | | } |
| | | |
| | |
| | | $result = new rcube_result_set($count); |
| | | |
| | | // cut first-page records |
| | | if ($CONFIG['pagesize'] < $count) { |
| | | $records = array_slice($records, 0, $CONFIG['pagesize']); |
| | | if ($PAGE_SIZE < $count) { |
| | | $records = array_slice($records, 0, $PAGE_SIZE); |
| | | } |
| | | |
| | | $result->records = array_values($records); |
| | |
| | | |
| | | // update message count display |
| | | $OUTPUT->command('set_env', 'search_request', $search_request); |
| | | $OUTPUT->command('set_env', 'pagecount', ceil($result->count / $CONFIG['pagesize'])); |
| | | $OUTPUT->command('set_env', 'pagecount', ceil($result->count / $PAGE_SIZE)); |
| | | $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result)); |
| | | // Re-set current source |
| | | $OUTPUT->command('set_env', 'search_id', $sid); |
| | |
| | | |
| | | $form = array( |
| | | 'main' => array( |
| | | 'name' => rcube_label('contactproperties'), |
| | | 'name' => rcube_label('properties'), |
| | | 'content' => array( |
| | | ), |
| | | ), |