Move Conference slots functionality to event cart
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 18 Sep 2023 04:03:57 +0000 (16:03 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 18 Sep 2023 04:03:57 +0000 (16:03 +1200)
CRM/Event/Form/ManageEvent/TabHeader.php
CRM/Event/Page/ManageEvent.php
CRM/Event/xml/Menu/Event.xml
ext/eventcart/CRM/Event/Cart/Form/Checkout/Payment.php
ext/eventcart/CRM/Event/Form/ManageEvent/Conference.php [moved from CRM/Event/Form/ManageEvent/Conference.php with 100% similarity]
ext/eventcart/eventcart.php
ext/eventcart/templates/CRM/Event/Form/ManageEvent/Conference.tpl [moved from templates/CRM/Event/Form/ManageEvent/Conference.tpl with 100% similarity]
ext/eventcart/xml/Menu/Eventcart.xml

index 8c159a7c397873bfce0414947fe08af7acc96e9d..27eba8a848c83e1202592435d15156a69ebf76a4 100644 (file)
@@ -76,7 +76,7 @@ class CRM_Event_Form_ManageEvent_TabHeader {
     if (CRM_Core_Permission::check('administer CiviCRM data') || !empty($permissions[CRM_Core_Permission::EDIT])) {
       $tabs['reminder'] = ['title' => ts('Schedule Reminders'), 'class' => 'livePage'] + $default;
     }
-    $tabs['conference'] = ['title' => ts('Conference Slots')] + $default;
+
     $tabs['friend'] = ['title' => ts('Tell a Friend')] + $default;
     $tabs['pcp'] = ['title' => ts('Personal Campaigns')] + $default;
     $tabs['repeat'] = ['title' => ts('Repeat')] + $default;
@@ -86,12 +86,6 @@ class CRM_Event_Form_ManageEvent_TabHeader {
       unset($tabs['repeat']['class']);
     }
 
-    // @todo Move to eventcart extension
-    // check if we're in shopping cart mode for events
-    if (!(bool) Civi::settings()->get('enable_cart')) {
-      unset($tabs['conference']);
-    }
-
     $eventID = $form->getVar('_id');
     if ($eventID) {
       // disable tabs based on their configuration status
index bee5e2ae2f14e53d8f76ac7b707d0d820a3f855b..aaf51395cd56e5b7c0d6864bbdb957c2ff4e6aa3 100644 (file)
@@ -134,11 +134,7 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page {
    * @throws \CRM_Core_Exception
    */
   public static function &tabs() {
-    // @todo Move to eventcart extension
-    // check if we're in shopping cart mode for events
-    $enableCart = (bool) Civi::settings()->get('enable_cart');
-
-    $cacheKey = $enableCart ? 1 : 0;
+    $cacheKey = 0;
     if (!(self::$_tabLinks)) {
       self::$_tabLinks = [];
     }
@@ -182,12 +178,6 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page {
             'field' => 'reminder',
           ];
       }
-      self::$_tabLinks[$cacheKey]['conference']
-        = [
-          'title' => ts('Conference Slots'),
-          'url' => 'civicrm/event/manage/conference',
-          'field' => 'slot_label_id',
-        ];
       self::$_tabLinks[$cacheKey]['friend']
         = [
           'title' => ts('Tell a Friend'),
@@ -208,10 +198,6 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page {
         ];
     }
 
-    if (!$enableCart) {
-      unset(self::$_tabLinks[$cacheKey]['conference']);
-    }
-
     CRM_Utils_Hook::tabset('civicrm/event/manage', self::$_tabLinks[$cacheKey], []);
     return self::$_tabLinks[$cacheKey];
   }
index 105ef9c08732e79e6b8bfd2db47352ea221047c6..fad961b091405c8e04c8206e3a316fcf372dde85 100644 (file)
      <adminGroup>CiviEvent</adminGroup>
      <weight>399</weight>
   </item>
-  <item>
-    <path>civicrm/admin/options/conference_slot</path>
-    <title>Conference Slot Labels</title>
-    <page_callback>CRM_Admin_Page_Options</page_callback>
-    <desc>Define conference slots and labels.</desc>
-    <access_arguments>administer CiviCRM,access CiviEvent</access_arguments>
-    <adminGroup>CiviEvent</adminGroup>
-    <weight>415</weight>
-  </item>
   <item>
      <path>civicrm/admin/setting/preferences/event</path>
      <title>CiviEvent Component Settings</title>
      <is_ssl>true</is_ssl>
      <weight>960</weight>
   </item>
-  <item>
-    <path>civicrm/event/manage/conference</path>
-    <title>Conference Slots</title>
-    <page_callback>CRM_Event_Form_ManageEvent_Conference</page_callback>
-    <access_arguments>access CiviEvent</access_arguments>
-    <is_ssl>true</is_ssl>
-    <weight>950</weight>
-  </item>
   <item>
      <path>civicrm/event/add</path>
      <path_arguments>action=add</path_arguments>
index 49e63c533c3970d2fc21471f391a54c7afca9cf0..580512291e57e94e378ce21733695ae0178a8691 100644 (file)
@@ -154,7 +154,21 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart {
     }
     else {
       $this->_paymentProcessorIDs = [$payment_processor_id];
-      $this->assignPaymentProcessor(FALSE);
+      $this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors([ucfirst($this->_mode) . 'Mode'], $this->_paymentProcessorIDs);
+
+      if (!empty($this->_paymentProcessors)) {
+        foreach ($this->_paymentProcessors as $paymentProcessorID => $paymentProcessorDetail) {
+          if (empty($this->_paymentProcessor) && $paymentProcessorDetail['is_default'] == 1 || (count($this->_paymentProcessors) == 1)
+          ) {
+            $this->_paymentProcessor = $paymentProcessorDetail;
+            $this->assign('paymentProcessor', $this->_paymentProcessor);
+            // Setting this is a bit of a legacy overhang.
+            $this->_paymentObject = $paymentProcessorDetail['object'];
+          }
+        }
+        // It's not clear why we set this on the form.
+        $this->set('paymentProcessors', $this->_paymentProcessors);
+      }
       CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, FALSE);
     }
     $this->assign('currency', $this->getCurrency());
index 5e04fc8cc1f835ceefbc53b15930978aac5fd0be..771659a4c200cd4886709fb842345fd2234f25db 100644 (file)
@@ -1,9 +1,7 @@
 <?php
 
 require_once 'eventcart.civix.php';
-// phpcs:disable
-use CRM_Eventcart_ExtensionUtil as E;
-// phpcs:enable
+use CRM_Event_Cart_ExtensionUtil as E;
 
 /**
  * Implements hook_civicrm_config().
@@ -64,3 +62,18 @@ function eventcart_civicrm_enable() {
 function eventcart_civicrm_entityTypes(&$entityTypes) {
   _eventcart_civix_civicrm_entityTypes($entityTypes);
 }
+
+function eventcart_civicrm_tabset($name, &$tabs) {
+  if ($name === 'civicrm/event/manage' && Civi::settings()->get('enable_cart')) {
+    $tabs['conference'] = [
+      'title' => E::ts('Conference Slots'),
+      'link' => NULL,
+      'valid' => TRUE,
+      'active' => TRUE,
+      'current' => FALSE,
+      'class' => 'ajaxForm',
+      'url' => 'civicrm/event/manage/conference',
+      'field' => 'slot_label_id',
+    ];
+  }
+}
index 838014501a74c9d6878066586daaf52d5d46a60d..5d452e1c86450cc23c8ad7bd69e4f2a6d9868d49 100644 (file)
     <is_public>true</is_public>
     <is_ssl>false</is_ssl>
   </item>
+  <item>
+    <path>civicrm/admin/options/conference_slot</path>
+    <title>Conference Slot Labels</title>
+    <page_callback>CRM_Admin_Page_Options</page_callback>
+    <desc>Define conference slots and labels.</desc>
+    <access_arguments>administer CiviCRM,access CiviEvent</access_arguments>
+    <adminGroup>CiviEvent</adminGroup>
+    <weight>415</weight>
+  </item>
+  <item>
+    <path>civicrm/event/manage/conference</path>
+    <title>Conference Slots</title>
+    <page_callback>CRM_Event_Form_ManageEvent_Conference</page_callback>
+    <access_arguments>access CiviEvent</access_arguments>
+    <is_ssl>true</is_ssl>
+    <weight>950</weight>
+  </item>
 </menu>