Calendar: Validation & Query String
Validate Input and Set Optional Query String Segment
if ( empty($Form->CategoryID) OR !is_array($Form->CategoryID) ) { $Form->CategoryID = array(); $Category = ''; } else { foreach ($Form->CategoryID AS $Key => $Value) { if ( !is_string($Value) OR !preg_match('/^\d{1,5}$/', $Value) ) { unset($Form->CategoryID[$Key]); } } $Category = ' AND CategoryID IN (' . implode(',', $Form->CategoryID) . ')'; }
Set Query String
$SQL->SQLQueryString = "SELECT {$Layout->BSYear}_Calendar.CalendarID, CategoryIDCSV, Title, LOWER(TIME_FORMAT(TimeStart, '%l:%i %p')) AS TimeStartStr FROM {$Layout->BSYear}_Calendar LEFT JOIN {$Layout->BSYear}_CalendarCategories ON ({$Layout->BSYear}_CalendarCategories.CalendarID = {$Layout->BSYear}_Calendar.CalendarID) WHERE ( (DateStart BETWEEN '$Form->From' AND '$Form->To') $Category GROUP BY CalendarID";