Ejemplo n.º 1
0
/**
 * load content of wiki page
 *
 * @param string $doc_id
 * @param int $wikicategory_id
 * @param int $version_no
 * @return db result
 */
function churchwiki_load($doc_id, $wikicategory_id, $version_no = null)
{
    if (!$version_no) {
        $version_no = churchwiki_getCurrentNo($doc_id, $wikicategory_id);
    }
    ct_log("Aufruf Hilfeseite {$wikicategory_id}:{$doc_id} ({$version_no})", 2, "-1", "help");
    $data = db_query("SELECT p.vorname, p.name, doc_id, version_no, wikicategory_id, text, modified_date, modified_pid, auf_startseite_yn\n                    FROM {cc_wiki} w LEFT JOIN {cdb_person} p ON (w.modified_pid=p.id)\n                    WHERE version_no=:version_no AND doc_id=:doc_id AND wikicategory_id=:wikicategory_id", array(':doc_id' => $doc_id, ':wikicategory_id' => $wikicategory_id, ':version_no' => $version_no))->fetch();
    if (isset($data->text)) {
        $data->text = preg_replace('/\\\\/', "", $data->text);
        $data->text = preg_replace('/===([^===]*)===/', "<h3>\$1</h3>", $data->text);
        $data->text = preg_replace('/==([^==]*)==/', "<h2>\$1</h2>", $data->text);
        $data->files = churchcore_getFilesAsDomainIdArr("wiki_" . $wikicategory_id, $doc_id);
    }
    return $data;
}
Ejemplo n.º 2
0
/**
 * get next services for current user
 * @param string $short
 * @return string
 */
function churchservice_getUserNextServices($short = true)
{
    global $user;
    include_once './' . CHURCHDB . '/churchdb_db.php';
    $pid = $user->id;
    $res = db_query("\n    SELECT e.id event_id, cal.bezeichnung AS event, DATE_FORMAT(e.startdate, '%d.%m.%Y %H:%i') AS datum,\n      s.bezeichnung AS service, sg.bezeichnung AS servicegroup, cdb_person_id,\n      DATE_FORMAT(es.modified_date, '%d.%m.%Y %H:%i') AS modified_date\n    FROM {cs_eventservice} es, {cs_event} e, {cc_cal} cal, {cs_servicegroup} sg, {cs_service} s\n    WHERE cal.id=e.cc_Cal_id AND e.valid_yn=1 AND cdb_person_id=:pid AND e.startdate>=current_date AND zugesagt_yn=1\n      AND es.valid_yn=1 AND es.event_id=e.id AND es.service_id=s.id AND sg.id=s.servicegroup_id order by e.startdate", array(':pid' => $pid));
    $nr = 0;
    $txt = "";
    foreach ($res as $arr) {
        $nr++;
        if ($nr <= 5 || !$short) {
            $txt .= "<p><a href='?q=churchservice&id={$arr->event_id}'>{$arr->datum} - {$arr->event}</a>:\n               <a href='?q=churchservice&id={$arr->event_id}'><b>{$arr->service}</b></a> ({$arr->servicegroup})";
            $files = churchcore_getFilesAsDomainIdArr("service", $arr->event_id);
            $txt .= '<span class="pull-right">';
            if (isset($files) && isset($files[$arr->event_id])) {
                $i = 0;
                foreach ($files[$arr->event_id] as $file) {
                    $i++;
                    if ($i < 4) {
                        $txt .= churchcore_renderFile($file) . "&nbsp;";
                    } else {
                        $txt .= "...";
                    }
                    // TODO: ... for each additional file?
                }
            }
            $txt .= "</span><small><br>&nbsp; &nbsp; &nbsp; " . t("confirmed.on", $arr->modified_date) . "</small>";
        }
    }
    return $txt;
}
/**
 * delete arrangement
 * @param unknown $params
 */
function churchservice_delArrangement($params)
{
    $i = new CTInterface();
    $i->setParam("id");
    $files = churchcore_getFilesAsDomainIdArr("song_arrangement", $params["id"]);
    if (isset($files) && isset($files[$params["id"]])) {
        foreach ($files[$params["id"]] as $file) {
            churchcore_delFile($file->id);
        }
    }
    db_delete("cs_song_arrangement")->fields($i->getDBInsertArrayFromParams($params))->condition("id", $params["id"], "=")->execute(false);
}
Ejemplo n.º 4
0
function churchservice_getUserNextServices($shorty = true)
{
    global $user;
    include_once './' . CHURCHDB . '/churchdb_db.php';
    $pid = $user->id;
    $res = db_query("SELECT e.id event_id, cal.bezeichnung event, DATE_FORMAT(e.startdate, '%d.%m.%Y %H:%i') datum, s.bezeichnung service, sg.bezeichnung servicegroup, cdb_person_id, DATE_FORMAT(es.modified_date, '%d.%m.%Y %H:%i') modified_date\n   FROM {cs_eventservice} es, {cs_event} e, {cc_cal} cal, {cs_servicegroup} sg, {cs_service} s where\n   cal.id=e.cc_Cal_id and e.valid_yn=1 and  \n     cdb_person_id={$pid} and e.startdate>=current_date and zugesagt_yn=1 and es.valid_yn=1 and es.event_id=e.id and es.service_id=s.id and sg.id=s.servicegroup_id order by e.startdate");
    $nr = 0;
    $txt = "";
    foreach ($res as $arr) {
        $nr = $nr + 1;
        if ($nr <= 5 || !$shorty) {
            $txt .= '<p><a href="?q=churchservice&id=' . $arr->event_id . '">' . $arr->datum . " - " . $arr->event . "</a>: ";
            $txt .= '<a href="?q=churchservice&id=' . $arr->event_id . '"><b>' . $arr->service . "</b></a> (" . $arr->servicegroup . ")";
            $files = churchcore_getFilesAsDomainIdArr("service", $arr->event_id);
            $txt .= '<span class="pull-right">';
            if (isset($files) && isset($files[$arr->event_id])) {
                $i = 0;
                foreach ($files[$arr->event_id] as $file) {
                    $i++;
                    if ($i < 4) {
                        $txt .= churchcore_renderFile($file) . "&nbsp;";
                    } else {
                        $txt .= "...";
                    }
                }
            }
            $txt .= "</span><small><br>&nbsp; &nbsp; &nbsp; ";
            $txt .= t("confirmed.on", $arr->modified_date) . "</small>";
        }
    }
    return $txt;
}