From faf51e191e49f34292e1ce5a5cc8f499421f3038 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 24 May 2010 21:57:34 -0600 Subject: [PATCH] Horde_Vfs fixes. getOb() scope argument must be optional - or else, default system is unusable. Move getVFSConfig() inside of Horde_Vfs factory. --- framework/Core/lib/Horde.php | 30 ------------------- framework/Core/lib/Horde/Core/Factory/Vfs.php | 42 +++++++++++++++++++++++---- turba/lib/Forms/Contact.php | 2 +- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index c3a75de9d..85bf10da2 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -816,36 +816,6 @@ HTML; return isset($conf[$type]) ? $conf[$type] : array(); } - - /** - * Returns the VFS driver parameters for the specified backend. - * - * @param string $name The VFS system name (e.g. 'images', 'documents') - * being used. - * - * @return array A hash with the VFS parameters; the VFS driver in 'type' - * and the connection parameters in 'params'. - * @throws Horde_Exception - */ - static public function getVFSConfig($name) - { - global $conf; - - if ($name !== 'horde' && !isset($conf[$name]['type'])) { - throw new Horde_Exception(_("You must configure a VFS backend.")); - } - - $vfs = ($name == 'horde' || $conf[$name]['type'] == 'horde') - ? $conf['vfs'] - : $conf[$name]; - - if ($vfs['type'] == 'sql') { - $vfs['params'] = self::getDriverConfig($name, 'sql'); - } - - return $vfs; - } - /** * Checks if all necessary parameters for a driver configuration * are set and throws a fatal error with a detailed explanation diff --git a/framework/Core/lib/Horde/Core/Factory/Vfs.php b/framework/Core/lib/Horde/Core/Factory/Vfs.php index 382ac0e77..275da226d 100644 --- a/framework/Core/lib/Horde/Core/Factory/Vfs.php +++ b/framework/Core/lib/Horde/Core/Factory/Vfs.php @@ -2,9 +2,10 @@ /** * A Horde_Injector:: based Horde_Vfs:: factory. * + * @author Michael J. Rubinsky * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @package Core - * @author Michael J. Rubinsky */ /** @@ -15,9 +16,10 @@ * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. * + * @author Michael J. Rubinsky * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @package Core - * @author Michael J. Rubinsky */ class Horde_Core_Factory_Vfs { @@ -49,17 +51,45 @@ class Horde_Core_Factory_Vfs * Obtain the Vfs instance. * * @param string $scope The vfs scope to return. - * + * * @return VFS The VFS object */ - public function getVfs($scope) + public function getVfs($scope = 'horde') { if (empty($this->_instances[$scope])) { - $params = Horde::getVFSConfig($scope); + $params = $this->getVFSConfig($scope); $this->_instances[$scope] = VFS::singleton($params['type'], $params['params']); } return $this->_instances[$scope]; } -} \ No newline at end of file + /** + * Returns the VFS driver parameters for the specified backend. + * + * @param string $name The VFS system name being used. + * + * @return array A hash with the VFS parameters; the VFS driver in 'type' + * and the connection parameters in 'params'. + * @throws Horde_Exception + */ + public function getVFSConfig($name = 'horde') + { + global $conf; + + if (($name !== 'horde') && !isset($conf[$name]['type'])) { + throw new Horde_Exception(_("You must configure a VFS backend.")); + } + + $vfs = ($name == 'horde' || $conf[$name]['type'] == 'horde') + ? $conf['vfs'] + : $conf[$name]; + + if ($vfs['type'] == 'sql') { + $vfs['params'] = Horde::getDriverConfig($name, 'sql'); + } + + return $vfs; + } + +} diff --git a/turba/lib/Forms/Contact.php b/turba/lib/Forms/Contact.php index a031eb8d7..eb0da664d 100644 --- a/turba/lib/Forms/Contact.php +++ b/turba/lib/Forms/Contact.php @@ -27,7 +27,7 @@ class Turba_ContactForm extends Horde_Form { $this->_addFields($contact); /* List files. */ - $v_params = Horde::getVFSConfig('documents'); + $v_params = $GLOBALS['injector']->getInstance('Horde_Vfs')->getConfig('documents'); if ($v_params['type'] != 'none') { $files = $contact->listFiles(); if (is_a($files, 'PEAR_Error')) { -- 2.11.0