Copyright 2002-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Автор: Chuck Hagenbuch (chuck@horde.org)
Пример #1
0
 /**
  * Constructor.
  *
  * @param array $params  A hash containing connection parameters.
  */
 public function __construct($params = array())
 {
     $params = array_merge(array('table' => 'horde_vfs'), $params);
     parent::__construct($params);
     $this->_db = $this->_params['db'];
     unset($this->_params['db']);
 }
Пример #2
0
 /**
  */
 public function clear()
 {
     try {
         $this->_vfs->emptyFolder($this->_params['vfspath']);
     } catch (Horde_Vfs_Exception $e) {
     }
 }
Пример #3
0
 /**
  * Constructs a new Filesystem based VFS object.
  *
  * @param array $params  A hash containing connection parameters. REQUIRED
  *                       parameters:
  *   - vfsroot: (string) The root path.
  *              Note: The user that your webserver runs as MUST have
  *              read/write permission to this directory.
  */
 public function __construct($params = array())
 {
     parent::__construct($params);
     if (!empty($this->_params['vfsroot']) && (substr($this->_params['vfsroot'], -1) == '/' || substr($this->_params['vfsroot'], -1) == '\\')) {
         $this->_params['vfsroot'] = substr($this->_params['vfsroot'], 0, strlen($this->_params['vfsroot']) - 1);
     }
     $this->_connect();
 }
Пример #4
0
 /**
  * Constructor.
  *
  * @param array $params  Additional parameters:
  * <pre>
  *   - collection: (string) The collection name for the folders data.
  *   - gridfs: (string) The GridFS name.
  *   - mongo_db: [REQUIRED] (Horde_Mongo_Client) A MongoDB client object.
  * </pre>
  */
 public function __construct(array $params = array())
 {
     if (!isset($params['mongo_db'])) {
         throw new InvalidArgumentException('Missing mongo_db parameter.');
     }
     parent::__construct(array_merge(array('collection' => 'horde_vfs_folders', 'gridfs' => 'horde_vfs'), $params));
     $this->_files = $this->_params['mongo_db']->selectDB(null)->getGridFS($this->_params['gridfs']);
     $this->_folders = $this->_params['mongo_db']->selectDB(null)->selectCollection($this->_params['collection']);
 }
Пример #5
0
 /**
  * Constructor.
  *
  * @param array $params  A hash containing connection parameters.
  * @throws Horde_Vfs_Exception
  */
 public function __construct($params = array())
 {
     parent::__construct($params);
     if (!isset($this->_params['horde_base'])) {
         throw new Horde_Vfs_Exception('Required "horde_base" not specified in VFS configuration.');
     }
     require_once $this->_params['horde_base'] . '/lib/Application.php';
     Horde_Registry::appInit('horde');
     // Create the Registry object.
     $this->_registry = $GLOBALS['registry'];
 }
Пример #6
0
 /**
  * Constructor.
  *
  * @param array $params  A hash containing connection parameters.
  */
 public function __construct($params = array())
 {
     parent::__construct($params);
     if (!isset($this->_params['share'])) {
         return;
     }
     $share_parts = explode('/', $this->_params['share']);
     $this->_params['share'] = array_shift($share_parts);
     if ($share_parts) {
         $this->_prefix = implode('/', $share_parts);
     }
 }
Пример #7
0
 /**
  * Stores user preferences in the backend.
  *
  * @param boolean $defaults  Whether to store the global defaults instead
  *                           of user options. Unused.
  *
  * @throws Sam_Exception
  */
 public function store($defaults = false)
 {
     /* Generate preference file. */
     $output = '# ' . _("SpamAssassin preference file generated by Sam") . ' (' . date('F j, Y, g:i a') . ")\n";
     foreach ($this->_options as $attribute => $value) {
         if (is_array($value)) {
             $output .= $this->_mapAttributeToOption($attribute) . ' ' . trim(implode(' ', $value)) . "\n";
         } else {
             $output .= $this->_mapAttributeToOption($attribute) . ' ' . trim($value) . "\n";
         }
     }
     /* Write preference file. */
     try {
         $this->_vfs->writeData(dirname($this->_params['user_prefs']), basename($this->_params['user_prefs']), $output, true);
     } catch (Horde_Vfs_Exception $e) {
         throw new Sam_Exception($e);
     }
 }
Пример #8
0
 /**
  * Returns the full path of an item.
  *
  * @param string $path  The directory of the item.
  * @param string $name  The name of the item.
  *
  * @return mixed  Full path to the file when $path is not empty and just
  *                $name when not set.
  */
 protected function _getPath($path, $name)
 {
     if (isset($this->_params['vfsroot']) && strlen($this->_params['vfsroot'])) {
         if (strlen($path)) {
             $path = $this->_params['vfsroot'] . '/' . $path;
         } else {
             $path = $this->_params['vfsroot'];
         }
     }
     return parent::_getPath($path, $name);
 }
Пример #9
0
 /**
  */
 public function exists()
 {
     return $this->_vfs->exists($this->_vfspath, $this->_id);
 }