1: <?php
2: 3: 4:
5: class Whups_Form_Query_Delete extends Horde_Form
6: {
7: public function __construct(&$vars)
8: {
9: parent::__construct($vars, _("Delete Query?"), 'Whups_Form_Query_Delete');
10:
11: $yesno = array(array(0 => _("No"), 1 => _("Yes")));
12: $this->addVariable(
13: _("Really delete this query? This operation is not undoable."),
14: 'yesno', 'enum', true, false, null, $yesno);
15: }
16:
17: public function execute(&$vars)
18: {
19: global $notification;
20:
21: if ($vars->get('yesno')) {
22: if (!$GLOBALS['whups_query']->hasPermission(
23: $GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
24: $notifications->push(sprintf(_("Permission denied.")), 'horde.error');
25: } else {
26: try {
27: $result = $GLOBALS['whups_query']->delete();
28:
29: $notification->push(
30: sprintf(
31: _("The query \"%s\" has been deleted."),
32: $GLOBALS['whups_query']->name), 'horde.success');
33: $qManager = new Whups_Query_Manager();
34: unset($GLOBALS['whups_query']);
35: $GLOBALS['whups_query'] = $qManager->newQuery();
36: } catch (Whups_Exception $e) {
37: $notification->push(
38: sprintf(_("The query \"%s\" couldn't be deleted: %s"), $GLOBALS['whups_query']->name, $result->getMessage()), 'horde.error');
39: }
40: }
41: }
42:
43: $this->unsetVars($vars);
44: }
45:
46: }