}
try {
- return VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs'));
+ return $GLOBALS['injector']->getInstance('Horde_Vfs');
} catch (VFS_Exception $e) {
return PEAR::raiseError($e);
}
}
}
-$vfs = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type']));
+$vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
$vfspath = '.horde/ansel/';
$garbagepath = $vfspath . 'garbage/';
--- /dev/null
+<?php
+class Horde_Core_Binder_Vfs implements Horde_Injector_Binder
+{
+ public function create(Horde_Injector $injector)
+ {
+ $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
+ $vfs->setLogger($injector->getInstance('Horde_Log_Logger'));
+
+ return $vfs;
+ }
+
+ public function equals(Horde_Injector_Binder $binder)
+ {
+ return false;
+ }
+}
'Horde_Notification' => new Horde_Core_Binder_Notification(),
'Horde_Perms' => new Horde_Core_Binder_Perms(),
'Horde_Template' => new Horde_Core_Binder_Template(),
+ 'Horde_Vfs' => new Horde_Core_Binder_Vfs(),
'Net_DNS_Resolver' => new Horde_Core_Binder_Dns()
);
<file name="Notification.php" role="php" />
<file name="Perms.php" role="php" />
<file name="Template.php" role="php" />
+ <file name="Vfs.php" role="php" />
</dir> <!-- /lib/Horde/Core/Binder -->
<dir name="Factory">
<file name="KolabServer.php" role="php" />
<install name="lib/Horde/Core/Binder/Notification.php" as="Horde/Core/Binder/Notification.php" />
<install name="lib/Horde/Core/Binder/Perms.php" as="Horde/Core/Binder/Perms.php" />
<install name="lib/Horde/Core/Binder/Template.php" as="Horde/Core/Binder/Template.php" />
+ <install name="lib/Horde/Core/Binder/Vfs.php" as="Horde/Core/Binder/Vfs.php" />
<install name="lib/Horde/Core/Factory/KolabServer.php" as="Horde/Core/Factory/KolabServer.php" />
<install name="lib/Horde/Core/Factory/KolabSession.php" as="Horde/Core/Factory/KolabSession.php" />
<install name="lib/Horde/Core/Log/Logger.php" as="Horde/Core/Log/Logger.php" />
public function serialize($id = '')
{
try {
- $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'],
- Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
$vfs->writeData('.horde/scheduler', Horde_String::lower(get_class($this)) . $id, serialize($this), true);
return true;
} catch (VFS_Exception $e) {
$scheduler = new $class;
try {
- $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'],
- Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
$data = $vfs->read('.horde/scheduler', $class . $id);
if ($tmp = @unserialize($data)) {
$scheduler = $tmp;
/* Getting a file from Horde's VFS. */
$path = Horde_Util::getFormData('p');
try {
- $vfs = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type']));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
$file_data = $vfs->read($path, $file);
} catch (VFS_Exception $e) {
Horde::logMessage(sprintf('Error displaying image [%s]: %s', $path . '/' . $file, $e->getMessage()), 'ERR');
*/
function Hylax_Storage($params)
{
- global $conf;
-
$this->_params = $params;
/* Set up the VFS storage. */
- if (!isset($conf['vfs']['type'])) {
+ if (!isset($GLOBALS['conf']['vfs']['type'])) {
Horde::fatal(_("You must configure a VFS backend to use Hylax."), __FILE__, __LINE__);
}
- $vfs_driver = $conf['vfs']['type'];
- $vfs_params = Horde::getDriverConfig('vfs', $vfs_driver);
- $this->_vfs = VFS::singleton($vfs_driver, $vfs_params);
+
+ $this->_vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
}
function saveFaxData($data, $type = '.ps')
// Initialize the VFS.
try {
- $vfsroot = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type']));
+ $vfsroot = $injector->getInstance('Horde_Vfs');
} catch (VFS_Exception $e) {
throw new IMP_Exception(sprintf(_("Could not create the VFS backend: %s"), $e->getMessage()));
}
*/
protected function _storeAttachment($part, $data, $vfs_file = true)
{
- global $conf;
-
/* Store in VFS. */
- if ($conf['compose']['use_vfs']) {
- $vfs = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type']));
- $cacheID = uniqid(mt_rand());
-
+ if ($GLOBALS['conf']['compose']['use_vfs']) {
try {
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
+ $cacheID = uniqid(mt_rand());
+
if ($vfs_file) {
$vfs->write(self::VFS_ATTACH_PATH, $cacheID, $data, true);
} else {
switch ($atc['filetype']) {
case 'vfs':
/* Delete from VFS. */
- $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
- $vfs->deleteFile(self::VFS_ATTACH_PATH, $atc['filename']);
+ try {
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
+ $vfs->deleteFile(self::VFS_ATTACH_PATH, $atc['filename']);
+ } catch (VFS_Exception $e) {}
break;
case 'file':
switch ($this->_cache[$id]['filetype']) {
case 'vfs':
// TODO: Use streams
- $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
- $part->setContents($vfs->read(self::VFS_ATTACH_PATH, $this->_cache[$id]['filename']));
+ try {
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
+ $part->setContents($vfs->read(self::VFS_ATTACH_PATH, $this->_cache[$id]['filename']));
+ } catch (VFS_Exception $e) {}
break;
case 'file':
$auth = Horde_Auth::getAuth();
$baseurl = Horde::applicationUrl('attachment.php', true)->setRaw(true);
- $vfs = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type']));
+ try {
+ $GLOBALS['injector']->getInstance('Horde_Vfs');
+ } catch (VFS_Exception $e) {
+ throw new IMP_Compose_Exception($e);
+ }
$ts = time();
$fullpath = sprintf('%s/%s/%d', self::VFS_LINK_ATTACH_PATH, $auth, $ts);
}
try {
- $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
$vfs->writeData(self::VFS_DRAFTS_PATH, hash('md5', Horde_Util::getFormData('user')), $body, true);
$GLOBALS['notification']->push(_("The message you were composing has been saved as a draft. The next time you login, you may resume composing your message."));
}
$filename = hash('md5', Horde_Auth::getAuth());
- $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
+
+ try {
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
+ } catch (VFS_Exception $e) {
+ return;
+ }
+
if ($vfs->exists(self::VFS_DRAFTS_PATH, $filename)) {
try {
$data = $vfs->read(self::VFS_DRAFTS_PATH, $filename);
/* Do garbage collection on compose VFS data. */
if ($GLOBALS['conf']['compose']['use_vfs']) {
try {
- $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
VFS_GC::gc($vfs, IMP_Compose::VFS_ATTACH_PATH, 86400);
} catch (VFS_Exception $e) {}
}
$del_time = gmmktime(0, 0, 0, date('n') - $GLOBALS['prefs']->getValue('delete_attachments_monthly_keep'), 1, date('Y'));
try {
- $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
} catch (VFS_Exception $e) {
return false;
}
function deleteTicket($info)
{
- global $conf;
-
$id = (int)$info['id'];
$tables = array('whups_ticket_listeners',
'whups_tickets',
'whups_attributes');
- if (!empty($conf['vfs']['type'])) {
+ if (!empty($GLOBALS['conf']['vfs']['type'])) {
try {
- $vfs = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs'));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
} catch (VFS_Exception $e) {
return PEAR::raiseError($e->getMessage());
}
*/
function addAttachment(&$attachment_name, $attachment_file)
{
- global $conf;
-
- if (!isset($conf['vfs']['type'])) {
+ if (!isset($GLOBALS['conf']['vfs']['type'])) {
return PEAR::raiseError(_("The VFS backend needs to be configured to enable attachment uploads."), 'horde.error');
}
try {
- $vfs = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs'));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
} catch (VFS_Exception $e) {
return PEAR::raiseError($e->getMessage());
}
*/
function deleteAttachment($attachment_name)
{
- global $conf;
-
- if (!isset($conf['vfs']['type'])) {
+ if (!isset($GLOBALS['conf']['vfs']['type'])) {
return PEAR::raiseError(_("The VFS backend needs to be configured to enable attachment uploads."), 'horde.error');
}
try {
- $vfs = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs'));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
} catch (VFS_Exception $e) {
return PEAR::raiseError($e->getMessage());
}
*/
function getAttachments($ticket, $name = null)
{
- global $conf;
-
- if (empty($conf['vfs']['type'])) {
+ if (empty($GLOBALS['conf']['vfs']['type'])) {
return false;
}
try {
- $vfs = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs'));
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
} catch (VFS_Exception $e) {
return PEAR::raiseError($vfs->getMessage());
}
{
if (!$this->_vfs) {
try {
- $this->_vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'],
- Horde::getDriverConfig('vfs'));
+ $this->_vfs = $GLOBALS['injector']->getInstance('Horde_Vfs');
} catch (VFS_Exception $e) {
return PEAR::raiseError($e->getMessage());
}