コード例 #1
0
 /**
  *
  * @see CTModuleInterface::getMasterData()
  */
 public function getMasterData()
 {
     global $user, $base_url, $files_dir, $config;
     include_once CHURCHCAL . '/churchcal_db.php';
     $auth = churchservice_getAuthorization();
     $res = $this->getMasterDataTables();
     $res["masterDataTables"] = $this->getMasterDataTablenames();
     $res["auth"] = $auth;
     $res["modulespath"] = churchservice_getModulesPath();
     $res["base_url"] = $base_url;
     $res["files_url"] = $base_url . $files_dir;
     $res["files_dir"] = $files_dir;
     $res["modulename"] = "churchservice";
     $res["adminemail"] = getConf('site_mail', '');
     $res["user_pid"] = $user->id;
     $res["user_name"] = $user->vorname . " " . $user->name;
     $res["userid"] = $user->cmsuserid;
     $res["settings"] = churchservice_getUserSettings($user->id);
     $res["notification"] = churchcore_getMyNotifications();
     $res["notificationtype"] = churchcore_getTableData("cc_notificationtype");
     $res["lastLogId"] = churchservice_getLastLogId();
     $res["eventtemplate"] = churchcore_getTableData("cs_eventtemplate", "sortkey");
     $res["category"] = churchcal_getAllowedCategories(false);
     $res["repeat"] = churchcore_getTableData("cc_repeat");
     $res["eventtemplate_services"] = churchservice_getEventtemplateServices($auth);
     $res["churchcal_name"] = $config["churchcal_name"];
     $res["churchservice_name"] = $config["churchservice_name"];
     $res["songwithcategoryasdir"] = getConf("churchservice_songwithcategoryasdir", "0");
     $res["songcategory"] = churchcore_getTableData("cs_songcategory", "sortkey");
     $res["views"] = array("ListView" => array("filename" => "cs_listview"), "SettingsView" => array("filename" => "cs_settingsview"), "CalView" => array("filename" => "cs_calview"), "SongView" => array("filename" => "cs_songview"), "AgendaView" => array("filename" => "cs_agendaview"), "FactView" => array("filename" => "cs_factview"), "MaintainView" => array("filename" => "cs_maintainview"));
     return $res;
 }
コード例 #2
0
 /**
  *
  * @see CTModuleInterface::getMasterData()
  */
 public function getMasterData()
 {
     global $user, $base_url, $files_dir, $config;
     include_once CHURCHCAL . '/churchcal_db.php';
     $auth = churchservice_getAuthorization();
     $res = $this->getMasterDataTables();
     $res["masterDataTables"] = $this->getMasterDataTablenames();
     $res["auth"] = $auth;
     $res["modulespath"] = churchservice_getModulesPath();
     $res["base_url"] = $base_url;
     $res["files_url"] = $base_url . $files_dir;
     $res["files_dir"] = $files_dir;
     $res["modulename"] = "churchservice";
     $res["adminemail"] = variable_get('site_mail', '');
     $res["user_pid"] = $user->id;
     $res["user_name"] = $user->vorname . " " . $user->name;
     $res["userid"] = $user->cmsuserid;
     $res["settings"] = churchservice_getUserSettings($user->id);
     $res["notification"] = churchcore_getMyNotifications();
     $res["notificationtype"] = churchcore_getTableData("cc_notificationtype");
     $res["lastLogId"] = churchservice_getLastLogId();
     $res["eventtemplate"] = churchcore_getTableData("cs_eventtemplate", "sortkey");
     $res["category"] = churchcal_getAllowedCategories(false);
     $res["eventtemplate_services"] = churchservice_getEventtemplateServices($auth);
     $res["churchcal_name"] = $config["churchcal_name"];
     $res["songwithcategoryasdir"] = variable_get("churchservice_songwithcategoryasdir", "0");
     $res["songcategory"] = churchcore_getTableData("cs_songcategory", "sortkey");
     return $res;
 }
