Esempio n. 1
0
/**
 * @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 ($a->argc >= 3 && strlen($a->argv[2]) > 0) {
            $uri = $a->argv[2];
            $recurr_uri = "";
            // @TODO
            if (isset($a->argv[3]) && $a->argv[3] == "edit") {
                $o = "";
                if (isset($_REQUEST["save"])) {
                    $o .= wdcal_postEditPage($uri, $recurr_uri);
                }
                $o .= wdcal_getEditPage($uri, $recurr_uri);
                return $o;
            } else {
                return wdcal_getDetailPage($uri, $recurr_uri);
            }
        } else {
            $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, $a->get_baseurl() . "/dav/wdcal/feed/", "week", 0, 200);
        }
    }
    return $x;
}
Esempio n. 2
0
/**
 * @return string
 */
function dav_content()
{
    $a = get_app();
    if (!isset($a->user["uid"]) || $a->user["uid"] == 0) {
        return login();
    }
    $x = "";
    try {
        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] == "new") {
                    $o = "";
                    if (isset($_REQUEST["save"])) {
                        check_form_security_token_redirectOnErr("/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"]);
                        }
                        goaway($a->get_baseurl() . "/dav/wdcal/");
                    }
                    $o .= wdcal_getNewPage();
                    return $o;
                } else {
                    $calendar_id = IntVal($a->argv[2]);
                    if (isset($a->argv[3]) && $a->argv[3] == "ics-export") {
                        wdcal_print_user_ics($calendar_id);
                    } elseif (isset($a->argv[3]) && $a->argv[3] == "ics-import") {
                        return wdcal_import_user_ics($calendar_id);
                    } elseif (isset($a->argv[3]) && $a->argv[3] > 0) {
                        if (isset($a->argv[4]) && $a->argv[4] == "edit") {
                            $o = "";
                            if (isset($_REQUEST["save"])) {
                                check_form_security_token_redirectOnErr("/dav/wdcal/", "caledit");
                                $ret = wdcal_postEditPage($a->argv[3], $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
                                if ($ret["ok"]) {
                                    notice($ret["msg"]);
                                } else {
                                    info($ret["msg"]);
                                }
                                goaway($a->get_baseurl() . "/dav/wdcal/");
                            }
                            $o .= wdcal_getEditPage($calendar_id, $a->argv[3]);
                            return $o;
                        } else {
                            return wdcal_getDetailPage($calendar_id, $a->argv[3]);
                        }
                    } 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);
            }
        }
    } catch (DAVVersionMismatchException $e) {
        $x = t("The current version of this plugin has not been set up correctly. Please contact the system administrator of your installation of friendica to fix this.");
    }
    return $x;
}