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;
 }
 /**
  * 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;
 }
Beispiel #3
0
/**
 * ChurchTools 2.0
 * http://www.churchtools.de
 *
 * Copyright (c) 2014 Jens Martin Rauen
 * Licensed under the MIT license, located in LICENSE.txt
 *
 * ChurchCal Module
 * Depends on ChurchCore
 */
function churchcal_main()
{
    global $config, $base_url, $config, $embedded;
    drupal_add_css(ASSETS . '/fullcalendar/fullcalendar.css');
    if (isset($_GET["printview"])) {
        drupal_add_css(ASSETS . '/fullcalendar/fullcalendar.print.css');
    }
    drupal_add_css(ASSETS . '/simplecolorpicker/jquery.simplecolorpicker.css');
    drupal_add_js(ASSETS . '/simplecolorpicker/jquery.simplecolorpicker.js');
    drupal_add_js(ASSETS . '/fullcalendar/moment.min.js');
    drupal_add_js(ASSETS . '/fullcalendar/fullcalendar.min.js');
    drupal_add_js(CHURCHCORE . '/cc_events.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(CHURCHCAL . '/eventview.js');
    drupal_add_js(CHURCHCAL . '/yearview.js');
    drupal_add_js(CHURCHCAL . '/calendar.js');
    drupal_add_js(CHURCHCAL . '/cal_sources.js');
    drupal_add_js(createI18nFile("churchcore"));
    drupal_add_js(createI18nFile("churchcal"));
    $txt = '';
    if ($catId = getVar("category_id")) {
        include_once CHURCHCAL . '/churchcal_db.php';
        $auth = churchcal_getAuthForAjax();
        $perm = true;
        foreach (explode(",", $catId) as $id) {
            // Check permission, perhaps show login mask
            if (empty($auth["view category"]) || empty($auth["view category"][$id])) {
                $perm = false;
            }
        }
        if (!$perm) {
            include_once MAIN . '/login.php';
            $login = login_main();
            if (!userLoggedIn()) {
                return $login;
            }
        }
        $txt .= '<input type="hidden" id="filtercategory_id" name="category_id" value="' . $catId . '"/>' . NL;
        if ($id = getVar("id")) {
            // only of category_id is set
            $txt .= '<input type="hidden" id="filterevent_id" name="id" value="' . $id . '"/>' . NL;
        }
    }
    if (getVar("printview")) {
        $txt .= '<input type="hidden" id="printview" value="true"/>';
        $embedded = true;
    }
    if ($embedded) {
        if ($catSel = getVar("category_select")) {
            $txt .= '<input type="hidden" id="filtercategory_select" name="category_select" value="' . $catSel . '"/>' . NL;
        }
        if ($cssUrl = getVar("cssurl")) {
            drupal_add_css($cssUrl);
        }
        // if (getConf("churchcal_css", "-") != "-") $txt .= '<style>' . getConf("churchcal_css") . '</style>'; //TODO: is
        // the '-' important?
        if ($css = getConf("churchcal_css")) {
            $txt .= "<style>{$css}</style>" . NL;
        }
        if (getVar("minical")) {
            $txt .= '<input type="hidden" id="isminical"/>';
        }
        $txt .= '
        <div class="row-fluid">
          <div id="cdb_filter"></div>
        </div>
        <div id="cdb_content"><div id="calendar"></div></div>
    ';
        if (getVar("embedded")) {
            $txt .= '<input type="hidden" id="isembedded"/>';
        }
        if ($t = getVar("title")) {
            $txt .= '<input type="hidden" id="embeddedtitle" value="' . $t . '"/>';
        }
        if ($e = getVar("entries")) {
            $txt .= '<input type="hidden" id="entries" value="' . $e . '"/>';
        }
        if ($s = getVar("startdate")) {
            $txt .= '<input type="hidden" id="init_startdate" value="' . $s . '"/>';
        }
        if ($e = getVar("enddate")) {
            $txt .= '<input type="hidden" id="init_enddate" value="' . $e . '"/>';
        }
    } else {
        $txt .= '
      <div class="row-fluid">
    <div class="span3"><div id="cdb_filter"></div></div>
    <div class="span9"><div id="header" class="pull-right"></div><div id="cdb_content"><div id="calendar"></div></div></div>
        <p align=right><small>
          <a target="_blank" href="' . $base_url . '?q=churchcal&embedded=true"> ' . t("embed", getConf("churchcal_name")) . '</a>
          <a target="_clean" href="http://intern.churchtools.de/?q=churchwiki#WikiView/filterWikicategory_id:0/doc:ChurchCal%C2%A0einbetten/"><i class="icon-question-sign"></i></a>
          &nbsp; <a id="abo" href="' . $base_url . '?q=churchcal/ical">' . $config["churchcal_name"] . ' ' . t("subscribe.to.ical") . '</a>' . '</small>';
    }
    if ($d = getVar("date")) {
        $txt .= '<input type="hidden" name="viewdate" id="viewdate" value="' . $d . '"/>';
    }
    if ($v = getVar("viewname")) {
        $txt .= '<input type="hidden" name="viewname" id="viewname" value="' . $v . '"/>';
    }
    return $txt;
}
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;
    }
}
/**
 * TODO: remove private cals?
 *
 * @param string $withPrivat
 * @param string $onlyIds
 * @return multitype:NULL Ambigous <object, boolean, db_accessor>
 */
function churchcal_getAllowedCategories($withPrivat = true, $onlyIds = false)
{
    global $user;
    include_once CHURCHDB . "/churchdb_db.php";
    $db = db_query("SELECT * FROM {cc_calcategory}");
    $res = array();
    $auth = churchcal_getAuthForAjax();
    foreach ($db as $category) {
        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 {
                    $category->textColor = getContrastYIQ($category->color);
                    $res[$category->id] = $category;
                }
            }
        }
    }
    return $res;
}