Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/addressbook/mailto.inc |
  5. | |
  6. | This file is part of the Roundcube Webmail client |
  7. | Copyright (C) 2007-2013, 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. | Compose a recipient list with all selected contacts |
  15. | |
  16. +-----------------------------------------------------------------------+
  17. | Author: Thomas Bruederli <roundcube@gmail.com> |
  18. +-----------------------------------------------------------------------+
  19. */
  20. $cids = rcmail_get_cids();
  21. $mailto = array();
  22. $sources = array();
  23. foreach ($cids as $source => $cid) {
  24. $CONTACTS = $RCMAIL->get_address_book($source);
  25. if ($CONTACTS->ready) {
  26. $CONTACTS->set_page(1);
  27. $CONTACTS->set_pagesize(count($cid) + 2); // +2 to skip counting query
  28. $sources[] = $CONTACTS->search($CONTACTS->primary_key, $cid, 0, true, true, 'email');
  29. }
  30. }
  31. if (!empty($_REQUEST['_gid']) && isset($_REQUEST['_source'])) {
  32. $source = rcube_utils::get_input_value('_source', rcube_utils::INPUT_GPC);
  33. $CONTACTS = $RCMAIL->get_address_book($source);
  34. $group_id = rcube_utils::get_input_value('_gid', rcube_utils::INPUT_GPC);
  35. $group_data = $CONTACTS->get_group($group_id);
  36. // group has an email address assigned: use that
  37. if ($group_data['email']) {
  38. $mailto[] = format_email_recipient($group_data['email'][0], $group_data['name']);
  39. }
  40. else if ($CONTACTS->ready) {
  41. $CONTACTS->set_group($group_id);
  42. $CONTACTS->set_page(1);
  43. $CONTACTS->set_pagesize(200); // limit somehow
  44. $sources[] = $CONTACTS->list_records();
  45. }
  46. }
  47. foreach ($sources as $source) {
  48. while (is_object($source) && ($rec = $source->iterate())) {
  49. $emails = $CONTACTS->get_col_values('email', $rec, true);
  50. if (!empty($emails)) {
  51. $mailto[] = format_email_recipient($emails[0], $rec['name']);
  52. }
  53. }
  54. }
  55. if (!empty($mailto)) {
  56. $mailto_str = join(', ', $mailto);
  57. $mailto_id = substr(md5($mailto_str), 0, 16);
  58. $_SESSION['mailto'][$mailto_id] = urlencode($mailto_str);
  59. $OUTPUT->command('open_compose_step', array('_mailto' => $mailto_id));
  60. }
  61. else {
  62. $OUTPUT->show_message('nocontactsfound', 'warning');
  63. }
  64. // send response
  65. $OUTPUT->send();