Added post processing to dataRegEvent.php to optionally ask for more data from Events...
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 21 Aug 2017 17:00:40 +0000 (13:00 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 21 Aug 2017 17:00:40 +0000 (13:00 -0400)
Added flag to admin reg events list to request the added data.

classes/data/dataRegEvent.php
models/admin/registrations/list.php

index 3551482..f6d2b6f 100644 (file)
@@ -72,6 +72,14 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
      * @access public
      */
     public $fields = false;
+    /**
+     * Flag to post process results and add current Event data to each result
+     * 
+     * @var $postProcAddedEventData
+     * @access public
+     */
+    public $postProcAddedEventData = false;
+    
 
     /**
      * Constructor
@@ -224,7 +232,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                 'use'       => 'a'
             ),
 
-            // Bitmap of restricted (admin use only) payment methods for this event - see payment_method
+            // Bitmap of restricted (admin use only) payment methods for this event - see paymenttrue_method
             'restricted_payment_methods' => array (
                 'field'     => 'restricted_payment_methods',
                 'type'      => 'bitmap',
@@ -277,6 +285,45 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
     
     }
 
+    /**
+     * Entry Post Processing Call-Back Method
+     *
+     * Perform post-processing for all result entries.
+     *
+     * @param array  $r Array of field result data for a single entry
+     * @param string $a Action being performed (l, i, g, ...)
+     *
+     * @return object Class object
+     *
+     */
+    public function entryPostProcessing( $result_data, $action )
+    {
+           
+        // If $postProcAddedEventData option set
+        if ($this->postProcAddedEventData) {
+            
+            // If doing the following actions 
+            if (in_array($action, array('l'))) {
+                    
+                // Use hook to Events to get current data for this event
+                $eventData = apply_filters('glm-member-db-events-get-event', $result_data['event']);
+
+                // Add to the registration event arraytrue
+                $result_data['intro']           = $eventData['intro'];
+                $result_data['descr']           = $eventData['descr'];
+                $result_data['image']           = $eventData['image'];
+                $result_data['contact_name']    = $eventData['contact_name'];
+                $result_data['contact_email']   = $eventData['contact_email'];
+                $result_data['contact_phone']   = $eventData['contact_phone'];
+                $result_data['url']             = $eventData['url'];
+                                    
+            }
+            
+        }
+        
+        return $result_data;
+    }
+    
     /*
      * Get Alpha list of first characters in event name
      *
@@ -310,11 +357,27 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
     /*
      * Get a simple reg event list - Event Name and ID only
      *
+     * @param string    $where      Where clause
+     * @param string    $order      Fields to order results by
+     * @param boolean   $fieldVals  Include all optional values for use with input selection
+     * @param string    $idField    ID field to use
+     * @param integer   $start      Starting at result #
+     * @param integer   $limit      Limit results to this number
+     * @param boolean   $extended   Add current base data for returned events 
+     * 
      * @return array Array of Name and ID for all reg events
      * @access public
      */
-    public function getSimpleRegEventsList($where = '', $order = '', $fieldVals = true, $idField = 'id', $start = false, $limit = false)
+    public function getSimpleRegEventsList($where = '', $order = '', $fieldVals = true, $idField = 'id', $start = false, $limit = false, $extended = false)
     {
+
+        // Save status of extended data flag
+        $saveExtended = $this->postProcAddedEventData;
+        
+        // If extended data is requested, then set flag for post processing
+        if ($extended) {
+            $this->postProcAddedEventData = true;
+        }
         
         // Save the current fields array and make a copy
         $fSave = $this->fields;
@@ -322,6 +385,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
         // Remove what we don't want from the copy and get the list
         $this->fields = array(
             'id' => $fSave['id'],
+            'event' => $fSave['event'],
             'event_name' => $fSave['event_name']
         );
         
@@ -330,6 +394,10 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
         // Restore the fields list
         $this->fields = $fSave;
         
+        // Restore status of extended data flag
+        $this->postProcAddedEventData = $saveExtended;
+        
+        
         return $regEventsList;
     }
     
index 816620f..ae60948 100644 (file)
@@ -131,8 +131,8 @@ class GlmMembersAdmin_registrations_list extends GlmDataRegistrationsRegEvent
         $filteredRegEventsFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere));
         
         // Get a current list of reg events
-        $listResult = $this->getSimpleRegEventsList($where.$alphaWhere, 'event_name', true, 'id', $start, $limit);
-        
+        $listResult = $this->getSimpleRegEventsList($where.$alphaWhere, 'event_name', true, 'id', $start, $limit, true);
+
         // Get paging results
         $numbDisplayed = $listResult['returned'];
         $lastDisplayed = $listResult['last'];