From 63cd4fcfa10ef02f06180b1f4268ee285bc459b0 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Tue, 21 May 2013 16:03:14 -0700 Subject: [PATCH] CRM-10935 - tweak so we dont display other tabs in summary if no access CiviCRM ---------------------------------------- * CRM-10935: Create new Core Permission - CiviCRM: Access own Contact or both "CiviCRM: View own Contact" and "CiviCRM: Edit own Contact" http://issues.civicrm.org/jira/browse/CRM-10935 --- CRM/Contact/Page/View/Summary.php | 23 ++++++++++++++++------- CRM/Core/xml/Menu/Contact.xml | 10 ++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index 4ec331ced5..76f41682f9 100644 --- a/CRM/Contact/Page/View/Summary.php +++ b/CRM/Contact/Page/View/Summary.php @@ -216,7 +216,8 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { $defaults['privacy_values'] = CRM_Core_SelectValues::privacy(); //Show blocks only if they are visible in edit form - $this->_editOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, + $this->_editOptions = CRM_Core_BAO_Setting::valueOptions( + CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options' ); @@ -262,16 +263,23 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { $allTabs = array(); $weight = 10; - $this->_viewOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - 'contact_view_options', TRUE + $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) { - if ( CRM_Utils_Array::value($name, $this->_viewOptions) && - CRM_Core_Permission::access($component->name) + if ( + CRM_Utils_Array::value($name, $this->_viewOptions) && + CRM_Core_Permission::access($component->name) ) { $elem = $component->registerTab(); @@ -317,10 +325,11 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { ); foreach ($rest as $k => $v) { - if (CRM_Utils_Array::value($k, $this->_viewOptions)) { + if ($accessCiviCRM && CRM_Utils_Array::value($k, $this->_viewOptions)) { $allTabs[] = array( 'id' => $k, - 'url' => CRM_Utils_System::url("civicrm/contact/view/$k", + 'url' => CRM_Utils_System::url( + "civicrm/contact/view/$k", "reset=1&snippet=1&cid={$this->_contactId}" ), 'title' => $v, diff --git a/CRM/Core/xml/Menu/Contact.xml b/CRM/Core/xml/Menu/Contact.xml index b5acc48ae9..25d2cc7512 100644 --- a/CRM/Core/xml/Menu/Contact.xml +++ b/CRM/Core/xml/Menu/Contact.xml @@ -6,8 +6,6 @@ CiviCRM CRM_Core_Permission::checkMenu access CiviCRM - edit my contact - view my contact CRM_Contact_Page_DashBoard null false @@ -82,6 +80,10 @@ p civicrm/contact/add New Contact + CRM_Core_Permission::checkMenu + access CiviCRM + edit my contact + view my contact CRM_Contact_Form_Contact addSequence=1 @@ -142,6 +144,10 @@ p civicrm/contact/view cid=%%cid%% Contact Summary + CRM_Core_Permission::checkMenu + access CiviCRM + edit my contact + view my contact CRM_Contact_Page_View_Summary -- 2.25.1