*/
public $_groupId;
- /**
- * Class constructor.
- *
- * @return CRM_Contact_Page_View_CustomData
- */
- public function __construct() {
- parent::__construct();
- }
-
/**
* Add a few specific things to view contact.
*/
$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) {
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') {
$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;
}
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 {