Changeset 4850 in subversion for trunk/roundcubemail/program/steps/addressbook/export.inc
- Timestamp:
- Jun 14, 2011 9:45:26 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/steps/addressbook/export.inc
r4752 r4850 7 7 | This file is part of the Roundcube Webmail client | 8 8 | Copyright (C) 2008-2011, The Roundcube Dev Team | 9 | Copyright (C) 2011, Kolab Systems AG | 9 10 | Licensed under the GNU GPL | 10 11 | | … … 14 15 +-----------------------------------------------------------------------+ 15 16 | Author: Thomas Bruederli <roundcube@gmail.com> | 17 | Author: Aleksander Machniak <machniak@kolabsys.com> | 16 18 +-----------------------------------------------------------------------+ 17 19 18 $Id :$20 $Id$ 19 21 20 22 */ 21 23 22 // get contacts for this user 23 $CONTACTS->set_page(1); 24 $CONTACTS->set_pagesize(99999); 25 $result = $CONTACTS->list_records(null, 0, true); 24 // Use search result 25 if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) 26 { 27 $search = (array)$_SESSION['search'][$_REQUEST['_search']]; 28 $records = array(); 29 30 // Get records from all sources 31 foreach ($search as $s => $set) { 32 $source = $RCMAIL->get_address_book($s); 33 34 // reset page 35 $source->set_page(1); 36 $source->set_pagesize(99999); 37 $source->set_search_set($set); 38 39 // get records 40 $result = $source->list_records(); 41 42 while ($row = $result->next()) { 43 $row['sourceid'] = $s; 44 $key = $row['name'] . ':' . $row['sourceid']; 45 $records[$key] = $row; 46 } 47 unset($result); 48 } 49 50 // sort the records 51 ksort($records, SORT_LOCALE_STRING); 52 53 // create resultset object 54 $count = count($records); 55 $result = new rcube_result_set($count); 56 $result->records = array_values($records); 57 } 58 // selected directory/group 59 else { 60 $CONTACTS = rcmail_contact_source(null, true); 61 62 // get contacts for this user 63 $CONTACTS->set_page(1); 64 $CONTACTS->set_pagesize(99999); 65 $result = $CONTACTS->list_records(null, 0, true); 66 } 26 67 27 68 // send downlaod headers … … 31 72 32 73 while ($result && ($row = $result->next())) { 33 // we already have a vcard record 34 if ($row['vcard'] && $row['name']) { 35 echo rcube_vcard::rfc2425_fold($row['vcard']) . "\n"; 36 } 37 // copy values into vcard object 38 else { 39 $vcard = new rcube_vcard($row['vcard']); 40 $vcard->reset(); 41 foreach ($row as $key => $values) { 42 list($field, $section) = explode(':', $key); 43 foreach ((array)$values as $value) { 44 if (is_array($value) || strlen($value)) 45 $vcard->set($field, $value, strtoupper($section)); 46 } 74 // we already have a vcard record 75 if ($row['vcard'] && $row['name']) { 76 echo rcube_vcard::rfc2425_fold($row['vcard']) . "\n"; 47 77 } 78 // copy values into vcard object 79 else { 80 $vcard = new rcube_vcard($row['vcard']); 81 $vcard->reset(); 48 82 49 echo $vcard->export(true) . "\n"; 50 } 83 foreach ($row as $key => $values) { 84 list($field, $section) = explode(':', $key); 85 foreach ((array)$values as $value) { 86 if (is_array($value) || strlen($value)) 87 $vcard->set($field, $value, strtoupper($section)); 88 } 89 } 90 91 echo $vcard->export(true) . "\n"; 92 } 51 93 } 52 94 53 95 exit; 54
Note: See TracChangeset
for help on using the changeset viewer.
