/**
 * Return an CT file for download
 */
function churchcore__filedownload()
{
    global $files_dir;
    include_once CHURCHCORE . "/churchcore_db.php";
    $mime_types = getMimeTypes();
    $file = db_query("select * from {cc_file} f where f.id=:id and filename=:filename", array(":id" => $_GET["id"], ":filename" => $_GET["filename"]))->fetch();
    $filename = "{$files_dir}/files/{$file->domain_type}/{$file->domain_id}/{$file->filename}";
    $handle = fopen($filename, "rb");
    if ($handle == false) {
        echo "Die Datei konnte nicht gefunden werden!";
    } else {
        $contents = fread($handle, filesize($filename));
        fclose($handle);
        if (isset($mime_types[substr(strrchr($filename, '.'), 1)])) {
            drupal_add_http_header('Content-Type', $mime_types[substr(strrchr($filename, '.'), 1)], false);
        } else {
            drupal_add_http_header('Content-Type', 'application/unknown', false);
        }
        if (isset($_GET["type"]) && $_GET["type"] == "download") {
            drupal_add_http_header('Content-Disposition', 'attachment;filename="' . $file->bezeichnung . '"', false);
        } else {
            drupal_add_http_header('Content-Disposition', 'inline;filename="' . $file->bezeichnung . '"', false);
        }
        drupal_add_http_header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', false);
        drupal_add_http_header('Cache-Control', 'private', true);
        $content = drupal_get_header();
        echo $contents;
    }
}
function churchcal__ical()
{
    global $base_url, $config;
    include_once CHURCHCAL . "/churchcal_db.php";
    drupal_add_http_header('Content-Type', 'text/calendar;charset=utf-8', false);
    drupal_add_http_header('Content-Disposition', 'inline;filename="ChurchTools.ics"', false);
    drupal_add_http_header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', false);
    drupal_add_http_header('Cache-Control', 'private', true);
    $content = drupal_get_header();
    $cat_names = null;
    if (isset($_GET["security"]) && isset($_GET["id"])) {
        $db = db_query("select * from {cc_calcategory} where id=:id and randomurl=:randomurl", array(":id" => $_GET["id"], ":randomurl" => $_GET["security"]))->fetch();
        if ($db != false) {
            $cat_names[$_GET["id"]] = new stdClass();
            $cat_names[$_GET["id"]]->bezeichnung = $db->bezeichnung;
            $cats = array(0 => $_GET["id"]);
        }
    }
    if ($cat_names == null) {
        $cats = churchcal_getAllowedCategories(false, true);
        $cat_names = churchcal_getAllowedCategories(false, false);
    }
    $arr = churchcal_getCalPerCategory(array("category_ids" => $cats), false);
    $txt = "";
    foreach ($arr as $cats) {
        foreach ($cats as $res) {
            $res->startdate = new DateTime($res->startdate);
            $res->enddate = new DateTime($res->enddate);
            $diff = $res->enddate->format("U") - $res->startdate->format("U");
            $subid = 0;
            foreach (getAllDatesWithRepeats($res, -90, 400) as $d) {
                $txt .= "BEGIN:VEVENT\r\n";
                $txt .= "ORGANIZER:MAILTO:" . variable_get('site_mail', '') . "\r\n";
                $txt .= "SUMMARY:" . $res->bezeichnung . "\r\n";
                //$txt.="X-MICROSOFT-CDO-BUSYSTATUS:BUSY\r\n";
                if ($res->link != "") {
                    $txt .= "URL:" . $res->link . "\r\n";
                } else {
                    $txt .= "URL:" . $base_url . "?q=churchcal\r\n";
                }
                if ($res->ort != "") {
                    $txt .= "LOCATION:" . $res->ort . "\r\n";
                }
                $subid++;
                $txt .= "UID:" . $res->id . "_{$subid}\r\n";
                $txt .= "DTSTAMP:" . churchcore_stringToDateICal($res->modified_date) . "\r\n";
                $ts = $diff + $d->format("U");
                //$enddate=new DateTime("@$ts");
                $enddate = clone $d;
                $enddate->modify("+{$diff} seconds");
                // Ganztagestermin
                if ($res->startdate->format('His') == "000000" && $res->enddate->format('His') == "000000") {
                    $txt .= "DTSTART;VALUE=DATE:" . $d->format('Ymd') . "\r\n";
                    $txt .= "DTEND;VALUE=DATE:" . date('Ymd', strtotime('+1 day', $enddate->format("U"))) . "\r\n";
                } else {
                    $txt .= "DTSTART:" . $d->format('Ymd\\THis') . "\r\n";
                    $txt .= "DTEND:" . $enddate->format('Ymd\\THis') . "\r\n";
                }
                $txt .= 'DESCRIPTION:Kalender:' . $cat_names[$res->category_id]->bezeichnung . ' - Cal[' . $res->id . '] - ' . $res->notizen . "\r\n";
                $txt .= "END:VEVENT\r\n";
            }
        }
    }
    echo surroundWithVCALENDER($txt);
}
示例#3
0
/**
 * use template for calendar entries, include text added by surroundWithVCALENDER
 */
