3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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 * Main page for viewing contact.
40 class CRM_Profile_Page_View
extends CRM_Core_Page
{
43 * The id of the contact
50 * The group id that we are editing
57 * Heart of the viewing process. The runner gets all the meta data for
58 * the contact and calls the appropriate type of page to view.
62 public function preProcess() {
63 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive',
67 $session = CRM_Core_Session
::singleton();
68 $this->_id
= $session->get('userID');
70 CRM_Core_Error
::fatal(ts('Could not find the required contact id parameter (id=) for viewing a contact record with a Profile.'));
73 $this->assign('cid', $this->_id
);
75 $gids = explode(',', CRM_Utils_Request
::retrieve('gid', 'String', CRM_Core_DAO
::$_nullObject, FALSE, 0, 'GET'));
77 $profileIds = array();
78 if (count($gids) > 1) {
80 foreach ($gids as $pfId) {
81 $profileIds[] = CRM_Utils_Type
::escape($pfId, 'Positive');
85 // check if we are rendering mixed profiles
86 if (CRM_Core_BAO_UFGroup
::checkForMixProfiles($profileIds)) {
87 CRM_Core_Error
::fatal(ts('You cannot combine profiles of multiple types.'));
90 $this->_gid
= $profileIds[0];
94 $this->_gid
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this, FALSE, 0, 'GET');
99 $page = new CRM_Profile_Page_Dynamic($this->_id
, $this->_gid
, 'Profile', FALSE, $profileIds);
100 $profileGroup = array();
101 $profileGroup['title'] = NULL;
102 $profileGroup['content'] = $page->run();
103 if (empty($profileGroup['content'])) {
106 $profileGroups[] = $profileGroup;
108 $gidString = $this->_gid
;
109 if (!empty($profileIds)) {
110 $gidString = implode(',', $profileIds);
113 $map = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid
, 'is_map');
115 $this->assign('mapURL',
116 CRM_Utils_System
::url("civicrm/profile/map",
117 "reset=1&pv=1&cid={$this->_id}&gid={$gidString}"
121 if (CRM_Core_Permission
::ufGroupValid($this->_gid
,
122 CRM_Core_Permission
::SEARCH
125 $this->assign('listingURL',
126 CRM_Utils_System
::url("civicrm/profile",
127 "force=1&gid={$gidString}"
133 $ufGroups = CRM_Core_BAO_UFGroup
::getModuleUFGroup('Profile');
135 $profileGroups = array();
136 foreach ($ufGroups as $groupid => $group) {
137 $page = new CRM_Profile_Page_Dynamic($this->_id
, $groupid, 'Profile', FALSE, $profileIds);
138 $profileGroup = array();
139 $profileGroup['title'] = $group['title'];
140 $profileGroup['content'] = $page->run();
141 if (empty($profileGroup['content'])) {
144 $profileGroups[] = $profileGroup;
146 $this->assign('listingURL',
147 CRM_Utils_System
::url("civicrm/profile",
153 $this->assign('groupID', $this->_gid
);
155 $this->assign('profileGroups', $profileGroups);
156 $this->assign('recentlyViewed', FALSE);
158 // do not set title if there is no content
161 CRM_Utils_System
::setTitle('');
166 * Build the outcome basing on the CRM_Profile_Page_Dynamic's HTML
170 public function run() {
172 return parent
::run();
176 * @param string $suffix
178 * @return null|string
180 public function checkTemplateFileExists($suffix = '') {
182 $templateFile = "CRM/Profile/Page/{$this->_gid}/View.{$suffix}tpl";
183 $template = CRM_Core_Page
::getTemplate();
184 if ($template->template_exists($templateFile)) {
185 return $templateFile;
188 // lets see if we have customized by name
189 $ufGroupName = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid
, 'name');
191 $templateFile = "CRM/Profile/Page/{$ufGroupName}/View.{$suffix}tpl";
192 if ($template->template_exists($templateFile)) {
193 return $templateFile;
201 * Use the form name to create the tpl file name
208 public function getTemplateFileName() {
209 $fileName = $this->checkTemplateFileExists();
210 return $fileName ?
$fileName : parent
::getTemplateFileName();
214 * Default extra tpl file basically just replaces .tpl with .extra.tpl
215 * i.e. we dont override
222 public function overrideExtraTemplateFileName() {
223 $fileName = $this->checkTemplateFileExists('extra.');
224 return $fileName ?
$fileName : parent
::overrideExtraTemplateFileName();