public static function CheckForEvents() { global $wgUser, $wgOut; helpers::debug('Checking for POST events'); $db = new CalendarDatabase(); $arr = explode('&', $_SERVER['REQUEST_URI']); $url = $arr[0]; //clear any previous parameters // this is the active user (can be the creator... or the editor) $whodidit = $wgUser->getName(); if (isset($_POST["options"])) { $optionURL = $url . "&Name=" . $_POST['CalendarKey'] . "&Options=true"; header("Location: " . $optionURL); return; } if (isset($_POST["SaveOptions"])) { helpers::debug("POST: SaveOptions"); $arrOptions = self::saveOptions(); $db->setOptions($_POST['calendar'], $arrOptions); } // see if a new event was saved and apply changes to database if (isset($_POST["save"])) { helpers::debug("POST: Event Saved"); $arrEvent = self::buildEventArray(); // are we updating or creating new? if ($_POST['eventid']) { $db->updateEvent($arrEvent, $_POST['eventid']); } else { $db->setEvent($arrEvent); } if (isset($_POST["invites"])) { CalendarEmail::send($_POST["invites"], $arrEvent, 'save'); } header("Location: " . $url); } if (isset($_POST["savebatch"])) { helpers::debug("POST: Batch Saved"); self::addFromBatch($db, $whodidit); header("Location: " . $url); } if (isset($_POST["delete"])) { helpers::debug("POST: Event Deleted"); $db->deleteEvent($_POST['eventid']); $arrEvent = self::buildEventArray(); if (isset($_POST["invites"])) { CalendarEmail::send($_POST["invites"], $arrEvent, 'delete'); } header("Location: " . $url); } if (isset($_POST["cancel"])) { helpers::debug("POST: Event Cancelled"); header("Location: " . $url); } // timestamp will be populated only if any nav butten is clicked if (isset($_POST["timestamp"])) { $month = $_POST['monthSelect']; $year = $_POST['yearSelect']; if (isset($_POST['monthForward'])) { $month += 1; } if (isset($_POST['monthBack'])) { $month -= 1; } if (isset($_POST['yearForward'])) { $year += 1; } if (isset($_POST['yearBack'])) { $year -= 1; } if (isset($_POST['today'])) { $timestamp = time(); //now } else { $timestamp = mktime(0, 0, 0, $month, 1, $year); //modified date } $cookie_name = helpers::cookie_name($_POST['CalendarKey']); setcookie($cookie_name, $timestamp); helpers::debug('Setting cookie: ' . $cookie_name); helpers::debug("POST: Navigation Activated: {$cookie_name}, TIMESTAMP: {$timestamp}"); header("Location: " . $url); } }
public function add_from_template($title, $body, $target) { $displayText = ""; $arrEvent = array(); $temp1 = explode('/', $title); $grab_tail = array_pop($temp1); // 2-2010 -Template $date = explode('-', $grab_tail); if (count($date) != 3) { return "[[Error Parsing]]: {$title} <br>"; } $db = new CalendarDatabase(); $month = trim($date[0]); $year = trim($date[1]); $displayText = $body; //$article->fetchContent(0,false,false); $arrAllEvents = explode(chr(10), $displayText); if (count($arrAllEvents) > 0) { for ($i = 0; $i < count($arrAllEvents); $i++) { $arrEvent = explode("#", $arrAllEvents[$i]); if (!isset($arrEvent[1])) { continue; } //skip if (strlen($arrEvent[1]) > 0) { //$day = $arrEvent[0]; $arrRepeat = explode("-", $arrEvent[0]); $startDay = $arrRepeat[0]; $endDay = $arrRepeat[0]; if (count($arrRepeat) > 1) { $endDay = $arrRepeat[1]; } $arr['calendar'] = $target; //$db->getCalendarID($target); $arr['subject'] = $arrEvent[1]; $arr['location'] = ''; $arr['start'] = mktime(0, 0, 0, $month, $startDay, $year); $arr['end'] = mktime(0, 0, 0, $month, $endDay, $year); $arr['allday'] = 1; $arr['text'] = ''; $arr['createdby'] = 'conversion'; $arr['invites'] = ''; if ($this->go == true) { $db->setEvent($arr); } } } } }