3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
35 * This class create activities for a case.
37 class CRM_Case_Form_Activity
extends CRM_Activity_Form_Activity
{
40 * Cases this activity belongs to.
47 * The default case type variable defined.
54 * The array of releted contact info.
58 public $_relatedContacts;
61 * The case type definition column info
66 public $_caseTypeDefinition;
69 * Build the form object.
71 public function preProcess() {
72 $caseIds = CRM_Utils_Request
::retrieve('caseid', 'CommaSeparatedIntegers', $this);
73 $this->_caseId
= $caseIds ?
explode(',', $caseIds) : [];
74 $this->_context
= CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $this);
75 if (!$this->_context
) {
76 $this->_context
= 'caseActivity';
78 $this->_crmDir
= 'Case';
79 $this->assign('context', $this->_context
);
83 $scheduleStatusId = CRM_Core_PseudoConstant
::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Scheduled');
84 $this->assign('scheduleStatusId', $scheduleStatusId);
86 if (!$this->_caseId
&& $this->_activityId
) {
87 $this->_caseId
= (array) CRM_Core_DAO
::getFieldValue('CRM_Case_DAO_CaseActivity', $this->_activityId
,
88 'case_id', 'activity_id'
92 $this->assign('caseId', $this->_caseId
);
93 $this->assign('countId', count($this->_caseId
));
94 $this->assign('caseID', CRM_Utils_Array
::first($this->_caseId
));
97 if (!$this->_caseId ||
98 (!$this->_activityId
&& !$this->_activityTypeId
)
100 CRM_Core_Error
::fatal('required params missing.');
103 //check for case activity access.
104 if (!CRM_Case_BAO_Case
::accessCiviCase()) {
105 CRM_Core_Error
::fatal(ts('You are not authorized to access this page.'));
108 if ($this->_caseId
&&
109 !CRM_Core_Permission
::check('access all cases and activities')
111 $params = array('type' => 'any');
112 $allCases = CRM_Case_BAO_Case
::getCases(TRUE, $params);
113 if (count(array_intersect($this->_caseId
, array_keys($allCases))) == 0) {
114 CRM_Core_Error
::fatal(ts('You are not authorized to access this page.'));
118 //validate case activity id.
119 if ($this->_activityId
&&
120 ($this->_action
& CRM_Core_Action
::UPDATE
)
122 $valid = CRM_Case_BAO_Case
::checkPermission($this->_activityId
, 'edit',
123 $this->_activityTypeId
126 CRM_Core_Error
::fatal(ts('You are not authorized to access this page.'));
130 foreach ($this->_caseId
as $casePos => $caseId) {
131 $this->_caseType
[$casePos] = CRM_Case_BAO_Case
::getCaseType($caseId, 'name');
133 $this->assign('caseType', $this->_caseType
);
135 $this->_caseTypeDefinition
= $this->getCaseTypeDefinition();
137 $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
138 $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
139 $this->assign('multiClient', $isMultiClient);
141 foreach ($this->_caseId
as $casePos => $caseId) {
142 $clients[] = CRM_Case_BAO_Case
::getContactNames($caseId);
144 $this->assign('client_names', $clients);
146 $caseIds = implode(',', $this->_caseId
);
147 // set context for pushUserContext and for statusBounce
148 if ($this->_context
== 'fulltext') {
149 if ($this->_action
== CRM_Core_Action
::UPDATE ||
$this->_action
== CRM_Core_Action
::DELETE
) {
150 $url = CRM_Utils_System
::url('civicrm/contact/view/case',
151 "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseIds}&show=1&context={$this->_context}"
155 $url = CRM_Utils_System
::url('civicrm/contact/search/custom', 'force=1');
159 $url = CRM_Utils_System
::url('civicrm/contact/view/case',
160 "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseIds}&show=1"
163 if (!$this->_activityId
) {
164 $caseTypes = CRM_Case_PseudoConstant
::caseType();
166 if (empty($caseTypes) && ($this->_activityTypeName
== 'Change Case Type') && !$this->_caseId
) {
167 $url = CRM_Utils_System
::url('civicrm/contact/view/case',
168 "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseIds}&show=1"
170 $session = CRM_Core_Session
::singleton();
171 $session->pushUserContext($url);
172 CRM_Core_Error
::statusBounce(ts("You do not have any active Case Types"));
175 // check if activity count is within the limit
176 $xmlProcessor = new CRM_Case_XMLProcessor_Process();
177 foreach ($this->_caseId
as $casePos => $caseId) {
178 $caseType = $this->_caseType
[$casePos];
179 $activityInst = $xmlProcessor->getMaxInstance($caseType);
181 // If not bounce back and also provide activity edit link
182 if (isset($activityInst[$this->_activityTypeName
])) {
183 $activityCount = CRM_Case_BAO_Case
::getCaseActivityCount($caseId, $this->_activityTypeId
);
184 if ($activityCount >= $activityInst[$this->_activityTypeName
]) {
185 if ($activityInst[$this->_activityTypeName
] == 1) {
186 $atArray = array('activity_type_id' => $this->_activityTypeId
);
187 $activities = CRM_Case_BAO_Case
::getCaseActivity($caseId,
189 $this->_currentUserId
191 $activityId = CRM_Utils_Array
::first(array_keys($activities['data']));
192 $editUrl = CRM_Utils_System
::url('civicrm/case/activity',
193 "reset=1&cid={$this->_currentlyViewedContactId}&caseid={$caseId}&action=update&id={$activityId}"
196 CRM_Core_Error
::statusBounce(ts("You can not add another '%1' activity to this case. %2",
198 1 => $this->_activityTypeName
,
199 2 => ts("Do you want to <a %1>edit the existing activity</a>?", array(1 => "href='$editUrl'")),
209 // Turn off the prompt which asks the user if they want to create separate
210 // activities when specifying multiple contacts "with" a new activity.
211 // Instead, always create one activity with all contacts together.
212 $this->supportsActivitySeparation
= FALSE;
214 $session = CRM_Core_Session
::singleton();
215 $session->pushUserContext($url);
219 * Set default values for the form.
221 public function setDefaultValues() {
222 $this->_defaults
= parent
::setDefaultValues();
223 $targetContactValues = array();
224 foreach ($this->_caseId
as $key => $val) {
226 $clients = CRM_Case_BAO_Case
::getContactNames($val);
227 if (isset($this->_activityId
) && empty($_POST)) {
228 if (!CRM_Utils_Array
::crmIsEmptyArray($this->_defaults
['target_contact'])) {
229 $targetContactValues = array_combine(array_unique($this->_defaults
['target_contact']),
230 explode(';', trim($this->_defaults
['target_contact_value']))
232 //exclude all clients.
233 foreach ($clients as $clientId => $vals) {
234 if (array_key_exists($clientId, $targetContactValues)) {
235 unset($targetContactValues[$clientId]);
240 $this->assign('targetContactValues', empty($targetContactValues) ?
FALSE : $targetContactValues);
242 if (isset($this->_encounterMedium
)) {
243 $this->_defaults
['medium_id'] = $this->_encounterMedium
;
245 elseif (empty($this->_defaults
['medium_id'])) {
246 // set default encounter medium CRM-4816
247 $medium = CRM_Core_OptionGroup
::values('encounter_medium', FALSE, FALSE, FALSE, 'AND is_default = 1');
248 if (count($medium) == 1) {
249 $this->_defaults
['medium_id'] = key($medium);
253 return $this->_defaults
;
257 public function buildQuickForm() {
258 $this->_fields
['source_contact_id']['label'] = ts('Reported By');
259 unset($this->_fields
['status_id']['attributes']['required']);
261 if ($this->restrictAssignmentByUserAccount()) {
262 $assigneeParameters['uf_user'] = 1;
265 $activityAssignmentGroups = $this->getActivityAssignmentGroups();
266 if (!empty($activityAssignmentGroups)) {
267 $assigneeParameters['group'] = ['IN' => $activityAssignmentGroups];
270 if (!empty($assigneeParameters)) {
271 $this->_fields
['assignee_contact_id']['attributes']['api']['params']
272 = array_merge($this->_fields
['assignee_contact_id']['attributes']['api']['params'], $assigneeParameters);
274 $this->_fields
['followup_assignee_contact_id']['attributes']['api']['params']
275 = array_merge($this->_fields
['followup_assignee_contact_id']['attributes']['api']['params'], $assigneeParameters);
277 //Disallow creating a contact from the assignee field UI.
278 $this->_fields
['assignee_contact_id']['attributes']['create'] = FALSE;
279 $this->_fields
['followup_assignee_contact_id']['attributes']['create'] = FALSE;
282 if ($this->_caseType
) {
283 $xmlProcessor = new CRM_Case_XMLProcessor_Process();
285 foreach (array_unique($this->_caseType
) as $val) {
286 $activityTypes = $xmlProcessor->get($val, 'ActivityTypes', TRUE);
287 $aTypes = $aTypes +
$activityTypes;
290 // remove Open Case activity type since we're inside an existing case
291 $openCaseID = CRM_Core_PseudoConstant
::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Open Case');
292 unset($aTypes[$openCaseID]);
294 $this->_fields
['followup_activity_type_id']['attributes'] = array('' => '- select activity type -') +
$aTypes;
297 parent
::buildQuickForm();
299 if ($this->_action
& (CRM_Core_Action
::DELETE | CRM_Core_Action
::DETACH | CRM_Core_Action
::RENEW
)) {
303 $this->assign('urlPath', 'civicrm/case/activity');
305 $encounterMediums = CRM_Case_PseudoConstant
::encounterMedium();
307 if ($this->_activityTypeFile
== 'OpenCase' && $this->_action
== CRM_Core_Action
::UPDATE
) {
308 $this->getElement('activity_date_time')->freeze();
310 if ($this->_activityId
) {
311 // Fixme: what's the justification for this? It seems like it is just re-adding an option in case it is the default and disabled.
312 // Is that really a big problem?
313 $this->_encounterMedium
= CRM_Core_DAO
::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId
, 'medium_id');
314 if (!array_key_exists($this->_encounterMedium
, $encounterMediums)) {
315 $encounterMediums[$this->_encounterMedium
] = CRM_Core_PseudoConstant
::getLabel('CRM_Activity_BAO_Activity', 'medium_id', $this->_encounterMedium
);
320 $this->add('select', 'medium_id', ts('Medium'), $encounterMediums, TRUE);
322 foreach ($this->_caseId
as $key => $val) {
323 $this->_relatedContacts
[] = $rgc = CRM_Case_BAO_Case
::getRelatedAndGlobalContacts($val);
324 $contName = CRM_Case_BAO_Case
::getContactNames($val);
325 foreach ($contName as $nkey => $nval) {
326 array_push($this->_relatedContacts
[$i][0], $this->_relatedContacts
[$i][0]['managerOf'] = $nval['display_name']);
331 //add case client in send a copy selector.CRM-4438.
332 foreach ($this->_caseId
as $key => $val) {
333 $relatedContacts[] = $relCon = CRM_Case_BAO_Case
::getContactNames($val);
336 if (!empty($relatedContacts)) {
337 foreach ($relatedContacts as $relatedContact) {
338 $this->_relatedContacts
[] = $relatedContact;
342 if (!empty($this->_relatedContacts
)) {
343 $checkBoxes = array();
344 foreach ($this->_relatedContacts
as $id => $row) {
345 foreach ($row as $key => $value) {
346 $checkBoxes[$key] = $this->addElement('checkbox', $key, NULL, NULL, array('class' => 'select-row'));
350 $this->addGroup($checkBoxes, 'contact_check');
351 $this->addElement('checkbox', 'toggleSelect', NULL, NULL,
352 array('class' => 'select-rows')
354 $this->assign('searchRows', $this->_relatedContacts
);
356 $this->_relatedContacts
= $rgc +
$relCon;
358 $this->addFormRule(array('CRM_Case_Form_Activity', 'formRule'), $this);
364 * @param array $fields
365 * The input form values.
366 * @param array $files
367 * The uploaded files if any.
371 * true if no errors, else array of errors
373 public static function formRule($fields, $files, $self) {
374 // skip form rule if deleting
375 if (CRM_Utils_Array
::value('_qf_Activity_next_', $fields) == 'Delete' || CRM_Utils_Array
::value('_qf_Activity_next_', $fields) == 'Restore') {
379 return parent
::formRule($fields, $files, $self);
383 * Process the form submission.
385 * @param array $params
387 public function postProcess($params = NULL) {
388 $transaction = new CRM_Core_Transaction();
390 if ($this->_action
& CRM_Core_Action
::DELETE
) {
393 //block deleting activities which affects
394 //case attributes.CRM-4543
395 $activityCondition = " AND v.name IN ('Open Case', 'Change Case Type', 'Change Case Status', 'Change Case Start Date')";
396 $caseAttributeActivities = CRM_Core_OptionGroup
::values('activity_type', FALSE, FALSE, FALSE, $activityCondition);
398 if (!array_key_exists($this->_activityTypeId
, $caseAttributeActivities)) {
399 $params = array('id' => $this->_activityId
);
400 $activityDelete = CRM_Activity_BAO_Activity
::deleteActivity($params, TRUE);
401 if ($activityDelete) {
402 $statusMsg = ts('The selected activity has been moved to the Trash. You can view and / or restore deleted activities by checking "Deleted Activities" from the Case Activities search filter (under Manage Case).<br />');
406 $statusMsg = ts("Selected Activity cannot be deleted.");
410 'entity_table' => 'civicrm_activity',
411 'entity_id' => $this->_activityId
,
413 CRM_Core_BAO_EntityTag
::del($tagParams);
415 CRM_Core_Session
::setStatus('', $statusMsg, 'info');
419 if ($this->_action
& CRM_Core_Action
::RENEW
) {
421 $params = array('id' => $this->_activityId
);
422 $activityRestore = CRM_Activity_BAO_Activity
::restoreActivity($params);
423 if ($activityRestore) {
424 $statusMsg = ts('The selected activity has been restored.<br />');
426 CRM_Core_Session
::setStatus('', $statusMsg, 'info');
430 // store the submitted values in an array
431 $params = $this->controller
->exportValues($this->_name
);
433 //set parent id if its edit mode
434 if ($parentId = CRM_Utils_Array
::value('parent_id', $this->_defaults
)) {
435 $params['parent_id'] = $parentId;
438 $params['activity_type_id'] = $this->_activityTypeId
;
440 // format with contact (target contact) values
441 if (isset($params['target_contact_id'])) {
442 $params['target_contact_id'] = explode(',', $params['target_contact_id']);
445 $params['target_contact_id'] = array();
448 // format activity custom data
449 if (!empty($params['hidden_custom'])) {
450 if ($this->_activityId
) {
451 // retrieve and include the custom data of old Activity
452 $oldActivity = civicrm_api3('Activity', 'getsingle', array('id' => $this->_activityId
));
453 $params = array_merge($oldActivity, $params);
455 // unset custom fields-id from params since we want custom
456 // fields to be saved for new activity.
457 foreach ($params as $key => $value) {
459 if (preg_match('/^(custom_\d+_)(\d+)$/', $key, $match)) {
460 $params[$match[1] . '-1'] = $params[$key];
462 // for autocomplete transfer hidden value instead of label
463 if ($params[$key] && isset($params[$key . '_id'])) {
464 $params[$match[1] . '-1_id'] = $params[$key . '_id'];
465 unset($params[$key . '_id']);
467 unset($params[$key]);
472 // build custom data getFields array
473 $customFields = CRM_Core_BAO_CustomField
::getFields('Activity', FALSE, FALSE, $this->_activityTypeId
);
474 $customFields = CRM_Utils_Array
::crmArrayMerge($customFields,
475 CRM_Core_BAO_CustomField
::getFields('Activity', FALSE, FALSE,
479 $params['custom'] = CRM_Core_BAO_CustomField
::postProcess($params,
485 // assigning formatted value
486 if (!empty($params['assignee_contact_id'])) {
487 $params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
490 $params['assignee_contact_id'] = array();
493 if (isset($this->_activityId
)) {
494 // activity which hasn't been modified by a user yet
495 if ($this->_defaults
['is_auto'] == 1) {
496 $params['is_auto'] = 0;
499 // always create a revision of an case activity. CRM-4533
500 $newActParams = $params;
502 // add target contact values in update mode
503 if (empty($params['target_contact_id']) && !empty($this->_defaults
['target_contact'])) {
504 $newActParams['target_contact_id'] = $this->_defaults
['target_contact'];
508 if (!isset($newActParams)) {
509 // add more attachments if needed for old activity
510 CRM_Core_BAO_File
::formatAttachment($params,
515 // call begin post process, before the activity is created/updated.
516 $this->beginPostProcess($params);
517 foreach ($this->_caseId
as $key => $val) {
518 $params['case_id'] = $val;
519 // activity create/update
520 $activity = CRM_Activity_BAO_Activity
::create($params);
521 $vvalue[] = array('case_id' => $val, 'actId' => $activity->id
);
522 // call end post process, after the activity has been created/updated.
523 $this->endPostProcess($params, $activity);
527 // since the params we need to set are very few, and we don't want rest of the
528 // work done by bao create method , lets use dao object to make the changes
529 $params = array('id' => $this->_activityId
);
530 $params['is_current_revision'] = 0;
531 $activity = new CRM_Activity_DAO_Activity();
532 $activity->copyValues($params);
536 // create a new version of activity if activity was found to
537 // have been modified/created by user
538 if (isset($newActParams)) {
539 // set proper original_id
540 if (!empty($this->_defaults
['original_id'])) {
541 $newActParams['original_id'] = $this->_defaults
['original_id'];
544 $newActParams['original_id'] = $activity->id
;
547 //is_current_revision will be set to 1 by default.
548 // add attachments if any
549 CRM_Core_BAO_File
::formatAttachment($newActParams,
554 // call begin post process, before the activity is created/updated.
555 $this->beginPostProcess($newActParams);
556 foreach ($this->_caseId
as $key => $val) {
557 $newActParams['case_id'] = $val;
558 $activity = CRM_Activity_BAO_Activity
::create($newActParams);
559 $vvalue[] = array('case_id' => $val, 'actId' => $activity->id
);
560 // call end post process, after the activity has been created/updated.
561 $this->endPostProcess($newActParams, $activity);
563 // copy files attached to old activity if any, to new one,
564 // as long as users have not selected the 'delete attachment' option.
565 if (empty($newActParams['is_delete_attachment']) && ($this->_activityId
!= $activity->id
)) {
566 CRM_Core_BAO_File
::copyEntityFile('civicrm_activity', $this->_activityId
,
567 'civicrm_activity', $activity->id
571 // copy back params to original var
572 $params = $newActParams;
575 foreach ($vvalue as $vkey => $vval) {
576 if ($vval['actId']) {
577 // add tags if exists
578 $tagParams = array();
579 if (!empty($params['tag'])) {
580 if (!is_array($params['tag'])) {
581 $params['tag'] = explode(',', $params['tag']);
584 $tagParams = array_fill_keys($params['tag'], 1);
588 CRM_Core_BAO_EntityTag
::create($tagParams, 'civicrm_activity', $vval['actId']);
591 if (isset($params['taglist']) && !empty($params['taglist'])) {
592 CRM_Core_Form_Tag
::postProcess($params['taglist'], $vval['actId'], 'civicrm_activity', $this);
596 // update existing case record if needed
597 $caseParams = $params;
598 $caseParams['id'] = $vval['case_id'];
599 if (!empty($caseParams['case_status_id'])) {
600 $caseParams['status_id'] = $caseParams['case_status_id'];
603 // unset params intended for activities only
604 unset($caseParams['subject'], $caseParams['details'],
605 $caseParams['status_id'], $caseParams['custom']
607 CRM_Case_BAO_Case
::create($caseParams);
608 // create case activity record
610 'activity_id' => $vval['actId'],
611 'case_id' => $vval['case_id'],
613 CRM_Case_BAO_Case
::processCaseActivity($caseParams);
616 // send copy to selected contacts.
618 $mailToContacts = array();
621 //check for notification settings for assignee contacts
622 $selectedContacts = array('contact_check');
623 if (Civi
::settings()->get('activity_assignee_notification')) {
624 $selectedContacts[] = 'assignee_contact_id';
627 foreach ($vvalue as $vkey => $vval) {
628 foreach ($selectedContacts as $dnt => $val) {
629 if (array_key_exists($val, $params) && !CRM_Utils_Array
::crmIsEmptyArray($params[$val])) {
630 if ($val == 'contact_check') {
631 $mailStatus = ts("A copy of the activity has also been sent to selected contacts(s).");
634 $this->_relatedContacts
= CRM_Activity_BAO_ActivityAssignment
::getAssigneeNames(array($vval['actId']), TRUE, FALSE);
635 $mailStatus .= ' ' . ts("A copy of the activity has also been sent to assignee contacts(s).");
637 //build an associative array with unique email addresses.
638 foreach ($params[$val] as $key => $value) {
639 if ($val == 'contact_check') {
646 if (isset($id) && array_key_exists($id, $this->_relatedContacts
) && isset($this->_relatedContacts
[$id]['email'])) {
647 //if email already exists in array then append with ', ' another role only otherwise add it to array.
648 if ($contactDetails = CRM_Utils_Array
::value($this->_relatedContacts
[$id]['email'], $mailToContacts)) {
649 $caseRole = CRM_Utils_Array
::value('role', $this->_relatedContacts
[$id]);
650 $mailToContacts[$this->_relatedContacts
[$id]['email']]['role'] = $contactDetails['role'] . ', ' . $caseRole;
653 $mailToContacts[$this->_relatedContacts
[$id]['email']] = $this->_relatedContacts
[$id];
660 $extraParams = array('case_id' => $vval['case_id'], 'client_id' => $this->_currentlyViewedContactId
);
661 $result = CRM_Activity_BAO_Activity
::sendToAssignee($activity, $mailToContacts, $extraParams);
662 if (empty($result)) {
666 // create follow up activity if needed
667 $followupStatus = '';
668 if (!empty($params['followup_activity_type_id'])) {
669 $followupActivity = CRM_Activity_BAO_Activity
::createFollowupActivity($vval['actId'], $params);
671 if ($followupActivity) {
673 'activity_id' => $followupActivity->id
,
674 'case_id' => $vval['case_id'],
676 CRM_Case_BAO_Case
::processCaseActivity($caseParams);
677 $followupStatus = ts("A followup activity has been scheduled.") . '<br /><br />';
680 $title = ts("%1 Saved", array(1 => $this->_activityTypeName
));
681 CRM_Core_Session
::setStatus($followupStatus . $mailStatus, $title, 'success');
686 * Returns the groups that contacts must belong to in order to be assigned
687 * an activity for this case. It returns an empty array if no groups are found for
688 * the case type linked to the caseId.
692 private function getActivityAssignmentGroups() {
693 if (!$this->_caseTypeDefinition
) {
697 $assignmentGroups = [];
698 foreach ($this->_caseTypeDefinition
as $caseId => $definition) {
699 if (!empty($definition['activityAsgmtGrps'])) {
700 $assignmentGroups = array_merge($assignmentGroups, $definition['activityAsgmtGrps']);
704 return $assignmentGroups;
708 * Returns whether contacts must have a user account in order to be
709 * assigned an activity for this case.
713 private function restrictAssignmentByUserAccount() {
714 if (!$this->_caseTypeDefinition
) {
718 foreach ($this->_caseTypeDefinition
as $caseId => $definition) {
719 if (!empty($definition['restrictActivityAsgmtToCmsUser'])) {
728 * Returns the case type definition column value for the case type linked to the caseId.
732 private function getCaseTypeDefinition() {
733 if (!$this->_caseId
) {
737 $definitions = civicrm_api3('CaseType', 'get', [
738 'return' => ['name', 'definition'],
739 'name' => ['IN' => array_unique($this->_caseType
)],
742 return array_column($definitions['values'], 'definition', 'name');