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