You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

list.inc 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/addressbook/list.inc |
  5. | |
  6. | This file is part of the Roundcube Webmail client |
  7. | Copyright (C) 2005-2012, The Roundcube Dev Team |
  8. | |
  9. | Licensed under the GNU General Public License version 3 or |
  10. | any later version with exceptions for skins & plugins. |
  11. | See the README file for a full license statement. |
  12. | |
  13. | PURPOSE: |
  14. | Send contacts list to client (as remote response) |
  15. | |
  16. +-----------------------------------------------------------------------+
  17. | Author: Thomas Bruederli <roundcube@gmail.com> |
  18. +-----------------------------------------------------------------------+
  19. */
  20. if (!empty($_GET['_page']))
  21. $page = intval($_GET['_page']);
  22. else
  23. $page = $_SESSION['page'] ?: 1;
  24. $_SESSION['page'] = $page;
  25. // Use search result
  26. if (($records = rcmail_search_update(true)) !== false) {
  27. // sort the records
  28. ksort($records, SORT_LOCALE_STRING);
  29. // create resultset object
  30. $count = count($records);
  31. $first = ($page-1) * $PAGE_SIZE;
  32. $result = new rcube_result_set($count, $first);
  33. // we need only records for current page
  34. if ($PAGE_SIZE < $count) {
  35. $records = array_slice($records, $first, $PAGE_SIZE);
  36. }
  37. $result->records = array_values($records);
  38. }
  39. // List selected directory
  40. else {
  41. $afields = $RCMAIL->config->get('contactlist_fields');
  42. $CONTACTS = rcmail_contact_source(null, true);
  43. // get contacts for this user
  44. $result = $CONTACTS->list_records($afields);
  45. if (!$result->count && $result->searchonly) {
  46. $OUTPUT->show_message('contactsearchonly', 'notice');
  47. $OUTPUT->command('command', 'advanced-search');
  48. }
  49. if ($CONTACTS->group_id) {
  50. $OUTPUT->command('set_group_prop', array('ID' => $CONTACTS->group_id)
  51. + array_intersect_key((array)$CONTACTS->get_group($CONTACTS->group_id), array('name'=>1,'email'=>1)));
  52. }
  53. }
  54. // update message count display
  55. $OUTPUT->set_env('pagecount', ceil($result->count / $PAGE_SIZE));
  56. $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result));
  57. // create javascript list
  58. rcmail_js_contacts_list($result);
  59. // send response
  60. $OUTPUT->send();