From 558067312e63789d0b22db44b5f174adc6cecfa9 Mon Sep 17 00:00:00 2001 From: Camilo Rodriguez Date: Thu, 11 Jan 2018 15:00:50 +0000 Subject: [PATCH] CRM-21425: Allow to Edit Inbound E-mails Within CiviCase Civicase used the activity's detail view form to show the detail for the activity and the edit and delete buttons, but the preprocessing lacked setting the required flags so the form buttons were shown. Fixed by setting the required flags and refactoring the new permissions check into the Activity BAO. --- CRM/Activity/BAO/Activity.php | 16 ++++++++++++++++ CRM/Activity/Form/Activity.php | 1 + CRM/Activity/Page/Tab.php | 18 +----------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 31c3c253d9..f2982096d3 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -2833,6 +2833,22 @@ INNER JOIN civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n return $allow; } + /** + * Checks if user has permissions to edit inbound e-mails, either bsic info + * or both basic information and content. + * + * @return bool + */ + public function checkEditInboundEmailsPermissions() { + if (CRM_Core_Permission::check('edit inbound email basic information') + || CRM_Core_Permission::check('edit inbound email basic information and content') + ) { + return TRUE; + } + + return FALSE; + } + /** * Wrapper for ajax activity selector. * diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index ce6404aff9..4990f1a3c3 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -308,6 +308,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { CRM_Activity_BAO_Activity::checkPermission($this->_activityId, CRM_Core_Action::UPDATE) ) { $this->assign('permission', 'edit'); + $this->assign('allow_edit_inbound_emails', CRM_Activity_BAO_Activity::checkEditInboundEmailsPermissions()); } if (!$this->_activityTypeId && $this->_activityId) { diff --git a/CRM/Activity/Page/Tab.php b/CRM/Activity/Page/Tab.php index 837eeb3608..4ebca1b531 100644 --- a/CRM/Activity/Page/Tab.php +++ b/CRM/Activity/Page/Tab.php @@ -131,7 +131,7 @@ class CRM_Activity_Page_Tab extends CRM_Core_Page { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); $this->assign('action', $this->_action); - $this->assign('allow_edit_inbound_emails', $this->checkEditInboundEmailsPermissions()); + $this->assign('allow_edit_inbound_emails', CRM_Activity_BAO_Activity::checkEditInboundEmailsPermissions()); // also create the form element for the activity links box $controller = new CRM_Core_Controller_Simple( @@ -144,22 +144,6 @@ class CRM_Activity_Page_Tab extends CRM_Core_Page { $controller->run(); } - /** - * Checks if user has permissions to edit inbound e-mails, either bsic info - * or both basic information and content. - * - * @return bool - */ - private function checkEditInboundEmailsPermissions() { - if (CRM_Core_Permission::check('edit inbound email basic information') - || CRM_Core_Permission::check('edit inbound email basic information and content') - ) { - return TRUE; - } - - return FALSE; - } - public function delete() { $controller = new CRM_Core_Controller_Simple( 'CRM_Activity_Form_Activity', -- 2.25.1