CRM-14043 - cid=0 contribution form giving contribution to logged in user
[civicrm-core.git] / CRM / Contact / Page / View / Email.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2013
32 * $Id$
33 *
34 */
35
36 /**
37 * Dummy page for details of Email
38 *
39 */
40 class CRM_Contact_Page_View_Email extends CRM_Core_Page {
41
42 /**
43 * Run the page.
44 *
45 * This method is called after the page is created.
46 *
47 * @return void
48 * @access public
49 *
50 */
51 function run() {
52 // get the callback, module and activity id
53 $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse' );
54 $id = CRM_Utils_Request::retrieve('id', 'Positive', $this );
55
56 $dao = new CRM_Core_DAO_ActivityHistory();
57 $dao->activity_id = $id;
58 $dao->activity_type = ts('Email Sent');
59 if ($dao->find(TRUE)) {
60 $cid = $dao->entity_id;
61 }
62
63 $dao = new CRM_Core_DAO_EmailHistory();
64 $dao->id = $id;
65
66 if ($dao->find(TRUE)) {
67 // get the display name and email for the contact
68 list($toContactName, $toContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($cid);
69
70 if (!trim($toContactName)) {
71 $toContactName = $toContactEmail;
72 }
73
74 if (trim($toContactEmail)) {
75 $toContactName = "\"$toContactName\" <$toContactEmail>";
76 }
77
78 $this->assign('toName', $toContactName);
79
80 // get the display name and email for the contact
81 list($fromContactName, $fromContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($dao->contact_id);
82
83 if (!trim($fromContactEmail)) {
84 CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
85 }
86
87 if (!trim($fromContactName)) {
88 $fromContactName = $fromContactEmail;
89 }
90
91 $this->assign('fromName', "\"$fromContactName\" <$fromContactEmail>");
92
93 $this->assign('sentDate', $dao->sent_date);
94 $this->assign('subject', $dao->subject);
95 $this->assign('message', $dao->message);
96
97 // get the display name and images for the contact
98 list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
99
100 CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
101 // also add the cid params to the Menu array
102 CRM_Core_Menu::addParam('cid', $cid);
103 }
104 return parent::run();
105 }
106 }
107