_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); $this->assign('contactId', $this->_contactId); // check logged in url permission CRM_Contact_Page_View::checkUserPermission($this); $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); } /** * Run the page. * * This method is called after the page is created. It checks for the * type of action and executes that action. * * @access public * * @param object $page - the view page which created this one * * @return void * @static * */ function run() { $this->preProcess(); //set the userContext stack $doneURL = 'civicrm/contact/view'; $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 comtact 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 customdata CRM-5518 $editOwnCustomData = FALSE; if ($session->get('userID') == $this->_contactId) { $editOwnCustomData = TRUE; } $this->assign('editOwnCustomData', $editOwnCustomData); if ($this->_action == CRM_Core_Action::BROWSE) { //Custom Groups Inline $entityType = CRM_Contact_BAO_Contact::getContactType($this->_contactId); $entitySubType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId); $groupTree = &CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $this->_contactId, $this->_groupId, $entitySubType ); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); } else { $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_CustomData', ts('Custom Data'), $this->_action ); $controller->setEmbedded(TRUE); $controller->set('tableId', $this->_contactId); $controller->set('groupId', $this->_groupId); $controller->set('entityType', CRM_Contact_BAO_Contact::getContactType($this->_contactId)); $controller->set('entitySubType', CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ',')); $controller->process(); $controller->run(); } return parent::run(); } }