Skip to content

Commit

Permalink
Merge branch 'master' into imp_6_2
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 8, 2013
2 parents 651bfd1 + 9b80259 commit 5c7cf75
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 32 deletions.
4 changes: 4 additions & 0 deletions framework/Core/lib/Horde/Config.php
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion framework/Core/lib/Horde/Core/Text/Filter/Emoticons.php
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions framework/Core/package.xml
Expand Up @@ -39,7 +39,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Allow disabling VFS via the configuration interface.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -3176,7 +3176,7 @@
<date>2013-10-08</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Allow disabling VFS via the configuration interface.
</notes>
</release>
</changelog>
Expand Down
4 changes: 2 additions & 2 deletions horde/js/sidebar.js
Expand Up @@ -29,15 +29,15 @@ 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');
document.cookie = 'horde_sidebar_c_' + elt.identify() + '=1' + params;
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');
Expand Down
1 change: 1 addition & 0 deletions turba/docs/CHANGES
Expand Up @@ -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.

Expand Down
8 changes: 6 additions & 2 deletions turba/lib/Application.php
Expand Up @@ -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
*/
Expand All @@ -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 = $object->vfsInit();
} 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),
Expand Down
8 changes: 6 additions & 2 deletions turba/lib/Form/Contact.php
Expand Up @@ -30,15 +30,19 @@ 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 {
/* This throws Turba_Exception if VFS not available. */
$contact->vfsInit();

try {
$files = $contact->listFiles();
$this->addVariable(_("Files"), '__vfs', 'html', false);
$vars->set('__vfs', implode('<br />', array_map(array($contact, 'vfsEditUrl'), $files)));
} catch (Turba_Exception $e) {
$notification->push($files, 'horde.error');
}
} catch (Turba_Exception $e) {
/* Ignore: VFS is not active. */
}
}

Expand Down
5 changes: 4 additions & 1 deletion turba/lib/Form/EditContact.php
Expand Up @@ -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);
Expand Down
40 changes: 23 additions & 17 deletions turba/lib/Object.php
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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 {
Expand All @@ -486,6 +490,8 @@ protected function _vfsInit()
throw new Turba_Exception($e);
}
}

return $this->_vfs;
}

}
2 changes: 2 additions & 0 deletions turba/package.xml
Expand Up @@ -40,6 +40,7 @@
</stability>
<license uri="http://www.horde.org/licenses/asl">ASL</license>
<notes>
* [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.
</notes>
Expand Down Expand Up @@ -1697,6 +1698,7 @@
<date>2013-08-27</date>
<license uri="http://www.horde.org/licenses/asl">ASL</license>
<notes>
* [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.
</notes>
Expand Down
6 changes: 1 addition & 5 deletions turba/view.php
Expand Up @@ -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');
Expand All @@ -36,7 +32,7 @@
}

try {
$vfs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('documents');
$vfs = $object->vfsInit();
} catch (Horde_Exception $e) {
throw new Turba_Exception($e);
}
Expand Down

0 comments on commit 5c7cf75

Please sign in to comment.