break; case "recur_yearly": $dates = exponent_datetime_recurringYearlyDates($start_recur, $stop_recur, $freq); break; default: $dates = array(); echo "Bad type: " . $_POST['recur'] . "<br />"; return; break; } $item->is_recurring = 1; // Set the recurrence flag. } else { $dates = array($start_recur); } $item->approved = 1; // Bypass workflow. $edate = null; $item->id = $db->insertObject($item, "calendar"); $edate->event_id = $item->id; $edate->location_data = $item->location_data; foreach ($dates as $d) { $edate->date = $d; $db->insertObject($edate, "eventdate"); } calendarmodule::spiderContent($item); } exponent_flow_redirect(); } else { echo SITE_403_HTML; }
# Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## /** @define "BASE" "../../../.." */ if (!defined('EXPONENT')) { exit(''); } //$item = $db->selectObject('calendar','id='.intval($_POST['id'])); $dates = $db->selectObjects("eventdate", $locsql . " AND date < " . strtotime('-1 months', time())); $all_events = calendarmodule::_getEventsForDates($dates); if ($item && $item->is_recurring == 1) { $eventdates = $db->selectObjectsIndexedArray('eventdate', 'event_id=' . $item->id); foreach (array_keys($_POST['dates']) as $d) { if (isset($eventdates[$d])) { $db->delete('eventdate', 'id=' . $d); unset($eventdates[$d]); } } if (!count($eventdates)) { $db->delete('calendar', 'id=' . $item->id); $db->delete("calendar_wf_info", "real_id=" . $_GET['id']); $db->delete("calendar_revision", "wf_original=" . $_GET['id']); //Delete search entries $db->delete('search', "ref_module='calendarmodule' AND ref_type='calendar' AND original_id=" . $item->id); }
function show($view, $loc = null, $title = '') { global $user; global $db; $template = new template('calendarmodule', $view, $loc); $template->assign('moduletitle', $title); $canviewapproval = false; $inapproval = false; if ($user) { $canviewapproval = pathos_permissions_check("approve", $loc) || pathos_permissions_check("manage_approval", $loc); } if ($db->countObjects("calendar", "location_data='" . serialize($loc) . "' AND approved!=1")) { foreach ($db->selectObjects("calendar", "location_data='" . serialize($loc) . "' AND approved!=1") as $c) { if ($c->poster == $user->id) { $canviewapproval = true; } } $inapproval = true; } $time = isset($_GET['time']) ? $_GET['time'] : time(); $template->assign("time", $time); $viewconfig = $template->viewparams; if ($viewconfig === null) { $viewconfig = array("type" => "default"); } if (!defined("SYS_DATETIME")) { require_once BASE . "subsystems/datetime.php"; } if (!defined('SYS_SORTING')) { require_once BASE . 'subsystems/sorting.php'; } if (!function_exists("pathos_sorting_byEventStartAscending")) { function pathos_sorting_byEventStartAscending($a, $b) { return $a->eventstart < $b->eventstart ? -1 : 1; } } if ($viewconfig['type'] == "minical") { $monthly = array(); $datesWithEvents = array(); $info = getdate(time()); $info = getdate(time()); // Grab non-day numbers only (before end of month) $week = 0; $currentweek = 0; $currentday = $info['mday']; $infofirst = getdate(mktime(12, 0, 0, $info['mon'], 1, $info['year'])); if ($infofirst['wday'] == 0) { $monthly[$week] = array(); } // initialize for non days for ($i = 0 - $infofirst['wday']; $i < 0; $i++) { $monthly[$week][$i] = array("number" => -1, "ts" => -1); } $weekday = $infofirst['wday']; // day number in grid. if 7+, switch weeks // Grab day counts $endofmonth = pathos_datetime_endOfMonthDay(time()); for ($i = 1; $i <= $endofmonth; $i++) { $start = mktime(0, 0, 0, $info['mon'], $i, $info['year']); if ($i == $info['mday']) { $currentweek = $week; } #$monthly[$week][$i] = array("ts"=>$start,"number"=>$db->countObjects("calendar","location_data='".serialize($loc)."' AND approved!=0 AND (eventstart >= $start AND eventend <= " . ($start+86399) . ")")); // NO WORKFLOW CONSIDERATIONS $monthly[$week][$i] = array("ts" => $start, "number" => $db->countObjects("eventdate", "location_data='" . serialize($loc) . "' AND date = {$start}")); if ($monthly[$week][$i]["number"] > 0) { $datesWithEvents[] = $i; } if ($weekday >= 6) { $week++; $monthly[$week] = array(); // allocate an array for the next week $weekday = 0; } else { $weekday++; } } // Grab non-day numbers only (after end of month) for ($i = 1; $weekday && $i <= 7 - $weekday; $i++) { $monthly[$week][$i + $endofmonth] = -1; } $template->assign("datesWithEvents", implode(",", $datesWithEvents)); $template->assign("monthly", $monthly); $template->assign("currentweek", $currentweek); $template->assign("currentday", $currentday); $template->assign("now", time()); } else { if ($viewconfig['type'] == "byday") { $startperiod = 0; $totaldays = 0; if ($viewconfig['range'] == "week") { $startperiod = pathos_datetime_startOfWeekTimestamp($time); $totaldays = 7; } else { $startperiod = pathos_datetime_startOfMonthTimestamp($time); $totaldays = pathos_datetime_endOfMonthDay($time); } $template->assign("prev_timestamp", $startperiod - 3600); $template->assign("next_timestamp", $startperiod + $totaldays * 86400 + 3600); $days = array(); for ($i = 0; $i < $totaldays; $i++) { $start = $startperiod + $i * 86400; #$days[$start] = $db->selectObjects("calendar","location_data='".serialize($loc)."' AND (eventstart >= $start AND eventend <= " . ($start+86399) . ") AND approved!=0"); $edates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date = {$start}"); $days[$start] = calendarmodule::_getEventsForDates($edates); for ($j = 0; $j < count($days[$start]); $j++) { $thisloc = pathos_core_makeLocation($loc->mod, $loc->src, $days[$start][$j]->id); $days[$start][$j]->permissions = array("administrate" => pathos_permissions_check("administrate", $thisloc) || pathos_permissions_check("administrate", $loc), "edit" => pathos_permissions_check("edit", $thisloc) || pathos_permissions_check("edit", $loc), "delete" => pathos_permissions_check("delete", $thisloc) || pathos_permissions_check("delete", $loc)); } usort($days[$start], "pathos_sorting_byEventStartAscending"); } $template->assign("days", $days); } else { if ($viewconfig['type'] == "monthly") { $monthly = array(); $counts = array(); $info = getdate($time); $nowinfo = getdate(time()); if ($info['mon'] != $nowinfo['mon']) { $nowinfo['mday'] = -10; } // Grab non-day numbers only (before end of month) $week = 0; $currentweek = -1; $timefirst = mktime(12, 0, 0, $info['mon'], 1, $info['year']); $infofirst = getdate($timefirst); if ($infofirst['wday'] == 0) { $monthly[$week] = array(); // initialize for non days $counts[$week] = array(); } for ($i = 1 - $infofirst['wday']; $i < 1; $i++) { $monthly[$week][$i] = array(); $counts[$week][$i] = -1; } $weekday = $infofirst['wday']; // day number in grid. if 7+, switch weeks // Grab day counts $endofmonth = pathos_datetime_endOfMonthDay($time); for ($i = 1; $i <= $endofmonth; $i++) { $start = mktime(0, 0, 0, $info['mon'], $i, $info['year']); if ($i == $nowinfo['mday']) { $currentweek = $week; } #$monthly[$week][$i] = $db->selectObjects("calendar","location_data='".serialize($loc)."' AND (eventstart >= $start AND eventend <= " . ($start+86399) . ") AND approved!=0"); $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date = {$start}"); $monthly[$week][$i] = calendarmodule::_getEventsForDates($dates); $counts[$week][$i] = count($monthly[$week][$i]); if ($weekday >= 6) { $week++; $monthly[$week] = array(); // allocate an array for the next week $counts[$week] = array(); $weekday = 0; } else { $weekday++; } } // Grab non-day numbers only (after end of month) for ($i = 1; $weekday && $i < 8 - $weekday; $i++) { $monthly[$week][$i + $endofmonth] = array(); $counts[$week][$i + $endofmonth] = -1; } $template->assign("currentweek", $currentweek); $template->assign("monthly", $monthly); $template->assign("counts", $counts); $template->assign("nextmonth", $timefirst + 86400 * 45); $template->assign("prevmonth", $timefirst - 86400 * 15); $template->assign("now", $timefirst); } else { if ($viewconfig['type'] == "administration") { // Check perms and return if cant view if ($viewconfig['type'] == "administration" && !$user) { return; } $continue = pathos_permissions_check("administrate", $loc) || pathos_permissions_check("post", $loc) || pathos_permissions_check("edit", $loc) || pathos_permissions_check("delete", $loc) || pathos_permissions_check("approve", $loc) || pathos_permissions_check("manage_approval", $loc) ? 1 : 0; $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "'"); $items = calendarmodule::_getEventsForDates($dates); if (!$continue) { foreach ($items as $i) { $iloc = pathos_core_makeLocation($loc->mod, $loc->src, $i->id); if (pathos_permissions_check("edit", $iloc) || pathos_permissions_check("delete", $iloc) || pathos_permissions_check("administrate", $iloc)) { $continue = true; } } } if (!$continue) { return; } for ($i = 0; $i < count($items); $i++) { $thisloc = pathos_core_makeLocation($loc->mod, $loc->src, $items[$i]->id); if ($user && $items[$i]->poster == $user->id) { $canviewapproval = 1; } $items[$i]->permissions = array("administrate" => pathos_permissions_check("administrate", $thisloc) || pathos_permissions_check("administrate", $loc), "edit" => pathos_permissions_check("edit", $thisloc) || pathos_permissions_check("edit", $loc), "delete" => pathos_permissions_check("delete", $thisloc) || pathos_permissions_check("delete", $loc)); } usort($items, "pathos_sorting_byEventStartAscending"); $template->assign("items", $items); } else { if ($viewconfig['type'] == "default") { if (!isset($viewconfig['range'])) { $viewconfig['range'] = "all"; } $limit = ''; if (isset($template->viewconfig) && isset($template->viewconfig['num_events']) && $template->viewconfig['num_events'] != 0) { $limit = $db->limit($template->viewconfig['num_events'], 0); } $items = null; $dates = null; $day = pathos_datetime_startOfDayTimestamp(time()); $sort_asc = true; // For the getEventsForDates call switch ($viewconfig['range']) { case "all": #$items = $db->selectObjects("calendar","location_data='" . serialize($loc) . "' AND approved!=0"); $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "'"); break; case "upcoming": #$items = $db->selectObjects("calendar","location_data='" . serialize($loc) . "' AND approved!=0 AND eventstart >= ".time()); $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date > {$day} ORDER BY date ASC " . $limit); break; case "past": #$items = $db->selectObjects("calendar","location_data='" . serialize($loc) . "' AND approved!=0 AND eventstart < ".time()); $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date < {$day} ORDER BY date DESC " . $limit); $sort_asc = false; break; case "today": #$items = $db->selectObjects("calendar","location_data='" . serialize($loc) . "' AND approved!=0 AND eventstart >= ".pathos_datetime_startOfDayTimestamp(time()) . " AND eventend <= " . (pathos_datetime_startOfDayTimestamp(time()) + 86400)); $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date = {$day}"); break; case "next": #$items = array($db->selectObject("calendar","location_data='" . serialize($loc) . "' AND approved!=0 AND eventstart >= ".time())); $dates = array($db->selectObject("eventdate", "location_data='" . serialize($loc) . "' AND date >= {$day}")); break; case "month": #$items = $db->selectObjects("calendar","location_data='" . serialize($loc) . "' AND approved!=0 AND eventstart >= ".pathos_datetime_startOfMonthTimestamp(time()) . " AND eventend <= " . pathos_datetime_endOfMonthTimestamp(time())); $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date >= " . pathos_datetime_startOfMonthTimestamp(time()) . " AND date <= " . pathos_datetime_endOfMonthTimestamp(time())); break; } $items = calendarmodule::_getEventsForDates($dates, $sort_asc); for ($i = 0; $i < count($items); $i++) { $thisloc = pathos_core_makeLocation($loc->mod, $loc->src, $items[$i]->id); if ($user && $items[$i]->poster == $user->id) { $canviewapproval = 1; } $items[$i]->permissions = array('administrate' => pathos_permissions_check('administrate', $thisloc) || pathos_permissions_check('administrate', $loc), 'edit' => pathos_permissions_check('edit', $thisloc) || pathos_permissions_check('edit', $loc), 'delete' => pathos_permissions_check('delete', $thisloc) || pathos_permissions_check('delete', $loc)); } $template->assign('items', $items); } } } } } $template->assign('in_approval', $inapproval); $template->assign('canview_approval_link', $canviewapproval); $template->register_permissions(array('administrate', 'configure', 'post', 'edit', 'delete', 'manage_approval', 'manage_categories', 'view'), $loc); $cats = $db->selectObjectsIndexedArray("category", "location_data='" . serialize($loc) . "'"); $cats[0] = null; $cats[0]->name = "<i>{#i18n_noitemsfound#}</i>"; $cats[0]->color = "#000000"; $template->assign("categories", $cats); $config = $db->selectObject("calendarmodule_config", "location_data='" . serialize($loc) . "'"); if (!$config) { $config->enable_categories = 0; } $template->assign("modconfig", $config); $template->output(); }
$count = 0; $info = getdate($startperiod); for ($i = 0; $i < $totaldays; $i++) { $start = mktime(0, 0, 0, $info['mon'], $info['mday'] + $i, $info['year']); // if ( $viewparams['range'] == "week" ) { // $start = mktime(0,0,0,$info['mon'],$info['mday']+$i,$info['year']); // } else if ( $viewparams['range'] == "twoweek" ) { // $start = mktime(0,0,0,$info['mon'],$info['mday']+$i,$info['year']); // // $start = $startperiod + ($i*86400); // } else { // range = month // $start = mktime(0,0,0,$info['mon'],$i,$info['year']); // } //$edates = $db->selectObjects("eventdate",$locsql." AND date = '".$start."'"); $edates = $db->selectObjects("eventdate", $locsql . " AND date = {$start}"); $days[$start] = array(); $days[$start] = calendarmodule::_getEventsForDates($edates); for ($j = 0; $j < count($days[$start]); $j++) { $thisloc = expCore::makeLocation($loc->mod, $loc->src, $days[$start][$j]->id); $days[$start][$j]->permissions = array("administrate" => expPermissions::check("administrate", $thisloc) || expPermissions::check("administrate", $loc), "edit" => expPermissions::check("edit", $thisloc) || expPermissions::check("edit", $loc), "delete" => expPermissions::check("delete", $thisloc) || expPermissions::check("delete", $loc)); } $counts[$start] = count($days[$start]); $count += count($days[$start]); $days[$start] = expSorter::sort(array('array' => $days[$start], 'sortby' => 'eventstart', 'order' => 'ASC')); } $template->assign("days", $days); $template->assign("counts", $counts); $template->assign("start", $startperiod); $template->assign("totaldays", $totaldays); // } else if ($viewparams['type'] == "monthly") { // $monthly = array(); // $counts = array();
return trim($output); } // end quoted_printable_encode } $tz = DISPLAY_DEFAULT_TIMEZONE; $msg = "BEGIN:VCALENDAR\n"; $msg .= "VERSION:2.0\n"; // version for iCalendar files vs vCalendar files $msg .= "CALSCALE:GREGORIAN\n"; $msg .= "METHOD: PUBLISH\n"; $msg .= "PRODID:<-//ExponentCMS//EN>\n"; if (isset($config->rss_cachetime) && $config->rss_cachetime > 0) { $msg .= "X-PUBLISHED-TTL:PT" . $config->rss_cachetime . "M\n"; } $msg .= "X-WR-CALNAME:{$Filename}\n"; $items = calendarmodule::_getEventsForDates($dates); for ($i = 0; $i < count($items); $i++) { // Convert events stored in local time to GMT $eventstart = new DateTime(date('r', $items[$i]->eventstart), new DateTimeZone($tz)); $eventstart->setTimezone(new DateTimeZone('GMT')); $eventend = new DateTime(date('r', $items[$i]->eventend), new DateTimeZone($tz)); $eventend->setTimezone(new DateTimeZone('GMT')); if ($items[$i]->is_allday) { $dtstart = "DTSTART;VALUE=DATE:" . date("Ymd", $items[$i]->eventstart) . "\n"; $dtend = "DTEND;VALUE=DATE:" . date("Ymd", strtotime("midnight +1 day", $items[$i]->eventstart)) . "\n"; } else { $dtstart = "DTSTART;VALUE=DATE-TIME:" . $eventstart->format("Ymd\\THi00") . "Z\n"; if ($items[$i]->eventend) { $dtend = "DTEND;VALUE=DATE-TIME:" . $eventend->format("Ymd\\THi00") . "Z\n"; } else { $dtend = "DTEND;VALUE=DATE-TIME:" . $eventstart->format("Ymd\\THi00") . "Z\n";
static function show($view, $loc = null, $title = '') { global $user; global $db; $locsql = "(location_data='" . serialize($loc) . "'"; $config = $db->selectObject("calendarmodule_config", "location_data='" . serialize($loc) . "'"); if (!empty($config->aggregate)) { $locations = unserialize($config->aggregate); foreach ($locations as $source) { $tmploc = null; $tmploc->mod = 'calendarmodule'; $tmploc->src = $source; $tmploc->int = ''; $locsql .= " OR location_data='" . serialize($tmploc) . "'"; } } $locsql .= ')'; $template = new template('calendarmodule', $view, $loc); if ($title == '') { $title = $db->selectValue('container', 'title', "internal='" . serialize($loc) . "'"); } $template->assign('moduletitle', $title); $canviewapproval = false; $inapproval = false; global $user; if ($user) { $canviewapproval = expPermissions::check("approve", $loc) || expPermissions::check("manage_approval", $loc); } if ($db->countObjects("calendar", "location_data='" . serialize($loc) . "' AND approved!=1")) { foreach ($db->selectObjects("calendar", "location_data='" . serialize($loc) . "' AND approved!=1") as $c) { if ($c->poster == $user->id) { $canviewapproval = true; } } $inapproval = true; } $time = isset($_GET['time']) ? $_GET['time'] : time(); $template->assign("time", $time); $viewparams = $template->viewparams; if ($viewparams === null) { $viewparams = array("type" => "default"); } if ($viewparams['type'] == "minical") { $monthly = expDateTime::monthlyDaysTimestamp($time); $info = getdate($time); $timefirst = mktime(12, 0, 0, $info['mon'], 1, $info['year']); $now = getdate(time()); $currentday = $now['mday']; $endofmonth = date('t', $time); foreach ($monthly as $weekNum => $week) { foreach ($week as $dayNum => $day) { if ($dayNum == $now['mday']) { $currentweek = $weekNum; } if ($dayNum <= $endofmonth) { $monthly[$weekNum][$dayNum]['number'] = $monthly[$weekNum][$dayNum]['ts'] != -1 ? $db->countObjects("eventdate", $locsql . " AND date = " . $day['ts']) : -1; } } } //eDebug($monthly); $template->assign("monthly", $monthly); $template->assign("currentweek", $currentweek); $template->assign("currentday", $currentday); $template->assign("now", $timefirst); $prevmonth = mktime(0, 0, 0, date("m", $timefirst) - 1, date("d", $timefirst) + 10, date("Y", $timefirst)); $nextmonth = mktime(0, 0, 0, date("m", $timefirst) + 1, date("d", $timefirst) + 10, date("Y", $timefirst)); $template->assign("prevmonth", $prevmonth); $template->assign("thismonth", $timefirst); $template->assign("nextmonth", $nextmonth); } else { if ($viewparams['type'] == "byday") { // Remember this is the code for weekly view and monthly listview // Test your fixes on both views before submitting your changes to cvs $startperiod = 0; $totaldays = 0; if ($viewparams['range'] == "week") { $startperiod = expDateTime::startOfWeekTimestamp($time); $totaldays = 7; $template->assign("prev_timestamp3", strtotime('-21 days', $startperiod)); $template->assign("prev_timestamp2", strtotime('-14 days', $startperiod)); $template->assign("prev_timestamp", strtotime('-7 days', $startperiod)); $template->assign("next_timestamp", strtotime('+7 days', $startperiod)); $template->assign("next_timestamp2", strtotime('+14 days', $startperiod)); $template->assign("next_timestamp3", strtotime('+21 days', $startperiod)); } else { if ($viewparams['range'] == "twoweek") { $time = time(); $startperiod = expDateTime::startOfWeekTimestamp($time); $totaldays = 14; $template->assign("prev_timestamp3", strtotime('-42 days', $startperiod)); $template->assign("prev_timestamp2", strtotime('-28 days', $startperiod)); $template->assign("prev_timestamp", strtotime('-14 days', $startperiod)); $template->assign("next_timestamp", strtotime('+14 days', $startperiod)); $template->assign("next_timestamp2", strtotime('+28 days', $startperiod)); $template->assign("next_timestamp3", strtotime('+42 days', $startperiod)); } else { // range = month $startperiod = expDateTime::startOfMonthTimestamp($time); $totaldays = date('t', $time); $template->assign("prev_timestamp3", strtotime('-3 months', $startperiod)); $template->assign("prev_timestamp2", strtotime('-2 months', $startperiod)); $template->assign("prev_timestamp", strtotime('-1 months', $startperiod)); $template->assign("next_timestamp", strtotime('+1 months', $startperiod)); $template->assign("next_timestamp2", strtotime('+2 months', $startperiod)); $template->assign("next_timestamp3", strtotime('+3 months', $startperiod)); } } $days = array(); // added per Ignacio $endofmonth = date('t', $time); for ($i = 1; $i <= $totaldays; $i++) { $info = getdate($time); if ($viewparams['range'] == "week") { $start = mktime(12, 0, 0, $info['mon'], $i, $info['year']); } else { if ($viewparams['range'] == "twoweek") { $start = mktime(12, 0, 0, $info['mon'], $info['mday'] + ($i - 1), $info['year']); // $start = $startperiod + ($i*86400); } else { // range = month $start = mktime(0, 0, 0, $info['mon'], $i, $info['year']); } } $edates = $db->selectObjects("eventdate", $locsql . " AND date = '" . $start . "'"); $days[$start] = calendarmodule::_getEventsForDates($edates); for ($j = 0; $j < count($days[$start]); $j++) { $thisloc = expCore::makeLocation($loc->mod, $loc->src, $days[$start][$j]->id); $days[$start][$j]->permissions = array("administrate" => expPermissions::check("administrate", $thisloc) || expPermissions::check("administrate", $loc), "edit" => expPermissions::check("edit", $thisloc) || expPermissions::check("edit", $loc), "delete" => expPermissions::check("delete", $thisloc) || expPermissions::check("delete", $loc)); } $days[$start] = expSorter::sort(array('array' => $days[$start], 'sortby' => 'eventstart', 'order' => 'ASC')); } $template->assign("days", $days); } else { if ($viewparams['type'] == "monthly") { $monthly = array(); $counts = array(); $info = getdate($time); $nowinfo = getdate(time()); if ($info['mon'] != $nowinfo['mon']) { $nowinfo['mday'] = -10; } // Grab non-day numbers only (before end of month) $week = 0; $currentweek = -1; $timefirst = mktime(12, 0, 0, $info['mon'], 1, $info['year']); $infofirst = getdate($timefirst); $monthly[$week] = array(); // initialize for non days $counts[$week] = array(); if ($infofirst['wday'] == 0 && DISPLAY_START_OF_WEEK == 1) { for ($i = -6; $i < 1 - DISPLAY_START_OF_WEEK; $i++) { $monthly[$week][$i] = array(); $counts[$week][$i] = -1; } $weekday = $infofirst['wday'] + 7; // day number in grid. if 7+, switch weeks } else { for ($i = 1 - $infofirst['wday']; $i < 1 - DISPLAY_START_OF_WEEK; $i++) { $monthly[$week][$i] = array(); $counts[$week][$i] = -1; } $weekday = $infofirst['wday']; // day number in grid. if 7+, switch weeks } // Grab day counts (deprecated, handled by the date function) // $endofmonth = expDateTime::endOfMonthDay($time); $endofmonth = date('t', $time); for ($i = 1; $i <= $endofmonth; $i++) { $start = mktime(0, 0, 0, $info['mon'], $i, $info['year']); if ($i == $nowinfo['mday']) { $currentweek = $week; } #$monthly[$week][$i] = $db->selectObjects("calendar","location_data='".serialize($loc)."' AND (eventstart >= $start AND eventend <= " . ($start+86399) . ") AND approved!=0"); //$dates = $db->selectObjects("eventdate",$locsql." AND date = $start"); $dates = $db->selectObjects("eventdate", $locsql . " AND date = '" . $start . "'"); $monthly[$week][$i] = calendarmodule::_getEventsForDates($dates); $counts[$week][$i] = count($monthly[$week][$i]); if ($weekday >= 6 + DISPLAY_START_OF_WEEK) { $week++; $monthly[$week] = array(); // allocate an array for the next week $counts[$week] = array(); $weekday = DISPLAY_START_OF_WEEK; } else { $weekday++; } } // Grab non-day numbers only (after end of month) for ($i = 1; $weekday && $i < 8 + DISPLAY_START_OF_WEEK - $weekday; $i++) { $monthly[$week][$i + $endofmonth] = array(); $counts[$week][$i + $endofmonth] = -1; } //eDebug($monthly); $template->assign("currentweek", $currentweek); $template->assign("monthly", $monthly); $template->assign("counts", $counts); $template->assign("prevmonth3", strtotime('-3 months', $timefirst)); $template->assign("prevmonth2", strtotime('-2 months', $timefirst)); $template->assign("prevmonth", strtotime('-1 months', $timefirst)); $template->assign("nextmonth", strtotime('+1 months', $timefirst)); $template->assign("nextmonth2", strtotime('+2 months', $timefirst)); $template->assign("nextmonth3", strtotime('+3 months', $timefirst)); $template->assign("now", $timefirst); $template->assign("today", strtotime('today') - 43200); } else { if ($viewparams['type'] == "administration") { // Check perms and return if cant view if ($viewparams['type'] == "administration" && !$user) { return; } $continue = expPermissions::check("administrate", $loc) || expPermissions::check("post", $loc) || expPermissions::check("edit", $loc) || expPermissions::check("delete", $loc) || expPermissions::check("approve", $loc) || expPermissions::check("manage_approval", $loc) ? 1 : 0; $dates = $db->selectObjects("eventdate", $locsql . " AND date >= '" . expDateTime::startOfDayTimestamp(time()) . "'"); $items = calendarmodule::_getEventsForDates($dates); if (!$continue) { foreach ($items as $i) { $iloc = expCore::makeLocation($loc->mod, $loc->src, $i->id); if (expPermissions::check("edit", $iloc) || expPermissions::check("delete", $iloc) || expPermissions::check("administrate", $iloc)) { $continue = true; } } } if (!$continue) { return; } for ($i = 0; $i < count($items); $i++) { $thisloc = expCore::makeLocation($loc->mod, $loc->src, $items[$i]->id); if ($user && $items[$i]->poster == $user->id) { $canviewapproval = 1; } $items[$i]->permissions = array("administrate" => expPermissions::check("administrate", $thisloc) || expPermissions::check("administrate", $loc), "edit" => expPermissions::check("edit", $thisloc) || expPermissions::check("edit", $loc), "delete" => expPermissions::check("delete", $thisloc) || expPermissions::check("delete", $loc)); } $items = expSorter::sort(array('array' => $items, 'sortby' => 'eventstart', 'order' => 'ASC')); $template->assign("items", $items); } else { if ($viewparams['type'] == "default") { if (!isset($viewparams['range'])) { $viewparams['range'] = "all"; } $items = null; $dates = null; $day = expDateTime::startOfDayTimestamp(time()); $sort_asc = true; // For the getEventsForDates call $moreevents = false; switch ($viewparams['range']) { case "all": $dates = $db->selectObjects("eventdate", $locsql); break; case "upcoming": if (!empty($config->rss_limit) && $config->rss_limit > 0) { $eventlimit = " AND date <= " . ($day + $config->rss_limit * 86400); } else { $eventlimit = ""; } $dates = $db->selectObjects("eventdate", $locsql . " AND date >= " . $day . $eventlimit . " ORDER BY date ASC "); // $moreevents = count($dates) < $db->countObjects("eventdate",$locsql." AND date >= $day"); break; case "past": $dates = $db->selectObjects("eventdate", $locsql . " AND date < {$day} ORDER BY date DESC "); // $moreevents = count($dates) < $db->countObjects("eventdate",$locsql." AND date < $day"); $sort_asc = false; break; case "today": $dates = $db->selectObjects("eventdate", $locsql . " AND date = {$day}"); break; case "next": $dates = array($db->selectObject("eventdate", $locsql . " AND date >= {$day}")); break; case "month": $dates = $db->selectObjects("eventdate", $locsql . " AND date >= " . expDateTime::startOfMonthTimestamp(time()) . " AND date <= " . expDateTime::endOfMonthTimestamp(time())); break; } $items = calendarmodule::_getEventsForDates($dates, $sort_asc, isset($template->viewconfig['featured_only']) ? true : false); // Upcoming events can be configured to show a specific number of events. // The previous call gets all events in the future from today // If configured, cut the array to the configured number of events // if ($template->viewconfig['num_events']) { // switch ($viewparams['range']) { // case "upcoming": // case "past": // $moreevents = $template->viewconfig['num_events'] < count($items); // break; // } // $items = array_slice($items, 0, $template->viewconfig['num_events']); //eDebug($items); // } for ($i = 0; $i < count($items); $i++) { $thisloc = expCore::makeLocation($loc->mod, $loc->src, $items[$i]->id); if ($user && $items[$i]->poster == $user->id) { $canviewapproval = 1; } $items[$i]->permissions = array('administrate' => expPermissions::check('administrate', $thisloc) || expPermissions::check('administrate', $loc), 'edit' => expPermissions::check('edit', $thisloc) || expPermissions::check('edit', $loc), 'delete' => expPermissions::check('delete', $thisloc) || expPermissions::check('delete', $loc)); } //Get the image file if there is one. // for ($i = 0; $i < count($items); $i++) { // if (isset($items[$i]->file_id) && $items[$i]->file_id > 0) { // $file = $db->selectObject('file', 'id='.$items[$i]->file_id); // $items[$i]->image_path = $file->directory.'/'.$file->filename; // } // } //eDebug($items); $template->assign('items', $items); $template->assign('moreevents', $moreevents); } } } } } $template->assign('in_approval', $inapproval); $template->assign('canview_approval_link', $canviewapproval); $template->register_permissions(array('administrate', 'configure', 'post', 'edit', 'delete', 'manage_approval', 'manage_categories'), $loc); // $cats = $db->selectObjectsIndexedArray("category","location_data='".serialize($loc)."'"); // $cats = $db->selectObjectsIndexedArray("category"); // $cats[0] = null; // $cats[0]->name = '<i>'.gt('No category').'</i>'; // $cats[0]->color = "#000000"; // $template->assign("categories",$cats); if (!$config) { // $config->enable_categories = 0; $config->enable_ical = 1; } $template->assign("config", $config); if (!isset($config->enable_ical)) { $config->enable_ical = 1; } $template->assign("enable_ical", $config->enable_ical); //Get the tags that have been selected to be shown in the grouped by tag views // if (isset($config->show_tags)) { // $available_tags = unserialize($config->show_tags); // } else { // $available_tags = array(); // } // if (isset($items) && is_array($items)) { // for ($i = 0; $i < count($items); $i++) { // //Get the tags for this calendar event // $selected_tags = array(); // $tag_ids = unserialize($items[$i]->tags); // if(is_array($tag_ids)) {$selected_tags = $db->selectObjectsInArray('tags', $tag_ids, 'name');} // $items[$i]->tags = $selected_tags; // //If this module was configured to group the newsitems by tags, then we need to change the data array a bit // if (isset($config->group_by_tags) && $config->group_by_tags == true) { // $grouped_news = array(); // foreach($items[$i]->tags as $tag) { // if (in_array($tag->id, $available_tags) || count($available_tags) == 0) { // if (!isset($grouped_news[$tag->name])) { $grouped_news[$tag->name] = array();} // array_push($grouped_news[$tag->name],$items[$i]); // } // } // } // } // } $template->output(); }
# # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # Exponent is distributed in the hope that it # will be useful, but WITHOUT ANY WARRANTY; # without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU # General Public License along with Exponent; if # not, write to: # # Free Software Foundation, Inc., # 59 Temple Place, # Suite 330, # Boston, MA 02111-1307 USA # # $Id: viewmonth.php,v 1.6 2005/02/19 00:32:29 filetreefrog Exp $ ################################################## if (!defined('PATHOS')) { exit(''); } pathos_flow_set(SYS_FLOW_PUBLIC, SYS_FLOW_ACTION); calendarmodule::show(DEFAULT_VIEW, $loc);
<?php ################################################## # # Copyright (c) 2004-2011 OIC Group, Inc. # Written and Designed by James Hunt # # This file is part of Exponent # # Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } global $router; //expHistory::flowSet(SYS_FLOW_PUBLIC,SYS_FLOW_ACTION); expHistory::set('viewable', $router->params); $view = isset($_GET['view']) ? $_GET['view'] : "Default"; $title = $db->selectValue('container', 'title', "internal='" . serialize($loc) . "'"); calendarmodule::show($view, $loc, $title);