function exponent_backup_095_calendar($db, $object) { if (!defined('SYS_DATETIME')) { include BASE . 'subsystems/datetime.php'; } // Pull edited / editor from posted / poster $object->editor = $object->poster; $object->edited = $object->posted; // Set recurrence and is_allday to false $object->is_recurring = 0; $object->is_allday = 0; // Reset eventstart and eventend to be just times, and create an eventdate. $eventdate = null; $eventdate->location_data = $object->location_data; // Get the time in seconds since midnight, first for event start $eventdate->date = exponent_datetime_startOfDayTimestamp($object->eventstart); $object->eventstart -= $eventdate->date; $object->eventend -= $eventdate->date; // Don't have to hangle categoriy_id, feedback_form or feedback_email $eventdate->event_id = $db->insertObject($object, 'calendar'); $db->insertObject($eventdate, 'eventdate'); }
$eventdate = $db->selectObject('eventdate', 'id=' . intval($_POST['date_id'])); $eventdate->date = exponent_datetime_startOfDayTimestamp(popupdatetimecontrol::parseData("eventdate", $_POST)); $db->updateObject($eventdate, 'eventdate'); } else { $item->approved = 1; $db->updateObject($item, "calendar"); // There should be only one eventdate $eventdate = $db->selectObject('eventdate', 'event_id = ' . $item->id); $eventdate->date = exponent_datetime_startOfDayTimestamp(popupdatetimecontrol::parseData("eventdate", $_POST)); $db->updateObject($eventdate, 'eventdate'); } calendarmodule::spiderContent($item); } else { exponent_forms_initialize(); $start_recur = exponent_datetime_startOfDayTimestamp(popupdatetimecontrol::parseData("eventdate", $_POST)); $stop_recur = exponent_datetime_startOfDayTimestamp(popupdatetimecontrol::parseData("untildate", $_POST)); if ($_POST['recur'] != "recur_none") { // Do recurrence $freq = $_POST['recur_freq_' . $_POST['recur']]; ###echo $_POST['recur'] . "<br />"; switch ($_POST['recur']) { case "recur_daily": $dates = exponent_datetime_recurringDailyDates($start_recur, $stop_recur, $freq); break; case "recur_weekly": $dates = exponent_datetime_recurringWeeklyDates($start_recur, $stop_recur, $freq, isset($_POST['day']) ? array_keys($_POST['day']) : array($dateinfo['wday'])); break; case "recur_monthly": $dates = exponent_datetime_recurringMonthlyDates($start_recur, $stop_recur, $freq, $_POST['month_type']); break; case "recur_yearly":
function exponent_datetime_recurringWeeklyDates($start, $end, $freq, $days) { // Holding array, for keeping the timestamps of applicable dates. // This variable will be returned to the calling scope. $dates = array(); // Need to figure out which weekday occurs directly after the specified // start date. This will be our launching point for the recurrence calculations. $dateinfo = getdate($start); // Finding the Start Date // // Start at the first weekday in the list ($days[$counter] where $counter is 0) // and go until we find a weekday greater than the weekday of the $start date. // // So, if we start on a Tuesday, and want to recur weekly for a MWF rotation, // This would check Monday, then Wednesday and stop, using wednesday for the // recacluated start date ($curdate) for ($counter = 0; $counter < count($days); $counter++) { if ($days[$counter] >= $dateinfo['wday']) { // exit loop, we found the weekday to use ($days[$counter]) break; } } if ($days[$counter] < $dateinfo['wday']) { // in case we did MWF and started on a Saturday... $counter = 0; // reset to first day of next week $start += 86400 * (7 - $dateinfo['wday'] + $days[$counter]); } else { if ($days[$counter] > $dateinfo['wday']) { // 'Normal' case, in which we started before one of the repeat days. $start += 86400 * ($days[$counter] - $dateinfo['wday']); } } // Found start date. Set curdate to the start date, so it gets picked // up in the do ... while loop. $curdate = $start; // Find all of the dates that match the recurrence criteria, within the // specified recurrence range. Implemented as a do ... while loop because // we always need at least the start date, and we have already determined // that with the code above (the $curdate variable) do { // Append $curdate to the array of dates. $curdate will be changed // at the end of the loop, to be equal to the next date meeting the // criteria. If $curdate ever falls outside the recurrence range, the // loop will exit. $dates[] = $curdate; $curdate += 8 * 3600; // Add 8 hours, to avoid DST problems // Grab the date information (weekday, month, day, year, etc.) for // the current date, so we can ratchet up to the next date in the series. $dateinfo = getdate($curdate); // Get the current weekday. $day = $days[$counter]; // Increment the counter so that the next time through we get the next // weekday. If the counter moves off the end of the list, reset it to 0. $counter++; if ($counter >= count($days)) { // Went off the end of the week. Reset the pointer to the beginning $counter = 0; // Difference in number of days between the last day in the rotation // and the first day (for recacluating the $curdate value) #$daydiff = $days[count($days)-1]-$days[0]; $daydiff = 7 + $days[0] - $days[count($days) - 1]; if ($daydiff == 0) { // In case we are in a single day rotation, the difference will be 0. // It needs to be 7, so that we skip ahead a full week. $daydiff = 7; } // Increment the current date to go off to the next week, first weekday // in the rotation. $curdate += 7 * 86400 * ($freq - 1) + 86400 * $daydiff; // Increment by number of weeks } else { // If we haven't gone off the end of the week, we just need to add the number // of days between the next weekday in the rotation ($days[$counter] - because // $counter was incremented above) and the $curdate weekday (store in the // $dateinfo array returned from the PHP call to getdate(), aboce). $curdate += 86400 * ($days[$counter] - $dateinfo['wday']); } // Round down to the start of the day (12:00 am) for $curdate, in case something // got a little out of whack thanks to DST. $curdate = exponent_datetime_startOfDayTimestamp($curdate); } while ($curdate <= $end); // If we go off the end of the recurrence range, ext. // We have no fully calculated the dates we need. Return them to the calling scope. return $dates; }
function show($view, $loc = null, $title = '') { global $user; global $db; $i18n = exponent_lang_loadFile('modules/calendarmodule/class.php'); $template = new template('calendarmodule', $view, $loc); $template->assign('moduletitle', $title); $canviewapproval = false; $inapproval = false; global $user; if ($user) { $canviewapproval = exponent_permissions_check("approve", $loc) || exponent_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")) { include_once BASE . "subsystems/datetime.php"; } if (!defined('SYS_SORTING')) { include_once BASE . 'subsystems/sorting.php'; } if (!function_exists("exponent_sorting_byEventStartAscending")) { function exponent_sorting_byEventStartAscending($a, $b) { return $a->eventstart < $b->eventstart ? -1 : 1; } } //Pathos Compatibility::this is deprecated if (@defined(PATHOS)) { if (!function_exists('pathos_sorting_byEventStartAscending')) { function pathos_sorting_byDateAscending($a, $b) { return exponent_sorting_byEventStartAscending($a, $b); } } } //End Pathos Compatibility if ($viewconfig['type'] == "minical") { $monthly = 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 (deprecated, handled by the php date function) // $endofmonth = exponent_datetime_endOfMonthDay(time()); $endofmonth = date('t', 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("eventdate", "location_data='" . serialize($loc) . "' AND date = {$start}")); 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("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 = exponent_datetime_startOfWeekTimestamp($time); $totaldays = 7; } else { $startperiod = exponent_datetime_startOfMonthTimestamp($time); $totaldays = date('t', time()); } $template->assign("prev_timestamp", $startperiod - 3600); $template->assign("next_timestamp", $startperiod + $totaldays * 86400 + 3600); $days = array(); //added per Ignacio $endofmonth = date('t', $time); for ($i = 1; $i <= $endofmonth; $i++) { $info = getdate($time); $start = mktime(0, 0, 0, $info['mon'], $i, $info['year']); //for ($i = 0; $i < $totaldays; $i++) { // if( $i == 0 ) // { // $start = $startperiod + ($i*86400); // } else { // $start = $startperiod + ($i*86400)-3600; // } #$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 = exponent_core_makeLocation($loc->mod, $loc->src, $days[$start][$j]->id); $days[$start][$j]->permissions = array("administrate" => exponent_permissions_check("administrate", $thisloc) || exponent_permissions_check("administrate", $loc), "edit" => exponent_permissions_check("edit", $thisloc) || exponent_permissions_check("edit", $loc), "delete" => exponent_permissions_check("delete", $thisloc) || exponent_permissions_check("delete", $loc)); } usort($days[$start], "exponent_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 (deprecated, handled by the date function) // $endofmonth = exponent_datetime_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", "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 = exponent_permissions_check("administrate", $loc) || exponent_permissions_check("post", $loc) || exponent_permissions_check("edit", $loc) || exponent_permissions_check("delete", $loc) || exponent_permissions_check("approve", $loc) || exponent_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 = exponent_core_makeLocation($loc->mod, $loc->src, $i->id); if (exponent_permissions_check("edit", $iloc) || exponent_permissions_check("delete", $iloc) || exponent_permissions_check("administrate", $iloc)) { $continue = true; } } } if (!$continue) { return; } for ($i = 0; $i < count($items); $i++) { $thisloc = exponent_core_makeLocation($loc->mod, $loc->src, $items[$i]->id); if ($user && $items[$i]->poster == $user->id) { $canviewapproval = 1; } $items[$i]->permissions = array("administrate" => exponent_permissions_check("administrate", $thisloc) || exponent_permissions_check("administrate", $loc), "edit" => exponent_permissions_check("edit", $thisloc) || exponent_permissions_check("edit", $loc), "delete" => exponent_permissions_check("delete", $thisloc) || exponent_permissions_check("delete", $loc)); } usort($items, "exponent_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 = exponent_datetime_startOfDayTimestamp(time()); $sort_asc = true; // For the getEventsForDates call switch ($viewconfig['range']) { case "all": $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "'"); break; case "upcoming": $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date > {$day} ORDER BY date ASC " . $limit); break; case "past": $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date < {$day} ORDER BY date DESC " . $limit); $sort_asc = false; break; case "today": $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date = {$day}"); break; case "next": $dates = array($db->selectObject("eventdate", "location_data='" . serialize($loc) . "' AND date >= {$day}")); break; case "month": $dates = $db->selectObjects("eventdate", "location_data='" . serialize($loc) . "' AND date >= " . exponent_datetime_startOfMonthTimestamp(time()) . " AND date <= " . exponent_datetime_endOfMonthTimestamp(time())); break; } $items = calendarmodule::_getEventsForDates($dates, $sort_asc); for ($i = 0; $i < count($items); $i++) { $thisloc = exponent_core_makeLocation($loc->mod, $loc->src, $items[$i]->id); if ($user && $items[$i]->poster == $user->id) { $canviewapproval = 1; } $items[$i]->permissions = array('administrate' => exponent_permissions_check('administrate', $thisloc) || exponent_permissions_check('administrate', $loc), 'edit' => exponent_permissions_check('edit', $thisloc) || exponent_permissions_check('edit', $loc), 'delete' => exponent_permissions_check('delete', $thisloc) || exponent_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'), $loc); $cats = $db->selectObjectsIndexedArray("category", "location_data='" . serialize($loc) . "'"); $cats[0] = null; $cats[0]->name = '<i>' . $i18n['no_category'] . '</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(); }
# 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(''); } exponent_flow_set(SYS_FLOW_PUBLIC, SYS_FLOW_ACTION); if (!defined('SYS_DATETIME')) { require_once BASE . 'subsystems/datetime.php'; } $time = isset($_GET['day']) ? $_GET['day'] : time(); $start_day = exponent_datetime_startOfDayTimestamp($time); $end_day = strtotime('+1 day', $start_day); $where = "location_data='" . serialize($loc) . "' AND (is_draft = 0 OR poster = " . ($user ? $user->id : -1) . ") AND posted >= {$start_day} AND posted <= {$end_day}"; if (!exponent_permissions_check('view_private', $loc)) { $where .= ' AND is_private = 0'; } $config = $db->selectObject('weblogmodule_config', "location_data='" . serialize($loc) . "'"); if ($config == null) { $config->allow_comments = 1; } $posts = $db->selectObjects('weblog_post', $where); if (!defined('SYS_SORTING')) { require_once BASE . 'subsystems/sorting.php'; } for ($i = 0; $i < count($posts); $i++) { $ploc = exponent_core_makeLocation($loc->mod, $loc->src, $posts[$i]->id);
# 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('SCRIPT_EXP_RELATIVE', 'modules/BannerModule/'); define('SCRIPT_FILENAME', 'banner_click.php'); include_once '../../exponent.php'; // Process click $banner = $db->selectObject('banner_ad', 'id=' . intval($_GET['id'])); if (!defined('SYS_DATETIME')) { include_once BASE . 'subsystems/datetime.php'; } $start = exponent_datetime_startOfDayTimestamp(time()); $clicks = $db->selectObject('banner_click', 'ad_id=' . $banner->id . ' AND date=' . $start); if ($clicks != null) { $clicks->clicks++; $db->updateObject($clicks, 'banner_click'); } else { $clicks->clicks = 1; $clicks->ad_id = $banner->id; $clicks->date = $start; $db->insertObject($clicks, 'banner_click'); } if (substr($banner->url, 0, 7) != 'http://') { $banner->url = 'http://' . $banner->url; } header('Location: ' . $banner->url);