Hook and html changes to support asking for event dates from registrations.
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 27 Nov 2017 21:52:38 +0000 (16:52 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 27 Nov 2017 21:52:38 +0000 (16:52 -0500)
setup/adminHooks.php
views/admin/events/edit.html

index b9dcb50..97b7a0c 100644 (file)
@@ -101,6 +101,52 @@ if ( $memberEventsAllowed ) {
 
 }
 
+/*
+ * Add a filter to include a link to either create registrations for an event or to update that.
+ * If this is for a an event that has registrations setup, also provide some messages for edit
+ * and update pages for the event to let users know they have to update registrations if they
+ * change the dates or schedules.
+ */
+add_filter(
+    'glm_members_add_link_to_registrations_event_list_entry',
+    function( $content ){
+
+        // Check if there's an existing reg_event record for the supplied event ID.
+        require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php';
+        $Events = new GlmDataEvents($this->wpdb, $this->config);
+
+        // If we were passed a valid Event ID
+        $eventId = $content-0;
+        if ($eventId > 0) {
+
+            // Try to get get the registrations data for this event
+            $event = $Events->getEntry($eventId);
+
+            // If we received valid registrations data for this event then it's already in registrations
+            if ($event) {
+
+                // Return link title and URL for this event in registrations
+                return array(
+                    'title' => 'Event',
+                    'url' => GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE."events-list&option=edit&event=".$event['id'],
+                    'warning_title' => 'Dashboard for this Event',
+                    'edit_warning' => '',
+                    'update_warning' => ''
+                );
+
+            }
+
+        }
+
+        // Since we must not have had a good event ID
+        return false;
+
+    },
+    10,
+    2
+    );
+
+
 /*
  * Provide basic event data by Lat/Lon search for use as map items.
  *
index fa7f4a3..03e2a7c 100644 (file)
@@ -6,6 +6,11 @@
 
 {if apply_filters('glm_members_permit_admin_member_event', true) && ($option == 'add' || $haveEvent)}
 
+                        {$e_link = apply_filters('glm_members_add_link_to_event_list_entry', $event.fieldData.id)}
+                         {if is_array($e_link)}
+                            <a class="button button-secondary glm-button glm-right" href="{$e_link.url|escape:'string'}">{$e_link.title}</a>
+                         {/if}
+
   {if $haveMember}
     <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=events&member={$memberID}&back=1" class="button button-secondary glm-button glm-right">Return to Events List</a>
   {else}
@@ -29,7 +34,7 @@
     {$e_link = apply_filters('glm_members_add_link_to_event_list_entry', $event.fieldData.id)}
     {if is_array($e_link) && $e_link.warning_title != false}
     <div style="margin: 1em 0em 1em 0em;">
-        <div class="glm-strong-warning">{if $option == 'edit'}{$e_link.edit_warning}{else}{$e_link.update_warning}{/if}<p><a class="button button-secondary glm-button-small" href="{$e_link.url|escape:'string'}">{$e_link.warning_title}</a></p></div>
+        <div class="glm-strong-warning">{if $option == 'edit'}{$e_link.edit_warning}{else}{$e_link.update_warning}{/if}</div>
        </div>
     {/if}
   {/if}