function fetch_event_date_time($info) { global $timerange, $vbulletin, $vbphrase, $months, $days, $day, $month, $year, $holiday, $eventdate; global $titlecolor, $date1, $date2, $time1, $time2, $recurcriteria, $allday, $show; require_once DIR . '/includes/functions_misc.php'; $daterange = ''; $recurcriteria = ''; $show['recuroption'] = false; $titlecolor = 'alt1'; $info['title'] = htmlspecialchars_uni($info['title']); if ($wordwrap != 0) { $info['title'] = fetch_word_wrapped_string($info['title']); } $info['event'] = iif(empty($info['event']), ' ', parse_calendar_bbcode($info['event'], $info['allowsmilies'])); if (!$info['recurring'] and !$info['singleday']) { $daystamp = gmmktime(0, 0, 0, $month, $day, $year); $eventfirstday = gmmktime(0, 0, 0, gmdate('n', $info['dateline_from_user']), gmdate('j', $info['dateline_from_user']), gmdate('Y', $info['dateline_from_user'])); $eventlastday = gmmktime(0, 0, 0, gmdate('n', $info['dateline_to_user']), gmdate('j', $info['dateline_to_user']), gmdate('Y', $info['dateline_to_user'])); if ($info['dateline_from'] == $daystamp) { if ($eventfirstday == $daystamp) { if ($eventfirstday != $eventlastday) { if (vbdate('g:ia', $info['dateline_from_user'], false, false) == '12:00am') { $allday = true; } else { $time2 = vbgmdate($vbulletin->options['timeformat'], gmmktime(0, 0, 0, $month, $day, $year)); } } } } else { if ($eventlastday == $daystamp) { $time1 = gmdate($vbulletin->options['timeformat'], gmmktime(0, 0, 0, $month, $day, $year)); $time1 = vbgmdate($vbulletin->options['timeformat'], gmmktime(0, 0, 0, $month, $day, $year)); } else { $allday = true; // Used in conditional } } } if ($info['holidayid']) { $eventdate = vbgmdate($vbulletin->options['dateformat'], gmmktime(0, 0, 0, $month, $day, $year)); } else { if ($info['singleday']) { $eventdate = vbgmdate($vbulletin->options['dateformat'], $info['dateline_from']); } else { $date1 = vbgmdate($vbulletin->options['dateformat'], $info['dateline_from_user']); $date2 = vbgmdate($vbulletin->options['dateformat'], $info['dateline_to_user']); $time1 = vbgmdate($vbulletin->options['timeformat'], $info['dateline_from_user']); $time2 = vbgmdate($vbulletin->options['timeformat'], $info['dateline_to_user']); if ($info['recurring']) { $recurcriteria = fetch_event_criteria($info); $show['recuroption'] = true; } else { $show['daterange'] = iif($date1 != $date2, true, false); $eventdate = vbgmdate($vbulletin->options['dateformat'], $info['dateline_from_user']); } } } return $info; }
} } if (empty($eventarray) and !$show['birthdays'] and !$show['holiday']) { eval(standard_error(fetch_error('noevents'))); } $monthselected = array($month => 'selected="selected"'); $calendarjump = construct_calendar_jump($calendarinfo['calendarid'], $month, $year); // Make Rest of Nav Bar require_once DIR . '/includes/functions_misc.php'; if ($vbulletin->GPC['eventid']) { if ($validdate) { $navbits['calendar.php?' . $vbulletin->session->vars['sessionurl'] . "do=getinfo&c={$calendarinfo['calendarid']}&day={$year}-{$month}-{$day}"] = vbgmdate($vbulletin->options['dateformat'], gmmktime(0, 0, 0, $month, $day, $year)); } $navbits[''] = $eventinfo['title']; } else { $navbits[''] = vbgmdate($vbulletin->options['dateformat'], gmmktime(0, 0, 0, $month, $day, $year)); } $navbits = construct_navbits($navbits); $navbar = render_navbar_template($navbits); ($hook = vBulletinHook::fetch_hook('calendar_getday_complete')) ? eval($hook) : false; $templater = vB_Template::create('calendar_showevents'); $templater->register_page_templates(); $templater->register('caldaybits', $caldaybits); $templater->register('userbdays', $userbdays); $templater->register('pagetitle', $pagetitle); $HTML = $templater->render(); $templater = vB_Template::create('CALENDAR'); $templater->register_page_templates(); $templater->register('calendarjump', $calendarjump); $templater->register('calendarid', $calendarid); $templater->register('calendarinfo', $calendarinfo);
/** * Any checks to run immediately before saving. If returning false, the save will not take place. * * @param boolean Do the query? * * @return boolean True on success; false if an error occurred */ function pre_save($doquery = true) { if ($this->presave_called !== null) { return $this->presave_called; } if (!$this->verify_image_count('event', 'allowsmilies', 'calendar')) { return false; } if ($this->verify_datetime) { if (!checkdate($this->info['fromdate']['month'], $this->info['fromdate']['day'], $this->info['fromdate']['year']) or $this->info['type'] != 'single' and !checkdate($this->info['todate']['month'], $this->info['todate']['day'], $this->info['todate']['year'])) { $this->error('calendarbaddate'); return false; } if ($this->info['type'] != 'single') { // extract the relevant info from from_time and to_time $time_re = '#^(0?[0-9]|1[012])\\s*[:.]\\s*([0-5]\\d)(\\s*[AP]M)?|([01]\\d|2[0-3])\\s*[:.]\\s*([0-5]\\d)$#i'; // match text in field for a valid time if (preg_match($time_re, $this->info['fromtime'], $matches)) { if (count($matches) == 3) { $from_hour = intval($matches[1]); $from_minute = intval($matches[2]); $from_ampm = $matches[1] == '12' ? 'PM' : 'AM'; } else { if (count($matches) == 4) { $from_hour = intval($matches[1]); $from_minute = intval($matches[2]); $from_ampm = strtoupper(trim($matches[3])); } else { $from_hour = intval($matches[4]); $from_minute = intval($matches[5]); $from_ampm = $from_hour <= 11 ? 'AM' : 'PM'; } } } else { $this->error('calendarbadtime'); return false; } // preg match text in field for a valid time if (preg_match($time_re, $this->info['totime'], $matches)) { if (count($matches) == 3) { $to_hour = intval($matches[1]); $to_minute = intval($matches[2]); $to_ampm = $matches[1] == '12' ? 'PM' : 'AM'; } else { if (count($matches) == 4) { $to_hour = intval($matches[1]); $to_minute = intval($matches[2]); $to_ampm = strtoupper(trim($matches[3])); } else { $to_hour = intval($matches[4]); $to_minute = intval($matches[5]); $to_ampm = $to_hour <= 11 ? 'AM' : 'PM'; } } } else { $this->error('calendarbadtime'); return false; } if (($pos = strpos($this->registry->options['timeformat'], 'H')) === false) { if ($to_ampm == 'PM') { if ($to_hour >= 1 and $to_hour <= 11) { $to_hour += 12; } } else { if ($to_hour == 12) { $to_hour = 0; } } if ($from_ampm == 'PM') { if ($from_hour >= 1 and $from_hour <= 11) { $from_hour += 12; } } else { if ($from_hour == 12) { $from_hour = 0; } } } $min_offset = $this->fetch_field('utc') - intval($this->fetch_field('utc')); $from_hour -= intval($this->fetch_field('utc')); $from_minute -= intval($min_offset * 60); $to_hour -= intval($this->fetch_field('utc')); $to_minute -= intval($min_offset * 60); $dateline_to = gmmktime($to_hour, $to_minute, 0, $this->info['todate']['month'], $this->info['todate']['day'], $this->info['todate']['year']); $dateline_from = gmmktime($from_hour, $from_minute, 0, $this->info['fromdate']['month'], $this->info['fromdate']['day'], $this->info['fromdate']['year']); if ($dateline_to < $dateline_from) { $this->error('calendartodate'); return false; } require_once DIR . '/includes/functions_misc.php'; $this->set_info('occurdate', vbgmdate('Y-n-j', $dateline_from + $this->registry->userinfo['timezoneoffset'] * 3600, false, false)); } else { $dateline_to = 0; $dateline_from = gmmktime(0, 0, 0, $this->info['fromdate']['month'], $this->info['fromdate']['day'], $this->info['fromdate']['year']); require_once DIR . '/includes/functions_misc.php'; $this->set_info('occurdate', $occurdate = vbgmdate('Y-n-j', $dateline_from, false, false)); } $this->set('dateline_to', $dateline_to); $this->set('dateline_from', $dateline_from); $recuroption = ''; if ($this->info['type'] == 'recur') { $checkevent = array('eventid' => 1, 'dateline_from' => $dateline_from, 'dateline_to' => $dateline_to, 'dateline_from_user' => $dateline_from + $this->registry->userinfo['timezoneoffset'] * 3600, 'dateline_to_user' => $dateline_to + $this->registry->userinfo['timezoneoffset'] * 3600, 'recurring' => $this->fetch_field('recurring'), 'utc' => $this->fetch_field('utc')); $startday = gmmktime(0, 0, 0, gmdate('n', $checkevent['dateline_from_user']), gmdate('j', $checkevent['dateline_from_user']), gmdate('Y', $checkevent['dateline_from_user'])); $endday = gmmktime(0, 0, 0, gmdate('n', $checkevent['dateline_to_user']), gmdate('j', $checkevent['dateline_to_user']), gmdate('Y', $checkevent['dateline_to_user'])); if ($this->info['recur']['pattern'] == 1) { $recuroption = $this->info['recur']['dailybox']; } else { if ($this->info['recur']['pattern'] == 3) { if ($this->info['recur']['weeklysun']) { $daybit = 1; } if ($this->info['recur']['weeklymon']) { $daybit += 2; } if ($this->info['recur']['weeklytue']) { $daybit += 4; } if ($this->info['recur']['weeklywed']) { $daybit += 8; } if ($this->info['recur']['weeklythu']) { $daybit += 16; } if ($this->info['recur']['weeklyfri']) { $daybit += 32; } if ($this->info['recur']['weeklysat']) { $daybit += 64; } $recuroption = $this->info['recur']['weeklybox'] . '|' . $daybit; } else { if ($this->info['recur']['pattern'] == 4) { $recuroption = $this->info['recur']['monthly1'] . '|' . $this->info['recur']['monthlybox1']; } else { if ($this->info['recur']['pattern'] == 5) { $recuroption = $this->info['recur']['monthly2'] . '|' . $this->info['recur']['monthly3'] . '|' . $this->info['recur']['monthlybox2']; } else { if ($this->info['recur']['pattern'] == 6) { $recuroption = $this->info['recur']['yearly1'] . '|' . $this->info['recur']['yearly2']; } else { if ($this->info['recur']['pattern'] == 7) { $recuroption = $this->info['recur']['yearly3'] . '|' . $this->info['recur']['yearly4'] . '|' . $this->info['recur']['yearly5']; } } } } } } $checkevent['recuroption'] = $recuroption; $foundevent = false; while ($startday <= $endday) { $temp = explode('-', gmdate('n-j-Y', $startday)); if (cache_event_info($checkevent, $temp[0], $temp[1], $temp[2], 0)) { $foundevent = true; break; } $startday += 86400; } if (!$foundevent) { $this->error('calendarnorecur'); return false; } } $this->set('recuroption', $recuroption); if ($this->condition === null) { if ($query = $this->dbobject->query_first("\n\t\t\t\t\tSELECT eventid\n\t\t\t\t\tFROM " . TABLE_PREFIX . "event\n\t\t\t\t\tWHERE userid = " . intval($this->fetch_field('userid')) . "\n\t\t\t\t\t\tAND dateline_from = " . intval($this->fetch_field('dateline_from')) . "\n\t\t\t\t\t\tAND dateline_to = " . intval($this->fetch_field('dateline_to')) . "\n\t\t\t\t\t\tAND event = '" . $this->dbobject->escape_string($this->fetch_field('event')) . "'\n\t\t\t\t\t\tAND title = '" . $this->dbobject->escape_string($this->fetch_field('title')) . "'\n\t\t\t\t\t\tAND calendarid = " . intval($this->fetch_field('calendarid')) . "\n\t\t\t\t")) { $this->error('calendareventexists'); return false; } if (!$this->fetch_field('dateline')) { $this->set('dateline', TIMENOW); } } } $return_value = true; ($hook = vBulletinHook::fetch_hook('eventdata_presave')) ? eval($hook) : false; $this->presave_called = $return_value; return $return_value; }