function churchcal__ical()
{
    global $base_url, $config;
    include_once CHURCHCAL . "/churchcal_db.php";
    drupal_add_http_header('Content-Type', 'text/calendar;charset=utf-8', false);
    drupal_add_http_header('Content-Disposition', 'inline;filename="ChurchTools.ics"', false);
    drupal_add_http_header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', false);
    drupal_add_http_header('Cache-Control', 'private', true);
    $content = drupal_get_header();
    $catNames = null;
    if (($security = getVar("security")) && ($id = getVar("id"))) {
        $db = db_query("SELECT * FROM {cc_calcategory}\n                    WHERE id=:id AND randomurl=:randomurl", array(":id" => $id, ":randomurl" => $security))->fetch();
        if ($db) {
            $catNames[$id] = new stdClass();
            $catNames[$id]->bezeichnung = $db->bezeichnung;
            $cats = array(0 => $id);
        }
    }
    if (!$catNames) {
        $cats = churchcal_getAllowedCategories(false, true);
        $catNames = churchcal_getAllowedCategories(false, false);
    }
    $arr = churchcal_getCalPerCategory(array("category_ids" => $cats), false);
    $txt = "";
    foreach ($arr as $cats) {
        foreach ($cats as $res) {
            $res->startdate = new DateTime($res->startdate);
            $res->enddate = new DateTime($res->enddate);
            $diff = $res->enddate->format("U") - $res->startdate->format("U");
            // TODO: use DateTime function like next line?
            //     $diff = $res->enddate->diff($res->startdate);
            $subid = 0;
            foreach (getAllDatesWithRepeats($res, -90, 730) as $d) {
                $txt .= "BEGIN:VEVENT" . NL;
                $txt .= "ORGANIZER:MAILTO:" . getConf('site_mail', '') . NL;
                $txt .= "SUMMARY:" . $res->bezeichnung . NL;
                //$txt.="X-MICROSOFT-CDO-BUSYSTATUS:BUSY" . NL;
                if ($res->link != "") {
                    $txt .= "URL:" . $res->link . NL;
                } else {
                    $txt .= "URL:" . $base_url . "?q=churchcal" . NL;
                }
                if ($res->ort != "") {
                    $txt .= "LOCATION:" . $res->ort . NL;
                }
                $subid++;
                $txt .= "UID:{$res->id}_{$subid}" . NL;
                $txt .= "DTSTAMP:" . churchcore_stringToDateICal($res->modified_date) . NL;
                $enddate = clone $d;
                $enddate->modify("+{$diff} seconds");
                // all day event
                if ($res->startdate->format('His') == "000000" && $res->enddate->format('His') == "000000") {
                    $txt .= "DTSTART;VALUE=DATE:" . $d->format('Ymd') . NL;
                    $txt .= "DTEND;VALUE=DATE:" . date('Ymd', strtotime('+1 day', $enddate->format("U"))) . NL;
                } else {
                    $txt .= "DTSTART:" . $d->format('Ymd\\THis') . NL;
                    $txt .= "DTEND:" . $enddate->format('Ymd\\THis') . NL;
                }
                $txt .= 'DESCRIPTION:Kalender:' . $catNames[$res->category_id]->bezeichnung;
                if (!empty($res->notizen)) {
                    $txt .= ' - ' . cleanICal($res->notizen);
                }
                $txt .= NL;
                $txt .= "END:VEVENT" . NL;
            }
        }
    }
    echo surroundWithVCALENDER($txt);
}
/**
 * echo ical for services to do from user id (read from request)
 */
