Horde_Vfs fixes.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 25 May 2010 03:57:34 +0000 (21:57 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 25 May 2010 03:57:34 +0000 (21:57 -0600)
getOb() scope argument must be optional - or else, default system is
unusable.
Move getVFSConfig() inside of Horde_Vfs factory.

framework/Core/lib/Horde.php
framework/Core/lib/Horde/Core/Factory/Vfs.php
turba/lib/Forms/Contact.php

index c3a75de..85bf10d 100644 (file)
@@ -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
index 382ac0e..275da22 100644 (file)
@@ -2,9 +2,10 @@
 /**
  * A Horde_Injector:: based Horde_Vfs:: factory.
  *
+ * @author   Michael J. Rubinsky <mrubinsk@horde.org>
  * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @package  Core
- * @author   Michael J. Rubinsky <mrubinsk@horde.org>
  */
 
 /**
  * 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 <mrubinsk@horde.org>
  * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @package  Core
- * @author   Michael J. Rubinsky <mrubinsk@horde.org>
  */
 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;
+    }
+
+}
index a031eb8..eb0da66 100644 (file)
@@ -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')) {