Updating shortcode to add region-search to list shortcode
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 12 Feb 2019 17:24:44 +0000 (12:24 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 12 Feb 2019 17:24:44 +0000 (12:24 -0500)
Adding region-search to event list shortcode.

classes/data/dataCategories.php
models/admin/events/list.php
models/front/events/frontAdd.php
models/front/events/list.php
setup/shortcodes.php

index 50c1bde..abf7311 100644 (file)
@@ -317,7 +317,7 @@ class GlmDataEventsCategories extends GlmDataAbstract
         $categoriesSorted = $this->sortParentChild($categories);
 
         if (!$forEdit) {
-            while (list($k, $v) = each($categoriesSorted)) {
+            foreach ( $categoriesSorted as $k => $v ) {
                 $categoriesSorted[$k]['parent_id'] = $v['parent']['value'];
                 $categoriesSorted[$k]['parent'] = $v['parent']['name'];
             }
index 3aefba1..b153f8d 100644 (file)
@@ -306,7 +306,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                         $_REQUEST[$locID.'_event'] = $this->eventID;
 
                         // Check for new cities in this location and if so use the new city real ID
-                        if (isset($_REQEUST[$locID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') {
+                        if (isset($_REQUEST[$locID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') {
                             $_REQUEST[$locID.'_city'] = $newCityID[$_REQUEST[$locID.'_city']];
                         }
 
@@ -501,10 +501,10 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                 if (isset($_REQUEST['locID'])) {
 
                     // For each location
-                    while (list($id, $locID) = each($_REQUEST['locID'])) {
+                    foreach ( $_REQUEST['locID'] $id => $locID ) {
 
                         // Check for new cities in this location and if so use the new city real ID
-                        if (isset($_REQEUST[$locID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') {
+                        if (isset($_REQUEST[$ocID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') {
                             $_REQUEST[$locID.'_city'] = $newCityID[$_REQUEST[$locID.'_city']];
                         }
 
@@ -708,7 +708,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
                 // Add "selected" element default false;
                 reset($categories);
-                while (list($k, $v) = each($categories)) {
+                foreach ( $categories $k => $v ) {
                     $categories[$k]['selected'] = false;
                 }
 
@@ -1240,7 +1240,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
             $Cities = new GlmDataCities($this->wpdb, $this->config);
 
             // For each new city submitted
-            while (list($k, $v) = each($_REQUEST['newCity'])) {
+            foreach ( $_REQUEST['newCity'] as $k => $v ) {
 
                 $cName = trim(filter_var($_REQUEST['newCity'][$k]));
 
index 4e4abcc..aaae766 100644 (file)
@@ -133,7 +133,7 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
 
             // Finally, move the files to the various size directories and rename them back to the correct name
             reset($this->config['imageSizes']);
-            while (list($k, $v) = each($this->config['imageSizes'])) {
+            foreach ( $this->config['imageSizes'] as $k => $v ) {
 
                 // Check if size directory needs to be made
                 if (!file_exists(GLM_MEMBERS_PLUGIN_IMAGES_PATH.'/'.$k)) {
index 9e48028..adaa457 100644 (file)
@@ -178,7 +178,7 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
             }
 
             // Check for numeric IDs only
-            while (list($k, $v) = each($catsRequested)) {
+            foreach ( $catsRequested as $k => $v ) {
 
                 // If it's just numeric - note Explode returns an array element with value = 0 if no string.
                 if (preg_match('/^[0-9]*$/', trim($v)) && $v > 0) {
@@ -194,6 +194,7 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
 
         }
 
+
         if ( isset( $_REQUEST['amenity'] ) && $amenityId = filter_var( $_REQUEST['amenity'], FILTER_VALIDATE_INT ) ) {
             $search = true;
             $action = 'event-list';
@@ -206,6 +207,10 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
             $search = true;
             $action = 'event-list';
         }
+        if ( isset( $actionData['request']['region-search'] ) && $regionId = filter_var( $actionData['request']['region-search'], FILTER_VALIDATE_INT ) ) {
+            $search = true;
+            $action = 'event-list';
+        }
         if ( isset( $_REQUEST['venue'] ) && $venueId = filter_var( $_REQUEST['venue'], FILTER_VALIDATE_INT ) ) {
             $search = true;
             $action = 'event-list';
index ec0f7be..97181eb 100644 (file)
@@ -99,17 +99,18 @@ $glmMembersEventsShortcodes = array(
         'action'     => 'list',
         'table'      => false,
         'attributes' => array(
-            'type'         => 'all',
-            'order'        => 'title',
-            'member'       => false,
-            'template'     => false,
-            'limit'        => null,
-            'featured'     => null,
-            'current'      => null,
-            'category'     => null,
-            'pageslug'     => null,
-            'group_by_day' => true,
-            'group_month'  => false,
+            'type'               => 'all',
+            'order'              => 'title',
+            'member'             => false,
+            'template'           => false,
+            'limit'              => null,
+            'featured'           => null,
+            'current'            => null,
+            'category'           => null,
+            'region-search'      => null,
+            'pageslug'           => null,
+            'group_by_day'       => true,
+            'group_month'        => false,
             'show_all_in_agenda' => false,
         )
     ),
@@ -160,6 +161,17 @@ $glmMembersEventsShortcodesDescription = '
             to display may be overridden by the "category-search" parameter.
         </td>
     </tr>
+    <tr>
+        <td>&nbsp;</td>
+        <th>
+            region-search="{ region ID }"
+        </th>
+        <td>
+            The "region-search" attribute selects members who are listed in the specified
+            region. The region is specified by ID rather than name. This may be overridden by
+            a "region" URL parameter.
+        </td>
+    </tr>
     <tr>
         <td>&nbsp;</td>
         <th>