From 7ada274b7ab8d8836a2785d4dc2227e3535c79fd Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 8 Oct 2013 15:55:57 -0600 Subject: [PATCH 1/8] [mms] Allow disabling VFS via the configuration interface. --- framework/Core/lib/Horde/Config.php | 4 ++++ framework/Core/package.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/framework/Core/lib/Horde/Config.php b/framework/Core/lib/Horde/Config.php index 6ffe9bd6bec..bb18e0b67c4 100644 --- a/framework/Core/lib/Horde/Config.php +++ b/framework/Core/lib/Horde/Config.php @@ -1401,6 +1401,10 @@ protected function _configVFS($ctx, $node) 'default' => $default, 'is_default' => $isDefault, 'switch' => array( + 'None' => array( + 'desc' => 'None', + 'fields' => array() + ), 'File' => array( 'desc' => 'Files on the local system', 'fields' => array( diff --git a/framework/Core/package.xml b/framework/Core/package.xml index edbb24afa46..800b9b58396 100644 --- a/framework/Core/package.xml +++ b/framework/Core/package.xml @@ -39,7 +39,7 @@ LGPL-2.1 -* +* [mms] Allow disabling VFS via the configuration interface. @@ -3176,7 +3176,7 @@ 2013-10-08 LGPL-2.1 -* +* [mms] Allow disabling VFS via the configuration interface. From fc91078460fa6b200cc2cb4ca3384f757f18f257 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 8 Oct 2013 16:00:20 -0600 Subject: [PATCH 2/8] Effect transitions that actually finish within the hour --- horde/js/sidebar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/horde/js/sidebar.js b/horde/js/sidebar.js index 1c6150c1c7e..2412a5ba338 100644 --- a/horde/js/sidebar.js +++ b/horde/js/sidebar.js @@ -29,7 +29,7 @@ var HordeSidebar = { while (Object.isElement(elt)) { switch (elt.className) { case 'horde-collapse': - elt.up().next().blindUp({ queue: 'end' }); + elt.up().next().blindUp({ duration: 0.5, queue: 'end' }); elt.title = this.text.expand; elt.removeClassName('horde-collapse'); elt.addClassName('horde-expand'); @@ -37,7 +37,7 @@ var HordeSidebar = { return; case 'horde-expand': - elt.up().next().blindDown({ queue: 'end' }); + elt.up().next().blindDown({ duration: 0.5, queue: 'end' }); elt.title = this.text.collapse; elt.removeClassName('horde-expand'); elt.addClassName('horde-collapse'); From eed6bdcb9b23b57b72bff1e9a6279c0e2b68f9d3 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 8 Oct 2013 16:04:15 -0600 Subject: [PATCH 3/8] Better sanity checking for VFS existence in view.php Coming commits should make it essentially impossible to reach this code if VFS is off. Thus, no need for detailed error message - sanity checking is sufficient. --- turba/view.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/turba/view.php b/turba/view.php index 9fef3b0b54d..5aec2b2a643 100644 --- a/turba/view.php +++ b/turba/view.php @@ -13,10 +13,6 @@ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('turba'); -if ($conf['documents']['type'] == 'none') { - throw new Turba_Exception(_("The VFS backend needs to be configured to enable attachment uploads.")); -} - $source = Horde_Util::getFormData('source'); $key = Horde_Util::getFormData('key'); $filename = Horde_Util::getFormData('file'); @@ -36,7 +32,7 @@ } try { - $vfs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('documents'); + $vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create('documents'); } catch (Horde_Exception $e) { throw new Turba_Exception($e); } From ca047cc740199f4ba0623b65badd61acea657a62 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 8 Oct 2013 16:11:39 -0600 Subject: [PATCH 4/8] Additional improved handling of installations without VFS configured --- turba/lib/Application.php | 8 ++++++-- turba/lib/Form/Contact.php | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/turba/lib/Application.php b/turba/lib/Application.php index 41cd8dc4ba4..4e9833cf43a 100644 --- a/turba/lib/Application.php +++ b/turba/lib/Application.php @@ -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 */ @@ -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), diff --git a/turba/lib/Form/Contact.php b/turba/lib/Form/Contact.php index 280799f09ad..45cfaeab310 100644 --- a/turba/lib/Form/Contact.php +++ b/turba/lib/Form/Contact.php @@ -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('
', 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('
', array_map(array($contact, 'vfsEditUrl'), $files))); + } catch (Turba_Exception $e) { + $notification->push($files, 'horde.error'); + } catch (Horde_Exception $e) { + /* Ignore: VFS is not active. */ } } From a7788248b91af76da2dbe79a71f575da3786eaaa Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 8 Oct 2013 16:17:29 -0600 Subject: [PATCH 5/8] Use Turba_Object#vfsInit() to get the Horde_Vfs object to use --- turba/lib/Application.php | 2 +- turba/lib/Form/Contact.php | 16 ++++++++------- turba/lib/Object.php | 40 ++++++++++++++++++++++---------------- turba/view.php | 2 +- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/turba/lib/Application.php b/turba/lib/Application.php index 4e9833cf43a..8dd908429ec 100644 --- a/turba/lib/Application.php +++ b/turba/lib/Application.php @@ -448,7 +448,7 @@ public function download(Horde_Variables $vars) } try { - $vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create('documents'); + $vfs = $object->vfsInit(); } catch (Horde_Vfs_Exception $e) { throw new Turba_Exception(_("Data cannot be downloaded as no VFS driver is configured.")); } diff --git a/turba/lib/Form/Contact.php b/turba/lib/Form/Contact.php index 45cfaeab310..acc5971dda0 100644 --- a/turba/lib/Form/Contact.php +++ b/turba/lib/Form/Contact.php @@ -31,15 +31,17 @@ public function __construct($vars, Turba_Object $contact, $tabs = true, $title = /* List files. */ try { - /* This throws Horde_Exception if VFS not available. */ - $injector->getInstance('Horde_Core_Factory_Vfs')->create('documents'); + /* This throws Turba_Exception if VFS not available. */ + $contact->vfsInit(); - $files = $contact->listFiles(); - $this->addVariable(_("Files"), '__vfs', 'html', false); - $vars->set('__vfs', implode('
', array_map(array($contact, 'vfsEditUrl'), $files))); + try { + $files = $contact->listFiles(); + $this->addVariable(_("Files"), '__vfs', 'html', false); + $vars->set('__vfs', implode('
', array_map(array($contact, 'vfsEditUrl'), $files))); + } catch (Turba_Exception $e) { + $notification->push($files, 'horde.error'); + } } catch (Turba_Exception $e) { - $notification->push($files, 'horde.error'); - } catch (Horde_Exception $e) { /* Ignore: VFS is not active. */ } } diff --git a/turba/lib/Object.php b/turba/lib/Object.php index 5914714e857..dd6f20f0721 100644 --- a/turba/lib/Object.php +++ b/turba/lib/Object.php @@ -319,10 +319,12 @@ public function addFile(array $info) if (!$this->getValue('__uid')) { throw new Turba_Exception('VFS not supported for this object.'); } - $this->_vfsInit(); + + $vfs = $this->vfsInit(); + $dir = Turba::VFS_PATH . '/' . $this->getValue('__uid'); $file = $info['name']; - while ($this->_vfs->exists($dir, $file)) { + while ($vfs->exists($dir, $file)) { if (preg_match('/(.*)\[(\d+)\](\.[^.]*)?$/', $file, $match)) { $file = $match[1] . '[' . ++$match[2] . ']' . $match[3]; } else { @@ -335,7 +337,7 @@ public function addFile(array $info) } } try { - $this->_vfs->write($dir, $file, $info['tmp_name'], true); + $vfs->write($dir, $file, $info['tmp_name'], true); } catch (Horde_Vfs_Exception $e) { throw new Turba_Exception($e); } @@ -352,9 +354,9 @@ public function deleteFile($file) if (!$this->getValue('__uid')) { throw new Turba_Exception('VFS not supported for this object.'); } - $this->_vfsInit(); + try { - $this->_vfs->deleteFile(Turba::VFS_PATH . '/' . $this->getValue('__uid'), $file); + $this->vfsInit()->deleteFile(Turba::VFS_PATH . '/' . $this->getValue('__uid'), $file); } catch (Horde_Vfs_Exception $e) { throw new Turba_Exception($e); } @@ -370,10 +372,12 @@ public function deleteFiles() if (!$this->getValue('__uid')) { throw new Turba_Exception('VFS not supported for this object.'); } - $this->_vfsInit(); - if ($this->_vfs->exists(Turba::VFS_PATH, $this->getValue('__uid'))) { + + $vfs = $this->vfsInit(); + + if ($vfs->exists(Turba::VFS_PATH, $this->getValue('__uid'))) { try { - $this->_vfs->deleteFolder(Turba::VFS_PATH, $this->getValue('__uid'), true); + $vfs->deleteFolder(Turba::VFS_PATH, $this->getValue('__uid'), true); } catch (Horde_Vfs_Exception $e) { throw new Turba_Exception($e); } @@ -387,15 +391,14 @@ public function deleteFiles() */ public function listFiles() { - if (!$this->getValue('__uid')) { - return array(); + if ($this->getValue('__uid')) { + try { + $vfs = $this->vfsInit(); + if ($vfs->exists(Turba::VFS_PATH, $this->getValue('__uid'))) { + return $vfs->listFolder(Turba::VFS_PATH . '/' . $this->getValue('__uid')); + } + } catch (Turba_Exception $e) {} } - try { - $this->_vfsInit(); - if ($this->_vfs->exists(Turba::VFS_PATH, $this->getValue('__uid'))) { - return $this->_vfs->listFolder(Turba::VFS_PATH . '/' . $this->getValue('__uid')); - } - } catch (Turba_Exception $e) {} return array(); } @@ -475,9 +478,10 @@ public function store() /** * Loads the VFS configuration and initializes the VFS backend. * + * @return Horde_Vfs A VFS object. * @throws Turba_Exception */ - protected function _vfsInit() + public function vfsInit() { if (!isset($this->_vfs)) { try { @@ -486,6 +490,8 @@ protected function _vfsInit() throw new Turba_Exception($e); } } + + return $this->_vfs; } } diff --git a/turba/view.php b/turba/view.php index 5aec2b2a643..64d808fba1d 100644 --- a/turba/view.php +++ b/turba/view.php @@ -32,7 +32,7 @@ } try { - $vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create('documents'); + $vfs = $object->vfsInit(); } catch (Horde_Exception $e) { throw new Turba_Exception($e); } From ce3f45c9a32d078e28371d146290c3802c8ab871 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 8 Oct 2013 16:19:31 -0600 Subject: [PATCH 6/8] Don't show add file option if VFS is not available --- turba/lib/Form/EditContact.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/turba/lib/Form/EditContact.php b/turba/lib/Form/EditContact.php index 2965d9327ae..6a923041f9b 100644 --- a/turba/lib/Form/EditContact.php +++ b/turba/lib/Form/EditContact.php @@ -28,7 +28,10 @@ public function __construct($vars, Turba_Object $contact) parent::_addFields($this->_contact); - $this->addVariable(_("Add file"), 'vfs', 'file', false); + try { + $contact->vfsInit(); + $this->addVariable(_("Add file"), 'vfs', 'file', false); + } catch (Turba_Exception $e) {} $object_values = $vars->get('object'); $object_keys = array_keys($contact->attributes); From a78246427076e83ede61a8382ac4ea6d2ebf2c63 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 8 Oct 2013 16:20:04 -0600 Subject: [PATCH 7/8] [mms] Remove features from UI when VFS is not available or disabled. --- turba/docs/CHANGES | 1 + turba/package.xml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/turba/docs/CHANGES b/turba/docs/CHANGES index 4ac4b2950cd..232aee5e385 100644 --- a/turba/docs/CHANGES +++ b/turba/docs/CHANGES @@ -2,6 +2,7 @@ v4.1.3-git ---------- +[mms] Remove features from UI when VFS is not available or disabled. [mjr] Fix filtering Facebook driver results (Bug #12739). [jan] Gracefully deal with columns removed from the backend. diff --git a/turba/package.xml b/turba/package.xml index 1ba0c407e6e..fae75d99bd1 100644 --- a/turba/package.xml +++ b/turba/package.xml @@ -40,6 +40,7 @@ ASL +* [mms] Remove features from UI when VFS is not available or disabled. * [mjr] Fix filtering Facebook driver results (Bug #12739). * [jan] Gracefully deal with columns removed from the backend. @@ -1697,6 +1698,7 @@ 2013-08-27 ASL +* [mms] Remove features from UI when VFS is not available or disabled. * [mjr] Fix filtering Facebook driver results (Bug #12739). * [jan] Gracefully deal with columns removed from the backend. From 9b80259a3accb1ddf6587bf77b73f9459940e442 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 8 Oct 2013 17:02:18 -0600 Subject: [PATCH 8/8] Fix typo --- framework/Core/lib/Horde/Core/Text/Filter/Emoticons.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/Core/lib/Horde/Core/Text/Filter/Emoticons.php b/framework/Core/lib/Horde/Core/Text/Filter/Emoticons.php index 0ba72505744..6e77505e6a2 100644 --- a/framework/Core/lib/Horde/Core/Text/Filter/Emoticons.php +++ b/framework/Core/lib/Horde/Core/Text/Filter/Emoticons.php @@ -24,7 +24,7 @@ class Horde_Core_Text_Filter_Emoticons extends Horde_Text_Filter_Emoticons */ public function getIcon($icon) { - return Horde_Themes_Tag::tag('emoticons/' . $this->getIcons($icon) . '.png', array( + return Horde_Themes_Image::tag('emoticons/' . $this->getIcons($icon) . '.png', array( 'alt' => $icon, 'attr' => array( 'align' => 'middle',