Skip to content

Commit 478f75d

Browse files
author
Chris Gårdenberg
committed
fix: Fix for filtering courses/events for the selected city, not just which course templates that has ever had an event there.
1 parent 548685c commit 478f75d

3 files changed

Lines changed: 8 additions & 11 deletions

File tree

PLUGIN-CHECKSUM

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a39447ffe765166511c2ef20fb003a4d
1+
23d5df3f333dd3ff156ad9369676c945

includes/edu-ajax-functions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function edu_listview_courselist() {
2626
' and LastApplicationDate ge ' . date_i18n( 'c' ) .
2727
' and StartDate le ' . edu_get_timezoned_date( 'c', 'now 23:59:59 +' . $fetch_months . ' months' ) .
2828
' and EndDate ge ' . edu_get_timezoned_date( 'c', 'now' ) .
29+
( ! empty( $_POST['city'] ) ? ' and LocationId eq ' . intval( $_POST['city'] ) : '' ) .
2930
';' .
3031
'$top=1' .
3132
';' .

includes/eduapi-helper-functions.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public function GetCourseList( $attributes, $category_id, $city, $subjectid, $co
182182
' and StartDate le ' . edu_get_timezoned_date( 'c', 'now 23:59:59 +' . $fetch_months . ' months' ) .
183183
' and EndDate ge ' . edu_get_timezoned_date( 'c', 'now' ) .
184184
' and OnDemand eq false' .
185+
( ! empty( $city ) ? ' and LocationId eq ' . intval( $city ) : '' ) .
185186
';' .
186187
'$expand=PriceNames($filter=PublicPriceName;$select=PriceNameId,PriceNameDescription,Price,MaxParticipantNumber,NumberOfParticipants,DiscountPercent;)' .
187188
';' .
@@ -223,11 +224,7 @@ public function GetCourseList( $attributes, $category_id, $city, $subjectid, $co
223224
$orderby = explode( ' ', $custom_order_by );
224225
$sortorder = explode( ' ', $custom_order_by_order );
225226
foreach ( $orderby as $od => $v ) {
226-
if ( isset( $sortorder[ $od ] ) ) {
227-
$or = $sortorder[ $od ];
228-
} else {
229-
$or = 'asc';
230-
}
227+
$or = isset( $sortorder[ $od ] ) ? $sortorder[ $od ] : 'asc';
231228

232229
if ( edu_validate_column( 'course', $v ) !== false ) {
233230
$sorting[] = $v . ' ' . strtolower( $or );
@@ -300,6 +297,7 @@ public function GetOnDemandCourseList( $attributes, $category_id, $city, $subjec
300297
' and CompanySpecific eq false' .
301298
' and OnDemand eq true' .
302299
' and OnDemandPublished eq true' .
300+
( ! empty( $city ) ? ' and LocationId eq ' . intval( $city ) : '' ) .
303301
';' .
304302
'$expand=PriceNames($filter=PublicPriceName;$select=PriceNameId,PriceNameDescription,Price,MaxParticipantNumber,NumberOfParticipants,DiscountPercent;)' .
305303
';' .
@@ -341,11 +339,7 @@ public function GetOnDemandCourseList( $attributes, $category_id, $city, $subjec
341339
$orderby = explode( ' ', $custom_order_by );
342340
$sortorder = explode( ' ', $custom_order_by_order );
343341
foreach ( $orderby as $od => $v ) {
344-
if ( isset( $sortorder[ $od ] ) ) {
345-
$or = $sortorder[ $od ];
346-
} else {
347-
$or = 'asc';
348-
}
342+
$or = isset( $sortorder[ $od ] ) ? $sortorder[ $od ] : 'asc';
349343

350344
if ( edu_validate_column( 'course', $v ) !== false ) {
351345
$sorting[] = $v . ' ' . strtolower( $or );
@@ -417,6 +411,7 @@ public function GetEventList( $attributes, $category_id, $city, $subjectid, $cou
417411
' and StartDate le ' . edu_get_timezoned_date( 'c', 'now 23:59:59 +' . $fetch_months . ' months' ) .
418412
' and EndDate ge ' . edu_get_timezoned_date( 'c', 'now' ) .
419413
' and OnDemand eq false' .
414+
( ! empty( $city ) ? ' and LocationId eq ' . intval( $city ) : '' ) .
420415
';' .
421416
'$expand=PriceNames($filter=PublicPriceName;$select=PriceNameId,PriceNameDescription,Price,MaxParticipantNumber,NumberOfParticipants,DiscountPercent;),EventDates($orderby=StartDate;$select=StartDate,EndDate;)' .
422417
';' .
@@ -530,6 +525,7 @@ public function GetOnDemandEventList( $attributes, $category_id, $city, $subject
530525
' and CompanySpecific eq false' .
531526
' and OnDemand eq true' .
532527
' and OnDemandPublished eq true' .
528+
( ! empty( $city ) ? ' and LocationId eq ' . intval( $city ) : '' ) .
533529
';' .
534530
'$expand=PriceNames($filter=PublicPriceName;$select=PriceNameId,PriceNameDescription,Price,MaxParticipantNumber,NumberOfParticipants,DiscountPercent;),EventDates($orderby=StartDate;$select=StartDate,EndDate;)' .
535531
';' .

0 commit comments

Comments
 (0)