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 contains the functions for Case Contact management.
21 class CRM_Case_BAO_CaseContact
extends CRM_Case_DAO_CaseContact
{
24 * Create case contact record.
26 * @param array $params
29 * @return CRM_Case_BAO_CaseContact
31 public static function create($params) {
32 $hook = empty($params['id']) ?
'create' : 'edit';
33 CRM_Utils_Hook
::pre($hook, 'CaseContact', CRM_Utils_Array
::value('id', $params), $params);
35 $caseContact = new self();
36 $caseContact->copyValues($params);
39 CRM_Utils_Hook
::post($hook, 'CaseContact', $caseContact->id
, $caseContact);
41 // add to recently viewed
42 $caseType = CRM_Case_BAO_Case
::getCaseType($caseContact->case_id
);
43 $url = CRM_Utils_System
::url('civicrm/contact/view/case',
44 "action=view&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home"
47 $title = CRM_Contact_BAO_Contact
::displayName($caseContact->contact_id
) . ' - ' . $caseType;
50 if (CRM_Core_Permission
::checkActionPermission('CiviCase', CRM_Core_Action
::DELETE
)) {
51 $recentOther['deleteUrl'] = CRM_Utils_System
::url('civicrm/contact/view/case',
52 "action=delete&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home"
56 // add the recently created case
57 CRM_Utils_Recent
::add($title,
59 $caseContact->case_id
,
61 $caseContact->contact_id
,
72 public function addSelectWhereClause() {
75 'case_id' => CRM_Utils_SQL
::mergeSubquery('Case'),
76 // Case acls already check for contact access so we can just mark contact_id as handled
79 // Don't call hook selectWhereClause, the case query already did