Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * This class handle activity view mode | |
38 | * | |
39 | */ | |
40 | class CRM_Activity_Form_ActivityView extends CRM_Core_Form { | |
41 | ||
42 | /** | |
100fef9d | 43 | * Set variables up before form is built |
6a488035 TO |
44 | * |
45 | * @return void | |
6a488035 TO |
46 | */ |
47 | public function preProcess() { | |
48 | //get the activity values | |
49 | $activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this); | |
50 | $context = CRM_Utils_Request::retrieve('context', 'String', $this); | |
51 | $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this); | |
52 | ||
53 | //check for required permissions, CRM-6264 | |
54 | if ($activityId && | |
55 | !CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW) | |
56 | ) { | |
57 | CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); | |
58 | } | |
59 | ||
60 | $session = CRM_Core_Session::singleton(); | |
61 | if (!in_array($context, array( | |
62 | 'home', 'dashlet', 'dashletFullscreen'))) { | |
63 | $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity"); | |
64 | } | |
65 | else { | |
66 | $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1'); | |
67 | } | |
68 | ||
69 | $session->pushUserContext($url); | |
70 | $defaults = array(); | |
71 | $params = array('id' => $activityId); | |
72 | CRM_Activity_BAO_Activity::retrieve($params, $defaults); | |
73 | ||
74 | //set activity type name and description to template | |
75 | list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']); | |
76 | ||
77 | $this->assign('activityTypeName', $activityTypeName); | |
78 | $this->assign('activityTypeDescription', $activityTypeDescription); | |
79 | ||
a7488080 | 80 | if (!empty($defaults['mailingId'])) { |
6a488035 TO |
81 | $this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults); |
82 | $mailingReport = CRM_Mailing_BAO_Mailing::report($this->_mailing_id, TRUE); | |
83 | CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this); | |
84 | $this->assign('mailingReport', $mailingReport); | |
85 | ||
86 | $full_open_report = CRM_Mailing_Event_BAO_Opened::getRows( | |
87 | $this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, $cid); | |
32864ccf | 88 | $this->assign('openreport', $full_open_report); |
6a488035 TO |
89 | |
90 | $click_thru_report = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows( $this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, NULL, $cid); | |
32864ccf | 91 | $this->assign('clickreport', $click_thru_report); |
6a488035 TO |
92 | } |
93 | ||
94 | foreach ($defaults as $key => $value) { | |
95 | if (substr($key, -3) != '_id') { | |
96 | $values[$key] = $value; | |
97 | } | |
98 | } | |
99 | ||
100 | //get the campaign | |
101 | if ($campaignId = CRM_Utils_Array::value('campaign_id', $defaults)) { | |
102 | $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId); | |
103 | $values['campaign'] = $campaigns[$campaignId]; | |
104 | } | |
105 | if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $defaults)) { | |
106 | $engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel(); | |
107 | $values['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel); | |
108 | } | |
109 | ||
110 | $values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId); | |
111 | $this->assign('values', $values); | |
112 | } | |
113 | ||
114 | /** | |
c490a46a | 115 | * Build the form object |
6a488035 | 116 | * |
355ba699 | 117 | * @return void |
6a488035 TO |
118 | */ |
119 | public function buildQuickForm() { | |
120 | $this->addButtons(array( | |
121 | array( | |
a10432db | 122 | 'type' => 'cancel', |
6a488035 TO |
123 | 'name' => ts('Done'), |
124 | 'spacing' => ' ', | |
125 | 'isDefault' => TRUE, | |
126 | ), | |
127 | ) | |
128 | ); | |
129 | } | |
130 | } |