<?php
+$a = get_app();
+$uri = parse_url($a->get_baseurl());
+$path = "";
+if (strlen($uri["path"]) > 1) {
+ $path = $uri["path"] . "/";
+}
+
define("CALDAV_SQL_DB", "");
define("CALDAV_SQL_PREFIX", "dav_");
-define("CALDAV_URL_PREFIX", "dav/");
+define("CALDAV_URL_PREFIX", $path . "dav/");
define("CALDAV_NAMESPACE_PRIVATE", 1);
define("CALDAV_NAMESPACE_FRIENDICA_NATIVE", 2);
/**
*
*/
-function wdcal_print_feed()
+function wdcal_print_feed($base_path = "")
{
$user_id = dav_compat_get_curr_user_id();
$cals = array();
$ret['error'] = null;
foreach ($cals as $c) {
- $events = $c->listItemsByRange($date[0], $date[1]);
+ $events = $c->listItemsByRange($date[0], $date[1], $base_path);
$ret["events"] = array_merge($ret["events"], $events);
}
* @abstract
* @param string $sd
* @param string $ed
+ * @param string $base_path
* @return array
*/
- public abstract function listItemsByRange($sd, $ed);
+ public abstract function listItemsByRange($sd, $ed, $base_path);
/**
return null;
}
-}
\ No newline at end of file
+}
return $obj_id . ".ics";
}
- private function jqcal2wdcal($row, $usr_id) {
+ private function jqcal2wdcal($row, $usr_id, $base_path) {
$evo = new DBClass_friendica_jqcalendar($row);
$not = q("SELECT COUNT(*) num FROM %s%snotifications WHERE `ical_uri` = '%s' AND `ical_recurr_uri` = '%s'",
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($row["ical_uri"]), $row["ical_recurr_uri"]
"location" => $evo->Location,
"attendees" => '',
"has_notification" => ($not[0]["num"] > 0 ? 1 : 0),
- "url_detail" => "/dav/wdcal/" . $evo->ical_uri . "/",
- "url_edit" => "/dav/wdcal/" . $evo->ical_uri . "/edit/",
+ "url_detail" => $base_path . $evo->ical_uri . "/",
+ "url_edit" => $base_path . $evo->ical_uri . "/edit/",
"special_type" => "",
);
return $arr;
/**
* @param string $sd
* @param string $ed
+ * @param string $base_path
* @return array
*/
- public function listItemsByRange($sd, $ed)
+ public function listItemsByRange($sd, $ed, $base_path)
{
$usr_id = IntVal($this->calendarDb->uid);
$usr_id, $this->getNamespace(), $this->namespace_id, dbesc($von), dbesc($bis));
$events = array();
- foreach ($evs as $row) $events[] = $this->jqcal2wdcal($row, $usr_id);
+ foreach ($evs as $row) $events[] = $this->jqcal2wdcal($row, $usr_id, $base_path);
return $events;
}
$x .= '<label style="margin-left: 10px; margin-right: 10px;"><input type="checkbox" name="cals[]" value="' . $cal["ns"] . '-' . $cal["id"] . '"';
$found = false;
foreach ($calendar_preselected as $pre) if ($pre["ns"] == $cal["ns"] && $pre["id"] == $cal["id"]) $found = true;
- if ($found) $x .= 'checked';
+ if ($found) $x .= ' checked';
$x .= '> ' . escape_tags($cal["displayname"]) . '</label> ';
}
$x .= '<div class="ctoolbar">
<div class="fbutton faddbtn" style="float: right;">
- <div><a href="/dav/settings/"><span>' . t("Settings") . ' / ' . t("Help") . '</span></a></div>
+ <div><a href="' . $a->get_baseurl() . '/dav/settings/"><span>' . t("Settings") . ' / ' . t("Help") . '</span></a></div>
</div>
<div class="btnseparator"></div>
<div class="fbutton showtodaybtn">
$details = $cs->getItemByUri($uri);
} catch (Exception $e) {
notification(t("Error") . ": " . $e);
- goaway("/dav/wdcal/");
+ goaway($a->get_baseurl() . "/dav/wdcal/");
}
}
$a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
- check_form_security_token_redirectOnErr("/dav/wdcal/", "caledit");
+ check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit");
if (isset($_REQUEST["allday"])) {
$start = $localization->date_parseLocal($_REQUEST["start_date"] . " 00:00");
} catch (Exception $e) {
notification(t("Error") . ": " . $e);
}
- goaway("/dav/wdcal/");
+ goaway($a->get_baseurl() . "/dav/wdcal/");
}
}
}
- $out = "<a href='/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
- $out .= "<form method='POST' action='/dav/wdcal/$uri/edit/'><input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n";
+ $out = "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
+ $out .= "<form method='POST' action='" . $a->get_baseurl() . "/dav/wdcal/$uri/edit/'><input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n";
$out .= "<label for='cal_subject'>Subject:</label>
<input name='color' id='cal_color' value='" . (strlen($event["Color"]) != 7 ? "#5858ff" : escape_tags($event["Color"])) . "'>
}
if (isset($_REQUEST["save"])) {
- check_form_security_token_redirectOnErr('/dav/settings/', 'calprop');
+ 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 .= "<a href='/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
+ $o .= "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
$o .= '<h3>' . t('Calendar Settings') . '</h3>';
$current_format = wdcal_local::getInstanceByUser($a->user["uid"]);
- $o .= '<form method="POST" action="/dav/settings/">';
+ $o .= '<form method="POST" action="' . $a->get_baseurl() . '/dav/settings/">';
$o .= "<input type='hidden' name='form_security_token' value='" . get_form_security_token('calprop') . "'>\n";
$o .= '<label for="wdcal_date_format">' . t('Date format') . ':</label><select name="wdcal_date_format" id="wdcal_date_format" size="1">';
<li>Add a new account</li>
<li>Other...</li>
<li>Calendar -> CalDAV-Account</li>
- <li><b>Server:</b> " . $a->get_hostname() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>
+ <li><b>Server:</b> " . $a->get_baseurl() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>
</ul>";
$o .= '<h4>' . t('Synchronizing your Friendica-Contacts with the iPhone') . '</h4>';
<li>Add a new account</li>
<li>Other...</li>
<li>Contacts -> CardDAV-Account</li>
- <li><b>Server:</b> " . $a->get_hostname() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>
+ <li><b>Server:</b> " . $a->get_baseurl() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>
</ul>";
return $o;
function dav_init(&$a)
{
- error_reporting(E_ALL);
- ini_set("display_errors", 1);
-
/*
* Recommended settings:
* ALTER TABLE `photo` ADD INDEX ( `contact-id` )
if ($a->argc >= 2 && $a->argv[1] == "wdcal") {
if ($a->argc >= 3 && $a->argv[2] == "feed") {
- wdcal_print_feed();
+ wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/");
killme();
} elseif ($a->argc >= 3 && strlen($a->argv[2]) > 0) {
wdcal_addRequiredHeadersEdit();
// The object tree needs in turn to be passed to the server class
$server = new Sabre_DAV_Server($tree);
- $server->setBaseUri("/" . CALDAV_URL_PREFIX);
+ $url = parse_url($a->get_baseurl());
+ $server->setBaseUri(CALDAV_URL_PREFIX);
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV');
$server->addPlugin($authPlugin);
$cals = dav_getMyCals($a->user["uid"]);
$cals_show = array();
foreach ($cals as $e) $cals_show[] = array("ns" => $e->namespace, "id" => $e->namespace_id, "displayname" => $e->displayname);
- $x = wdcal_printCalendar($cals, $cals_show, "/dav/wdcal/feed/", "week", 0, 200);
+ $x = wdcal_printCalendar($cals, $cals_show, $a->get_baseurl() . "/dav/wdcal/feed/", "week", 0, 200);
}
}
return $x;
{
$b["tabs"][] = array(
"label" => t('Calendar'),
- "url" => "/dav/wdcal/",
+ "url" => $a->get_baseurl() . "/dav/wdcal/",
"sel" => "",
"title" => t('Extended calendar with CalDAV-support'),
);
$tables = dav_get_create_statements();
foreach ($tables as $t) $o .= escape_tags($t . "\n\n");
$o .= "</pre></blockquote>";
-}
\ No newline at end of file
+}
position: absolute; visibility: hidden; font-size: 9pt; top: 0px; left: 0px\r
}\r
.bubble-table {\r
- width: 100%; TABLE-LAYOUT: fixed\r
+ width: 100%; TABLE-LAYOUT: fixed;\r
+ border-spacing: 0;\r
}\r
+.bubble-table > tbody > tr > td { padding: 0; }\r
.bubble-cell-side {\r
width: 25px\r
}\r
.monthdayshow:hover\r
{\r
text-decoration:underline;\r
-}
\ No newline at end of file
+}\r
$end = wdcal_mySql2PhpTime($row["data_end"]);
if ($row["data_allday"]) $end--;
$start = wdcal_mySql2PhpTime($row["data_start"]);
+ $a = get_app();
$arr = array(
"uri" => $row["data_uri"],
"subject" => escape_tags($row["data_subject"]),
"location" => $row["data_location"],
"attendees" => '',
"has_notification" => false,
- "url_detail" => "/dav/wdcal/" . $row["data_uri"] . "/",
+ "url_detail" => $a->get_baseurl() . "/dav/wdcal/" . $row["data_uri"] . "/",
"url_edit" => "",
"special_type" => ($row["data_type"] == "birthday" ? "birthday" : ""),
);
/**
* @param string $sd
* @param string $ed
+ * @param string $base_path
* @return array
*/
- public function listItemsByRange($sd, $ed)
+ public function listItemsByRange($sd, $ed, $base_path)
{
$usr_id = IntVal($this->calendarDb->uid);
public function getItemDetailRedirect($uri) {
$x = explode("@", $uri);
$y = explode("-", $x[0]);
+ $a = get_app();
if (count($y) != 3) {
- goaway("/dav/wdcal/");
+ goaway($a->get_baseurl() . "/dav/wdcal/");
killme();
}
$a = get_app();