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 provides the functionality to email a group of contacts
21 class CRM_Activity_Form_Task_FileOnCase
extends CRM_Activity_Form_Task
{
24 * The title of the group.
31 * Variable to store redirect path.
34 protected $_userContext;
37 * Variable to store contact Ids.
43 * Build all the data structures needed to build the form.
45 public function preProcess() {
47 $session = CRM_Core_Session
::singleton();
48 $this->_userContext
= $session->readUserContext();
50 CRM_Utils_System
::setTitle(ts('File on Case'));
54 * Build the form object.
56 public function buildQuickForm() {
57 $this->addEntityRef('unclosed_case_id', ts('Select Case'), ['entity' => 'Case'], TRUE);
58 $this->addDefaultButtons(ts('Save'));
62 * Process the form after the input has been submitted and validated.
64 public function postProcess() {
65 $formparams = $this->exportValues();
66 $caseId = $formparams['unclosed_case_id'];
68 foreach ($this->_activityHolderIds
as $key => $id) {
69 $targetContactValues = $defaults = [];
70 $params = ['id' => $id];
71 CRM_Activity_BAO_Activity
::retrieve($params, $defaults);
72 if (CRM_Case_BAO_Case
::checkPermission($id, 'File On Case', $defaults['activity_type_id'])) {
74 if (!CRM_Utils_Array
::crmIsEmptyArray($defaults['target_contact'])) {
75 $targetContactValues = array_combine(array_unique($defaults['target_contact']),
76 explode(';', trim($defaults['target_contact_value']))
78 $targetContactValues = implode(',', array_keys($targetContactValues));
84 'newSubject' => empty($defaults['subject']) ?
'' : $defaults['subject'],
85 'targetContactIds' => $targetContactValues,
89 $error_msg = CRM_Activity_Page_AJAX
::_convertToCaseActivity($params);
90 if (empty($error_msg['error_msg'])) {
94 CRM_Core_Session
::setStatus($error_msg['error_msg'], ts("Error"), "error");
98 CRM_Core_Session
::setStatus(
99 ts('Not permitted to file activity %1 %2.', [
100 1 => empty($defaults['subject']) ?
'' : $defaults['subject'],
101 2 => $defaults['activity_date_time'],
103 ts("Error"), "error");
107 CRM_Core_Session
::setStatus($filedActivities, ts("Filed Activities"), "success");
108 CRM_Core_Session
::setStatus("", ts('Total Selected Activities: %1', [1 => count($this->_activityHolderIds
)]), "info");