From 987e3a4f29f7e1ca58cc7285e41442695ac4e395 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 6 May 2021 14:19:08 +1200 Subject: [PATCH] [REF] Cleanup BAO_ActionSchedule::getlist() signature This is only called from 3 places. Only one passes variables. Of the 3 2 check if the results is an array - civirules does not (civirules doesn't really use this function - it would be better to do a v4 api get) --- CRM/Admin/Page/ScheduleReminders.php | 38 +++++++-------- CRM/Core/BAO/ActionSchedule.php | 6 +-- .../Form/ManageEvent/ScheduleReminders.php | 48 +++++++++---------- 3 files changed, 43 insertions(+), 49 deletions(-) diff --git a/CRM/Admin/Page/ScheduleReminders.php b/CRM/Admin/Page/ScheduleReminders.php index 524031760e..2eb555d175 100644 --- a/CRM/Admin/Page/ScheduleReminders.php +++ b/CRM/Admin/Page/ScheduleReminders.php @@ -126,27 +126,25 @@ class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic { // Get list of configured reminders $reminderList = CRM_Core_BAO_ActionSchedule::getList(); - if (is_array($reminderList)) { - // Add action links to each of the reminders - foreach ($reminderList as & $format) { - $action = array_sum(array_keys($this->links())); - if ($format['is_active']) { - $action -= CRM_Core_Action::ENABLE; - } - else { - $action -= CRM_Core_Action::DISABLE; - } - $format['action'] = CRM_Core_Action::formLink( - self::links(), - $action, - ['id' => $format['id']], - ts('more'), - FALSE, - 'actionSchedule.manage.action', - 'ActionSchedule', - $format['id'] - ); + // Add action links to each of the reminders + foreach ($reminderList as & $format) { + $action = array_sum(array_keys($this->links())); + if ($format['is_active']) { + $action -= CRM_Core_Action::ENABLE; } + else { + $action -= CRM_Core_Action::DISABLE; + } + $format['action'] = CRM_Core_Action::formLink( + self::links(), + $action, + ['id' => $format['id']], + ts('more'), + FALSE, + 'actionSchedule.manage.action', + 'ActionSchedule', + $format['id'] + ); } $this->assign('rows', $reminderList); diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index b57abb0a2c..b2f4d1770a 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -102,9 +102,6 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { /** * Retrieve list of Scheduled Reminders. * - * @param bool $namesOnly - * Return simple list of names. - * * @param \Civi\ActionSchedule\Mapping|null $filterMapping * Filter by the schedule's mapping type. * @param int $filterValue @@ -114,7 +111,8 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { * (reference) reminder list * @throws \CRM_Core_Exception */ - public static function &getList($namesOnly = FALSE, $filterMapping = NULL, $filterValue = NULL) { + public static function getList($filterMapping = NULL, $filterValue = NULL): array { + $list = []; $query = " SELECT title, diff --git a/CRM/Event/Form/ManageEvent/ScheduleReminders.php b/CRM/Event/Form/ManageEvent/ScheduleReminders.php index 36b4619f51..7e1144afc2 100644 --- a/CRM/Event/Form/ManageEvent/ScheduleReminders.php +++ b/CRM/Event/Form/ManageEvent/ScheduleReminders.php @@ -35,32 +35,30 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => ($this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID), ])); - $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id); - if ($reminderList && is_array($reminderList)) { - // Add action links to each of the reminders - foreach ($reminderList as & $format) { - $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE; - if ($format['is_active']) { - $action += CRM_Core_Action::DISABLE; - } - else { - $action += CRM_Core_Action::ENABLE; - } - $scheduleReminder = new CRM_Admin_Page_ScheduleReminders(); - $links = $scheduleReminder->links(); - $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}"; - $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}"; - $format['action'] = CRM_Core_Action::formLink( - $links, - $action, - ['id' => $format['id']], - ts('more'), - FALSE, - 'actionSchedule.manage.action', - 'ActionSchedule', - $this->_id - ); + $reminderList = CRM_Core_BAO_ActionSchedule::getList($mapping, $this->_id); + // Add action links to each of the reminders + foreach ($reminderList as & $format) { + $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE; + if ($format['is_active']) { + $action += CRM_Core_Action::DISABLE; } + else { + $action += CRM_Core_Action::ENABLE; + } + $scheduleReminder = new CRM_Admin_Page_ScheduleReminders(); + $links = $scheduleReminder->links(); + $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}"; + $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}"; + $format['action'] = CRM_Core_Action::formLink( + $links, + $action, + ['id' => $format['id']], + ts('more'), + FALSE, + 'actionSchedule.manage.action', + 'ActionSchedule', + $this->_id + ); } $this->assign('rows', $reminderList); -- 2.25.1