3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * Page for displaying custom data
40 class CRM_Contact_Page_View_CustomData
extends CRM_Core_Page
{
43 * the id of the object being viewed (note/relationship etc)
53 * @return CRM_Contact_Page_View_CustomData
55 public function __construct() {
56 parent
::__construct();
60 * add a few specific things to view contact
66 function preProcess() {
67 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
68 $this->assign('contactId', $this->_contactId
);
70 // check logged in url permission
71 CRM_Contact_Page_View
::checkUserPermission($this);
73 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
74 $this->assign('action', $this->_action
);
76 $this->_groupId
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this, TRUE);
77 $this->assign('groupId', $this->_groupId
);
79 $this->_multiRecordDisplay
= CRM_Utils_Request
::retrieve('multiRecordDisplay', 'String', $this, FALSE);
80 $this->_cgcount
= CRM_Utils_Request
::retrieve('cgcount', 'Positive', $this, FALSE);
81 $this->_recId
= CRM_Utils_Request
::retrieve('recId', 'Positive', $this, FALSE);
87 * This method is called after the page is created. It checks for the
88 * type of action and executes that action.
92 * @param object $page - the view page which created this one
101 //set the userContext stack
102 $doneURL = 'civicrm/contact/view';
103 $session = CRM_Core_Session
::singleton();
104 $session->pushUserContext(CRM_Utils_System
::url($doneURL, 'action=browse&selectedChild=custom_' . $this->_groupId
), FALSE);
106 // get permission detail view or edit
107 // use a comtact id specific function which gives us much better granularity
109 $editCustomData = CRM_Contact_BAO_Contact_Permission
::allow($this->_contactId
, CRM_Core_Permission
::EDIT
);
110 $this->assign('editCustomData', $editCustomData);
112 //allow to edit own customdata CRM-5518
113 $editOwnCustomData = FALSE;
114 if ($session->get('userID') == $this->_contactId
) {
115 $editOwnCustomData = TRUE;
117 $this->assign('editOwnCustomData', $editOwnCustomData);
119 if ($this->_action
== CRM_Core_Action
::BROWSE
) {
120 //Custom Groups Inline
121 $entityType = CRM_Contact_BAO_Contact
::getContactType($this->_contactId
);
122 $entitySubType = CRM_Contact_BAO_Contact
::getContactSubType($this->_contactId
);
123 $groupTree = &CRM_Core_BAO_CustomGroup
::getTree($entityType, $this, $this->_contactId
,
124 $this->_groupId
, $entitySubType
127 $displayStyle = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomGroup',
132 if ($displayStyle === 'Tab with table' && $this->_multiRecordDisplay
!= 'single') {
133 $id = "custom_{$this->_groupId}";
134 $this->ajaxResponse
['tabCount'] = CRM_Contact_BAO_Contact
::getCountComponent($id, $this->_contactId
, $groupTree[$this->_groupId
]['table_name']);
135 $ctype = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Contact',
140 $this->assign('displayStyle', 'tableOriented');
141 // here the multi custom data listing code will go
142 $multiRecordFieldListing = TRUE;
143 $page = new CRM_Profile_Page_MultipleRecordFieldsListing();
144 $page->set('contactId', $this->_contactId
);
145 $page->set('customGroupId', $this->_groupId
);
146 $page->set('action', CRM_Core_Action
::BROWSE
);
147 $page->set('multiRecordFieldListing', $multiRecordFieldListing);
148 $page->set('pageViewType', 'customDataView');
149 $page->set('contactType', $ctype);
154 if ($this->_multiRecordDisplay
== 'single') {
155 $groupTitle = CRM_Core_BAO_CustomGroup
::getTitle($this->_groupId
);
156 CRM_Utils_System
::setTitle(ts('View %1 Record', array(1 => $groupTitle)));
158 $recId = $this->_recId
;
159 $this->assign('multiRecordDisplay', $this->_multiRecordDisplay
);
160 $this->assign('skipTitle', 1);
162 CRM_Core_BAO_CustomGroup
::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, $recId);
167 $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_CustomData',
171 $controller->setEmbedded(TRUE);
173 $controller->set('tableId', $this->_contactId
);
174 $controller->set('groupId', $this->_groupId
);
175 $controller->set('entityType', CRM_Contact_BAO_Contact
::getContactType($this->_contactId
));
176 $controller->set('entitySubType', CRM_Contact_BAO_Contact
::getContactSubType($this->_contactId
, ','));
177 $controller->process();
180 return parent
::run();