PluginProbe
Smart Forms – when you need more than just a contact form / trunk
Smart Forms – when you need more than just a contact form vtrunk
trunk 0.5 0.5.5 0.6 0.7 0.8 0.8.5 0.9.1
smart-forms / php_classes / api / query / comparators / DateComparator.php

DateComparator.php in Smart Forms – when you need more than just a contact form trunk, at php_classes/api/query/comparators/DateComparator.php

44 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 require_once SMART_FORMS_DIR.'php_classes/api/query/comparators/ComparatorBase.php';
4
5 class DateComparator extends ComparatorBase
6 {
7
8 public function Validate()
9 {
10 if($this->Comparator!='=' &&
11 $this->Comparator!='<>'&&
12 $this->Comparator!='>'&&
13 $this->Comparator!='>='&&
14 $this->Comparator!='<'&&
15 $this->Comparator!='<='
16 )
17 return 'Invalid Comparison for '.$this->Field->Id.'. Allowed values =,<>,>,>=,<,<=';
18 }
19
20 public function GetConditionString()
21 {
22 global $wpdb;
23 $date=$this->Value;
24 if(is_numeric($date))
25 $date=date('c',$date);
26
27 switch ($this->Comparator)
28 {
29 case '<>':
30 return $wpdb->prepare(" detail.datevalue <> %s ", $date);
31 case '=':
32 return $wpdb->prepare(" detail.datevalue =%s ", $date);
33 case '>':
34 return $wpdb->prepare(" detail.datevalue >%s ", $date);
35 case '>=':
36 return $wpdb->prepare(" detail.datevalue >=%s ",$date);
37 case '<':
38 return $wpdb->prepare(" detail.datevalue < %s ", $date);
39 case '<=':
40 return $wpdb->prepare(" detail.datevalue <=%s ",$date);
41 }
42 }
43 }
44