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 * Main page for viewing activities,
21 class CRM_Activity_Page_Tab
extends CRM_Core_Page
{
24 * Browse all activities for a particular contact.
26 public function browse() {
27 $this->assign('admin', FALSE);
28 $this->assign('context', 'activity');
30 // also create the form element for the activity filter box
31 $controller = new CRM_Core_Controller_Simple(
32 'CRM_Activity_Form_ActivityFilter',
33 ts('Activity Filter'),
37 $controller->set('contactId', $this->_contactId
);
38 $controller->setEmbedded(TRUE);
40 $this->ajaxResponse
['tabCount'] = CRM_Contact_BAO_Contact
::getCountComponent('activity', $this->_contactId
);
48 public function edit() {
50 $context = CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $this);
51 $this->assign('context', $context);
53 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Integer', $this);
55 $this->_caseId
= CRM_Utils_Request
::retrieve('caseid', 'Integer', $this);
57 $activityTypeId = CRM_Utils_Request
::retrieve('atype', 'Positive', $this);
59 // Email and Create Letter activities use a different form class
60 $emailTypeValue = CRM_Core_PseudoConstant
::getKey('CRM_Activity_BAO_Activity',
65 $letterTypeValue = CRM_Core_PseudoConstant
::getKey('CRM_Activity_BAO_Activity',
70 switch ($activityTypeId) {
72 $wrapper = new CRM_Utils_Wrapper();
73 $arguments = ['attachUpload' => 1];
74 return $wrapper->run('CRM_Contact_Form_Task_Email', ts('Email a Contact'), $arguments);
76 case $letterTypeValue:
77 $wrapper = new CRM_Utils_Wrapper();
78 $arguments = ['attachUpload' => 1];
79 return $wrapper->run('CRM_Contact_Form_Task_PDF', ts('Create PDF Letter'), $arguments);
82 $controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_Activity',
83 ts('Contact Activities'),
85 FALSE, FALSE, FALSE, TRUE
89 $controller->setEmbedded(TRUE);
91 $controller->set('contactId', $this->_contactId
);
92 $controller->set('atype', $activityTypeId);
93 $controller->set('id', $this->_id
);
94 $controller->set('pid', $this->get('pid'));
95 $controller->set('action', $this->_action
);
96 $controller->set('context', $context);
98 $controller->process();
103 * Heart of the viewing process.
105 * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
107 public function preProcess() {
108 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
109 $this->assign('contactId', $this->_contactId
);
110 // FIXME: need to fix this conflict
111 $this->assign('contactID', $this->_contactId
);
113 // check logged in url permission
114 CRM_Contact_Page_View
::checkUserPermission($this);
116 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
117 $this->assign('action', $this->_action
);
118 $this->assign('allow_edit_inbound_emails', CRM_Activity_BAO_Activity
::checkEditInboundEmailsPermissions());
120 // also create the form element for the activity links box
121 $controller = new CRM_Core_Controller_Simple(
122 'CRM_Activity_Form_ActivityLinks',
123 ts('Activity Links'),
127 $controller->setEmbedded(TRUE);
131 public function delete() {
132 $controller = new CRM_Core_Controller_Simple(
133 'CRM_Activity_Form_Activity',
134 ts('Activity Record'),
137 $controller->set('id', $this->_id
);
138 $controller->setEmbedded(TRUE);
139 $controller->process();
144 * Perform actions and display for activities.
146 public function run() {
147 $context = CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $this);
148 $contactId = CRM_Utils_Request
::retrieve('cid', 'Positive', $this);
149 $action = CRM_Utils_Request
::retrieve('action', 'String', $this);
150 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
152 // Do check for view/edit operation.
154 in_array($action, [CRM_Core_Action
::UPDATE
, CRM_Core_Action
::VIEW
])
156 if (!CRM_Activity_BAO_Activity
::checkPermission($this->_id
, $action)) {
157 CRM_Core_Error
::fatal(ts('You are not authorized to access this page.'));
161 if ($context == 'standalone' ||
(!$contactId && ($action != CRM_Core_Action
::DELETE
) && !$this->_id
)) {
162 $this->_action
= CRM_Core_Action
::ADD
;
163 $this->assign('action', $this->_action
);
166 // we should call contact view, preprocess only for activity in contact summary
170 // route behaviour of contact/view/activity based on action defined
171 if ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::VIEW
)
174 $activityTypeId = CRM_Utils_Request
::retrieve('atype', 'Positive', $this);
176 // Email and Create Letter activities use a different form class
177 $emailTypeValue = CRM_Core_PseudoConstant
::getKey('CRM_Activity_BAO_Activity',
182 $letterTypeValue = CRM_Core_PseudoConstant
::getKey('CRM_Activity_BAO_Activity',
187 if (in_array($activityTypeId, [
194 elseif ($this->_action
& (CRM_Core_Action
::DELETE | CRM_Core_Action
::DETACH
)) {
201 return parent
::run();