<commit_before><?php

/**
 * ChurchTools 2.0
 * http://www.churchtools.de
 *
 * Copyright (c) 2014 <NAME>
 * 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();
  	// Check permission, perhaps show login mask
  	if (empty($auth["view category"]) || empty($auth["view category"][$catId])) {
  		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 ($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"/>';<commit_msg>(Cal) Fix embedding category auth problem<commit_after><?php

/**
 * ChurchTools 2.0
 * http://www.churchtools.de
 *
 * Copyright (c) 2014 <NAME>
 * 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 ($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"/>';
{'fraction_non_alphanumeric': 0.19133213501098462, 'fraction_numerical': 0.003994407829039345, 'mean_word_length': 4.152263374485597, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5192467', 'n_tokens_mistral': 1862, 'n_tokens_neox': 1795, 'n_words': 315}