Compare commits
No commits in common. "19cce2c90d11d3ea1bc3e9287678fc83b97bff32" and "45ca1c4c48abf6309a5fbfefd3335c9f7330d362" have entirely different histories.
19cce2c90d
...
45ca1c4c48
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"auth": {
|
||||
"kind": "basic",
|
||||
"data": null
|
||||
},
|
||||
"source": {
|
||||
"kind": "ics_feed",
|
||||
"data": {
|
||||
"url": "http://{{username}}:{{password}}@localhost:7845/export/ics",
|
||||
"combine": true
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"timezone": "UTC"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace davigil;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
class _state
|
||||
{
|
||||
public static $parameters = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function set_parameters(
|
||||
$parameters
|
||||
) : void
|
||||
{
|
||||
_state::$parameters = $parameters;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
function get_parameters(
|
||||
)
|
||||
{
|
||||
return _state::$parameters;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
namespace davigil;
|
||||
|
||||
require_once('vendor/autoload.php');
|
||||
require_once('base.php');
|
||||
require_once('overwrites/principal_backend.php');
|
||||
require_once('overwrites/auths/_factory.php');
|
||||
require_once('overwrites/caldav_backend.php');
|
||||
|
|
@ -16,8 +15,6 @@ function main(
|
|||
{
|
||||
\davigil\conf\load('conf.json');
|
||||
|
||||
\davigil\set_parameters([]);
|
||||
|
||||
\date_default_timezone_set(\davigil\conf\get()->settings->timezone);
|
||||
|
||||
$source = \davigil\sources\make(
|
||||
|
|
@ -52,7 +49,7 @@ function main(
|
|||
/**
|
||||
* this somehow breaks authentication, but seems to be required for calendar discovery
|
||||
*/
|
||||
// $server->addPlugin(new \Sabre\DAVACL\Plugin());
|
||||
$server->addPlugin(new \Sabre\DAVACL\Plugin());
|
||||
$server->addPlugin(new \Sabre\CalDAV\Plugin());
|
||||
$server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
|
||||
$server->addPlugin(new \Sabre\CalDAV\Schedule\Plugin());
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace davigil\overwrites;
|
||||
|
||||
require_once('vendor/autoload.php');
|
||||
require_once('base.php');
|
||||
require_once('sources/_interface.php');
|
||||
|
||||
|
||||
|
|
@ -38,15 +37,12 @@ class class_auth_backend_basic
|
|||
/*string */$password
|
||||
)/* : bool*/
|
||||
{
|
||||
$parameters = [
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
];
|
||||
/**
|
||||
* @todo check for security
|
||||
*/
|
||||
\davigil\set_parameters($parameters);
|
||||
$data = $this->source->get(/*$parameters*/[]);
|
||||
$data = $this->source->get(
|
||||
[
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
]
|
||||
);
|
||||
return ($data !== null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -227,24 +227,24 @@ class class_caldav_backend
|
|||
)
|
||||
{
|
||||
$id = $objectUri;
|
||||
$calendar = $this->source->get([]);
|
||||
$events = \array_values(
|
||||
$data = $this->source->get([]);
|
||||
$entries = \array_values(
|
||||
\array_filter(
|
||||
$calendar->events,
|
||||
fn($event) => ($event->id === $id)
|
||||
$data,
|
||||
fn($entry) => ($entry->id === $id)
|
||||
)
|
||||
);
|
||||
if (\count($events) < 1)
|
||||
if (\count($entries) < 1)
|
||||
{
|
||||
throw (new \Exception(\sprintf('not found: %s', $objectUri)));
|
||||
}
|
||||
else if (\count($events) > 1)
|
||||
else if (\count($entries) > 1)
|
||||
{
|
||||
throw (new \Exception(\sprintf('ambiguous: %s', $objectUri)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$vcalendar = $this->events_to_vcalendar($events);
|
||||
$vcalendar = $this->events_to_vcalendar($entries);
|
||||
$ics = \davigil\helpers\ics\vcalendar_encode($vcalendar);
|
||||
return [
|
||||
'calendardata' => $ics,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ require_once('helpers/string.php');
|
|||
require_once('helpers/cache.php');
|
||||
require_once('helpers/pit.php');
|
||||
require_once('helpers/ics.php');
|
||||
require_once('base.php');
|
||||
require_once('model.php');
|
||||
|
||||
|
||||
|
|
@ -18,7 +17,7 @@ class class_source_ics_feed
|
|||
|
||||
/**
|
||||
*/
|
||||
private string $url_template;
|
||||
private string $url;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -34,12 +33,12 @@ class class_source_ics_feed
|
|||
/**
|
||||
*/
|
||||
public function __construct(
|
||||
string $url_template,
|
||||
string $url,
|
||||
?int $lifetime,
|
||||
bool $combine
|
||||
)
|
||||
{
|
||||
$this->url_template = $url_template;
|
||||
$this->url = $url;
|
||||
$this->lifetime = $lifetime;
|
||||
$this->combine = $combine;
|
||||
$this->cache_file = \davigil\helpers\call\convey(
|
||||
|
|
@ -60,19 +59,6 @@ class class_source_ics_feed
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
private function url(
|
||||
$parameters
|
||||
) : string
|
||||
{
|
||||
return \davigil\helpers\string_\coin(
|
||||
$this->url_template,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
private function vcalendar_to_calendar(
|
||||
|
|
@ -136,13 +122,12 @@ class class_source_ics_feed
|
|||
/**
|
||||
*/
|
||||
private function retrieve(
|
||||
string $url
|
||||
)
|
||||
{
|
||||
$client = new \Sabre\HTTP\Client();
|
||||
$request = new \Sabre\HTTP\Request(
|
||||
'GET',
|
||||
$url,
|
||||
$this->url,
|
||||
[],
|
||||
null
|
||||
);
|
||||
|
|
@ -182,11 +167,8 @@ class class_source_ics_feed
|
|||
array $parameters
|
||||
) : \davigil\model\struct_calendar
|
||||
{
|
||||
$url = $this->url(\davigil\get_parameters());
|
||||
$key = $url;
|
||||
$f1 = fn() => $this->retrieve(
|
||||
$url
|
||||
);
|
||||
$key = $this->url;
|
||||
$f1 = fn() => $this->retrieve();
|
||||
$f2 = fn() => \davigil\helpers\cache\get(
|
||||
$this->cache_file,
|
||||
$key,
|
||||
|
|
|
|||
Loading…
Reference in a new issue