diff --git a/CRM/Contact/Page/View.php b/CRM/Contact/Page/View.php index b8dde815fd26c2aeecee96b38f26bc400a14e2ee..f2e43c68cd2addf60e7eb676c7a203a1d204cca7 100644 --- a/CRM/Contact/Page/View.php +++ b/CRM/Contact/Page/View.php @@ -228,7 +228,7 @@ class CRM_Contact_Page_View extends CRM_Core_Page { // set page title $title = self::setTitle($this->_contactId, $isDeleted); $this->assign('title', $title); - + // Check if this is default domain contact CRM-10482 if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactId)) { $this->assign('domainContact', TRUE); diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index 4ec331ced5fd2744d89c27971c312051cf2bc878..76f41682f966a2b21d39997cce70d2c236792fe3 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/BAO/Setting.php b/CRM/Core/BAO/Setting.php index 0161abe92e6d3e4e6b7d79ccd1ba265c81a872e5..8d325de6cea343ad6175e42311575c1121cf12e7 100644 --- a/CRM/Core/BAO/Setting.php +++ b/CRM/Core/BAO/Setting.php @@ -178,7 +178,8 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { * @static * @access public */ - static function getItem($group, + static function getItem( + $group, $name = NULL, $componentID = NULL, $defaultValue = NULL, diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index e27da5830faae5a18545f5765ee855a5e02b456f..066cc4c357d333b6764608309072cdd0ced44505 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -444,6 +444,8 @@ class CRM_Core_Permission { 'add contacts' => $prefix . ts('add contacts'), 'view all contacts' => $prefix . ts('view all contacts'), 'edit all contacts' => $prefix . ts('edit all contacts'), + 'view my contact' => $prefix . ts('view my contact'), + 'edit my contact' => $prefix . ts('edit my contact'), 'delete contacts' => $prefix . ts('delete contacts'), 'access deleted contacts' => $prefix . ts('access deleted contacts'), 'import contacts' => $prefix . ts('import contacts'), diff --git a/CRM/Core/Permission/DrupalBase.php b/CRM/Core/Permission/DrupalBase.php index 296915d0cb3f6f0908bbccf98bf6341b6d8fe2c1..66edb9a4e6a9418a570fdb3c51c84580ebf912b4 100644 --- a/CRM/Core/Permission/DrupalBase.php +++ b/CRM/Core/Permission/DrupalBase.php @@ -102,19 +102,23 @@ class CRM_Core_Permission_DrupalBase extends CRM_Core_Permission_Base { $ids = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_saved_search', $groups); - foreach (array_values($ids) as $id) { - $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $id, 'title'); - $this->_viewPermissionedGroups[$groupKey][$id] = $title; - $this->_viewPermission = TRUE; + if (!empty($ids)) { + foreach (array_values($ids) as $id) { + $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $id, 'title'); + $this->_viewPermissionedGroups[$groupKey][$id] = $title; + $this->_viewPermission = TRUE; + } } $ids = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_saved_search', $groups); - foreach (array_values($ids) as $id) { - $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $id, 'title'); - $this->_editPermissionedGroups[$groupKey][$id] = $title; - $this->_viewPermissionedGroups[$groupKey][$id] = $title; - $this->_editPermission = TRUE; - $this->_viewPermission = TRUE; + if (!empty($ids)) { + foreach (array_values($ids) as $id) { + $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $id, 'title'); + $this->_editPermissionedGroups[$groupKey][$id] = $title; + $this->_viewPermissionedGroups[$groupKey][$id] = $title; + $this->_editPermission = TRUE; + $this->_viewPermission = TRUE; + } } } diff --git a/CRM/Core/xml/Menu/Contact.xml b/CRM/Core/xml/Menu/Contact.xml index 628a9a764f00822d1c2854a2107d1dc064d76d11..25d2cc7512cabc7b24edcc26edbd498aa4484b37 100644 --- a/CRM/Core/xml/Menu/Contact.xml +++ b/CRM/Core/xml/Menu/Contact.xml @@ -36,7 +36,7 @@ <weight>10</weight> <page_type>1</page_type> </item> - <item> +p <item> <path>civicrm/contact/image</path> <title>Process Uploaded Images</title> <page_callback>CRM_Contact_BAO_Contact::processImage</page_callback> @@ -80,9 +80,12 @@ <item> <path>civicrm/contact/add</path> <title>New Contact</title> + <access_callback>CRM_Core_Permission::checkMenu</access_callback> + <access_arguments>access CiviCRM</access_arguments> + <access_arguments>edit my contact</access_arguments> + <access_arguments>view my contact</access_arguments> <page_callback>CRM_Contact_Form_Contact</page_callback> <page_arguments>addSequence=1</page_arguments> - <access_arguments>access CiviCRM</access_arguments> </item> <item> <path>civicrm/contact/add/individual</path> @@ -141,6 +144,10 @@ <path>civicrm/contact/view</path> <path_arguments>cid=%%cid%%</path_arguments> <title>Contact Summary</title> + <access_callback>CRM_Core_Permission::checkMenu</access_callback> + <access_arguments>access CiviCRM</access_arguments> + <access_arguments>edit my contact</access_arguments> + <access_arguments>view my contact</access_arguments> <page_callback>CRM_Contact_Page_View_Summary</page_callback> </item> <item> @@ -171,7 +178,7 @@ <path_arguments>action=add</path_arguments> <title>Activities</title> <page_callback>CRM_Contact_Form_Task_PDF</page_callback> - </item> + </item> <item> <path>civicrm/contact/view/rel</path> <path_arguments>cid=%%cid%%</path_arguments> diff --git a/templates/CRM/Contact/Page/View/Summary.tpl b/templates/CRM/Contact/Page/View/Summary.tpl index 4b2e15b6b0e38cb16a57f08abfc005dfd56381e0..8637835141a88ea1eb8034e2e6d082b3eee1cec3 100644 --- a/templates/CRM/Contact/Page/View/Summary.tpl +++ b/templates/CRM/Contact/Page/View/Summary.tpl @@ -51,15 +51,19 @@ {* Include the Actions and Edit buttons if user has 'edit' permission and contact is NOT in trash. *} {if $permission EQ 'edit' and !$isDeleted} + {if call_user_func(array('CRM_Core_Permission','check'), 'access CiviCRM')} <li class="crm-contact-activity crm-summary-block"> {include file="CRM/Contact/Page/Inline/Actions.tpl"} </li> + {/if} + {if call_user_func(array('CRM_Core_Permission','check'), 'edit my contact')} <li> {assign var='editParams' value=$urlParams|cat:"&action=update&cid=$contactId"} <a href="{crmURL p='civicrm/contact/add' q=$editParams}" class="edit button" title="{ts}Edit{/ts}"> <span><div class="icon edit-icon"></div>{ts}Edit{/ts}</span> </a> </li> + {/if} {/if} {* Check for permissions to provide Restore and Delete Permanently buttons for contacts that are in the trash. *} @@ -262,7 +266,7 @@ <div class="contactCardLeft"> <div class="crm-summary-comm-pref-block"> <div class="crm-summary-block" id="communication-pref-block" > - {include file="CRM/Contact/Page/Inline/CommunicationPreferences.tpl"} + {include file="CRM/Contact/Page/Inline/CommunicationPreferences.tpl"} </div> </div> </div> <!-- contactCardLeft --> @@ -271,7 +275,7 @@ <div class="contactCardRight"> <div class="crm-summary-demographic-block"> <div class="crm-summary-block" id="demographic-block"> - {include file="CRM/Contact/Page/Inline/Demographics.tpl"} + {include file="CRM/Contact/Page/Inline/Demographics.tpl"} </div> </div> </div> <!-- contactCardRight --> @@ -280,7 +284,7 @@ <div class="separator"></div> </div> <!-- contact panel --> </div><!--contact_details--> - + {if $showCustomData} <div id="customFields"> <div class="contact_panel"> @@ -295,8 +299,8 @@ <div class="clear"></div> </div> </div> - {/if} - + {/if} + {if !empty($hookContent) and isset($hookContentPlacement) and $hookContentPlacement eq 1} {include file="CRM/Contact/Page/View/SummaryHook.tpl"} {/if}