argc >= 2 && $a->argv[1] == "wdcal") { if ($a->argc >= 3 && $a->argv[2] == "feed") { wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/"); killme(); } elseif ($a->argc >= 3 && strlen($a->argv[2]) > 0) { wdcal_addRequiredHeadersEdit(); } else { wdcal_addRequiredHeaders(); } return; } if ($a->argc >= 2 && $a->argv[1] == "getExceptionDates") { echo wdcal_getEditPage_exception_selector(); killme(); } if ($a->argc >= 2 && $a->argv[1] == "settings") { return; } if (isset($_REQUEST["test"])) { renderAllCalDavEntries(); } $server = dav_create_server(); $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); $server->exec(); killme(); } /** * @return string */ function dav_content() { $a = get_app(); if (!isset($a->user["uid"]) || $a->user["uid"] == 0) { return login(); } $x = ""; if ($a->argv[1] == "settings") { return wdcal_getSettingsPage($a); } elseif ($a->argv[1] == "wdcal") { if (isset($a->argv[2]) && strlen($a->argv[2]) > 0) { if ($a->argv[2] == "ics") { wdcal_print_user_ics(); } elseif ($a->argv[2] == "new") { $o = ""; if (isset($_REQUEST["save"])) { check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit"); $ret = wdcal_postEditPage("new", "", $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/"); if ($ret["ok"]) notice($ret["msg"]); else info($ret["msg"]); } $o .= wdcal_getNewPage(); return $o; } else { $calendar_id = IntVal($a->argv[2]); if (isset($a->argv[3]) && $a->argv[3] > 0) { $recurr_uri = ""; // @TODO if (isset($a->argv[4]) && $a->argv[4] == "edit") { $o = ""; if (isset($_REQUEST["save"])) { check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit"); $ret = wdcal_postEditPage($a->argv[3], $recurr_uri, $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/"); if ($ret["ok"]) notice($ret["msg"]); else info($ret["msg"]); } $o .= wdcal_getEditPage($calendar_id, $a->argv[3], $recurr_uri); return $o; } else { return wdcal_getDetailPage($calendar_id, $a->argv[3], $recurr_uri); } } else { // @TODO Edit Calendar } } } else { $server = dav_create_server(true, true, false); $cals = dav_get_current_user_calendars($server, DAV_ACL_READ); $x = wdcal_printCalendar($cals, array(), $a->get_baseurl() . "/dav/wdcal/feed/", "week", 0, 200); } } return $x; } /** * @param App $a * @param object $b */ function dav_event_created_hook(&$a, &$b) { dav_include_files(); // @TODO Updating the cache instead of completely invalidating and rebuilding it Sabre_CalDAV_Backend_Friendica::invalidateCache($a->user["uid"], CALDAV_FRIENDICA_CONTACTS); Sabre_CalDAV_Backend_Friendica::invalidateCache($a->user["uid"], CALDAV_FRIENDICA_MINE); } /** * @param App $a * @param object $b */ function dav_event_updated_hook(&$a, &$b) { dav_include_files(); // @TODO Updating the cache instead of completely invalidating and rebuilding it Sabre_CalDAV_Backend_Friendica::invalidateCache($a->user["uid"], CALDAV_FRIENDICA_CONTACTS); Sabre_CalDAV_Backend_Friendica::invalidateCache($a->user["uid"], CALDAV_FRIENDICA_MINE); } /** * @param App $a * @param object $b */ function dav_profile_tabs_hook(&$a, &$b) { $b["tabs"][] = array( "label" => t('Calendar'), "url" => $a->get_baseurl() . "/dav/wdcal/", "sel" => "", "title" => t('Extended calendar with CalDAV-support'), ); } /** * @param App $a * @param null|object $o */ function dav_plugin_admin_post(&$a = null, &$o = null) { check_form_security_token_redirectOnErr('/admin/plugins/dav', 'dav_admin_save'); dav_include_files(); require_once(__DIR__ . "/database-init.inc.php"); if (isset($_REQUEST["install"])) { $errs = dav_create_tables(); if (count($errs) == 0) info(t('The database tables have been installed.') . EOL); else notice(t("An error occurred during the installation.") . EOL); } if (isset($_REQUEST["upgrade"])) { $errs = dav_upgrade_tables(); if (count($errs) == 0) info(t('The database tables have been updated.') . EOL); else notice(t("An error occurred during the update.") . EOL); } } /** * @param App $a * @param string $o */ function dav_plugin_admin(&$a, &$o) { dav_include_files(); require_once(__DIR__ . "/database-init.inc.php"); $dbstatus = dav_check_tables(); $o = ''; $o .= '' . t("No system-wide settings yet.") . '

'; $o .= '

' . t('Database status') . '

'; switch ($dbstatus) { case 0: $o .= t('Installed'); break; case 1: $o .= t('Upgrade needed') . "

"; break; case -1: $o .= t('Not installed') . "

"; break; } $o .= "

"; $o .= "

" . t("Troubleshooting") . "

"; $o .= "

" . t("Manual creation of the database tables:") . "

"; $o .= "" . t("Show SQL-statements") . ""; }