1: <?php
2: 3: 4:
5: class Whups_Form_Query_ChooseNameForLoad extends Horde_Form
6: {
7:
8: public function __construct(&$vars)
9: {
10: parent::__construct($vars, _("Load Query"), 'Whups_Form_Query_ChooseNameForLoad');
11:
12: $qManager = new Whups_Query_Manager();
13: $qParams = $qManager->listQueries($GLOBALS['registry']->getAuth());
14: if (count($qParams)) {
15: $qType = 'enum';
16: } else {
17: $qType = 'invalid';
18: $qParams = _("You have no saved queries.");
19: }
20:
21: $this->addVariable(_("Name"), 'name', $qType, true, false, null, array($qParams));
22: }
23:
24: public function execute(&$vars)
25: {
26: $qManager = new Whups_Query_Manager();
27: try {
28: $query = $qManager->getQuery($vars->get('name'));
29: $GLOBALS['whups_query'] = $query;
30: } catch (Whups_Exception $e) {
31: $GLOBALS['notification']->push(
32: sprintf(_("The query couldn't be loaded:"), $e->getMessage()),
33: 'horde.error');
34: }
35: $this->unsetVars($vars);
36: }
37:
38: }