Update the test for empty categories if an array.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 27 Jul 2017 17:33:30 +0000 (13:33 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 27 Jul 2017 17:33:30 +0000 (13:33 -0400)
This is where it is checking for an array and at same time if array is
not empty. Moving the filter_var part before this fixes the issue where
it wouldn't pass.

models/front/events/baseAction.php
models/front/events/list.php

index 9e094dc..69d45f3 100644 (file)
@@ -237,8 +237,11 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
             ";
         }
 
+        // Get cats if categoryId is an array
+        $cats  = filter_var( $categoryId, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FORCE_ARRAY ) );
+        $catId = filter_var( $categoryId, FILTER_VALIDATE_INT );
         // If a category ID is supplied
-        if ( $catId = filter_var( $categoryId, FILTER_VALIDATE_INT ) ) {
+        if ( $catId ) {
             //$events = $this->getEventsByCategory( $catId, $limit );
             $whereParts[] = "
                 T.id IN (
@@ -258,7 +261,7 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
                 $order .= " LIMIT {$limit} OFFSET 0";
             }
             // Else if the $categoryId is an array
-        } else if ( $cats = filter_var( $categoryId, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FORCE_ARRAY ) ) && !empty( $cats ) ) {
+        } else if ( $cats && !empty( $cats ) ) {
             $whereParts[] = "
                 T.id IN (
                     SELECT event
index 1f3a248..63cbf01 100644 (file)
@@ -836,13 +836,13 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
             } else {
 
                 if($current_year == $year){
-          
+
                     $sql = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times ';
                     $sql .= "WHERE YEAR(start_time) = $year ";
                     $sql .= "AND MONTH(start_time) >= MONTH(CURDATE()) ";
                     $sql .= "AND event IN (select id from ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10) ";
                     $sql .= "GROUP BY month";
-            
+
                     $results[$year] = $wpdb->get_results($sql, ARRAY_A);
                 } else {
                     $sql  = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times ';