3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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-2018
36 * Main page for viewing contact.
39 class CRM_Profile_Page_View
extends CRM_Core_Page
{
42 * The id of the contact.
49 * The group id that we are editing.
56 * Heart of the viewing process. The runner gets all the meta data for
57 * the contact and calls the appropriate type of page to view.
60 public function preProcess() {
61 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive',
65 $session = CRM_Core_Session
::singleton();
66 $this->_id
= $session->get('userID');
68 CRM_Core_Error
::fatal(ts('Could not find the required contact id parameter (id=) for viewing a contact record with a Profile.'));
71 $this->assign('cid', $this->_id
);
73 $gids = explode(',', CRM_Utils_Request
::retrieve('gid', 'String', CRM_Core_DAO
::$_nullObject, FALSE, 0, 'GET'));
75 $profileIds = array();
76 if (count($gids) > 1) {
78 foreach ($gids as $pfId) {
79 $profileIds[] = CRM_Utils_Type
::escape($pfId, 'Positive');
83 // check if we are rendering mixed profiles
84 if (CRM_Core_BAO_UFGroup
::checkForMixProfiles($profileIds)) {
85 CRM_Core_Error
::fatal(ts('You cannot combine profiles of multiple types.'));
88 $this->_gid
= $profileIds[0];
92 $this->_gid
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this, FALSE, 0, 'GET');
97 $page = new CRM_Profile_Page_Dynamic($this->_id
, $this->_gid
, 'Profile', FALSE, $profileIds);
98 $profileGroup = array();
99 $profileGroup['title'] = NULL;
100 $profileGroup['content'] = $page->run();
101 if (empty($profileGroup['content'])) {
104 $profileGroups[] = $profileGroup;
106 $gidString = $this->_gid
;
107 if (!empty($profileIds)) {
108 $gidString = implode(',', $profileIds);
111 $map = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid
, 'is_map');
113 $this->assign('mapURL',
114 CRM_Utils_System
::url("civicrm/profile/map",
115 "reset=1&pv=1&cid={$this->_id}&gid={$gidString}"
119 if (CRM_Core_Permission
::ufGroupValid($this->_gid
,
120 CRM_Core_Permission
::SEARCH
123 $this->assign('listingURL',
124 CRM_Utils_System
::url("civicrm/profile",
125 "force=1&gid={$gidString}"
131 $ufGroups = CRM_Core_BAO_UFGroup
::getModuleUFGroup('Profile');
133 $profileGroups = array();
134 foreach ($ufGroups as $groupid => $group) {
135 $page = new CRM_Profile_Page_Dynamic($this->_id
, $groupid, 'Profile', FALSE, $profileIds);
136 $profileGroup = array();
137 $profileGroup['title'] = $group['title'];
138 $profileGroup['content'] = $page->run();
139 if (empty($profileGroup['content'])) {
142 $profileGroups[] = $profileGroup;
144 $this->assign('listingURL',
145 CRM_Utils_System
::url("civicrm/profile",
151 $this->assign('groupID', $this->_gid
);
153 $this->assign('profileGroups', $profileGroups);
154 $this->assign('recentlyViewed', FALSE);
156 // do not set title if there is no content
159 CRM_Utils_System
::setTitle('');
164 * Build the outcome basing on the CRM_Profile_Page_Dynamic's HTML.
167 public function run() {
169 return parent
::run();
173 * @param string $suffix
175 * @return null|string
177 public function checkTemplateFileExists($suffix = '') {
179 $templateFile = "CRM/Profile/Page/{$this->_gid}/View.{$suffix}tpl";
180 $template = CRM_Core_Page
::getTemplate();
181 if ($template->template_exists($templateFile)) {
182 return $templateFile;
185 // lets see if we have customized by name
186 $ufGroupName = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid
, 'name');
188 $templateFile = "CRM/Profile/Page/{$ufGroupName}/View.{$suffix}tpl";
189 if ($template->template_exists($templateFile)) {
190 return $templateFile;
198 * Use the form name to create the tpl file name.
202 public function getTemplateFileName() {
203 $fileName = $this->checkTemplateFileExists();
204 return $fileName ?
$fileName : parent
::getTemplateFileName();
208 * Default extra tpl file basically just replaces .tpl with .extra.tpl
209 * i.e. we dont override
213 public function overrideExtraTemplateFileName() {
214 $fileName = $this->checkTemplateFileExists('extra.');
215 return $fileName ?
$fileName : parent
::overrideExtraTemplateFileName();