3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * This class handle activity view mode
40 class CRM_Activity_Form_ActivityView
extends CRM_Core_Form
{
43 * Function to set variables up before form is built
48 public function preProcess() {
49 //get the activity values
50 $activityId = CRM_Utils_Request
::retrieve('id', 'Positive', $this);
51 $context = CRM_Utils_Request
::retrieve('context', 'String', $this);
52 $cid = CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
54 //check for required permissions, CRM-6264
56 !CRM_Activity_BAO_Activity
::checkPermission($activityId, CRM_Core_Action
::VIEW
)
58 CRM_Core_Error
::fatal(ts('You do not have permission to access this page.'));
61 $session = CRM_Core_Session
::singleton();
62 if (!in_array($context, array(
63 'home', 'dashlet', 'dashletFullscreen'))) {
64 $url = CRM_Utils_System
::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
67 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
70 $session->pushUserContext($url);
72 $params = array('id' => $activityId);
73 CRM_Activity_BAO_Activity
::retrieve($params, $defaults);
75 //set activity type name and description to template
76 list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue
::getActivityTypeDetails($defaults['activity_type_id']);
78 $this->assign('activityTypeName', $activityTypeName);
79 $this->assign('activityTypeDescription', $activityTypeDescription);
81 if (!empty($defaults['mailingId'])) {
82 $this->_mailing_id
= CRM_Utils_Array
::value('source_record_id', $defaults);
83 $mailingReport = CRM_Mailing_BAO_Mailing
::report($this->_mailing_id
, TRUE);
84 CRM_Mailing_BAO_Mailing
::getMailingContent($mailingReport, $this);
85 $this->assign('mailingReport', $mailingReport);
87 $full_open_report = CRM_Mailing_Event_BAO_Opened
::getRows(
88 $this->_mailing_id
, NULL, FALSE, NULL, NULL, NULL, $cid);
89 $this->assign('openreport',$full_open_report);
91 $click_thru_report = CRM_Mailing_Event_BAO_TrackableURLOpen
::getRows( $this->_mailing_id
, NULL, FALSE, NULL, NULL, NULL, NULL, $cid);
92 $this->assign('clickreport',$click_thru_report);
95 foreach ($defaults as $key => $value) {
96 if (substr($key, -3) != '_id') {
97 $values[$key] = $value;
102 if ($campaignId = CRM_Utils_Array
::value('campaign_id', $defaults)) {
103 $campaigns = CRM_Campaign_BAO_Campaign
::getCampaigns($campaignId);
104 $values['campaign'] = $campaigns[$campaignId];
106 if ($engagementLevel = CRM_Utils_Array
::value('engagement_level', $defaults)) {
107 $engagementLevels = CRM_Campaign_PseudoConstant
::engagementLevel();
108 $values['engagement_level'] = CRM_Utils_Array
::value($engagementLevel, $engagementLevels, $engagementLevel);
111 $values['attachment'] = CRM_Core_BAO_File
::attachmentInfo('civicrm_activity', $activityId);
112 $this->assign('values', $values);
116 * Function to build the form
121 public function buildQuickForm() {
122 $this->addButtons(array(
125 'name' => ts('Done'),
126 'spacing' => ' ',