1: <?php
2: 3: 4:
5: class Whups_Form_Query_PropertyCriterion extends Horde_Form
6: {
7: public function __construct(&$vars)
8: {
9: global $whups_driver;
10:
11: parent::__construct(
12: $vars,
13: $vars->get('edit') ? _("Edit Property Criterion") : _("Add Property Criterion"),
14: 'Whups_Form_Query_PropertyCriterion');
15:
16: $this->addHidden('', 'edit', 'boolean', false);
17: $this->addVariable(_("Id"), 'id', 'intlist', false);
18:
19:
20: $this->addVariable(
21: _("Type"), 'ttype', 'enum', false, false, null,
22: array($whups_driver->getAllTypes(), _("Any")));
23:
24:
25:
26: $queues = Whups::permissionsFilter(
27: $whups_driver->getQueues(), 'queue', Horde_Perms::READ);
28: if (count($queues)) {
29: $v = &$this->addVariable(
30: _("Queue"), 'queue', 'enum', false, false, null,
31: array($queues, _("Any")));
32: $v->setAction(Horde_Form_Action::factory('reload'));
33: if ($vars->get('queue')) {
34: $this->addVariable(
35: _("Version"), 'version', 'enum', false, false, null,
36: array($whups_driver->getVersions($vars->get('queue')), _("Any")));
37: }
38: }
39:
40:
41: $states = $whups_driver->getStates();
42: $this->addVariable(
43: _("State"), 'state', 'enum', false, false, null,
44: array($states, _("Any")));
45:
46:
47: $priorities = $whups_driver->getPriorities();
48: $this->addVariable(
49: _("Priority"), 'priority', 'enum', false, false, null,
50: array($priorities, _("Any")));
51: }
52:
53: public function execute(&$vars)
54: {
55: $path = $vars->get('path');
56:
57: $id = $vars->get('id');
58: if (strlen(trim($id))) {
59: $newpath = $path;
60: $ids = split("[\\t\\n ,]+", $id);
61:
62: if (count($ids) > 1) {
63: $newpath = $GLOBALS['whups_query']->insertBranch(
64: $path, Whups_Query::TYPE_OR);
65: }
66:
67: foreach ($ids as $id) {
68: $GLOBALS['whups_query']->insertCriterion(
69: $newpath, Whups_Query::CRITERION_ID, null,
70: Whups_Query::OPERATOR_EQUAL, $id);
71: }
72: }
73:
74: $queue = $vars->get('queue');
75: if ($queue) {
76: $version = $vars->get('version');
77: if ($version) {
78: $path = $GLOBALS['whups_query']->insertBranch(
79: $path, Whups_Query::TYPE_AND);
80: }
81: $GLOBALS['whups_query']->insertCriterion(
82: $path, Whups_Query::CRITERION_QUEUE, null,
83: Whups_Query::OPERATOR_EQUAL, $queue);
84: if ($version) {
85: $GLOBALS['whups_query']->insertCriterion(
86: $path, Whups_Query::CRITERION_VERSION, null,
87: Whups_Query::OPERATOR_EQUAL, $version);
88: }
89: }
90:
91: $type = $vars->get('ttype');
92: if ($type) {
93: $GLOBALS['whups_query']->insertCriterion(
94: $path, Whups_Query::CRITERION_TYPE, null,
95: Whups_Query::OPERATOR_EQUAL, $type);
96: }
97:
98: $state = $vars->get('state');
99: if ($state) {
100: $GLOBALS['whups_query']->insertCriterion(
101: $path, Whups_Query::CRITERION_STATE, null,
102: Whups_Query::OPERATOR_EQUAL, $state);
103: }
104:
105: $priority = $vars->get('priority');
106: if ($priority) {
107: $GLOBALS['whups_query']->insertCriterion(
108: $path, Whups_Query::CRITERION_PRIORITY, null,
109: Whups_Query::OPERATOR_EQUAL, $priority);
110: }
111:
112: $this->unsetVars($vars);
113: }
114:
115: }