1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: 17: 18:
19: class Whups_Form_Query_UserCriterion extends Horde_Form
20: {
21: public function __construct(&$vars)
22: {
23: parent::Horde_Form(
24: $vars,
25: $vars->get('edit') ? _("Edit User Criterion") : _("Add User Criterion"),
26: 'Whups_Form_Query_UserCriterion');
27:
28: $this->addHidden('', 'edit', 'boolean', false);
29: $this->addVariable(_("User ID"), 'user', 'text', true);
30: $this->addVariable
31: (_("Match Operator"), 'operator', 'enum', true, false, null,
32: array(Whups_Query::textOperators()));
33: $this->addVariable(_("Search Owners"), 'owners', 'boolean', false);
34: $this->addVariable(_("Search Requester"), 'requester', 'boolean', false);
35: $this->addVariable(_("Search Comments"), 'comments', 'boolean', false);
36: }
37:
38: public function execute(&$vars)
39: {
40: $path = $vars->get('path');
41: $user = $vars->get('user');
42: $operator = $vars->get('operator');
43: $owners = $vars->get('owners');
44: $requester = $vars->get('requester');
45: $comments = $vars->get('comments');
46:
47:
48:
49: if ((bool)$owners + (bool)$requester + (bool)$comments > 1) {
50: $path = $GLOBALS['whups_query']->insertBranch($path, Whups_Query::TYPE_OR);
51: }
52:
53: if ($owners) {
54: $GLOBALS['whups_query']->insertCriterion(
55: $path, Whups_Query::CRITERION_OWNERS, null, $operator, $user);
56: }
57:
58: if ($requester) {
59: $GLOBALS['whups_query']->insertCriterion(
60: $path, Whups_Query::CRITERION_REQUESTER, null, $operator, $user);
61: }
62:
63: if ($comments) {
64: $GLOBALS['whups_query']->insertCriterion(
65: $path, Whups_Query::CRITERION_ADDED_COMMENT, null, $operator, $user);
66: }
67:
68: $this->unsetVars($vars);
69: }
70:
71: }