$lastModified = CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact');
$this->assign_by_ref('lastModified', $lastModified);
- $allTabs = array();
- $weight = 10;
-
$this->_viewOptions = CRM_Core_BAO_Setting::valueOptions(
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_view_options',
TRUE
);
- // show the tabs only if user has generic access to CiviCRM
- $accessCiviCRM = CRM_Core_Permission::check('access CiviCRM');
-
$changeLog = $this->_viewOptions['log'];
$this->assign_by_ref('changeLog', $changeLog);
- $components = CRM_Core_Component::getEnabledComponents();
- foreach ($components as $name => $component) {
+ $this->assign('allTabs', $this->getTabs());
+
+ // hook for contact summary
+ // ignored but needed to prevent warnings
+ $contentPlacement = CRM_Utils_Hook::SUMMARY_BELOW;
+ CRM_Utils_Hook::summary($this->_contactId, $content, $contentPlacement);
+ if ($content) {
+ $this->assign_by_ref('hookContent', $content);
+ $this->assign('hookContentPlacement', $contentPlacement);
+ }
+ }
+
+ /**
+ * @return string
+ */
+ public function getTemplateFileName() {
+ if ($this->_contactId) {
+ $contactSubtypes = $this->get('contactSubtype') ? explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->get('contactSubtype')) : array();
+
+ // there could be multiple subtypes. We check templates for each of the subtype, and return the first one found.
+ foreach ($contactSubtypes as $csType) {
+ if ($csType) {
+ $templateFile = "CRM/Contact/Page/View/SubType/{$csType}.tpl";
+ $template = CRM_Core_Page::getTemplate();
+ if ($template->template_exists($templateFile)) {
+ return $templateFile;
+ }
+ }
+ }
+ }
+ return parent::getTemplateFileName();
+ }
+
+ /**
+ * @return array
+ * @throws \CRM_Core_Exception
+ */
+ public function getTabs() {
+ $allTabs = [];
+ $weight = 10;
+
+ foreach (CRM_Core_Component::getEnabledComponents() as $name => $component) {
if (!empty($this->_viewOptions[$name]) &&
CRM_Core_Permission::access($component->name)
) {
if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
$q .= "&isTest=1";
}
- $allTabs[] = array(
+ $allTabs[] = [
'id' => $i,
'url' => CRM_Utils_System::url("civicrm/contact/view/$u", $q),
'title' => $elem['title'],
'weight' => $elem['weight'],
'count' => CRM_Contact_BAO_Contact::getCountComponent($u, $this->_contactId),
'class' => 'livePage',
- );
+ ];
// make sure to get maximum weight, rest of tabs go after
// FIXME: not very elegant again
if ($weight < $elem['weight']) {
}
}
- $rest = array(
- 'activity' => array(
+ $rest = [
+ 'activity' => [
'title' => ts('Activities'),
'class' => 'livePage',
- ),
- 'rel' => array(
+ ],
+ 'rel' => [
'title' => ts('Relationships'),
'class' => 'livePage',
- ),
- 'group' => array(
+ ],
+ 'group' => [
'title' => ts('Groups'),
'class' => 'ajaxForm',
- ),
- 'note' => array(
+ ],
+ 'note' => [
'title' => ts('Notes'),
'class' => 'livePage',
- ),
- 'tag' => array(
+ ],
+ 'tag' => [
'title' => ts('Tags'),
- ),
- 'log' => array(
+ ],
+ 'log' => [
'title' => ts('Change Log'),
- ),
- );
+ ],
+ ];
+ // show the tabs only if user has generic access to CiviCRM
+ $accessCiviCRM = CRM_Core_Permission::check('access CiviCRM');
foreach ($rest as $k => $v) {
if ($accessCiviCRM && !empty($this->_viewOptions[$k])) {
- $allTabs[] = $v + array(
+ $allTabs[] = $v + [
'id' => $k,
'url' => CRM_Utils_System::url(
"civicrm/contact/view/$k",
),
'weight' => $weight,
'count' => CRM_Contact_BAO_Contact::getCountComponent($k, $this->_contactId),
- );
+ ];
$weight += 10;
}
}
foreach ($activeGroups as $group) {
$id = "custom_{$group['id']}";
- $allTabs[] = array(
+ $allTabs[] = [
'id' => $id,
'url' => CRM_Utils_System::url($group['path'], $group['query'] . "&selectedChild=$id"),
'title' => $group['title'],
'count' => CRM_Contact_BAO_Contact::getCountComponent($id, $this->_contactId, $group['table_name']),
'hideCount' => !$group['is_multiple'],
'class' => 'livePage',
- );
+ ];
$weight += 10;
}
- $context = array('contact_id' => $this->_contactId);
+ $context = ['contact_id' => $this->_contactId];
// see if any other modules want to add any tabs
CRM_Utils_Hook::tabs($allTabs, $this->_contactId);
CRM_Utils_Hook::tabset('civicrm/contact/view', $allTabs, $context);
- $allTabs[] = array(
+ $allTabs[] = [
'id' => 'summary',
'url' => '#contact-summary',
'title' => ts('Summary'),
'weight' => 0,
- );
+ ];
// now sort the tabs based on weight
- usort($allTabs, array('CRM_Utils_Sort', 'cmpFunc'));
-
- $this->assign('allTabs', $allTabs);
-
- // hook for contact summary
- // ignored but needed to prevent warnings
- $contentPlacement = CRM_Utils_Hook::SUMMARY_BELOW;
- CRM_Utils_Hook::summary($this->_contactId, $content, $contentPlacement);
- if ($content) {
- $this->assign_by_ref('hookContent', $content);
- $this->assign('hookContentPlacement', $contentPlacement);
- }
- }
-
- /**
- * @return string
- */
- public function getTemplateFileName() {
- if ($this->_contactId) {
- $contactSubtypes = $this->get('contactSubtype') ? explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->get('contactSubtype')) : array();
-
- // there could be multiple subtypes. We check templates for each of the subtype, and return the first one found.
- foreach ($contactSubtypes as $csType) {
- if ($csType) {
- $templateFile = "CRM/Contact/Page/View/SubType/{$csType}.tpl";
- $template = CRM_Core_Page::getTemplate();
- if ($template->template_exists($templateFile)) {
- return $templateFile;
- }
- }
- }
- }
- return parent::getTemplateFileName();
+ usort($allTabs, ['CRM_Utils_Sort', 'cmpFunc']);
+ return $allTabs;
}
}