[REF] Preliminary cleanup for #17339
authoreileen <emcnaughton@wikimedia.org>
Thu, 28 May 2020 21:56:09 +0000 (09:56 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 28 May 2020 21:59:18 +0000 (09:59 +1200)
This merges changes to code around event cart to simplify the larger PR

CRM/Event/BAO/Event.php
CRM/Event/Cart/BAO/MerParticipant.php
CRM/Event/Form/ManageEvent/TabHeader.php
CRM/Event/Page/DashBoard.php
CRM/Event/Page/EventInfo.php
CRM/Event/Page/ManageEvent.php

index 0399390af657b9a9371f0c9333b3dd1746a50882..794e5d14e5a4b00c469db67c7c42805fea015a8b 100644 (file)
@@ -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'];
index 553ab9578b08a158326aa0129fc2d2e8f6f343d0..4cdf4e341b9c90d17b4ac33c3bb9c26b7ca0e260 100644 (file)
@@ -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;
   }
 
   /**
index 890782c624000db48c27a42b30f5ab4623d25a10..6b4c83d199510f27b32804144b6a445c8cdf3d5a 100644 (file)
@@ -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'],
index f477b0921115f30068b23e57735ba614c33693ff..9f86809e13c49c2731e46e1454a5993e965f85e0 100644 (file)
@@ -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) &&
index 19ee467fd5133b8c99ad34613156f13fc01c73c7..265b3f5dfeb81ab09a04d8351c591a2fb6fcccdc 100644 (file)
@@ -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();
index 1e9a7a06d5bdd149025df86f4cc74f0cffab077c..bc7badd236d30c9614641857e90209c9a0cbcc96 100644 (file)
@@ -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 = [];