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"; break;
default: $a->page['htmlhead'] .= '' . "\r\n";
}
$a->page['htmlhead'] .= '' . "\r\n";
$a->page['htmlhead'] .= '' . "\r\n";
}
/**
*
*/
function wdcal_addRequiredHeadersEdit()
{
$a = get_app();
$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";
}
/**
* @param array|DBClass_friendica_calendars[] $calendars
* @param array $calendar_preselected
* @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, $calendar_preselected, $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"]);
$cals_avail = array();
foreach ($calendars as $c) $cals_avail[] = array("ns" => $c->namespace, "id" => $c->namespace_id, "displayname" => $c->displayname);
$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(),
);
$x = '
Available Calendars: ';
foreach ($cals_avail as $cal) {
$x .= ' ';
}
$x .= '
Sorry, could not load your data, please try again later
';
if ($show_nav) {
$x .= '
' . t("Date") . '
';
}
$x .= '
';
return $x;
}
/**
* @param string $uri
* @param string $recurr_uri
* @return string
*/
function wdcal_getDetailPage($uri, $recurr_uri)
{
$a = get_app();
$details = null;
$cals = dav_getMyCals($a->user["uid"]);
foreach ($cals as $c) {
$cs = wdcal_calendar_factory($a->user["uid"], $c->namespace, $c->namespace_id);
$p = $cs->getPermissionsItem($a->user["uid"], $uri, $recurr_uri);
if ($p["read"]) try {
$redirect = $cs->getItemDetailRedirect($uri);
if ($redirect !== null) goaway($redirect);
$details = $cs->getItemByUri($uri);
} catch (Exception $e) {
notification(t("Error") . ": " . $e);
goaway("/dav/wdcal/");
}
}
return $uri . " / " . $recurr_uri . " " . print_r($details, true);
}
/**
* @param string $uri
* @param string $recurr_uri
* @return string
*/
function wdcal_postEditPage($uri, $recurr_uri)
{
$a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
check_form_security_token_redirectOnErr("/dav/wdcal/", "caledit");
if (isset($_REQUEST["allday"])) {
$start = $localization->date_parseLocal($_REQUEST["start_date"] . " 00:00");
$end = $localization->date_parseLocal($_REQUEST["end_date"] . " 20:00");
$isallday = true;
} else {
$start = $localization->date_parseLocal($_REQUEST["start_date"] . " " . $_REQUEST["start_time"]);
$end = $localization->date_parseLocal($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]);
$isallday = false;
}
$cals = dav_getMyCals($a->user["uid"]);
foreach ($cals as $c) {
$cs = wdcal_calendar_factory($a->user["uid"], $c->namespace, $c->namespace_id);
$p = $cs->getPermissionsItem($a->user["uid"], $uri, $recurr_uri);
if ($p["write"]) try {
$cs->updateItem($uri, $start, $end,
stripslashes($_REQUEST["subject"]), $isallday, wdcal_parse_text_serverside($_REQUEST["wdcal_desc"]),
stripslashes($_REQUEST["location"]), $_REQUEST["color"], $a->timezone,
isset($_REQUEST["notification"]), $_REQUEST["notification_type"], $_REQUEST["notification_value"]);
} catch (Exception $e) {
notification(t("Error") . ": " . $e);
}
goaway("/dav/wdcal/");
}
}
/**
* @param string $uri
* @param string $recurr_uri
* @return string
*/
function wdcal_getEditPage($uri, $recurr_uri)
{
$a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
if ($uri != "" && $uri != "new") {
$o = q("SELECT * FROM %s%sjqcalendar WHERE `uid` = %d AND `ical_uri` = '%s' AND `ical_recurr_uri` = '%s'",
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $a->user["uid"], dbesc($uri), dbesc($recurr_uri)
);
if (count($o) != 1) return t('Not found');
$event = $o[0];
$calendarSource = wdcal_calendar_factory($a->user["uid"], $event["namespace"], $event["namespace_id"]);
$permissions = $calendarSource->getPermissionsItem($a->user["uid"], $uri, $recurr_uri, $event);
if (!$permissions["write"]) return t('No access');
$n = q("SELECT * FROM %s%snotifications WHERE `uid` = %d AND `ical_uri` = '%s' AND `ical_recurr_uri` = '%s'",
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $a->user["uid"], dbesc($uri), dbesc($recurr_uri)
);
if (count($n) > 0) {
$notification_type = $n[0]["rel_type"];
$notification_value = -1 * $n[0]["rel_value"];
$notification = true;
} else {
if ($event["IsAllDayEvent"]) {
$notification_type = "hour";
$notification_value = 24;
} else {
$notification_type = "minute";
$notification_value = 60;
}
$notification = false;
}
} elseif (isset($_REQUEST["start"]) && $_REQUEST["start"] > 0) {
$event = array(
"id" => 0,
"Subject" => $_REQUEST["title"],
"Location" => "",
"Description" => "",
"StartTime" => $_REQUEST["start"],
"EndTime" => $_REQUEST["end"],
"IsAllDayEvent" => $_REQUEST["isallday"],
"Color" => null,
"RecurringRule" => null,
);
if ($_REQUEST["isallday"]) {
$notification_type = "hour";
$notification_value = 24;
} else {
$notification_type = "hour";
$notification_value = 1;
}
$notification = true;
} else {
$event = array(
"id" => 0,
"Subject" => "",
"Location" => "",
"Description" => "",
"StartTime" => "",
"EndTime" => "",
"IsAllDayEvent" => "",
"Color" => null,
"RecurringRule" => null,
);
$notification_type = "hour";
$notification_value = 1;
$notification = true;
}
$out = "" . t("Go back to the calendar") . " ";
$out .= "";
return $out;
}
/**
* @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('/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 .= " \n";
$o .= '' . t('Date format') . ': ';
$classes = wdcal_local::getInstanceClasses();
foreach ($classes as $c) {
$o .= '';
}
$o .= ' ';
$o .= '' . t('Time zone') . ': ';
$o .= ' ';
$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_hostname() . "/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_hostname() . "/dav/ / Username/Password: the same as your friendica-login
";
return $o;
}