2021-08-25 21:47:18 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Name: WebDAV Storage
|
|
|
|
* Description: Adds the possibility to use WebDAV as a selectable storage backend
|
|
|
|
* Version: 1.0
|
|
|
|
* Author: Philipp Holzer
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Friendica\Addon\webdav_storage\src\WebDav;
|
2021-10-04 09:40:05 +00:00
|
|
|
use Friendica\Addon\webdav_storage\src\WebDavConfig;
|
2021-08-25 21:47:18 +00:00
|
|
|
use Friendica\Core\Hook;
|
|
|
|
use Friendica\DI;
|
|
|
|
|
2024-11-23 08:32:43 +00:00
|
|
|
function webdav_storage_install()
|
2021-08-25 21:47:18 +00:00
|
|
|
{
|
|
|
|
Hook::register('storage_instance' , __FILE__, 'webdav_storage_instance');
|
2021-10-04 09:40:05 +00:00
|
|
|
Hook::register('storage_config' , __FILE__, 'webdav_storage_config');
|
2021-08-25 21:47:18 +00:00
|
|
|
DI::storageManager()->register(WebDav::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
function webdav_storage_uninstall()
|
|
|
|
{
|
2021-10-04 09:40:05 +00:00
|
|
|
DI::storageManager()->unregister(WebDav::class);
|
2021-08-25 21:47:18 +00:00
|
|
|
}
|
|
|
|
|
2023-01-14 02:16:09 +00:00
|
|
|
function webdav_storage_instance(array &$data)
|
2021-08-25 21:47:18 +00:00
|
|
|
{
|
2022-01-07 01:14:24 +00:00
|
|
|
if ($data['name'] == WebDav::getName()) {
|
|
|
|
$config = new WebDavConfig(DI::l10n(), DI::config(), DI::httpClient());
|
|
|
|
$data['storage'] = new WebDav($config->getUrl(), $config->getAuthOptions(), DI::httpClient(), DI::logger());
|
|
|
|
}
|
2021-10-04 09:40:05 +00:00
|
|
|
}
|
|
|
|
|
2023-01-14 02:16:09 +00:00
|
|
|
function webdav_storage_config(array &$data)
|
2021-10-04 09:40:05 +00:00
|
|
|
{
|
2022-01-07 01:14:24 +00:00
|
|
|
if ($data['name'] == WebDav::getName()) {
|
|
|
|
$data['storage_config'] = new WebDavConfig(DI::l10n(), DI::config(), DI::httpClient());
|
|
|
|
}
|
2021-08-25 21:47:18 +00:00
|
|
|
}
|