Ejemplo n.º 1
0
function pathos_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 = pathos_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');
}
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
         $eventdate = $db->selectObject('eventdate', 'id=' . $_POST['date_id']);
         $eventdate->date = pathos_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 = pathos_datetime_startOfDayTimestamp(popupdatetimecontrol::parseData("eventdate", $_POST));
         $db->updateObject($eventdate, 'eventdate');
     }
     calendarmodule::spiderContent($item);
 } else {
     pathos_forms_initialize();
     $start_recur = pathos_datetime_startOfDayTimestamp(popupdatetimecontrol::parseData("eventdate", $_POST));
     $stop_recur = pathos_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 = pathos_datetime_recurringDailyDates($start_recur, $stop_recur, $freq);
                 break;
             case "recur_weekly":
                 $dates = pathos_datetime_recurringWeeklyDates($start_recur, $stop_recur, $freq, isset($_POST['day']) ? array_keys($_POST['day']) : array($dateinfo['wday']));
                 break;
             case "recur_monthly":
                 $dates = pathos_datetime_recurringMonthlyDates($start_recur, $stop_recur, $freq, $_POST['month_type']);
                 break;
             case "recur_yearly":
Ejemplo n.º 4
0
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307  USA
#
# $Id: view_day.php,v 1.1 2005/04/25 15:29:50 filetreefrog Exp $
##################################################
if (!defined('PATHOS')) {
    exit('');
}
pathos_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 = pathos_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 (!pathos_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 = pathos_core_makeLocation($loc->mod, $loc->src, $posts[$i]->id);
Ejemplo n.º 5
0
function pathos_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 = pathos_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;
}
#
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307  USA
#
# $Id: banner_click.php,v 1.6 2005/04/18 15:21:56 filetreefrog Exp $
##################################################
define('SCRIPT_EXP_RELATIVE', 'modules/bannermodule/');
define('SCRIPT_FILENAME', 'banner_click.php');
include_once '../../pathos.php';
// Process click
$banner = $db->selectObject('banner_ad', 'id=' . $_GET['id']);
if (!defined('SYS_DATETIME')) {
    require_once BASE . 'subsystems/datetime.php';
}
$start = pathos_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);