function showOptions($calendar) { helpers::debug('showOptions()'); $html = "<form name=frmOptions method=POST>"; $html .= "<h2>Options</h2>"; $html .= $this->buildOptionList($calendar); $html .= "<br><hr><input type=submit name='SaveOptions' value='Save' />"; $html .= "<input type=hidden name='calendar' value='{$calendar}' />"; $html .= "</form>"; return $html; }
static function is_my_calendar($key) { $arr = explode('&', $_SERVER['REQUEST_URI']); if (isset($arr[1])) { $url_name = urldecode($arr[1]); if (stripos($url_name, $key) > 0) { return true; } } if (isset($_POST['calendar'])) { helpers::debug("is_my_calendar-\$_POST: " . $_POST['CalendarKey']); if ($_POST['CalendarKey'] == $key) { return true; } } return false; }
private function url_EditEvent($safeUrl, $eventID) { helpers::debug('url_EditEvent'); global $wgUser, $wgParser, $wgScript; $currentUser = $wgUser->getName(); $html = $this->tabHtml; $strInvites = ''; $lastedited = ''; $arr_invites = array(); $tranlated = ''; $event = $this->db->getEvent($eventID); $start = helpers::date($event['start']); $end = helpers::date($event['end']); $startTime = helpers::time($event['start']); $endTime = helpers::time($event['end']); if (isset($event['editeddate'])) { $editeddate = helpers::date($event['editeddate']); $lastedited = helpers::translate('mwc_last_edited_by') . ': ' . $event['editedby'] . " ({$editeddate})"; } $createddate = helpers::date($event['createddate']); $createdby = helpers::translate('mwc_created_by') . ": " . $event['createdby'] . " ({$createddate})"; $this->makeSafeHtml($event); // build invite(notify) list $arr_invites = unserialize($event['invites']); if (is_array($arr_invites)) { foreach ($arr_invites as $invite) { if (strpos($invite, "#") === 0) { $grpCount = count($this->db->getGroupUsers(trim(str_replace("#", "", $invite)))); $strInvites .= "{$invite} ({$grpCount} " . helpers::translate("mwc_members") . ")" . " "; } else { $user = User::newFromName(trim($invite)); if ($user) { $strInvites .= $invite . "(" . $user->getRealName() . ") "; } } } } $disableTimeFields = ''; $allDayChecked = ''; if ($event['allday'] == true) { $allDayChecked = 'checked'; $disableTimeFields = 'disabled'; } ## funky display as the text is saves as \r\n.. so I'm removing the \n and leaving the \r ## caused textarea to add html tags (<p><br/>) etc $text = $event['text']; //$text = $wgParser->recursiveTagParse($text); if (!$this->useRTE) { $text = str_replace("\r\n", "\r", $text); $text = strip_tags($text); } if ($this->useRTE) { //$text = str_replace("\n", "x", $event['text']); //$text = str_replace("\r", "x", $event['text']); } helpers::debug($text, 2); // update the 'hidden' input field so we retain the calendar name for the db update $html = str_replace('[[calendar]]', $this->calendarName, $html); $html = str_replace('[[CalendarKey]]', $this->key, $html); $html = str_replace('[[EventID]]', $event['id'], $html); $html = str_replace('[[Subject]]', $event['subject'], $html); $html = str_replace('[[Location]]', $event['location'], $html); $html = str_replace('[[Invites]]', $strInvites, $html); $html = str_replace('[[Start]]', $start, $html); $html = str_replace('[[End]]', $end, $html); $html = str_replace('[[Text]]', $text, $html); $html = str_replace('[[LastEdited]]', $lastedited, $html); $html = str_replace('[[CreatedBy]]', $createdby, $html); $html = str_replace('[[START_TIME]]', $startTime, $html); $html = str_replace('[[END_TIME]]', $endTime, $html); $html = str_replace('[[START_TIME_DISABLED]]', $disableTimeFields, $html); $html = str_replace('[[END_TIME_DISABLED]]', $disableTimeFields, $html); $html = str_replace('[[ALL_DAY_CHECKED]]', $allDayChecked, $html); $html = str_replace('[[URL]]', $safeUrl, $html); // disable delete for users that didnt create the event... only creator or admin can delete //$isValid = User::newFromName( $event['createdby'] )->getID(); $isValid = User::newFromName($event['createdby']); $isAdmin = in_array('sysop', $wgUser->getGroups()); if ($currentUser != $event['createdby'] && $isValid && !$isAdmin) { $tranlated = helpers::translate('mwc_delete_title'); $html = str_replace('[[Disabled]]', "disabled title='{$tranlated}'", $html); } return $this->setHtmlTags($html); }
} } } if (!empty($files)) { $src = []; foreach ($files as $file) { helpers::debug(chr(9) . 'Adding ' . $file); $src[] = file_get_contents($file); } if (!empty($src)) { $src = implode(PHP_EOL, $src); helpers::debug('Cleaning ' . $group); $src = helpers::clean($src); helpers::debug('Uglifying ' . $group); $src = helpers::uglify($src); $all[] = $src; $name = sprintf($filename, $group); helpers::debug('Saving ' . $group . ' to ' . $name); helpers::save($path, $name, $prefix . $src); } } else { helpers::debug(chr(9) . 'No sources found'); } } if (!empty($all)) { $name = sprintf($filename, 'all'); helpers::debug('Saving combined sources to ' . $name); helpers::save($path, $name, $prefix . implode(PHP_EOL, $all)); } helpers::debug('Done');
private static function sendmail($to, $subject, $message, $headers) { helpers::debug("Email event triggered"); $db = new CalendarDatabase(); $arrUsers = array(); $grpUserArr = array(); $email_addresses = ''; $arr = explode("\n", $to); foreach ($arr as $invite) { ##clean off the (xyz) stuff $temp = explode('(', $invite); $invite = trim($temp[0]); if (strpos($invite, "#") === 0) { $grpUserArr = $db->getGroupUsers(str_replace("#", "", $invite)); $arrUsers = array_merge($grpUserArr, $arrUsers); } else { $arrUsers[] = $invite; } } $arrUsers = array_unique($arrUsers); foreach ($arrUsers as $u) { $user = User::newFromName($u); if ($user) { if (!$user->getEmail() == '') { $email_addresses .= $user->getEmail() . ","; } } } if ($email_addresses != "") { helpers::debug("Emails sent to: {$email_addresses}"); mail($email_addresses, $subject, $message, $headers); } }
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); } }