1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10: 11: 12: 13: 14: 15:
16: class Mnemo_Form_DeleteNotepad extends Horde_Form
17: {
18: 19: 20:
21: protected $_notepad;
22:
23: 24: 25:
26: public function __construct(&$vars, $notepad)
27: {
28: $this->_notepad = $notepad;
29: parent::__construct($vars, sprintf(_("Delete %s"), $notepad->get('name')));
30:
31: $this->addHidden('', 'n', 'text', true);
32: $this->addVariable(sprintf(_("Really delete the notepad \"%s\"? This cannot be undone and all data on this notepad will be permanently removed."), $this->_notepad->get('name')), 'desc', 'description', false);
33:
34: $this->setButtons(array(_("Delete"), _("Cancel")));
35: }
36:
37: public function execute()
38: {
39:
40: if ($this->_vars->get('submitbutton') == _("Cancel")) {
41: return false;
42: }
43:
44: if (!$GLOBALS['registry']->getAuth() ||
45: $this->_notepad->get('owner') != $GLOBALS['registry']->getAuth()) {
46:
47: throw new Horde_Exception_PermissionDenied(_("Permission denied"));
48: }
49:
50:
51: $storage = $GLOBALS['injector']->getInstance('Mnemo_Factory_Driver')->create($this->_notepad->getName());
52: $result = $storage->deleteAll();
53:
54: try {
55: $GLOBALS['mnemo_shares']->removeShare($this->_notepad);
56: } catch (Horde_Share_Exception $e) {
57: Horde::logMessage($e->getMessage(), 'ERR');
58: throw new Mnemo_Exception($e->getMessage());
59: }
60:
61: return true;
62: }
63:
64: }
65: