Code cleanup for event configuration extracted from advancedevents extension
authorMatthew Wire <mjw@mjwconsult.co.uk>
Tue, 30 Aug 2022 12:50:42 +0000 (13:50 +0100)
committerMatthew Wire <mjw@mjwconsult.co.uk>
Tue, 30 Aug 2022 15:59:47 +0000 (16:59 +0100)
CRM/Event/Form/ManageEvent/Repeat.php
templates/CRM/Event/Page/ManageEvent.tpl

index 2012c6c9d313006ab5e324e6379b5280907719d3..591060786284713f56184818c5baee45ddefe756 100644 (file)
@@ -1,14 +1,16 @@
 <?php
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
  */
 
 /**
- * Description of Repeat
- *
- * @author Priyanka
+ * Class to manage the "Repeat" functionality for event
  */
 class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
 
@@ -24,12 +26,19 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
    */
   protected $_parentEventEndDate = NULL;
 
+  /**
+   * @return int
+   */
+  protected function getEventId() {
+    return $this->_id;
+  }
+
   public function preProcess() {
     parent::preProcess();
     $this->setSelectedChild('repeat');
-    $this->assign('currentEventId', $this->_id);
+    $this->assign('currentEventId', $this->getEventId());
 
-    $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
+    $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->getEventId(), 'civicrm_event');
     //If this ID has parent, send parent id
     if ($checkParentExistsForThisId) {
       /**
@@ -64,7 +73,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
       }
     }
 
-    $parentEventParams = ['id' => $this->_id];
+    $parentEventParams = ['id' => $this->getEventId()];
     $parentEventValues = [];
     $parentEventReturnProperties = ['start_date', 'end_date'];
     $parentEventAttributes = CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $parentEventParams, $parentEventValues, $parentEventReturnProperties);
@@ -83,7 +92,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
     $defaults = [];
 
     //Always pass current event's start date by default
-    $defaults['repetition_start_date'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'start_date', 'id');
+    $defaults['repetition_start_date'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->getEventId(), 'start_date', 'id');
     $recurringEntityDefaults = CRM_Core_Form_RecurringEntity::setDefaultValues();
     return array_merge($defaults, $recurringEntityDefaults);
   }
@@ -93,7 +102,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
   }
 
   public function postProcess() {
-    if ($this->_id) {
+    if ($this->getEventId()) {
       $params = $this->controller->exportValues($this->_name);
       if ($this->_parentEventStartDate && $this->_parentEventEndDate) {
         $interval = CRM_Core_BAO_RecurringEntity::getInterval($this->_parentEventStartDate, $this->_parentEventEndDate);
@@ -102,22 +111,22 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
       $params['dateColumns'] = ['start_date'];
       $params['excludeDateRangeColumns'] = ['start_date', 'end_date'];
       $params['entity_table'] = 'civicrm_event';
-      $params['entity_id'] = $this->_id;
+      $params['entity_id'] = $this->getEventId();
 
       // CRM-16568 - check if parent exist for the event.
-      $parentId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
+      $parentId = CRM_Core_BAO_RecurringEntity::getParentFor($this->getEventId(), 'civicrm_event');
       $params['parent_entity_id'] = !empty($parentId) ? $parentId : $params['entity_id'];
       //Unset event id
       unset($params['id']);
 
       $url = 'civicrm/event/manage/repeat';
-      $urlParams = "action=update&reset=1&id={$this->_id}&selectedChild=repeat";
+      $urlParams = "action=update&reset=1&id={$this->getEventId()}&selectedChild=repeat";
 
       $linkedEntities = [
         [
           'table' => 'civicrm_price_set_entity',
           'findCriteria' => [
-            'entity_id' => $this->_id,
+            'entity_id' => $this->getEventId(),
             'entity_table' => 'civicrm_event',
           ],
           'linkedColumns' => ['entity_id'],
@@ -126,7 +135,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
         [
           'table' => 'civicrm_uf_join',
           'findCriteria' => [
-            'entity_id' => $this->_id,
+            'entity_id' => $this->getEventId(),
             'entity_table' => 'civicrm_event',
           ],
           'linkedColumns' => ['entity_id'],
@@ -135,7 +144,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
         [
           'table' => 'civicrm_tell_friend',
           'findCriteria' => [
-            'entity_id' => $this->_id,
+            'entity_id' => $this->getEventId(),
             'entity_table' => 'civicrm_event',
           ],
           'linkedColumns' => ['entity_id'],
@@ -144,7 +153,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
         [
           'table' => 'civicrm_pcp_block',
           'findCriteria' => [
-            'entity_id' => $this->_id,
+            'entity_id' => $this->getEventId(),
             'entity_table' => 'civicrm_event',
           ],
           'linkedColumns' => ['entity_id'],
@@ -155,7 +164,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
       CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
     }
     else {
-      CRM_Core_Error::statusBounce("Could not find Event ID");
+      CRM_Core_Error::statusBounce(ts('Could not find Event ID'));
     }
     parent::endPostProcess();
   }
index 0adfb8893eeebda87c1b0a325be3dbc3be0329ed..b634902a124cbba9933bc46809150bfa606e854f 100644 (file)
                 <ul class="panel" id="panel_participants_{$row.id}">
                   {if $findParticipants.statusCounted}
                     <li>
-                      <a class="action-item crm-hover-button" href="{crmURL p='civicrm/event/search'
+                      <a title="{ts}Counted Participants{/ts}" class="action-item crm-hover-button" href="{crmURL p='civicrm/event/search'
                       q="reset=1&force=1&status=true&event=`$row.id`"}">{$findParticipants.statusCounted}
                       </a>
                     </li>
                   {/if}
                   {if $findParticipants.statusNotCounted}
                     <li>
-                      <a class="action-item crm-hover-button"
+                      <a title="{ts}Participants Not Counted{/ts}" class="action-item crm-hover-button"
                            href="{crmURL p='civicrm/event/search'
                            q="reset=1&force=1&status=false&event=`$row.id`"}">{$findParticipants.statusNotCounted}
                       </a>
                   {/if}
                   {if $row.participant_listing_id}
                     <li>
-                      <a class="action-item crm-hover-button"
+                      <a title="{ts}Public Participant Listing{/ts}" class="action-item crm-hover-button"
                          href="{crmURL p='civicrm/event/participant' q="reset=1&id=`$row.id`"
                          fe='true'}">{ts}Public Participant Listing{/ts}
                       </a>