From f6c2476bd7f1f54566f2ce9652943320f955974e Mon Sep 17 00:00:00 2001 From: colemanw Date: Mon, 2 Oct 2023 00:54:28 -0400 Subject: [PATCH] CiviCase - Add "manage case" link to metadata, make cid optional --- CRM/Case/DAO/Case.php | 11 ++++++++++- CRM/Case/Form/CaseView.php | 20 +++++++++++++++++--- CRM/Case/Page/Tab.php | 5 ----- xml/schema/Case/Case.xml | 3 +++ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/CRM/Case/DAO/Case.php b/CRM/Case/DAO/Case.php index 08d048818b..cc6544671c 100644 --- a/CRM/Case/DAO/Case.php +++ b/CRM/Case/DAO/Case.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Case/Case.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:83be6db09d4f5220f74ccc72149dcab6) + * (GenCodeChecksum:b5dbbb96b15e9ff288890017d324b984) */ /** @@ -45,6 +45,15 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO { */ public static $_log = TRUE; + /** + * Paths for accessing this entity in the UI. + * + * @var string[] + */ + protected static $_paths = [ + 'view' => 'civicrm/contact/view/case?action=view&reset=1&id=[id]', + ]; + /** * Unique Case ID * diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php index 24c0f4552c..bf50e3ec6a 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -49,6 +49,8 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { */ public $_contactID; + private $_caseClients; + /** * ID of case being viewed * @@ -100,9 +102,21 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $this->_hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities'); $this->assign('hasAccessToAllCases', $this->_hasAccessToAllCases); - $this->assign('contactID', $this->_contactID = (int) $this->get('cid')); $this->assign('caseID', $this->_caseID = (int) $this->get('id')); + $this->_caseClients = CRM_Case_BAO_Case::getContactNames($this->_caseID); + + $cid = $this->get('cid'); + + // If no cid supplied, use first case client + if (!$cid) { + $cid = array_keys($this->_caseClients)[0]; + } + elseif (!isset($this->_caseClients[$cid])) { + CRM_Core_Error::statusBounce("Contact $cid not a client of case " . $this->_caseID); + } + $this->assign('contactID', $this->_contactID = (int) $cid); + // Access check. if (!CRM_Case_BAO_Case::accessCase($this->_caseID, FALSE)) { CRM_Core_Error::statusBounce(ts('You do not have permission to access this case.')); @@ -147,7 +161,7 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { "action=view&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home" ); - $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID); + $displayName = $this->_caseClients[$this->_contactID]['display_name']; $this->assign('displayName', $displayName); $this->setTitle($displayName . ' - ' . $caseType); @@ -366,7 +380,7 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $this->assign('caseRelationships', $caseRelationships); //also add client as role. CRM-4438 - $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID); + $caseRoles['client'] = $this->_caseClients; $this->assign('caseRoles', $caseRoles); diff --git a/CRM/Case/Page/Tab.php b/CRM/Case/Page/Tab.php index 8c91b6ffb5..3dc37a7e6b 100644 --- a/CRM/Case/Page/Tab.php +++ b/CRM/Case/Page/Tab.php @@ -61,11 +61,6 @@ class CRM_Case_Page_Tab extends CRM_Core_Page { CRM_Contact_Page_View::checkUserPermission($this); } } - else { - if ($this->_action & CRM_Core_Action::VIEW) { - CRM_Core_Error::statusBounce(ts('Contact Id is required for view action.')); - } - } $activityTypes = CRM_Case_PseudoConstant::caseActivityType(); diff --git a/xml/schema/Case/Case.xml b/xml/schema/Case/Case.xml index d78de6fc22..3ca859baad 100644 --- a/xml/schema/Case/Case.xml +++ b/xml/schema/Case/Case.xml @@ -10,6 +10,9 @@ fa-folder-open subject CiviCase + + civicrm/contact/view/case?action=view&reset=1&id=[id] + id int unsigned -- 2.25.1