Skip to content

Commit

Permalink
Merge pull request #19626 from colemanw/multiRecordCustomViewLink
Browse files Browse the repository at this point in the history
SearchKit - Add links to view multi-record custom data
  • Loading branch information
eileenmcnaughton authored Feb 21, 2021
2 parents 89e79e9 + e8854d6 commit a732a37
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
24 changes: 18 additions & 6 deletions CRM/Contact/Page/View/CustomData.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class CRM_Contact_Page_View_CustomData extends CRM_Core_Page {

/**
* The id of the object being viewed (note/relationship etc).
* Custom group id.
*
* @var int
*/
Expand All @@ -40,7 +40,23 @@ public function __construct() {
* Add a few specific things to view contact.
*/
public function preProcess() {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->_groupId = CRM_Utils_Request::retrieve('gid', 'Positive', $this, TRUE);
$this->assign('groupId', $this->_groupId);

$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_recId = CRM_Utils_Request::retrieve('recId', 'Positive', $this);

// If no cid supplied, look it up
if (!$this->_contactId && $this->_recId) {
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_groupId, 'table_name');
if ($tableName) {
$this->_contactId = CRM_Core_DAO::singleValueQuery("SELECT entity_id FROM `$tableName` WHERE id = %1", [1 => [$this->_recId, 'Integer']]);
}
}
if (!$this->_contactId) {
throw new CRM_Core_Exception(ts('Could not find valid value for %1', [1 => 'cid']));
}

$this->assign('contactId', $this->_contactId);

// check logged in url permission
Expand All @@ -49,12 +65,8 @@ public function preProcess() {
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);

$this->_groupId = CRM_Utils_Request::retrieve('gid', 'Positive', $this, TRUE);
$this->assign('groupId', $this->_groupId);

$this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this, FALSE);
$this->_cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE);
$this->_recId = CRM_Utils_Request::retrieve('recId', 'Positive', $this, FALSE);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion Civi/Api4/Action/Entity/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ private function addCustomEntities(&$entities) {
'description' => ts('Custom group for %1', [1 => $baseEntity::getInfo()['title_plural']]),
'searchable' => TRUE,
'type' => ['CustomValue'],
'paths' => [],
'paths' => [
'view' => "civicrm/contact/view/cd?reset=1&gid={$customEntity['id']}&recId=[id]&multiRecordDisplay=single",
],
'see' => [
'https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/#multiple-record-fieldsets',
'\\Civi\\Api4\\CustomGroup',
Expand Down

0 comments on commit a732a37

Please sign in to comment.