2 // Copyright (C) 2010-2011 Aron Racho <aron@mi-squred.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
10 * Description of RuleCriteriaDatabaseBucketBuilder
14 class RuleCriteriaDatabaseBucket
extends RuleCriteria
{
20 var $frequencyComparator;
23 function __construct( $category, $item, $completed,
24 $frequencyComparator, $frequency ) {
25 $this->category
= $category;
26 $this->categoryLbl
= $this->getLabel($this->category
, 'rule_action_category');
28 $this->itemLbl
= $this->getLabel($this->item
, 'rule_action');
29 $this->completed
= $completed;
30 $this->frequencyComparator
= $frequencyComparator;
31 $this->frequency
= $frequency;
34 function getRequirements() {
35 $requirements .= xl( "Completed" ) . ": ";
36 $requirements .= $this->completed ?
xl( "Yes" ) : xl( "No" );
37 $requirements .= " | ";
38 $requirements .= xl( "Frequency" ) . ": ";
39 $requirements .= $this->decodeComparator( $this->frequencyComparator
) . " "
40 . $this->frequency
. " ";
45 return $this->getCategoryLabel() . " - " . $this->getItemLabel();
48 function getCategoryLabel() {
49 return $this->categoryLbl
;
52 function getItemLabel() {
53 return $this->itemLbl
;
60 function getDbView() {
61 $dbView = parent
::getDbView();
63 $dbView->method
= "database";
64 $dbView->methodDetail
= "";
67 . $this->category
. "::" . $this->item
. "::"
68 . ($this->completed ?
"YES":"NO") . "::"
69 . $this->frequencyComparator
. "::" . $this->frequency
;
74 function updateFromRequest() {
75 parent
::updateFromRequest();
77 $category = _post("fld_category");
78 $categoryLbl = _post("fld_category_lbl");
79 $item = _post("fld_item");
80 $itemLbl = _post("fld_item_lbl");
81 $completed = _post("fld_completed");
82 $frequency = _post("fld_frequency");
83 $frequencyComparator = _post("fld_frequency_comparator");
85 $this->completed
= $completed == 'yes';
86 $this->frequency
= $frequency;
87 $this->frequencyComparator
= $frequencyComparator;
90 // xxx todo abstract this out to a manager (which may or may not defer to core options handling code)!
91 // xxx this belongs more in the rule manager
92 $dbLbl = getLabel($category, 'rule_action_category');
93 if ( $category && $dbLbl != $categoryLbl ) {
95 sqlQuery(sqlStatement( "UPDATE list_options SET title = ? WHERE list_id = 'rule_action_category' AND option_id = ?", array(
101 $dbLbl = getLabel($item, 'rule_action');
102 if ( $item && $dbLbl != $itemLbl ) {
104 sqlQuery(sqlStatement( "UPDATE list_options SET title = ? WHERE list_id = 'rule_action' AND option_id = ?", array(
110 $this->category
= $category;
112 $this->itemLbl
= $itemLbl;
113 $this->categoryLbl
= $categoryLbl;