From 7856f5882bceaf83d5df42e117c23badc89ad1a8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 15 Sep 2018 10:10:43 +0200 Subject: 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 --- Zotlabs/Module/Cdav.php | 52 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index 6737ac4ee..69030b582 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -1,6 +1,9 @@ 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 = 'CalDAV App (Not Installed):
'; + $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 = 'CardDAV App (Not Installed):
'; + $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'), -- cgit v1.2.3