function churchservice_ical()
{
    global $base_url, $config;
    if (!($id = readVar("id"))) {
        echo t("please.specify.id");
    }
    drupal_add_http_header('Content-Type', 'text/calendar;charset=utf-8', false);
    drupal_add_http_header('Content-Disposition', 'inline;filename="ChurchTools.ics"', false);
    drupal_add_http_header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', false);
    drupal_add_http_header('Cache-Control', 'private', false);
    $content = drupal_get_header();
    include_once './' . CHURCHSERVICE . '/churchservice_db.php';
    $arr = churchservice_getUserCurrentServices($id);
    // TODO: use txt Template
    $txt = "";
    foreach ($arr as $res) {
        $txt .= "BEGIN:VEVENT\r\n";
        $txt .= "ORGANIZER:MAILTO:" . readConf('site_mail', '') . "\r\n";
        if ($res->zugesagt_yn == 1) {
            $txt .= "SUMMARY:" . $res->dienst . " (" . $res->servicegroup . ")\r\n";
        } else {
            $txt .= "SUMMARY:Anfrage: " . $res->dienst . " (" . $res->servicegroup . ")?\r\n";
        }
        $txt .= "X-MICROSOFT-CDO-BUSYSTATUS:BUSY\r\n";
        $txt .= "URL:" . $base_url . "/?q=churchservice/entrylist\r\n";
        if ($res->ort != "") {
            $txt .= "LOCATION:" . $res->ort . "\r\n";
        }
        $txt .= "DESCRIPTION:" . $res->dienst . " (" . $res->servicegroup . ") bei " . $res->event . ".";
        if ($res->zugesagt_yn == 1) {
            $txt .= "\r\n";
        } else {
            $txt .= " " . t("request.from") . " {$res->vorname} {$res->name} [{$res->modified_pid}]\r\n";
        }
        $txt .= "DTSTAMP:" . $res->modified_date . "\r\n";
        $txt .= "UID:" . $res->eventservice_id . "\r\n";
        $txt .= "DTSTART;TZID=" . $config["timezone"] . ":" . $res->datum_start . "\r\n";
        $txt .= "DTEND;TZID=" . $config["timezone"] . ":" . $res->datum_end . "\r\n";
        $txt .= "END:VEVENT\r\n";
    }
    echo surroundWithVCALENDER($txt);
}
/**
 * print view
 * echo html content
 */
