thomascube
2011-09-19 50077da8e6daab205f8ee9512b2f37b5378f9938
commit | author | age
f11541 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/addressbook/mailto.inc                                  |
6  |                                                                       |
e019f2 7  | This file is part of the Roundcube Webmail client                     |
f5e7b3 8  | Copyright (C) 2007, The Roundcube Dev Team                            |
f11541 9  | Licensed under the GNU GPL                                            |
T 10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Compose a recipient list with all selected contacts                 |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
18  $Id: copy.inc 471 2007-02-09 21:25:50Z thomasb $
19
20 */
21
ecf295 22 $cids   = rcmail_get_cids();
f11541 23 $mailto = array();
T 24
ecf295 25 foreach ($cids as $source => $cid)
f11541 26 {
ecf295 27     $CONTACTS = $RCMAIL->get_address_book($source);
f11541 28
ecf295 29     if ($CONTACTS->ready)
A 30     {
31         $CONTACTS->set_page(1);
32         $CONTACTS->set_pagesize(count($cid) + 2); // +2 to skip counting query
33         $recipients = $CONTACTS->search($CONTACTS->primary_key, $cid, false, true, true, 'email');
34
35         while (is_object($recipients) && ($rec = $recipients->iterate())) {
36             $emails = $CONTACTS->get_col_values('email', $rec, true);
37             $mailto[] = format_email_recipient($emails[0], $rec['name']);
38         }
39     }
f11541 40 }
T 41
42 if (!empty($mailto))
43 {
ecf295 44     $mailto_str = join(', ', $mailto);
A 45     $mailto_id = substr(md5($mailto_str), 0, 16);
46     $_SESSION['mailto'][$mailto_id] = urlencode($mailto_str);
47     $OUTPUT->redirect(array('task' => 'mail', '_action' => 'compose', '_mailto' => $mailto_id));
f11541 48 }
ecf295 49 else {
A 50     $OUTPUT->show_message('nocontactsfound', 'warning');
51 }
f11541 52
T 53 // send response
54 $OUTPUT->send();