3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class handle activity view mode.
21 class CRM_Activity_Form_ActivityView
extends CRM_Core_Form
{
26 public $submitOnce = TRUE;
29 * Set variables up before form is built.
31 public function preProcess() {
32 // Get the activity values.
33 $activityId = CRM_Utils_Request
::retrieve('id', 'Positive', $this);
34 $context = CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $this);
35 $cid = CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
37 // Check for required permissions, CRM-6264.
39 !CRM_Activity_BAO_Activity
::checkPermission($activityId, CRM_Core_Action
::VIEW
)
41 CRM_Core_Error
::statusBounce(ts('You do not have permission to access this page.'));
44 $session = CRM_Core_Session
::singleton();
45 if (!in_array($context, [
51 $url = CRM_Utils_System
::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
54 $url = CRM_Utils_System
::url('civicrm/dashboard', 'reset=1');
57 $session->pushUserContext($url);
59 $params = ['id' => $activityId];
60 CRM_Activity_BAO_Activity
::retrieve($params, $defaults);
62 // Send activity type description to template.
63 list(, $activityTypeDescription) = CRM_Core_BAO_OptionValue
::getActivityTypeDetails($defaults['activity_type_id']);
64 $this->assign('activityTypeDescription', $activityTypeDescription);
66 if (!empty($defaults['mailingId'])) {
67 $this->_mailing_id
= $defaults['source_record_id'] ??
NULL;
68 $mailingReport = CRM_Mailing_BAO_Mailing
::report($this->_mailing_id
, TRUE);
69 CRM_Mailing_BAO_Mailing
::getMailingContent($mailingReport, $this);
70 $this->assign('mailingReport', $mailingReport);
72 $full_open_report = CRM_Mailing_Event_BAO_Opened
::getRows(
73 $this->_mailing_id
, NULL, FALSE, NULL, NULL, NULL, $cid);
74 $this->assign('openreport', $full_open_report);
76 $click_thru_report = CRM_Mailing_Event_BAO_TrackableURLOpen
::getRows($this->_mailing_id
, NULL, FALSE, NULL, NULL, NULL, NULL, $cid);
77 $this->assign('clickreport', $click_thru_report);
80 foreach ($defaults as $key => $value) {
81 if (substr($key, -3) != '_id') {
82 $values[$key] = $value;
87 if ($campaignId = CRM_Utils_Array
::value('campaign_id', $defaults)) {
88 $campaigns = CRM_Campaign_BAO_Campaign
::getCampaigns($campaignId);
89 $values['campaign'] = $campaigns[$campaignId];
91 if ($engagementLevel = CRM_Utils_Array
::value('engagement_level', $defaults)) {
92 $engagementLevels = CRM_Campaign_PseudoConstant
::engagementLevel();
93 $values['engagement_level'] = CRM_Utils_Array
::value($engagementLevel, $engagementLevels, $engagementLevel);
96 $values['attachment'] = CRM_Core_BAO_File
::attachmentInfo('civicrm_activity', $activityId);
97 $this->assign('values', $values);
99 $url = CRM_Utils_System
::url(implode("/", $this->urlPath
), "reset=1&id={$activityId}&action=view&cid={$defaults['source_contact_id']}");
100 CRM_Utils_Recent
::add($defaults['subject'],
104 $defaults['source_contact_id'],
105 $defaults['source_contact']
110 * Build the form object.
112 public function buildQuickForm() {
116 'name' => ts('Done'),
117 'spacing' => ' ',