/** */ public function update(Horde_Core_Prefs_Ui $ui) { if (!isset($ui->vars->sources)) { return false; } $backends = Gollem_Auth::getBackend(); if (count($backends) == 1) { $sources = json_decode($ui->vars->sources); array_unshift($sources, key($backends)); $sources = json_encode(array($sources)); } else { $sources = $ui->vars->sources; } $GLOBALS['prefs']->setValue('columns', $sources); return true; }
/** * Returns the VFS instance. * * @param string $backend The backend to return. * * @return Horde_Vfs The VFS object. */ public function create($backend) { if (empty($this->_instances[$backend])) { $be_config = Gollem_Auth::getBackend($backend); $params = $be_config['params']; switch (Horde_String::lower($be_config['driver'])) { case 'sql': case 'sqlfile': case 'musql': $db_params = $params; unset($db_params['table']); $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('gollem', $db_params); $params['user'] = $GLOBALS['registry']->getAuth(); break; } $vfs = Horde_Vfs::factory($be_config['driver'], $params); if (!empty($be_config['quota'])) { $vfs->setQuotaRoot($be_config['root'] == '/' ? '' : $be_config['root']); if (isset($be_config['quota_val'])) { $vfs->setQuota($be_config['quota_val'], $be_config['quota_metric']); } else { $quota_metric = array('B' => Horde_Vfs::QUOTA_METRIC_BYTE, 'KB' => Horde_Vfs::QUOTA_METRIC_KB, 'MB' => Horde_Vfs::QUOTA_METRIC_MB, 'GB' => Horde_Vfs::QUOTA_METRIC_GB); $quota_str = explode(' ', $be_config['quota'], 2); if (is_numeric($quota_str[0])) { $metric = trim(Horde_String::upper($quota_str[1])); if (!isset($quota_metric[$metric])) { $metric = 'B'; } $vfs->setQuota($quota_str[0], $quota_metric[$metric]); } } } $this->_instances[$backend] = $vfs; } return $this->_instances[$backend]; }
/** * Returns a link to the gollem file preview interface * * @param string $dir File absolute path * @param string $file File basename * @param string $backend_key Backend key. Defaults to * Gollem_Auth::getPreferredBackend(). * * @return Horde_Url The URL object. */ public function getViewLink($dir, $file, $backend_key = '') { if (empty($backend_key)) { $backend_key = Gollem_Auth::getPreferredBackend(); } $backend = Gollem_Auth::getBackend($backend_key); return Horde::url('view.php')->add(array('dir' => $dir, 'driver' => $backend['driver'], 'file' => $file, 'type' => substr($file, strrpos($file, '.') + 1))); }
/** */ public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array()) { $icon = Horde_Themes::img('gollem.png'); $url = Horde::url('manager.php'); foreach (Gollem_Auth::getBackend() as $key => $val) { $tree->addNode(array('id' => $parent . $key, 'parent' => $parent, 'label' => $val['name'], 'expanded' => false, 'params' => array('icon' => $icon, 'url' => $url->add(array('backend_key' => $key))))); } }
/** * Parses the 'columns' preference. * * @return array The list of columns to be displayed. */ public static function getColumns($backend) { if (!isset(self::$_columns)) { self::$_columns = array(); $sources = json_decode($GLOBALS['prefs']->getValue('columns')); foreach ($sources as $source) { self::$_columns[array_shift($source)] = $source; } } if (empty(self::$_columns[$backend])) { $info = Gollem_Auth::getBackend($backend); self::$_columns[$backend] = $info['attributes']; } return self::$_columns[$backend]; }
* * This script is just a proxy for horde/services/shares/edit.php that * makes sure that a folder share exists before trying to edit it. * * Copyright 2012-2015 Horde LLC (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you * did notcan receive this file, see http://www.horde.org/licenses/gpl. * * @author Jan Schneider <*****@*****.**> * @category Horde * @license http://www.horde.org/licenses/gpl GPL * @package Gollem */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('gollem'); /* Check if the user has permissions to create shares here. */ $share = Horde_Util::getFormData('share'); @(list($backend_key, $dir) = explode('|', $share)); $backend = Gollem_Auth::getBackend($backend_key); if (!$backend || empty($backend['shares']) || strpos($dir, $backend['home']) !== 0) { throw new Gollem_Excception(_("You are not allowed to share this folder")); } /* Create a folder share if it doesn't exist yet. */ $shares = $injector->getInstance('Gollem_Shares'); if (!$shares->exists($share)) { $shareOb = $shares->newShare($registry->getAuth(), $share, basename($dir)); $shares->addShare($shareOb); } /* Proceed with the regular share editing. */ Horde::url('services/shares/edit.php', true, array('app' => 'horde'))->add(array('app' => 'gollem', 'share' => $share))->redirect();
* See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.horde.org/licenses/gpl. * * @author Vijay Mahrra <*****@*****.**> * @category Horde * @license http://www.horde.org/licenses/gpl GPL * @package Gollem */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('gollem', array('admin' => true)); if (!Gollem_Auth::getBackend()) { $notification->push(_("You need at least one backend defined to set permissions."), 'horde.error'); Horde::url('index.php', true)->redirect(); } /* Edit permissions for the preferred backend if none is selected. */ $key = Horde_Util::getFormData('backend', Gollem_Auth::getPreferredBackend()); $app = $registry->getApp(); $backendTag = $app . ':backends:' . $key; $perms = $injector->getInstance('Horde_Perms'); if ($perms->exists($backendTag)) { $permission = $perms->getPermission($backendTag); $perm_id = $perms->getPermissionId($permission); } else { $permission = $injector->getInstance('Horde_Perms')->newPermission($backendTag); try { $perms->addPermission($permission, $app); } catch (Horde_Perms_Exception $e) { $notification->push(sprintf(_("Unable to create backend permission: %s"), $e->getMessage()), 'horde.error'); Horde::url('index.php', true)->redirect(); } $perm_id = $perms->getPermissionId($permission);