function churchresource__printview()
{
    global $user;
    drupal_add_js(ASSETS . "/js/jquery-2.1.1.js");
    drupal_add_js(ASSETS . "/js/jquery-migrate-1.2.1.min.js");
    drupal_add_js(CHURCHCORE . '/shortcut.js');
    drupal_add_js(ASSETS . '/js/jquery.history.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.core.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.datepicker.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.position.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.widget.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.autocomplete.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.dialog.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.mouse.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.draggable.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.resizable.min.js');
    drupal_add_js(CHURCHCORE . '/churchcore.js');
    drupal_add_js(CHURCHCORE . '/cc_events.js');
    drupal_add_js(CHURCHCORE . '/churchforms.js');
    drupal_add_js(CHURCHCORE . '/cc_abstractview.js');
    drupal_add_js(CHURCHCORE . '/cc_standardview.js');
    drupal_add_js(CHURCHCORE . '/cc_maintainstandardview.js');
    drupal_add_js(CHURCHCORE . '/cc_interface.js');
    drupal_add_js(CHURCHRESOURCE . '/cr_loadandmap.js');
    drupal_add_js(CHURCHRESOURCE . '/cr_maintainview.js');
    drupal_add_js(CHURCHRESOURCE . '/cr_weekview.js');
    drupal_add_js(CHURCHRESOURCE . '/cr_main.js');
    drupal_add_js(createI18nFile("churchcore"));
    drupal_add_js(createI18nFile("churchresource"));
    $content = "<html><head>" . drupal_get_header();
    $content .= '<link type="text/css" rel="stylesheet" media="all" href="' . INCLUDES . '/churchtools.css" />';
    $content .= '<link type="text/css" rel="stylesheet" media="all" href="' . CHURCHRESOURCE . '/cr_printview.css" />';
    $content .= "</head><body>";
    $content .= "<input type='hidden' id='printview' value='true'/>";
    $content .= "<script>jsversion=" . JS_VERSION . "</script>";
    if ($curdate = getVar("curdate")) {
        $content .= "<input type='hidden' id='curdate' value='{$curdate}'/>";
    }
    $content .= "<div id='cdb_f_ilter'></div></div> <div id='cdb_content'>Seite wird aufgebaut...</div>";
    $content .= "</body></html>";
    echo $content;
}
function churchresource__printview()
{
    global $user;
    $content = "<html><head>";
    drupal_add_js(ASSETS . "/js/jquery-1.10.2.min.js");
    drupal_add_js(ASSETS . "/js/jquery-migrate-1.2.1.min.js");
    drupal_add_js(CHURCHCORE . '/shortcut.js');
    drupal_add_js(ASSETS . '/js/jquery.history.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.core.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.datepicker.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.position.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.widget.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.autocomplete.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.dialog.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.mouse.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.draggable.min.js');
    drupal_add_js(ASSETS . '/ui/jquery.ui.resizable.min.js');
    drupal_add_js(CHURCHCORE . '/churchcore.js');
    drupal_add_js(CHURCHCORE . '/churchforms.js');
    drupal_add_js(CHURCHCORE . '/cc_abstractview.js');
    drupal_add_js(CHURCHCORE . '/cc_standardview.js');
    drupal_add_js(CHURCHCORE . '/cc_maintainstandardview.js');
    drupal_add_js(CHURCHCORE . '/cc_interface.js');
    drupal_add_js(CHURCHRESOURCE . '/cr_loadandmap.js');
    drupal_add_js(CHURCHRESOURCE . '/cr_maintainview.js');
    drupal_add_js(CHURCHRESOURCE . '/cr_weekview.js');
    drupal_add_js(CHURCHRESOURCE . '/cr_main.js');
    drupal_add_js(createI18nFile("churchcore"));
    drupal_add_js(createI18nFile("churchresource"));
    $content = $content . drupal_get_header();
    $content = $content . '<link type="text/css" rel="stylesheet" media="all" href="' . phpLUDES . '/churchtools.css" />';
    $content = $content . '<link type="text/css" rel="stylesheet" media="all" href="' . CHURCHRESOURCE . '/cr_printview.css" />';
    $content = $content . "</head><body>";
    $content = $content . "<input type=\"hidden\" id=\"printview\" value=\"true\"/>";
    if (isset($_GET["curdate"]) && $_GET["curdate"] != null) {
        $content = $content . "<input type=\"hidden\" id=\"curdate\" value=\"" . $_GET["curdate"] . "\"/>";
    }
    $content = $content . "<div id=\"cdb_f_ilter\"></div></div> <div id=\"cdb_content\">Seite wird aufgebaut...</div>";
    $content = $content . "</body></html>";
    echo $content;
}