X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FPage%2FView%2FCustomData.php;h=8d8a5e9fefaa94ec07c781e8236241dc7bfd1a5a;hb=89952fb62b7a7a90a4427ff0f657358c8f405ebe;hp=8e78b9064d2dc8c14462dc771354035ea3562443;hpb=7f892a5eb184dae1f01e71ef5b647d9757eebd7b;p=civicrm-core.git diff --git a/CRM/Contact/Page/View/CustomData.php b/CRM/Contact/Page/View/CustomData.php index 8e78b9064d..8d8a5e9fef 100644 --- a/CRM/Contact/Page/View/CustomData.php +++ b/CRM/Contact/Page/View/CustomData.php @@ -27,15 +27,6 @@ class CRM_Contact_Page_View_CustomData extends CRM_Core_Page { */ public $_groupId; - /** - * Class constructor. - * - * @return CRM_Contact_Page_View_CustomData - */ - public function __construct() { - parent::__construct(); - } - /** * Add a few specific things to view contact. */ @@ -83,18 +74,9 @@ class CRM_Contact_Page_View_CustomData extends CRM_Core_Page { $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url($doneURL, 'action=browse&selectedChild=custom_' . $this->_groupId), FALSE); - // Get permission detail - view or edit. - // use a contact id specific function which gives us much better granularity - // CRM-12646 - $editCustomData = CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT); - $this->assign('editCustomData', $editCustomData); - - // Allow to edit own custom data CRM-5518. - $editOwnCustomData = FALSE; - if ($session->get('userID') == $this->_contactId) { - $editOwnCustomData = TRUE; - } - $this->assign('editOwnCustomData', $editOwnCustomData); + // Check permission to edit this contact + $editPermission = CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT); + $this->assign('editPermission', $editPermission); if ($this->_action == CRM_Core_Action::BROWSE) { @@ -105,8 +87,7 @@ class CRM_Contact_Page_View_CustomData extends CRM_Core_Page { if ($this->_multiRecordDisplay != 'single') { $id = "custom_{$this->_groupId}"; - $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_groupId, 'table_name'); - $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent($id, $this->_contactId, $tableName); + $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent($id, $this->_contactId); } if ($displayStyle === 'Tab with table' && $this->_multiRecordDisplay != 'single') { @@ -137,7 +118,7 @@ class CRM_Contact_Page_View_CustomData extends CRM_Core_Page { $groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupId); CRM_Utils_System::setTitle(ts('View %1 Record', [1 => $groupTitle])); $groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, NULL, $this->_contactId, - $this->_groupId, $entitySubType, NULL, TRUE, NULL, FALSE, TRUE, $this->_cgcount + $this->_groupId, $entitySubType, NULL, TRUE, NULL, FALSE, CRM_Core_Permission::VIEW, $this->_cgcount ); $recId = $this->_recId; @@ -146,10 +127,10 @@ class CRM_Contact_Page_View_CustomData extends CRM_Core_Page { } else { $groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, NULL, $this->_contactId, - $this->_groupId, $entitySubType + $this->_groupId, $entitySubType, NULL, TRUE, NULL, FALSE, CRM_Core_Permission::VIEW ); } - CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, $recId, $this->_contactId); + CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, $recId, $this->_contactId, TRUE); } } else {