コード例 #3
0
 public function getMasterData()
 {
     global $user, $base_url;
     $ret = array();
     $ret["modulename"] = "churchcal";
     $ret["modulespath"] = CHURCHCAL;
     $ret["churchservice_name"] = variable_get("churchservice_name");
     $ret["churchcal_name"] = variable_get("churchcal_name");
     $ret["churchresource_name"] = variable_get("churchresource_name");
     $ret["maincal_name"] = variable_get("churchcal_maincalname", "Gemeindekalender");
     $ret["base_url"] = $base_url;
     $ret["user_pid"] = $user->id;
     if (user_access("view", "churchdb")) {
         $ret["absent_reason"] = churchcore_getTableData("cs_absent_reason");
     }
     if (user_access("view", "churchresource") || user_access("create bookings", "churchresource")) {
         $ret["resources"] = churchcore_getTableData("cr_resource");
         $ret["resourceTypes"] = churchcore_getTableData("cr_resourcetype");
         $ret["bookingStatus"] = churchcore_getTableData("cr_status");
     }
     $ret["category"] = churchcal_getAllowedCategories(true);
     $ret["settings"] = churchcore_getUserSettings("churchcal", $user->id);
     $ret["repeat"] = churchcore_getTableData("cc_repeat");
     if (count($ret["settings"]) == 0) {
         $arr["checkboxEvents"] = "true";
         $ret["settings"] = $arr;
     }
     $ret["auth"] = churchcal_getAuthForAjax();
     return $ret;
 }
コード例 #4
0
 /**
  * get getMasterData
  */
 public function getMasterData()
 {
     global $user, $base_url;
     $ret = array();
     $ret["modulename"] = "churchcal";
     $ret["modulespath"] = CHURCHCAL;
     $ret["churchservice_name"] = getConf("churchservice_name");
     $ret["churchcal_name"] = getConf("churchcal_name");
     $ret["churchresource_name"] = getConf("churchresource_name");
     $ret["maincal_name"] = getConf("churchcal_maincalname", "Gemeindekalender");
     $ret["firstDayInWeek"] = getConf("churchcal_firstdayinweek", 1);
     $ret["notification"] = churchcore_getMyNotifications();
     $ret["notificationtype"] = churchcore_getTableData("cc_notificationtype");
     $ret["reminder"] = ct_getMyReminders($user->id, "event");
     $ret["base_url"] = $base_url;
     $ret["user_pid"] = $user->id;
     if (user_access("view", "churchdb")) {
         $ret["cdb_bereich"] = churchcore_getTableData("cdb_bereich");
         $ret["cdb_status"] = churchcore_getTableData("cdb_status");
         $ret["cdb_station"] = churchcore_getTableData("cdb_station");
         $ret["absent_reason"] = churchcore_getTableData("cs_absent_reason");
         foreach ($ret["absent_reason"] as $key => $reason) {
             if (isset($reason->color)) {
                 $ret["absent_reason"][$key]->textColor = getContrastYIQ($reason->color);
             }
         }
     }
     if (user_access("view", "churchresource") || user_access("create bookings", "churchresource")) {
         $ret["resources"] = churchcore_getTableData("cr_resource");
         $ret["resourceTypes"] = churchcore_getTableData("cr_resourcetype");
         $ret["bookingStatus"] = churchcore_getTableData("cr_status");
     }
     $ret["category"] = churchcal_getAllowedCategories(true);
     $ret["settings"] = churchcore_getUserSettings("churchcal", $user->id);
     $ret["repeat"] = churchcore_getTableData("cc_repeat");
     if (count($ret["settings"]) == 0) {
         $arr["checkboxEvents"] = "true";
         $ret["settings"] = $arr;
     }
     $ret["auth"] = churchcal_getAuthForAjax();
     $ret["views"] = array("WeekView" => array("filename" => "../churchresource/cr_weekview"));
     return $ret;
 }
コード例 #5
0
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);
}
コード例 #6
0
function churchcal_getAllowedCategories($withPrivat = true, $onlyIds = false)
{
    global $user;
    $withPrivat = false;
    include_once CHURCHDB . "/churchdb_db.php";
    $db = db_query("select * from {cc_calcategory}");
    $res = array();
    $auth = churchcal_getAuthForAjax();
    $privat_vorhanden = false;
    foreach ($db as $category) {
        if ($category->privat_yn == 1 && $category->modified_pid == $user->id) {
            $privat_vorhanden = true;
        }
        if ($category->privat_yn == 0 || $withPrivat) {
            // Zugriff, weil ich View-Rechte auf die Kategorie habe
            if (isset($auth["view category"]) && isset($auth["view category"][$category->id]) || isset($auth["edit category"]) && isset($auth["edit category"][$category->id])) {
                if ($onlyIds) {
                    $res[$category->id] = $category->id;
                } else {
                    $res[$category->id] = $category;
                }
            }
        }
    }
    if (!$privat_vorhanden && $user->id > 0 && user_access("personal category", "churchcal")) {
        $dt = new datetime();
        $id = db_insert("cc_calcategory")->fields(array("bezeichnung" => $user->vorname . "s Kalender", "sortkey" => 0, "oeffentlich_yn" => 0, "privat_yn" => 1, "color" => "black", "modified_date" => $dt->format('Y-m-d H:i:s'), "modified_pid" => $user->id))->execute();
        // Add permission for person who created the event
        db_query("insert into {cc_domain_auth} (domain_type, domain_id, auth_id, daten_id)\n                  values ('person', {$user->id}, 404, {$id})");
        $_SESSION["user"]->auth = getUserAuthorization($_SESSION["user"]->id);
        churchcore_saveUserSetting("churchcal", $user->id, "filterMeineKalender", "[" . ($id + 100) . "]");
        return churchcal_getAllowedCategories($withPrivat, $onlyIds);
    } else {
        return $res;
    }
}
コード例 #7
0
ファイル: churchcal.php プロジェクト: toXel/churchtools_basic
/**
 * 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);
}
コード例 #8
0
/**
 * Load all Events and services in the current time slot
 * 
 * @param array $params
 * @return array
 */
