1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16: 17: 18:
19: class Kronolith_Form_DeleteResource 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(sprintf(_("Really delete the resource \"%s\"? This cannot be undone and all data on this resource will be permanently removed."), $this->_resource->get('name')), 'desc', 'description', false);
35:
36: $this->setButtons(array(_("Delete"), _("Cancel")));
37: }
38:
39: 40: 41:
42: public function execute()
43: {
44:
45: if ($this->_vars->get('submitbutton') == _("Cancel")) {
46: return;
47: }
48:
49: if (!($this->_resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE))) {
50: throw new Kronolith_Exception(_("Permission denied"));
51: }
52:
53:
54: try {
55: Kronolith::getDriver('Resource')->delete($this->_resource);
56: } catch (Exception $e) {
57: throw new Kronolith_Exception(sprintf(_("Unable to delete \"%s\": %s"), $this->_resource->get('name'), $e->getMessage()));
58: }
59: }
60:
61: }
62: