/
RuleCriteriaDatabaseCustom.php
92 lines (78 loc) · 2.77 KB
/
RuleCriteriaDatabaseCustom.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
// Copyright (C) 2010-2011 Aron Racho <aron@mi-squred.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
/**
* Description of RuleCriteriaDatabaseCustom
*
* @author aron
*/
class RuleCriteriaDatabaseCustom extends RuleCriteria {
var $table;
var $column;
var $valueComparator;
var $value;
var $frequencyComparator;
var $frequency;
function __construct( $table, $column,
$valueComparator, $value,
$frequencyComparator, $frequency) {
$this->table = $table;
$this->column = $column;
$this->valueComparator = $valueComparator;
$this->value = $value;
$this->frequencyComparator = $frequencyComparator;
$this->frequency = $frequency;
}
function getRequirements() {
$requirements = "";
if ( $this->value ) {
$requirements .= xl( "Value" ) . ": ";
$requirements .= $this->decodeComparator($this->valueComparator) . " " . $this->value;
$requirements .= " | ";
}
$requirements .= xl( "Frequency" ) . ": ";
$requirements .= $this->decodeComparator($this->frequencyComparator) . " " . $this->frequency;
return $requirements;
}
function getTitle() {
return xl( $this->table ) . "." . xl( $this->column );
}
function getView() {
return "custom.php";
}
function getTableNameOptions() {
$options = array();
$stmts = sqlStatement( "SHOW TABLES" );
for($iter=0; $row=sqlFetchArray($stmts); $iter++) {
foreach( $row as $key=>$value) {
array_push( $options, array( "id" => out( $value ), "label" => out( xl ( $value ) ) ) );
}
}
return $options;
}
function getDbView() {
$dbView = parent::getDbView();
$dbView->method = "database";
$dbView->methodDetail = "";
$dbView->value =
"::"
. $this->table . "::" . $this->column. "::"
. $this->valueComparator . "::" . $this->value . "::"
. $this->frequencyComparator . "::" . $this->frequency;
return $dbView;
}
function updateFromRequest() {
parent::updateFromRequest();
$this->table = _post("fld_table");
$this->column = _post("fld_column");
$this->value = _post("fld_value");
$this->valueComparator = _post("fld_value_comparator");
$this->frequency = _post("fld_frequency");
$this->frequencyComparator = _post("fld_frequency_comparator");
}
}
?>