From 74ac3403368d814584a424ab4e3802209145da86 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 7 Nov 2017 12:36:40 +0000 Subject: [PATCH] More fixes to core_Task --- CRM/Activity/Form/Search.php | 4 +-- CRM/Activity/Task.php | 6 ++-- CRM/Campaign/Form/Search.php | 3 +- CRM/Campaign/Task.php | 4 ++- CRM/Case/Form/Search.php | 8 ++--- CRM/Case/Task.php | 6 ++-- CRM/Contact/Form/Search.php | 37 ++++--------------- CRM/Contact/Task.php | 13 ++++--- CRM/Contribute/Form/Search.php | 6 ++-- CRM/Contribute/Task.php | 13 ++++--- CRM/Core/Task.php | 49 ++++++++++++++----------- CRM/Event/Form/Search.php | 8 ++--- CRM/Event/Form/Task.php | 2 +- CRM/Event/Task.php | 8 ++--- CRM/Grant/Form/Search.php | 4 +-- CRM/Grant/Form/Task.php | 7 ++-- CRM/Grant/Task.php | 66 ++++++++++------------------------ CRM/Mailing/Task.php | 9 +++-- CRM/Member/Form/Search.php | 4 +-- CRM/Member/Form/Task.php | 2 +- CRM/Member/Task.php | 8 ++--- CRM/Pledge/Form/Search.php | 4 +-- CRM/Pledge/Task.php | 17 +++++---- 23 files changed, 125 insertions(+), 163 deletions(-) diff --git a/CRM/Activity/Form/Search.php b/CRM/Activity/Form/Search.php index 8f275c62aad9..6bbd12db9b95 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -170,9 +170,7 @@ public function buildQuickForm() { $this->addRowSelectors($rows); } - $permission = CRM_Core_Permission::getPermission(); - - $this->addTaskMenu(CRM_Activity_Task::permissionedTaskTitles($permission)); + $this->addTaskMenu(CRM_Activity_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission())); } } diff --git a/CRM/Activity/Task.php b/CRM/Activity/Task.php index c01d5d2f9f52..bb6d86c17891 100644 --- a/CRM/Activity/Task.php +++ b/CRM/Activity/Task.php @@ -125,12 +125,12 @@ public static function tasks() { * Show tasks selectively based on the permission level of the user. * * @param int $permission + * @param array $params * * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $deleteContacts = FALSE) { - $tasks = array(); + public static function permissionedTaskTitles($permission, $params = array()) { if ($permission == CRM_Core_Permission::EDIT) { $tasks = self::taskTitles(); } @@ -144,6 +144,8 @@ public static function permissionedTaskTitles($permission, $deleteContacts = FAL $tasks[self::DELETE_ACTIVITIES] = self::$_tasks[self::DELETE_ACTIVITIES]['title']; } } + + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; } diff --git a/CRM/Campaign/Form/Search.php b/CRM/Campaign/Form/Search.php index da3d9fafbcb1..393e97c8e161 100644 --- a/CRM/Campaign/Form/Search.php +++ b/CRM/Campaign/Form/Search.php @@ -205,8 +205,7 @@ public function buildQuickForm() { $this->addRowSelectors($rows); } - $permission = CRM_Core_Permission::getPermission(); - $allTasks = CRM_Campaign_Task::permissionedTaskTitles($permission); + $allTasks = CRM_Campaign_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission()); //hack to serve right page to state machine. $taskMapping = array( diff --git a/CRM/Campaign/Task.php b/CRM/Campaign/Task.php index c8fad8b44d7f..531b00709f2d 100644 --- a/CRM/Campaign/Task.php +++ b/CRM/Campaign/Task.php @@ -89,13 +89,15 @@ public static function tasks() { * of the user * * @param int $permission + * @param array $params * * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $deleteContacts = FALSE) { + public static function permissionedTaskTitles($permission, $params = array()) { $tasks = self::taskTitles(); + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; } diff --git a/CRM/Case/Form/Search.php b/CRM/Case/Form/Search.php index 37b0b38dbaad..d258882734a8 100644 --- a/CRM/Case/Form/Search.php +++ b/CRM/Case/Form/Search.php @@ -174,15 +174,13 @@ public function buildQuickForm() { $this->addRowSelectors($rows); } - $permission = CRM_Core_Permission::getPermission(); - - $tasks = CRM_Case_Task::permissionedTaskTitles($permission); + $tasks = CRM_Case_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission()); if (!empty($this->_formValues['case_deleted'])) { - unset($tasks[1]); + unset($tasks[CRM_Case_Task::DELETE_CASES]); } else { - unset($tasks[4]); + unset($tasks[CRM_Case_Task::RESTORE_CASES]); } $this->addTaskMenu($tasks); diff --git a/CRM/Case/Task.php b/CRM/Case/Task.php index 6b1920d20d77..111c8fe2c777 100644 --- a/CRM/Case/Task.php +++ b/CRM/Case/Task.php @@ -95,12 +95,12 @@ public static function tasks() { * of the user * * @param int $permission + * @param array $params * * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $deletedContacts = FALSE) { - $tasks = array(); + public static function permissionedTaskTitles($permission, $params = array()) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('access all cases and activities') || CRM_Core_Permission::check('access my cases and activities') @@ -116,6 +116,8 @@ public static function permissionedTaskTitles($permission, $deletedContacts = FA $tasks[self::DELETE_CASES] = self::$_tasks[self::DELETE_CASES]['title']; } } + + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; } diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index 40b1fc9b3e7b..a9f02b3c6627 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -337,25 +337,15 @@ public static function getModeSelect() { */ public function buildTaskList() { if ($this->_context !== 'amtg') { - $permission = CRM_Core_Permission::getPermission(); - + $taskParams['deletedContacts'] = FALSE; if ($this->_componentMode == CRM_Contact_BAO_Query::MODE_CONTACTS || $this->_componentMode == CRM_Contact_BAO_Query::MODE_CONTACTSRELATED) { - $this->_taskList += CRM_Contact_Task::permissionedTaskTitles($permission, - CRM_Utils_Array::value('deleted_contacts', $this->_formValues) - ); - } - else { - $className = $this->_modeValue['taskClassName']; - $this->_taskList += $className::permissionedTaskTitles($permission, FALSE); - } - - // Only offer the "Update Smart Group" task if a smart group/saved search is already in play - if (isset($this->_ssID) && $permission == CRM_Core_Permission::EDIT) { - $this->_taskList += CRM_Contact_Task::optionalTaskTitle(); + $taskParams['deletedContacts'] = CRM_Utils_Array::value('deleted_contacts', $this->_formValues); } + $className = $this->_modeValue['taskClassName']; + $taskParams['ssID'] = isset($this->_ssID) ? $this->_ssID : NULL; + $this->_taskList += $className::permissionedTaskTitles(CRM_Core_Permission::getPermission(), $taskParams); } - asort($this->_taskList); return $this->_taskList; } @@ -368,24 +358,11 @@ public function buildQuickForm() { // jsTree is needed for tags popup ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE) ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header'); - $permission = CRM_Core_Permission::getPermission(); + // some tasks.. what do we want to do with the selected contacts ? - $tasks = array(); - if ($this->_componentMode == CRM_Contact_BAO_Query::MODE_CONTACTS || $this->_componentMode == CRM_Contact_BAO_Query::MODE_CONTACTSRELATED) { - $tasks += CRM_Contact_Task::permissionedTaskTitles($permission, - CRM_Utils_Array::value('deleted_contacts', $this->_formValues) - ); - } - else { - $className = $this->_modeValue['taskClassName']; - $tasks += $className::permissionedTaskTitles($permission, FALSE); - } + $this->_taskList = $this->buildTaskList(); if (isset($this->_ssID)) { - if ($permission == CRM_Core_Permission::EDIT) { - $tasks = $tasks + CRM_Contact_Task::optionalTaskTitle(); - } - $search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id'); diff --git a/CRM/Contact/Task.php b/CRM/Contact/Task.php index 10f0c2436119..a19d990e6870 100644 --- a/CRM/Contact/Task.php +++ b/CRM/Contact/Task.php @@ -244,16 +244,19 @@ public static function tasks() { * of the user * * @param int $permission - * @param bool $deletedContacts - * Are these tasks for operating on deleted contacts?. + * @param array $params: + * bool deletedContacts: Are these tasks for operating on deleted contacts?. * * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $deletedContacts = FALSE) { + public static function permissionedTaskTitles($permission, $params = array()) { + if (!isset($params['deletedContacts'])) { + $params['deletedContacts'] = FALSE; + } self::tasks(); $tasks = array(); - if ($deletedContacts) { + if ($params['deletedContacts']) { if (CRM_Core_Permission::check('access deleted contacts')) { $tasks[self::RESTORE] = self::$_tasks[self::RESTORE]['title']; if (CRM_Core_Permission::check('delete contacts')) { @@ -283,6 +286,8 @@ public static function permissionedTaskTitles($permission, $deletedContacts = FA $tasks[self::CREATE_MAILING] = self::$_tasks[self::CREATE_MAILING]['title']; } } + + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; } diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index b0174523f6bb..2d3d66570d1e 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -197,11 +197,11 @@ public function buildQuickForm() { $permission = CRM_Core_Permission::getPermission(); $queryParams = $this->get('queryParams'); - $softCreditFiltering = FALSE; + $taskParams['softCreditFiltering'] = FALSE; if (!empty($queryParams)) { - $softCreditFiltering = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams); + $taskParams['softCreditFiltering'] = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams); } - $tasks = CRM_Contribute_Task::permissionedTaskTitles($permission, $softCreditFiltering); + $tasks = CRM_Contribute_Task::permissionedTaskTitles($permission, $taskParams); $this->addTaskMenu($tasks); } diff --git a/CRM/Contribute/Task.php b/CRM/Contribute/Task.php index 89ab544cd84d..c9bfabe0bb66 100644 --- a/CRM/Contribute/Task.php +++ b/CRM/Contribute/Task.php @@ -130,13 +130,16 @@ public static function tasks() { * * @param int $permission * - * @param bool $softCreditFiltering + * @param array $params: + * bool softCreditFiltering: derived from CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled * * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $softCreditFiltering = FALSE) { - $tasks = array(); + public static function permissionedTaskTitles($permission, $params = array()) { + if (!isset($params['softCreditFiltering'])) { + $params['softCreditFiltering'] = FALSE; + } if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('edit contributions') ) { @@ -154,9 +157,11 @@ public static function permissionedTaskTitles($permission, $softCreditFiltering $tasks[self::DELETE_CONTRIBUTIONS] = self::$_tasks[self::DELETE_CONTRIBUTIONS]['title']; } } - if ($softCreditFiltering) { + if ($params['softCreditFiltering']) { unset($tasks[self::BATCH_CONTRIBUTIONS], $tasks[self::PDF_RECEIPT]); } + + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; } diff --git a/CRM/Core/Task.php b/CRM/Core/Task.php index 6e93659b32a6..4ef94042e02c 100644 --- a/CRM/Core/Task.php +++ b/CRM/Core/Task.php @@ -111,7 +111,12 @@ abstract class CRM_Core_Task { // Pledge tasks DELETE_PLEDGES = 66, PRINT_PLEDGES = 67, - EXPORT_PLEDGES = 68; + EXPORT_PLEDGES = 68, + // Grant Tasks + DELETE_GRANTS = 1, + PRINT_GRANTS = 2, + EXPORT_GRANTS = 3, + UPDATE_GRANTS = 4; /** * The task array @@ -120,13 +125,6 @@ abstract class CRM_Core_Task { */ static $_tasks = NULL; - /** - * The optional task array - * - * @var array - */ - static $_optionalTasks = NULL; - abstract public static function tasks(); /** @@ -144,9 +142,6 @@ public static function taskTitles() { $titles[$id] = $value['title']; } - // hack unset update saved search - unset($titles[self::SAVE_SEARCH_UPDATE]); - if (!CRM_Utils_Mail::validOutBoundMail()) { unset($titles[self::EMAIL_CONTACTS]); unset($titles[self::CREATE_MAILING]); @@ -164,26 +159,40 @@ public static function taskTitles() { /** * Show tasks selectively based on the permission level * of the user + * This function should be call parent::corePermissionedTaskTitles * * @param int $permission - * @param bool $deletedContacts - * Are these tasks for operating on deleted contacts?. + * @param array $params + * "ssID: Saved Search ID": If !empty we are in saved search context * * @return array * set of tasks that are valid for the user */ - abstract public static function permissionedTaskTitles($permission, $deletedContacts = FALSE); + abstract public static function permissionedTaskTitles($permission, $params); /** - * These tasks get added based on the context the user is in. + * Show tasks selectively based on the permission level + * of the user + * This function should be called by permissionedTaskTitles in children + * + * @param int $permission + * @param array $params + * "ssID: Saved Search ID": If !empty we are in saved search context + * @param array $tasks: The array of tasks generated by permissionedTaskTitles * * @return array - * the set of optional tasks for a group of contacts + * set of tasks that are valid for the user */ - public static function optionalTaskTitle() { - $tasks = array( - self::SAVE_SEARCH_UPDATE => self::$_tasks[self::SAVE_SEARCH_UPDATE]['title'], - ); + public static function corePermissionedTaskTitles($tasks, $permission, $params) { + // Only offer the "Update Smart Group" task if a smart group/saved search is already in play and we have edit permissions + if (!empty($params['ssID']) && ($permission == CRM_Core_Permission::EDIT)) { + $tasks[self::SAVE_SEARCH_UPDATE] = self::$_tasks[self::SAVE_SEARCH_UPDATE]['title']; + } + else { + unset($tasks[self::SAVE_SEARCH_UPDATE]); + } + + asort($tasks); return $tasks; } diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index 455210313596..5ac763c52307 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -229,14 +229,10 @@ public function buildQuickForm() { $this->assign('participantCount', $participantCount); $this->assign('lineItems', $lineItems); - $permission = CRM_Core_Permission::getPermission(); + $taskParams['ssID'] = isset($this->_ssID) ? $this->_ssID : NULL; + $tasks = CRM_Event_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission(), $taskParams); - $tasks = CRM_Event_Task::permissionedTaskTitles($permission); if (isset($this->_ssID)) { - if ($permission == CRM_Core_Permission::EDIT) { - $tasks = $tasks + CRM_Event_Task::optionalTaskTitle(); - } - $savedSearchValues = array( 'id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), diff --git a/CRM/Event/Form/Task.php b/CRM/Event/Form/Task.php index a06174dc3003..6151248be2d8 100644 --- a/CRM/Event/Form/Task.php +++ b/CRM/Event/Form/Task.php @@ -89,7 +89,7 @@ public static function preProcessCommon(&$form, $useTable = FALSE) { $form->_task = $values['task']; $tasks = CRM_Event_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission()); - if (!array_key_exists($form->_task, CRM_Event_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission()))) { + if (!array_key_exists($form->_task, $tasks)) { CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); } $form->assign('taskName', $tasks[$form->_task]); diff --git a/CRM/Event/Task.php b/CRM/Event/Task.php index 2c11434aad22..df261a0c5536 100644 --- a/CRM/Event/Task.php +++ b/CRM/Event/Task.php @@ -139,14 +139,12 @@ public static function tasks() { * of the user * * @param int $permission - * @param bool $deletedContacts - * Are these tasks for operating on deleted contacts?. + * @param array $params * * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $deletedContacts = FALSE) { - $tasks = array(); + public static function permissionedTaskTitles($permission, $params = array()) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('edit event participants') ) { @@ -163,6 +161,8 @@ public static function permissionedTaskTitles($permission, $deletedContacts = FA $tasks[self::DELETE_EVENTS] = self::$_tasks[self::DELETE_EVENTS]['title']; } } + + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; } diff --git a/CRM/Grant/Form/Search.php b/CRM/Grant/Form/Search.php index 3a1400ad7565..cb8b1fd651a7 100644 --- a/CRM/Grant/Form/Search.php +++ b/CRM/Grant/Form/Search.php @@ -170,9 +170,7 @@ public function buildQuickForm() { $this->addRowSelectors($rows); } - $permission = CRM_Core_Permission::getPermission(); - - $this->addTaskMenu(CRM_Grant_Task::permissionedTaskTitles($permission)); + $this->addTaskMenu(CRM_Grant_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission())); } } diff --git a/CRM/Grant/Form/Task.php b/CRM/Grant/Form/Task.php index c7700b34b94e..1b882e88b936 100644 --- a/CRM/Grant/Form/Task.php +++ b/CRM/Grant/Form/Task.php @@ -88,8 +88,11 @@ public static function preProcessCommon(&$form, $useTable = FALSE) { $values = $form->controller->exportValues('Search'); $form->_task = $values['task']; - $grantTasks = CRM_Grant_Task::tasks(); - $form->assign('taskName', $grantTasks[$form->_task]); + $tasks = CRM_Grant_Task::tasks(); + if (!array_key_exists($form->_task, $tasks)) { + CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); + } + $form->assign('taskName', $tasks[$form->_task]); $ids = array(); if ($values['radio_ts'] == 'ts_sel') { diff --git a/CRM/Grant/Task.php b/CRM/Grant/Task.php index 290f52ab78f2..9fd64dbeee6f 100644 --- a/CRM/Grant/Task.php +++ b/CRM/Grant/Task.php @@ -38,22 +38,7 @@ * used by the search forms * */ -class CRM_Grant_Task { - const DELETE_GRANTS = 1, PRINT_GRANTS = 2, EXPORT_GRANTS = 3, UPDATE_GRANTS = 4; - - /** - * The task array - * - * @var array - */ - static $_tasks = NULL; - - /** - * The optional task array - * - * @var array - */ - static $_optionalTasks = NULL; +class CRM_Grant_Task extends CRM_Core_Task { /** * These tasks are the core set of tasks that the user can perform @@ -62,20 +47,20 @@ class CRM_Grant_Task { * @return array * the set of tasks for a group of contacts */ - public static function &tasks() { + public static function tasks() { if (!(self::$_tasks)) { self::$_tasks = array( - 1 => array( + self::DELETE_GRANTS => array( 'title' => ts('Delete grants'), 'class' => 'CRM_Grant_Form_Task_Delete', 'result' => FALSE, ), - 2 => array( + self::PRINT_GRANTS => array( 'title' => ts('Print selected rows'), 'class' => 'CRM_Grant_Form_Task_Print', 'result' => FALSE, ), - 3 => array( + self::EXPORT_GRANTS => array( 'title' => ts('Export grants'), 'class' => array( 'CRM_Export_Form_Select', @@ -83,7 +68,7 @@ public static function &tasks() { ), 'result' => FALSE, ), - 4 => array( + self::UPDATE_GRANTS => array( 'title' => ts('Update grants'), 'class' => 'CRM_Grant_Form_Task_Update', 'result' => FALSE, @@ -91,7 +76,7 @@ public static function &tasks() { ); if (!CRM_Core_Permission::check('delete in CiviGrant')) { - unset(self::$_tasks[1]); + unset(self::$_tasks[self::DELETE_GRANTS]); } CRM_Utils_Hook::searchTasks('grant', self::$_tasks); @@ -101,32 +86,17 @@ public static function &tasks() { return self::$_tasks; } - /** - * These tasks are the core set of task titles - * - * @return array - * the set of task titles - */ - public static function &taskTitles() { - self::tasks(); - $titles = array(); - foreach (self::$_tasks as $id => $value) { - $titles[$id] = $value['title']; - } - return $titles; - } - /** * Show tasks selectively based on the permission level * of the user * * @param int $permission + * @param array $params * * @return array * set of tasks that are valid for the user */ - public static function &permissionedTaskTitles($permission) { - $tasks = array(); + public static function permissionedTaskTitles($permission, $params = array()) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('edit grants') ) { @@ -134,13 +104,15 @@ public static function &permissionedTaskTitles($permission) { } else { $tasks = array( - 3 => self::$_tasks[3]['title'], + self::EXPORT_GRANTS => self::$_tasks[self::EXPORT_GRANTS]['title'], ); //CRM-4418, if (CRM_Core_Permission::check('delete in CiviGrant')) { - $tasks[1] = self::$_tasks[1]['title']; + $tasks[self::DELETE_GRANTS] = self::$_tasks[self::DELETE_GRANTS]['title']; } } + + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; } @@ -154,14 +126,12 @@ public static function &permissionedTaskTitles($permission) { */ public static function getTask($value) { self::tasks(); - if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) { - // make the print task by default - $value = 2; + + if (!CRM_Utils_Array::value($value, self::$_tasks)) { + // make it the print task by default + $value = self::PRINT_GRANTS; } - return array( - self::$_tasks[$value]['class'], - self::$_tasks[$value]['result'], - ); + return parent::getTask($value); } } diff --git a/CRM/Mailing/Task.php b/CRM/Mailing/Task.php index 89fec6488944..b14d4a2b74a0 100644 --- a/CRM/Mailing/Task.php +++ b/CRM/Mailing/Task.php @@ -67,13 +67,16 @@ public static function tasks() { * of the user. * * @param int $permission + * @param array $params * * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $deleteContacts = FALSE) { - $task = array(); - return $task; + public static function permissionedTaskTitles($permission, $params = array()) { + $tasks = array(); + + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); + return $tasks; } /** diff --git a/CRM/Member/Form/Search.php b/CRM/Member/Form/Search.php index e21293931a3b..d08bb993c513 100644 --- a/CRM/Member/Form/Search.php +++ b/CRM/Member/Form/Search.php @@ -163,9 +163,7 @@ public function buildQuickForm() { $this->addRowSelectors($rows); } - $permission = CRM_Core_Permission::getPermission(); - - $this->addTaskMenu(CRM_Member_Task::permissionedTaskTitles($permission)); + $this->addTaskMenu(CRM_Member_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission())); } } diff --git a/CRM/Member/Form/Task.php b/CRM/Member/Form/Task.php index 7dfa160ab533..6c56017486fa 100644 --- a/CRM/Member/Form/Task.php +++ b/CRM/Member/Form/Task.php @@ -96,7 +96,7 @@ public static function preProcessCommon(&$form, $useTable = FALSE) { $form->_task = $values['task']; $tasks = CRM_Member_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission()); - if (!array_key_exists($form->_task, CRM_Member_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission()))) { + if (!array_key_exists($form->_task, $tasks)) { CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); } $form->assign('taskName', $tasks[$form->_task]); diff --git a/CRM/Member/Task.php b/CRM/Member/Task.php index 6da42c315bb2..f208c2b5953a 100644 --- a/CRM/Member/Task.php +++ b/CRM/Member/Task.php @@ -138,14 +138,12 @@ public static function taskTitles() { * of the user * * @param int $permission - * @param bool $deletedContacts - * Are these tasks for operating on deleted contacts?. + * @param array $params * * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $deletedContacts = FALSE) { - $tasks = array(); + public static function permissionedTaskTitles($permission, $params = array()) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('edit memberships') ) { @@ -161,6 +159,8 @@ public static function permissionedTaskTitles($permission, $deletedContacts = FA $tasks[self::DELETE_MEMBERS] = self::$_tasks[self::DELETE_MEMBERS]['title']; } } + + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; } diff --git a/CRM/Pledge/Form/Search.php b/CRM/Pledge/Form/Search.php index e0e23cfa0618..c5a4c8608b7a 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -155,9 +155,7 @@ public function buildQuickForm() { $this->addRowSelectors($rows); } - $permission = CRM_Core_Permission::getPermission(); - - $this->addTaskMenu(CRM_Pledge_Task::permissionedTaskTitles($permission)); + $this->addTaskMenu(CRM_Pledge_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission())); } } diff --git a/CRM/Pledge/Task.php b/CRM/Pledge/Task.php index dab2820ac7cc..7d3baf8ddcf3 100644 --- a/CRM/Pledge/Task.php +++ b/CRM/Pledge/Task.php @@ -83,12 +83,12 @@ public static function tasks() { * of the user * * @param int $permission + * @param array $params * * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $deleteContact = FALSE) { - $tasks = array(); + public static function permissionedTaskTitles($permission, $params = array()) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('edit pledges') ) { @@ -103,6 +103,8 @@ public static function permissionedTaskTitles($permission, $deleteContact = FALS $tasks[self::DELETE_PLEDGES] = self::$_tasks[self::DELETE_PLEDGES]['title']; } } + + $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; } @@ -117,15 +119,12 @@ public static function permissionedTaskTitles($permission, $deleteContact = FALS */ public static function getTask($value) { self::tasks(); - if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) { - // make the print task by default + + if (!CRM_Utils_Array::value($value, self::$_tasks)) { + // make it the print task by default $value = self::PRINT_PLEDGES; } - - return array( - self::$_tasks[$value]['class'], - self::$_tasks[$value]['result'], - ); + return parent::getTask($value); } }