From e432d43712f8b80e57ac66472ad6a0b5714cadbb Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 18 Sep 2023 16:03:57 +1200 Subject: [PATCH] Move Conference slots functionality to event cart --- CRM/Event/Form/ManageEvent/TabHeader.php | 8 +------- CRM/Event/Page/ManageEvent.php | 16 +--------------- CRM/Event/xml/Menu/Event.xml | 17 ----------------- .../CRM/Event/Cart/Form/Checkout/Payment.php | 16 +++++++++++++++- .../Event/Form/ManageEvent/Conference.php | 0 ext/eventcart/eventcart.php | 19 ++++++++++++++++--- .../CRM/Event/Form/ManageEvent/Conference.tpl | 0 ext/eventcart/xml/Menu/Eventcart.xml | 17 +++++++++++++++++ 8 files changed, 50 insertions(+), 43 deletions(-) rename {CRM => ext/eventcart/CRM}/Event/Form/ManageEvent/Conference.php (100%) rename {templates => ext/eventcart/templates}/CRM/Event/Form/ManageEvent/Conference.tpl (100%) diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 8c159a7c39..27eba8a848 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -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 diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index bee5e2ae2f..aaf51395cd 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -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]; } diff --git a/CRM/Event/xml/Menu/Event.xml b/CRM/Event/xml/Menu/Event.xml index 105ef9c087..fad961b091 100644 --- a/CRM/Event/xml/Menu/Event.xml +++ b/CRM/Event/xml/Menu/Event.xml @@ -127,15 +127,6 @@ CiviEvent 399 - - civicrm/admin/options/conference_slot - Conference Slot Labels - CRM_Admin_Page_Options - Define conference slots and labels. - administer CiviCRM,access CiviEvent - CiviEvent - 415 - civicrm/admin/setting/preferences/event CiviEvent Component Settings @@ -224,14 +215,6 @@ true 960 - - civicrm/event/manage/conference - Conference Slots - CRM_Event_Form_ManageEvent_Conference - access CiviEvent - true - 950 - civicrm/event/add action=add diff --git a/ext/eventcart/CRM/Event/Cart/Form/Checkout/Payment.php b/ext/eventcart/CRM/Event/Cart/Form/Checkout/Payment.php index 49e63c533c..580512291e 100644 --- a/ext/eventcart/CRM/Event/Cart/Form/Checkout/Payment.php +++ b/ext/eventcart/CRM/Event/Cart/Form/Checkout/Payment.php @@ -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()); diff --git a/CRM/Event/Form/ManageEvent/Conference.php b/ext/eventcart/CRM/Event/Form/ManageEvent/Conference.php similarity index 100% rename from CRM/Event/Form/ManageEvent/Conference.php rename to ext/eventcart/CRM/Event/Form/ManageEvent/Conference.php diff --git a/ext/eventcart/eventcart.php b/ext/eventcart/eventcart.php index 5e04fc8cc1..771659a4c2 100644 --- a/ext/eventcart/eventcart.php +++ b/ext/eventcart/eventcart.php @@ -1,9 +1,7 @@ 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', + ]; + } +} diff --git a/templates/CRM/Event/Form/ManageEvent/Conference.tpl b/ext/eventcart/templates/CRM/Event/Form/ManageEvent/Conference.tpl similarity index 100% rename from templates/CRM/Event/Form/ManageEvent/Conference.tpl rename to ext/eventcart/templates/CRM/Event/Form/ManageEvent/Conference.tpl diff --git a/ext/eventcart/xml/Menu/Eventcart.xml b/ext/eventcart/xml/Menu/Eventcart.xml index 838014501a..5d452e1c86 100644 --- a/ext/eventcart/xml/Menu/Eventcart.xml +++ b/ext/eventcart/xml/Menu/Eventcart.xml @@ -45,4 +45,21 @@ true false + + civicrm/admin/options/conference_slot + Conference Slot Labels + CRM_Admin_Page_Options + Define conference slots and labels. + administer CiviCRM,access CiviEvent + CiviEvent + 415 + + + civicrm/event/manage/conference + Conference Slots + CRM_Event_Form_ManageEvent_Conference + access CiviEvent + true + 950 + -- 2.25.1