3
* Horde_Form for deleting address books.
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.
12
* The Turba_Form_DeleteAddressbook class provides the form for
13
* deleting an address book.
15
* @author Chuck Hagenbuch <chuck@horde.org>
18
class Turba_Form_DeleteAddressBook extends Horde_Form
21
* Address book being deleted
23
protected $_addressbook;
25
public function __construct($vars, $addressbook)
27
$this->_addressbook = $addressbook;
28
parent::__construct($vars, sprintf(_("Delete %s"), $addressbook->get('name')));
30
$this->addHidden('', 'a', 'text', true);
31
$this->addVariable(sprintf(_("Really delete the address book \"%s\"? This cannot be undone and all contacts in this address book will be permanently removed."), $this->_addressbook->get('name')), 'desc', 'description', false);
33
$this->setButtons(array(
34
array('class' => 'horde-delete', 'value' => _("Delete")),
35
array('class' => 'horde-cancel', 'value' => _("Cancel")),
40
* @throws Turba_Exception
42
public function execute()
44
// If cancel was clicked, return false.
45
if ($this->_vars->get('submitbutton') == _("Cancel")) {
46
Horde::url('', true)->redirect();
49
if (!$GLOBALS['registry']->getAuth() ||
50
$this->_addressbook->get('owner') != $GLOBALS['registry']->getAuth()) {
51
throw new Turba_Exception(_("You do not have permissions to delete this address book."));
54
$driver = $GLOBALS['injector']
55
->getInstance('Turba_Factory_Driver')
56
->create($this->_addressbook->getName());
57
if ($driver->hasCapability('delete_all')) {
60
} catch (Turba_Exception $e) {
61
Horde::logMessage($e->getMessage(), 'ERR');
66
// Address book successfully deleted from backend, remove the share.
69
->getInstance('Turba_Shares')
70
->removeShare($this->_addressbook);
71
} catch (Horde_Share_Exception $e) {
72
Horde::logMessage($e->getMessage(), 'ERR');
73
throw new Turba_Exception($e);
76
if ($GLOBALS['session']->get('turba', 'source') == Horde_Util::getFormData('deleteshare')) {
77
$GLOBALS['session']->remove('turba', 'source');