function churchservice_getAllEventData($params)
{
    global $user;
    $id = null;
    if (isset($params["id"])) {
        $id = $params["id"];
    }
    $auth = churchservice_getAuthorization();
    include_once CHURCHCAL . '/churchcal_db.php';
    $cat = churchcal_getAllowedCategories(false, true);
    $cat[] = -1;
    $lastday = -readConf('churchservice_entries_last_days');
    // $auth=user_access("view servicegroup","churchservice");
    $res = db_query('SELECT e.id, e.startdate startdate, e.valid_yn, cal.startdate cal_startdate, cal.enddate cal_enddate, 
          e.cc_cal_id, cal.bezeichnung, e.special, cal.category_id, e.admin, cal.repeat_id, 
         datediff(e.startdate,CURRENT_DATE) datediff
       FROM {cs_event} e, {cc_cal} cal 
       WHERE cal.id=e.cc_cal_id AND ' . ($id != null ? "e.id={$id}" : "1=1") . " AND cal.category_id in (" . implode(",", $cat) . ")");
    $sql = "SELECT es.service_id, es.name, es.cdb_person_id, es.id eventservice_id, es.counter,\n               es.zugesagt_yn, es.valid_yn, es.modified_date, es.modified_pid, es.mailsenddate,\n               case when p.id is null then '?' else  \n               concat(p.vorname, ' ',p.name) end as modifieduser, \n               es.reason, s.servicegroup_id \n          FROM {cs_service} s, {cs_eventservice} es left join {cdb_person} p on (es.modified_pid=p.id) \n          WHERE es.service_id=s.id and event_id=:event_id";
    $events = array();
    if ($res != false) {
        foreach ($res as $arr) {
            // check booking info, damit ich wei�, dass er hier nicht das Datum �ndern darf.
            // check booking info to know if date can be changed here
            // TODO: dont SELECT * if SELECT id is sufficient
            $b = db_query("SELECT * FROM {cr_booking} WHERE cc_cal_id=:cal_id", array(":cal_id" => $arr->cc_cal_id))->fetch();
            $arr->bookings = $b != false;
            // Check if agenda items are available for this event
            $b = db_query("SELECT * FROM {cs_event_item} WHERE event_id=:event_id limit 1", array(":event_id" => $arr->id))->fetch();
            $arr->agenda = $b != false;
            // here we go!
            $events[$arr->id] = $arr;
            $event_admin = false;
            if ($arr->admin == null) {
                $events[$arr->id]->admin = null;
            } else {
                if (in_array($user->id, explode(",", $arr->admin))) {
                    $event_admin = true;
                }
            }
            if ($arr->special == null) {
                $events[$arr->id]->special = null;
            }
            // We don't have an enddate in cs-event, so we calculate it from the calendar
            $diff = strtotime($arr->cal_enddate) - strtotime($arr->cal_startdate);
            $event_enddate = new DateTime($arr->startdate);
            $event_enddate->modify("+" . $diff . " seconds");
            $arr->enddate = $event_enddate->format('Y-m-d H:i:s');
            if (1 == 1 && $arr->datediff > $lastday) {
                ///TODO: remove 1 == 1
                $services = db_query($sql, array(":event_id" => $arr->id));
                $s = array();
                foreach ($services as $service) {
                    if ($service->servicegroup_id != null && (isset($auth["viewgroup"][$service->servicegroup_id]) || $event_admin)) {
                        $s[] = churchservice_extractEventServiceData($service, $auth, $event_admin);
                    }
                }
                if (count($s) > 0) {
                    $events[$arr->id]->services = $s;
                }
            }
        }
    }
    return $events;
}
コード例 #9
0
/**
 * Load all Events and services in the current time slot
 *
 * @param array $params
 * @return array
 */
function churchservice_getAllEventData($params)
{
    global $user;
    $id = null;
    if (isset($params["id"])) {
        $id = $params["id"];
    }
    $auth = churchservice_getAuthorization();
    include_once CHURCHCAL . '/churchcal_db.php';
    $cat = churchcal_getAllowedCategories(false, true);
    $cat[] = -1;
    $lastday = -getConf('churchservice_entries_last_days');
    $excs_db = db_query("SELECT id, cal_id, except_date_start, except_date_end FROM {cc_cal_except}");
    $excs = array();
    foreach ($excs_db as $exc) {
        if (!isset($excs[$exc->cal_id])) {
            $excs[$exc->cal_id] = array();
        }
        $excs[$exc->cal_id][] = $exc;
    }
    $res = db_query('SELECT e.id, e.startdate startdate, e.valid_yn, cal.startdate cal_startdate, cal.enddate cal_enddate,
          e.cc_cal_id, cal.bezeichnung, e.special, cal.category_id, e.admin, cal.repeat_id, cal.repeat_until,
          cal.repeat_frequence, cal.repeat_option_id, cal.intern_yn, cal.notizen, cal.ort, cal.link,
         datediff(e.startdate,CURRENT_DATE) datediff
       FROM {cs_event} e, {cc_cal} cal
       WHERE cal.id=e.cc_cal_id AND ' . ($id != null ? "e.id={$id}" : "1=1") . " AND cal.category_id in (" . db_implode($cat) . ")" . " AND DATEDIFF(now(), e.startdate)<366*2");
    $events = array();
    if ($res != false) {
        foreach ($res as $arr) {
            if ($arr->repeat_frequence == null) {
                unset($arr->repeat_frequence);
            }
            if ($arr->repeat_option_id == null) {
                unset($arr->repeat_option_id);
            }
            if ($arr->repeat_until == null) {
                unset($arr->repeat_until);
            }
            if (isset($excs[$arr->cc_cal_id])) {
                $arr->exceptions = $excs[$arr->cc_cal_id];
            }
            // here we go!
            $events[$arr->id] = $arr;
            $event_admin = false;
            if ($arr->admin == null) {
                unset($events[$arr->id]->admin);
            } else {
                if (in_array($user->id, explode(",", $arr->admin))) {
                    $event_admin = true;
                }
            }
            if ($arr->special == null) {
                $events[$arr->id]->special = null;
            }
            // We don't have an enddate in cs-event, so we calculate it from the calendar
            $diff = strtotime($arr->cal_enddate) - strtotime($arr->cal_startdate);
            $event_enddate = new DateTime($arr->startdate);
            $event_enddate->modify("+" . $diff . " seconds");
            $arr->enddate = $event_enddate->format('Y-m-d H:i:s');
            if (1 == 1 && $arr->datediff > $lastday) {
                ///TODO: remove 1 == 1
                // Check if agenda items are available for this event
                $b = db_query("SELECT * FROM {cs_event_item}\n          WHERE event_id=:event_id limit 1", array(":event_id" => $arr->id))->fetch();
                $arr->agenda = $b != false;
                $services = db_query("\n          SELECT es.service_id, es.name, es.cdb_person_id, es.id eventservice_id, es.counter,\n               es.zugesagt_yn, es.valid_yn, es.modified_date, es.modified_pid, es.mailsenddate,\n               case when p.id is null then '?' else\n               concat(p.vorname, ' ',p.name) end as modifieduser,\n               es.reason, s.servicegroup_id, cmsuser.cmsuserid\n          FROM {cs_service} s, {cs_eventservice} es left join {cdb_person} p on (es.modified_pid=p.id)\n          LEFT JOIN {cdb_person} cmsuser on (es.cdb_person_id=cmsuser.id)\n          WHERE es.service_id=s.id and event_id=:event_id", array(":event_id" => $arr->id));
                $s = array();
                foreach ($services as $service) {
                    if ($service->servicegroup_id != null && (isset($auth["viewgroup"][$service->servicegroup_id]) || $event_admin)) {
                        $s[] = churchservice_extractEventServiceData($service, $auth, $event_admin);
                    }
                }
                if (count($s) > 0) {
                    $events[$arr->id]->services = $s;
                }
            }
        }
    }
    return $events;
}