1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16: 17: 18:
19: class Kronolith_Form_DeleteResourceGroup extends Horde_Form
20: {
21: 22: 23: 24: 25:
26: protected $_resource;
27:
28: public function __construct($vars, $resource)
29: {
30: $this->_resource = $resource;
31: parent::__construct($vars, sprintf(_("Delete %s"), $resource->get('name')));
32:
33: $this->addHidden('', 'c', 'text', true);
34: $this->addVariable(
35: sprintf(_("Really delete the resource \"%s\"? This cannot be undone and all data on this resource will be permanently removed."), $this->_resource->get('name')),
36: 'desc', 'description', false);
37: $this->setButtons(array(_("Delete"), _("Cancel")));
38: }
39:
40: 41: 42:
43: public function execute()
44: {
45:
46: if ($this->_vars->get('submitbutton') == _("Cancel")) {
47: return;
48: }
49:
50: if (!($this->_resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE))) {
51: throw new Kronolith_Exception(_("Permission denied"));
52: }
53:
54:
55: try {
56: Kronolith::getDriver('Resource')->delete($this->_resource);
57: } catch (Exception $e) {
58: throw new Kronolith_Exception(sprintf(_("Unable to delete \"%s\": %s"), $this->_resource->get('name'), $e->getMessage()));
59: }
60: }
61:
62: }
63: