appify cdav stuff. WARNING: if you use caldav or carddav from a client or the webinterface you will need to enable those apps to make things work again

This commit is contained in:
Mario Vavti 2018-09-15 10:10:43 +02:00
parent ab611e9ef3
commit 7856f5882b

View File

@ -1,6 +1,9 @@
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Lib\Apps;
require_once('include/event.php');
require_once('include/auth.php');
@ -126,8 +129,18 @@ class Cdav extends \Zotlabs\Web\Controller {
$auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . 'CalDAV/CardDAV');
if (local_channel()) {
logger('loggedin');
$channel = \App::get_channel();
if((argv(1) == 'calendars') && (!Apps::system_app_installed(local_channel(), 'CalDAV'))) {
killme();
}
if((argv(1) == 'addressbooks') && (!Apps::system_app_installed(local_channel(), 'CardDAV'))) {
killme();
}
$channel = App::get_channel();
$auth->setCurrentUser($channel['channel_address']);
$auth->channel_id = $channel['channel_id'];
$auth->channel_hash = $channel['channel_hash'];
@ -161,12 +174,15 @@ class Cdav extends \Zotlabs\Web\Controller {
$nodes = [
// /principals
new \Sabre\CalDAV\Principal\Collection($principalBackend),
// /calendars
new \Sabre\CalDAV\CalendarRoot($principalBackend, $caldavBackend),
// /addressbook
new \Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend),
new \Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend)
];
// The object tree needs in turn to be passed to the server class
$server = new \Sabre\DAV\Server($nodes);
@ -204,7 +220,15 @@ class Cdav extends \Zotlabs\Web\Controller {
if(! local_channel())
return;
$channel = \App::get_channel();
if((argv(1) === 'calendar') && (! Apps::system_app_installed(local_channel(), 'CalDAV'))) {
return;
}
if((argv(1) === 'addressbook') && (! Apps::system_app_installed(local_channel(), 'CardDAV'))) {
return;
}
$channel = App::get_channel();
$principalUri = 'principals/' . $channel['channel_address'];
if(!cdav_principal($principalUri))
@ -807,7 +831,25 @@ class Cdav extends \Zotlabs\Web\Controller {
if(!local_channel())
return;
$channel = \App::get_channel();
if((argv(1) === 'calendar') && (! Apps::system_app_installed(local_channel(), 'CalDAV'))) {
//Do not display any associated widgets at this point
App::$pdl = '';
$o = '<b>CalDAV App (Not Installed):</b><br>';
$o .= t('CalDAV capable calendar');
return $o;
}
if((argv(1) === 'addressbook') && (! Apps::system_app_installed(local_channel(), 'CardDAV'))) {
//Do not display any associated widgets at this point
App::$pdl = '';
$o = '<b>CardDAV App (Not Installed):</b><br>';
$o .= t('CalDAV capable addressbook');
return $o;
}
$channel = App::get_channel();
$principalUri = 'principals/' . $channel['channel_address'];
$pdo = \DBA::$dba->db;
@ -874,7 +916,7 @@ class Cdav extends \Zotlabs\Web\Controller {
$o .= replace_macros(get_markup_template('cdav_calendar.tpl'), [
'$sources' => $sources,
'$color' => $color,
'$lang' => \App::$language,
'$lang' => App::$language,
'$first_day' => $first_day,
'$prev' => t('Previous'),
'$next' => t('Next'),