Overview

Packages

  • Mnemo
  • None

Classes

  • Mnemo
  • Mnemo_Ajax_Application
  • Mnemo_Ajax_Imple_EditNote
  • Mnemo_Api
  • Mnemo_Driver
  • Mnemo_Driver_Kolab
  • Mnemo_Driver_Sql
  • Mnemo_Exception
  • Mnemo_Factory_Driver
  • Mnemo_Factory_Notepads
  • Mnemo_Form_CreateNotepad
  • Mnemo_Form_DeleteNotepad
  • Mnemo_Form_EditNotepad
  • Mnemo_Notepads_Base
  • Mnemo_Notepads_Default
  • Mnemo_Notepads_Kolab
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Horde_Form for deleting notepads.
 4:  *
 5:  * See the enclosed file LICENSE for license information (ASL). If you
 6:  * did not receive this file, see http://www.horde.org/licenses/apache.
 7:  *
 8:  * @package Mnemo
 9:  */
10: /**
11:  * The Mnemo_Form_DeleteNotepad class provides the form for deleting a notepad.
12:  *
13:  * @author  Chuck Hagenbuch <chuck@horde.org>
14:  * @package Mnemo
15:  */
16: class Mnemo_Form_DeleteNotepad extends Horde_Form
17: {
18:     /**
19:      * Notepad being deleted
20:      */
21:     protected $_notepad;
22: 
23:     /**
24:      * Const'r
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:         // If cancel was clicked, return false.
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:         // Delete the notepad.
51:         $storage = $GLOBALS['injector']->getInstance('Mnemo_Factory_Driver')->create($this->_notepad->getName());
52:         $result = $storage->deleteAll();
53:         // Remove share and all groups/permissions.
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: 
API documentation generated by ApiGen