If anyone is interested in helping out, here is the code I am using. This is to be cronned as a scheduled task.
PHP Code:
<?php
// ######################## SET PHP ENVIRONMENT ###########################
//error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
exit;
}
// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################
require_once(DIR . '/includes/functions_newpost.php');
require_once(DIR . '/includes/functions_wysiwyg.php');
require_once(DIR . '/includes/functions_calendar.php');
$now = time();
$month = date('m', $now);
$day = date('d', $now);
$year = date('Y', $now);
$date = mktime(0, 0, 0, $month, $day, $year);
$day1 = $date + 604800;
$day2 = $day1 + 86400;
$day3 = $day2 + 86400;
$day4 = $day3 + 86400;
$day5 = $day4 + 86400;
$day6 = $day5 + 86400;
$day7 = $day6 + 86400;
$calendarinfo[calendarid] = 5;
echo "<html><head><title>test</title></head><body>Today is: $date and One Week from Today is: $day1 Calendarid is $calendarinfo[calendarid]</body></html>";
$day1post1title = "7am - OPEN";
$day1post2title = "10am - OPEN";
$day1post3title = "1pm - OPEN";
$day1post4title = "4pm - OPEN";
$day1post5title = "7pm - OPEN";
$day1post6title = "10pm - OPEN";
$vbulletin->db->query_write("
INSERT INTO " . TABLE_PREFIX ."event (eventid, userid, event, title, allowsmilies, recurring, recuroption, calendarid, customfields, visible, dateline, utc, dst, dateline_from, dateline_to)
VALUES ('', '1', 'Open', '" . $day1post1title . "', '1', '0', '', '5', NULL, '1', '" . $day1 . "', '0.00', '0', '" . $day1 . "', '0')
");
global $vbulletin, $vbphrase, $_CALENDAROPTIONS;
if (!$vbulletin->options['showevents'])
{
return false;
}
$storeevents = array();
// Store timestamp 48 hours before the current time and 48 hours after the showevent period
$beginday = TIMENOW - 172800;
$endday = TIMENOW + 86400 + 86400 * $vbulletin->options['showevents'];
$storeevents['date'] = gmdate('n-j-Y' , $endday);
$events = $vbulletin->db->query_read_slave("
SELECT eventid, userid, event.title, recurring, recuroption, dateline_from, dateline_to, event.calendarid, IF (dateline_to = 0, 1, 0) AS singleday, customfields,
dateline_from AS dateline_from_user, dateline_to AS dateline_to_user, utc, dst
FROM " . TABLE_PREFIX . "event AS event
INNER JOIN " . TABLE_PREFIX . "calendar AS calendar USING (calendarid)
WHERE ((dateline_to >= $beginday AND dateline_from < $endday) OR (dateline_to = 0 AND dateline_from >= $beginday AND dateline_from <= $endday ))
AND visible = 1
AND calendar.options & " . intval($_CALENDAROPTIONS['showupcoming']) . "
ORDER BY dateline_from
");
while ($event = $vbulletin->db->fetch_array($events))
{
$event['title'] = htmlspecialchars_uni($event['title']);
$storeevents["$event[eventid]"] = $event;
}
build_datastore('eventcache', serialize($storeevents), 1);
return $storeevents;
?>
This successfully inserts the event, which can then be access via calendar.php?e=xxxx&c=5 but the event is not viewable on the calendar.