Curious if we can allow the “Upcoming Calendar” events to tie into saveable/add-able iCal/Gmail saveable events that could link to the thread slated for the event?
I'm not familiar with iCal/Gmail. I've read that iCal import has limited functionality on this site and no export capability, but that was for a slightly older version (2.0.0) of the software. I don't know what if any differences there are in this version (2.0.15) I can't find any documentation on how to use it. I read that the next major release of the forum software is supposed to have enhanced import and export iCal functionality.
I've not slept since Wed morning and my brain is not fully functioning right now. I'll have a look when I'm fresh and see if I can figure it out how to import and possibly export. You may need to know the calendar event ID to import to it. Not understanding the Google iCal is not helping me.
If I were to guess I think the URL to access a calendar event, if it works, would be something like this
https://washingtoncapitalsfanforum.com/index.php?action=calendar;sa=ical;eventid=102where the event id must match the event id of the calendar event. You can see it in the URL if you edit the calendar event. It looks like "eventid=102", the one for tonight's calendar event.
I'll attach the "
Calendar.php" and "
Subs-Calendar.php" and "
Post.php" files to this post and you can have a look and see if you can see how it lines up with what you need. We can edit these too and test when the site is not too busy.
If we use any google API's in the code we'll probably have to install a couple of PHP modules to the site. I believe CURL & JSON might be needed. I think I have these available to install.
We should probably talk on the phone about this in the future.
I just found someone that wrote a tweak for the 2.0.0 version of SMF Forum, again ours is version 2.0.15.. Claims it works for both Apple and Google iCal exports.
Here is the modified function: (would go in Calendar.php)
--------------------
function iCalDownload()
{
global $smcFunc, $sourcedir, $forum_version, $context, $modSettings, $mbname;
// Goes without saying that this is required.
if (!isset($_REQUEST['eventid']))
fatal_lang_error('no_access', false);
// This is kinda wanted.
require_once($sourcedir . '/Subs-Calendar.php');
// Load up the event in question and check it exists.
$event = getEventProperties($_REQUEST['eventid']);
if ($event === false)
fatal_lang_error('no_access', false);
// Check the title isn't too long - iCal requires some formatting if so.
$title = str_split($event['title'], 30);
foreach ($title as $id => $line)
{
if ($id != 0)
$title[$id] = ' ' . $title[$id];
$title[$id] .= "\n";
}
// Format the date. Note: No separator characters are to be used! jre -2011-06-26
$date = $event['year'] . ($event['month'] < 10 ? '0' . $event['month'] : $event['month']) . ($event['day'] < 10 ? '0' . $event['day'] : $event['day']);
// $date .= '120000Z'; Since there is no time associated with SMF events this is not required.
// This is what we will be sending later.
$filecontents = '';
$filecontents .= 'BEGIN:VCALENDAR' . "\n";
$filecontents .= 'VERSION:2.0' . "\n";
$filecontents .= 'CALSCALE:GREGORIAN' . "\n"; //jre 2011-06-26
$filecontents .= 'METHOD:PUBLISH' . "\n"; //jre 2011-06-26
$filecontents .= 'PRODID:-//SimpleMachines//SMF ' . (empty($forum_version) ? 1.0 : strtr($forum_version, array('SMF ' => ''))) . '//EN' . "\n";
$filecontents .= 'X-WR-CALNAME:'. $mbname. "\n"; //jre 2011-06-26
// $filecontents .= 'X-WR-TIMEZONE:'. date_default_timezone_get() . "\n"; //not required as there is no time associated with the events. jre 2011-06-26
$filecontents .= 'BEGIN:VEVENT' . "\n";
$filecontents .= 'DTSTART;VALUE=DATE:' .$date. "\n"; //jre 2011-06-30
// $filecontents .= 'DTSTART:' .$date. "\n"; //jre 2011-06-26
// $filecontents .= 'DTEND:' .$date. "\n"; //jre 2011-06-30
$filecontents .= 'SUMMARY:' . implode('', $title);
$filecontents .= 'UID:'.$event['id_event']."@".str_replace(" ","-",$mbname)."\n";//jre 2011-06-30
$filecontents .= 'END:VEVENT' . "\n";
$filecontents .= 'END:VCALENDAR';
// Send some standard headers.
ob_end_clean();
if (!empty($modSettings['enableCompressedOutput']))
@ob_start('ob_gzhandler');
else
ob_start();
// Send the file headers
header('Pragma: ');
header('Cache-Control: no-cache');
if (!$context['browser']['is_gecko'])
header('Content-Transfer-Encoding: binary');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT');
header('Accept-Ranges: bytes');
header('Connection: close');
header('Content-Disposition: attachment; filename=' . $event['title'] . '.ics');
// How big is it?
if (empty($modSettings['enableCompressedOutput']))
header('Content-Length: ' . $smcFunc['strlen']($filecontents));
// This is a calendar item!
header('Content-Type: text/calendar');
// Chuck out the card.
echo $filecontents;
// Off we pop - lovely!
obExit(false);
}
-------------------------
Now I have about 2 hours or so to sleep before the game. I hope I hear the alarm.
Cheers,