page['htmlhead'] .= ' ' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
$a->page['htmlhead'] .= ' ' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
$a->page['htmlhead'] .= ' ' . "\r\n";
$a->page['htmlhead'] .= ' ' . "\r\n";
switch (get_config("system", "language")) {
case "de":
$a->page['htmlhead'] .= '' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
break;
default:
$a->page['htmlhead'] .= '' . "\r\n";
}
$a->page['htmlhead'] .= '' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
}
/**
*
*/
function wdcal_addRequiredHeadersEdit()
{
$a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
$a->page['htmlhead'] .= ' ' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
$a->page['htmlhead'] .= ' ' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
$a->page['htmlhead'] .= ' ' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
$a->page['htmlhead'] .= ' ' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
switch ($localization->getLanguageCode()) {
case "de":
$a->page['htmlhead'] .= '' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
break;
default:
$a->page['htmlhead'] .= '' . "\r\n";
}
}
/**
* @param array|int[] $calendars
*/
function wdcal_print_user_ics($calendars = array())
{
$add = "";
if (count($calendars) > 0) {
$c = array();
foreach ($calendars as $i) $c[] = IntVal($i);
$add = " AND `id` IN (" . implode(", ", $c) . ")";
}
$a = get_app();
header("Content-type: text/plain");
$str = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Friendica//DAV-Plugin//EN\r\n";
$cals = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d %s", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, $a->user["uid"], $add);
if (count($cals) > 0) {
$ids = array();
foreach ($cals as $c) $ids[] = IntVal($c["id"]);
$objs = q("SELECT * FROM %s%scalendarobjects WHERE `calendar_id` IN (" . implode(", ", $ids) . ") ORDER BY `firstOccurence`", CALDAV_SQL_DB, CALDAV_SQL_PREFIX);
foreach ($objs as $obj) {
preg_match("/BEGIN:VEVENT(.*)END:VEVENT/siu", $obj["calendardata"], $matches);
$str2 = preg_replace("/([^\\r])\\n/siu", "\\1\r\n", $matches[0]);
$str2 = preg_replace("/MAILTO:.*[^:a-z0-9_\+äöüß\\n\\n@-]+.*(:|\\r\\n[^ ])/siU", "\\1", $str2);
$str .= $str2 . "\r\n";
}
}
$str .= "END:VCALENDAR\r\n";
echo $str;
killme();
}
/**
* @param array|Sabre_CalDAV_Calendar[] $calendars
* @param array|int[] $calendars_selected
* @param string $data_feed_url
* @param string $view
* @param int $theme
* @param int $height_diff
* @param bool $readonly
* @param string $curr_day
* @param array $add_params
* @param bool $show_nav
* @return string
*/
function wdcal_printCalendar($calendars, $calendars_selected, $data_feed_url, $view = "week", $theme = 0, $height_diff = 175, $readonly = false, $curr_day = "", $add_params = array(), $show_nav = true)
{
$a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
if (count($calendars_selected) == 0) foreach ($calendars as $c) {
$prop = $c->getProperties(array("id"));
$calendars_selected[] = $prop["id"];
}
$opts = array(
"view" => $view,
"theme" => $theme,
"readonly" => $readonly,
"height_diff" => $height_diff,
"weekstartday" => $localization->getFirstDayOfWeek(),
"data_feed_url" => $data_feed_url,
"date_format_dm1" => $localization->dateformat_js_dm1(),
"date_format_dm2" => $localization->dateformat_js_dm2(),
"date_format_dm3" => $localization->dateformat_js_dm3(),
"date_format_full" => $localization->dateformat_datepicker_js(),
"baseurl" => $a->get_baseurl() . "/dav/wdcal/",
);
$x = '
Available Calendars: ';
foreach ($calendars as $cal) {
$cal_id = $cal->getProperties(array("id", DAV_DISPLAYNAME));
$x .= ' ';
}
$x .= '
Sorry, could not load your data, please try again later
';
if ($show_nav) {
$x .= '
' . t("Date") . '
';
}
$x .= '
';
return $x;
}
/**
* @param int $calendar_id
* @param int $calendarobject_id
* @param string $recurr_uri
* @return string
*/
function wdcal_getDetailPage($calendar_id, $calendarobject_id, $recurr_uri)
{
$a = get_app();
try {
$details = null;
$server = dav_create_server(true, true, false);
$cal = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_READ);
$obj = Sabre_CalDAV_Backend_Common::loadCalendarobjectById($calendarobject_id);
dav_get_current_user_calendarobject($server, $cal, $obj["uri"], DAV_ACL_READ); // Check permissions
$calbackend = wdcal_calendar_factory_by_id($calendar_id);
$redirect = $calbackend->getItemDetailRedirect($calendar_id, $calendarobject_id);
if ($redirect !== null) goaway($a->get_baseurl() . $redirect);
$details = $obj;
} catch (Exception $e) {
info(t("Error") . ": " . $e);
goaway($a->get_baseurl() . "/dav/wdcal/");
}
return print_r($details, true);
}
/**
* @param int $calendar_id
* @param int $uri
* @param string $recurr_uri
* @return string
*/
function wdcal_getEditPage($calendar_id, $uri, $recurr_uri = "")
{
$a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
return wdcal_getEditPage_str($localization, $a->get_baseurl(), $a->user["uid"], $calendar_id, $uri, $recurr_uri);
}
function wdcal_getNewPage()
{
$a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
return wdcal_getEditPage_str($localization, $a->get_baseurl(), $a->user["uid"], 0, 0);
}
/**
* @param App $a
* @return string
*/
function wdcal_getSettingsPage(&$a)
{
if (!local_user()) {
notice(t('Permission denied.') . EOL);
return '';
}
if (isset($_REQUEST["save"])) {
check_form_security_token_redirectOnErr($a->get_baseurl() . '/dav/settings/', 'calprop');
set_pconfig($a->user["uid"], "dav", "dateformat", $_REQUEST["wdcal_date_format"]);
info(t('The new values have been saved.'));
}
$o = "";
$o .= "" . t("Go back to the calendar") . " ";
$o .= '' . t('Calendar Settings') . ' ';
$current_format = wdcal_local::getInstanceByUser($a->user["uid"]);
$o .= '';
$o .= "" . t("Limitations") . " ";
$o .= "- The native friendica events are embedded as read-only, half-transparent in the calendar. ";
$o .= "" . t("Warning") . " ";
$o .= "This plugin still is in a very early stage of development. Expect major bugs! ";
$o .= "" . t("Synchronization (iPhone, Thunderbird Lightning, Android, ...)") . " ";
$o .= 'This plugin enables synchronization of your dates and contacts with CalDAV- and CardDAV-enabled programs or devices.
As an example, the instructions how to set up two-way synchronization with an iPhone/iPodTouch are provided below.
Unfortunately, Android does not have native support for CalDAV or CardDAV, so an app has to be installed.
On desktops, the Lightning-extension to Mozilla Thunderbird should be able to use this plugin as a backend. ';
$o .= '' . t('Synchronizing this calendar with the iPhone') . ' ';
$o .= "
Go to the settings
Mail, contacts, settings
Add a new account
Other...
Calendar -> CalDAV-Account
Server: " . $a->get_baseurl() . "/dav/ / Username/Password: the same as your friendica-login
";
$o .= '' . t('Synchronizing your Friendica-Contacts with the iPhone') . ' ';
$o .= "
Go to the settings
Mail, contacts, settings
Add a new account
Other...
Contacts -> CardDAV-Account
Server: " . $a->get_baseurl() . "/dav/ / Username/Password: the same as your friendica-login
";
return $o;
}