From: eileen Date: Thu, 28 May 2020 21:56:09 +0000 (+1200) Subject: [REF] Preliminary cleanup for #17339 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7fffa5fa0101377d23badeb25f378745b4741337;p=civicrm-core.git [REF] Preliminary cleanup for #17339 This merges changes to code around event cart to simplify the larger PR --- diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 0399390af6..794e5d14e5 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -846,10 +846,6 @@ WHERE civicrm_event.is_active = 1 // be clearer & safer here $permissions = CRM_Core_Permission::event(CRM_Core_Permission::VIEW); - // check if we're in shopping cart mode for events - $enable_cart = Civi::settings()->get('enable_cart'); - if ($enable_cart) { - } while ($dao->fetch()) { if (!empty($permissions) && in_array($dao->event_id, $permissions)) { $info = []; @@ -891,7 +887,9 @@ WHERE civicrm_event.is_active = 1 $info['location'] = $address; $info['url'] = CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE); - if ($enable_cart) { + // @todo Move to eventcart extension + // check if we're in shopping cart mode for events + if ((bool) Civi::settings()->get('enable_cart')) { $reg = CRM_Event_Cart_BAO_EventInCart::get_registration_link($dao->event_id); $info['registration_link'] = CRM_Utils_System::url($reg['path'], $reg['query'], TRUE); $info['registration_link_text'] = $reg['label']; diff --git a/CRM/Event/Cart/BAO/MerParticipant.php b/CRM/Event/Cart/BAO/MerParticipant.php index 553ab9578b..4cdf4e341b 100644 --- a/CRM/Event/Cart/BAO/MerParticipant.php +++ b/CRM/Event/Cart/BAO/MerParticipant.php @@ -38,7 +38,7 @@ class CRM_Event_Cart_BAO_MerParticipant extends CRM_Event_BAO_Participant { $a = (array) $participant; $this->copyValues($a); - $this->email = $participant['email'] ?? NULL; + $this->email = $a['email'] ?? NULL; } /** diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 890782c624..6b4c83d199 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -86,8 +86,7 @@ class CRM_Event_Form_ManageEvent_TabHeader { } // check if we're in shopping cart mode for events - $enableCart = Civi::settings()->get('enable_cart'); - if (!$enableCart) { + if (!(bool) Civi::settings()->get('enable_cart')) { unset($tabs['conference']); } @@ -107,7 +106,7 @@ LEFT JOIN civicrm_recurring_entity re ON ( e.id = re.entity_id AND re.entity_ta WHERE e.id = %1 "; //Check if repeat is configured - $eventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($eventID, 'civicrm_event'); + CRM_Core_BAO_RecurringEntity::getParentFor($eventID, 'civicrm_event'); $params = [ 1 => [$eventID, 'Integer'], 2 => [$eventNameMapping->getId(), 'Integer'], diff --git a/CRM/Event/Page/DashBoard.php b/CRM/Event/Page/DashBoard.php index f477b09211..9f86809e13 100644 --- a/CRM/Event/Page/DashBoard.php +++ b/CRM/Event/Page/DashBoard.php @@ -9,14 +9,6 @@ +--------------------------------------------------------------------+ */ -/** - * - * @package CRM - * @copyright CiviCRM LLC https://civicrm.org/licensing - * $Id$ - * - */ - /** * This is page is for Event Dashboard */ @@ -32,8 +24,7 @@ class CRM_Event_Page_DashBoard extends CRM_Core_Page { CRM_Utils_System::setTitle(ts('CiviEvent')); $eventSummary = CRM_Event_BAO_Event::getEventSummary(); - $enableCart = Civi::settings()->get('enable_cart'); - $eventSummary['tab'] = CRM_Event_Page_ManageEvent::tabs($enableCart); + $eventSummary['tab'] = CRM_Event_Page_ManageEvent::tabs(); $actionColumn = FALSE; if (!empty($eventSummary) && diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index 19ee467fd5..265b3f5dfe 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -341,8 +341,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { $this->assign('location', $values['location']); if (CRM_Core_Permission::check(['access CiviEvent', 'edit all events'])) { - $enableCart = Civi::settings()->get('enable_cart'); - $this->assign('manageEventLinks', CRM_Event_Page_ManageEvent::tabs($enableCart)); + $this->assign('manageEventLinks', CRM_Event_Page_ManageEvent::tabs()); } return parent::run(); diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index 1e9a7a06d5..bc7badd236 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -130,7 +130,8 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { * @return array * (reference) of tab links */ - public static function &tabs($enableCart) { + public static function &tabs() { + $enableCart = Civi::settings()->get('enable_cart'); $cacheKey = $enableCart ? 1 : 0; if (!(self::$_tabLinks)) { self::$_tabLinks = [];