Skip to content

Commit

Permalink
Additional improved handling of installations without VFS configured
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 8, 2013
1 parent eed6bdc commit ca047cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
8 changes: 6 additions & 2 deletions turba/lib/Application.php
Expand Up @@ -426,7 +426,6 @@ public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null,
/* Download data. */

/**
* @throws Horde_Vfs_Exception
* @throws Turba_Exception
* @throws Horde_Exception_NotFound
*/
Expand All @@ -448,7 +447,12 @@ public function download(Horde_Variables $vars)
throw new Turba_Exception(_("You do not have permission to view this contact."));
}

$vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create('documents');
try {
$vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create('documents');
} catch (Horde_Vfs_Exception $e) {
throw new Turba_Exception(_("Data cannot be downloaded as no VFS driver is configured."));
}

try {
return array(
'data' => $vfs->read(Turba::VFS_PATH . '/' . $object->getValue('__uid'), $vars->file),
Expand Down
20 changes: 11 additions & 9 deletions turba/lib/Form/Contact.php
Expand Up @@ -30,15 +30,17 @@ public function __construct($vars, Turba_Object $contact, $tabs = true, $title =
$this->_addFields($contact, $tabs);

/* List files. */
$v_params = $injector->getInstance('Horde_Core_Factory_Vfs')->getConfig('documents');
if ($v_params['type'] != 'none') {
try {
$files = $contact->listFiles();
$this->addVariable(_("Files"), '__vfs', 'html', false);
$vars->set('__vfs', implode('<br />', array_map(array($contact, 'vfsEditUrl'), $files)));
} catch (Turba_Exception $e) {
$notification->push($files, 'horde.error');
}
try {
/* This throws Horde_Exception if VFS not available. */
$injector->getInstance('Horde_Core_Factory_Vfs')->create('documents');

$files = $contact->listFiles();
$this->addVariable(_("Files"), '__vfs', 'html', false);
$vars->set('__vfs', implode('<br />', array_map(array($contact, 'vfsEditUrl'), $files)));
} catch (Turba_Exception $e) {
$notification->push($files, 'horde.error');
} catch (Horde_Exception $e) {
/* Ignore: VFS is not active. */
}
}

Expand Down

0 comments on commit ca047cc

Please sign in to comment.