diff --git a/config/config.inc.php.dist b/config/config.inc.php.dist index 65489ed..14e9bf3 100644 --- a/config/config.inc.php.dist +++ b/config/config.inc.php.dist @@ -1,95 +1,111 @@ array( 'driver' => 'seafile', 'host' => 'seacloud.cc', // when username is set to '%u' current user name and password // will be used to authenticate to this storage source 'username' => '%u', ), 'Public-Files' => array( 'driver' => 'webdav', 'baseuri' => 'https://some.host.tld/Files', 'username' => 'admin', 'password' => 'pass', ), ); */ +// Default values for sources configuration dialog. +// Note: use driver names as the array keys. +// Note: %u variable will be resolved to the current username. +/* +$config['fileapi_presets'] = array( + 'seafile' => array( + 'host' => 'seacloud.cc', + 'username' => '%u', + ), + 'webdav' => array( + 'baseuri' => 'https://some.host.tld/Files', + 'username' => '%u', + ), +); +*/ + // Manticore service URL. Enables use of WebODF collaborative editor. // Note: this URL should be accessible from Chwala host and Roundcube host as well. $config['fileapi_manticore'] = null; // WOPI/Office service URL. Enables use of collaborative editor supporting WOPI. // Note: this URL should be accessible from Chwala host and Roundcube host as well. $config['fileapi_wopi_office'] = null; // Kolab WOPI service URL. Enables use of collaborative editor supporting WOPI. // Note: this URL should be accessible from Chwala host and Office host as well. $config['fileapi_wopi_service'] = null; // Name of the user interface skin. $config['file_api_skin'] = 'default'; // Chwala UI communicates with Chwala API via HTTP protocol // The URL here is a location of Chwala API service. By default // the UI location is used with addition of /api/ suffix. $config['file_api_url'] = ''; // Type of Chwala cache. Supported values: 'db', 'apc' and 'memcache'. // Note: This is only for some additional data like WOPI capabilities. $config['fileapi_cache'] = 'db'; // lifetime of Chwala cache // possible units: s, m, h, d, w $config['fileapi_cache_ttl'] = '1d'; // ------------------------------------------------ // SeaFile driver settings // ------------------------------------------------ // Enables SeaFile Web API conversation log $config['fileapi_seafile_debug'] = true; // Enables caching of some SeaFile information e.g. folders list // Note: 'db', 'apc' and 'memcache' are supported $config['fileapi_seafile_cache'] = 'db'; // Expiration time of SeaFile cache entries $config['fileapi_seafile_cache_ttl'] = '7d'; // Default SeaFile Web API host // Note: http:// and https:// (default) prefixes can be used here $config['fileapi_seafile_host'] = 'localhost'; // Enables SSL certificates validation when connecting // with any SeaFile server $config['fileapi_seafile_ssl_verify_host'] = false; $config['fileapi_seafile_ssl_verify_peer'] = false; // ------------------------------------------------ // WebDAV driver settings // ------------------------------------------------ // Default URI location for WebDAV storage $config['fileapi_webdav_baseuri'] = 'https://localhost/iRony'; diff --git a/lib/api/folder_types.php b/lib/api/folder_types.php index c57a0ac..58c996e 100644 --- a/lib/api/folder_types.php +++ b/lib/api/folder_types.php @@ -1,58 +1,61 @@ | +--------------------------------------------------------------------------+ | Author: Aleksander Machniak | +--------------------------------------------------------------------------+ */ class file_api_folder_types extends file_api_common { /** * Request handler */ public function handle() { parent::handle(); $drivers = $this->rc->config->get('fileapi_drivers'); + $presets = (array) $this->rc->config->get('fileapi_presets'); $result = array(); if (!empty($drivers)) { foreach ((array) $drivers as $driver_name) { if ($driver_name != 'kolab' && !isset($result[$driver_name])) { $driver = $this->api->load_driver_object($driver_name); $meta = $driver->driver_metadata(); + $meta = $this->parse_metadata($meta); - $result[$driver_name] = $this->parse_metadata($meta); + if (!empty($presets[$driver_name]) && empty($meta['form_values'])) { + $meta['form_values'] = (array) $presets[$driver_name]; + $user = $this->rc->get_user_name(); + + foreach ($meta['form_values'] as $key => $val) { + $meta['form_values'][$key] = str_replace('%u', $user, $val); + } + } + + $result[$driver_name] = $meta; } } } -/* - // add local storage to the list - if (!empty($result)) { - $backend = $this->api->get_backend(); - $meta = $backend->driver_metadata(); - $result = array_merge(array('default' => $this->parse_metadata($meta, true)), $result); - } -*/ return $result; } }