3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Main page for viewing contact.
22 class CRM_Profile_Page_View
extends CRM_Core_Page
{
25 * The id of the contact.
32 * The group id that we are editing.
39 * Should the primary email be converted into a link, if emailabe.
43 protected $isShowEmailTaskLink = FALSE;
46 * Heart of the viewing process. The runner gets all the meta data for
47 * the contact and calls the appropriate type of page to view.
50 public function preProcess() {
51 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive',
54 $this->isShowEmailTaskLink
= CRM_Utils_Request
::retrieve('is_show_email_task', 'Positive', $this);
56 $session = CRM_Core_Session
::singleton();
57 $this->_id
= $session->get('userID');
59 CRM_Core_Error
::statusBounce(ts('Could not find the required contact id parameter (id=) for viewing a contact record with a Profile.'));
62 $this->assign('cid', $this->_id
);
64 $gids = explode(',', CRM_Utils_Request
::retrieve('gid', 'String', CRM_Core_DAO
::$_nullObject, FALSE, 0, 'GET'));
67 if (count($gids) > 1) {
69 foreach ($gids as $pfId) {
70 $profileIds[] = CRM_Utils_Type
::escape($pfId, 'Positive');
74 // check if we are rendering mixed profiles
75 if (CRM_Core_BAO_UFGroup
::checkForMixProfiles($profileIds)) {
76 CRM_Core_Error
::statusBounce(ts('You cannot combine profiles of multiple types.'));
79 $this->_gid
= $profileIds[0];
83 $this->_gid
= CRM_Utils_Request
::retrieve('gid', 'Positive', $this, FALSE, 0, 'GET');
88 $page = new CRM_Profile_Page_Dynamic($this->_id
, $this->_gid
, 'Profile', FALSE, $profileIds, $this->isShowEmailTaskLink
);
90 $profileGroup['title'] = NULL;
91 $profileGroup['content'] = $page->run();
92 if (empty($profileGroup['content'])) {
95 $profileGroups[] = $profileGroup;
97 $gidString = $this->_gid
;
98 if (!empty($profileIds)) {
99 $gidString = implode(',', $profileIds);
102 $map = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid
, 'is_map');
104 $this->assign('mapURL',
105 CRM_Utils_System
::url("civicrm/profile/map",
106 "reset=1&pv=1&cid={$this->_id}&gid={$gidString}"
110 if (CRM_Core_Permission
::ufGroupValid($this->_gid
,
111 CRM_Core_Permission
::SEARCH
114 $this->assign('listingURL',
115 CRM_Utils_System
::url("civicrm/profile",
116 "force=1&gid={$gidString}"
122 $ufGroups = CRM_Core_BAO_UFGroup
::getModuleUFGroup('Profile');
125 foreach ($ufGroups as $groupid => $group) {
126 $page = new CRM_Profile_Page_Dynamic($this->_id
, $groupid, 'Profile', FALSE, $profileIds);
128 $profileGroup['title'] = $group['title'];
129 $profileGroup['content'] = $page->run();
130 if (empty($profileGroup['content'])) {
133 $profileGroups[] = $profileGroup;
135 $this->assign('listingURL',
136 CRM_Utils_System
::url("civicrm/profile",
142 $this->assign('groupID', $this->_gid
);
144 $this->assign('profileGroups', $profileGroups);
145 $this->assign('recentlyViewed', FALSE);
147 // do not set title if there is no content
150 CRM_Utils_System
::setTitle('');
155 * Build the outcome basing on the CRM_Profile_Page_Dynamic's HTML.
158 public function run() {
160 return parent
::run();
164 * @param string $suffix
166 * @return null|string
168 public function checkTemplateFileExists($suffix = '') {
170 $templateFile = "CRM/Profile/Page/{$this->_gid}/View.{$suffix}tpl";
171 $template = CRM_Core_Page
::getTemplate();
172 if ($template->template_exists($templateFile)) {
173 return $templateFile;
176 // lets see if we have customized by name
177 $ufGroupName = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid
, 'name');
179 $templateFile = "CRM/Profile/Page/{$ufGroupName}/View.{$suffix}tpl";
180 if ($template->template_exists($templateFile)) {
181 return $templateFile;
189 * Use the form name to create the tpl file name.
193 public function getTemplateFileName() {
194 $fileName = $this->checkTemplateFileExists();
195 return $fileName ?
$fileName : parent
::getTemplateFileName();
199 * Default extra tpl file basically just replaces .tpl with .extra.tpl
200 * i.e. we dont override
204 public function overrideExtraTemplateFileName() {
205 $fileName = $this->checkTemplateFileExists('extra.');
206 return $fileName ?
$fileName : parent
::overrideExtraTemplateFileName();