1: <?php
2: 3: 4:
5: class Whups_Form_Query_GroupCriterion extends Horde_Form
6: {
7: public function __construct(&$vars)
8: {
9: parent::__construct(
10: $vars,
11: $vars->get('edit') ? _("Edit Group Criterion") : _("Add Group Criterion"),
12: 'Whups_Form_Query_GroupCriterion');
13:
14: $this->addHidden('', 'edit', 'boolean', false);
15:
16: try {
17: $grouplist = $GLOBALS['injector']
18: ->getInstance('Horde_Group')
19: ->listAll();
20: } catch (Horde_Group_Exception $e) {
21: $grouplist = array();
22: }
23:
24: if (count($grouplist)) {
25: $type_params = array(_("Could not find any groups."));
26: $this->addVariable(
27: _("Groups"), 'groups', 'invalid', false, false, null, $type_params);
28: } else {
29: $this->addVariable(
30: _("Groups"), 'groups', 'enum', true, false, null, array($grouplist));
31: }
32: }
33:
34: public function execute(&$vars)
35: {
36: $path = $vars->get('path');
37: $groups = $vars->get('groups');
38:
39: if ($groups) {
40: $GLOBALS['whups_query']->insertCriterion(
41: $path,
42: Whups_Query::CRITERION_GROUPS,
43: null,
44: Whups_Query::OPERATOR_EQUAL,
45: $groups);
46: }
47:
48: $this->unsetVars($vars);
49: }
50:
51: }