Page 1 of 1

iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Mon Sep 28, 2009 6:54 pm
by JeremyBASS
Hello, so here as another simple trick to do...


UDT:    addEvent

Code: Select all




$filename="uploads/calendarEvents/".$params['EventName'].".ics";

if(file_exists($filename)){

}else{
if(!file_exists("uploads/calendarEvents/")){
     mkdir("uploads/calendarEvents/", 0777);
}
	$ourFileName = $filename;
	$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
	fclose($ourFileHandle);
$DESCRIPTION=mysql_real_escape_string ($params['DESCRIPTION']);
$event="BEGIN:VCALENDAR
PRODID:-//NCITA//northcentralidaho.org 1.0//EN
VERSION:1.0
BEGIN:VEVENT
BEGIN:VTIMEZONE
TZID:US-Pacific
LAST-MODIFIED:19870101T000000Z
TZURL:http://zones.stds_r_us.net/tz/US-Pacific
BEGIN:STANDARD
DTSTART:20071104T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=11
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20070311T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=3
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
END:DAYLIGHT
END:VTIMEZONE
URL:http://www.northcentralidaho.org
ORGANIZER:MAILTO:info@northcentralidaho.info
DTSTART;TZID=US-Pacific:".$params['DTSTART']."
DTEND;TZID=US-Pacific:".$params['DTEND']."
LOCATION:".$params['LOCATION']."
SUMMARY:".$params['SUMMARY']."
SEQUENCE:0
UID:1
CATEGORIES:".$params['CATEGORIES']."
DESCRIPTION:".$DESCRIPTION."
END:VEVENT
END:VCALENDAR
";

	// GET LENGTH, AND STORE DATA TO OUR SERVER (OR DATA BASE)
    $len = strlen($event);
    $chk = file_put_contents($filename, $event);
    
    // TEST FOR SUCCESSFUL STORAGE
	if ($len!=$chk) die("LENGTH MISMATCH");
}
echo '<a href="'.$filename.'" target="_blank">'.$params['linktext'].'</a>';

In the cal template

Code: Select all


{assign var=date_start value=$event.event_date_start|replace:" ":"-"}
{assign var=EName value=$event.event_title|replace:"/":""|replace:" ":"-"|replace:"’":""}
{assign var=Name value="$date_start-$EName"}
{assign var=DTSTART value=$date_start|date_format:"%Y%m%dT%H%M%S"}
{assign var=DTEND value=$event.event_date_end|date_format:"%Y%m%dT%H%M%S"}
{assign var=Thesummary value=$event.event_summary}
{assign var=title value=$event.event_title"}
{assign var=SUMMARY value="$title-$Thesummary"}
{assign var=CATEGORIES value=""}
{assign var=LOCATION value=""}
{assign var=DESCRIPTION value=$event.event_details|strip_tags}

{assign var=altFront value='<img src="/images/cms/editbutton.png" alt="Add '}
{assign var=AltBack value=' To your Calendar" />'}

{addEvent EventName="$Name" DTSTART=$DTSTART DTEND=$DTEND SUMMARY=$SUMMARY LOCATION=$LOCATION CATEGORIES=$CATEGORIES DESCRIPTION=$DESCRIPTION linktext=$altFront$AltName$AltBack}




now if you don't want the image... change

Code: Select all

{assign var=altFront value='<img src="/images/cms/editbutton.png" alt="Add '}
{assign var=AltBack value=' To your Calendar" />'}



to

Code: Select all

{assign var=altFront value=''}
{assign var=AltBack value=''}



I will be cleaning this out more later... but.... simple dirty and gets the job done... you can view the output here,


http://98.129.105.20/

which will be come

http://www.northcentralidaho.org


Cheers
Jeremy Bass

Please let me know
what programs you tried it in, any errors, etc... I have Outlook 2000 and 2007 confirmed working... but it should work with much more...


Compatible and tested with:
  • Outlook 2000
  • Outlook 2007
  • Lightning 0.9   (for Thunderbird)
  • Sunbird


Note:
You may want to add this to your .htaccess or equal since there is iis users out there

Code: Select all

AddType application/octet-stream .ics


You need to force the download since some browsers are not well debate who cares get the job done... ;) see ... I got your back

also change your time zone.. I'm sure you all are not in US-Pacific

TZID:US-Pacific

and adjust this to match

TZOFFSETFROM:-0700
TZOFFSETTO:-0800
.
.
.
TZOFFSETFROM:-0800
TZOFFSETTO:-0700

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Wed Dec 16, 2009 2:58 am
by JeremyBASS
Well just an update... I made a module for this..

http://dev.cmsmadesimple.org/projects/ical

just add {cms_module module=iCal Mode="default" Btn="TestSET"} to your CGCalendar template... or anywhere... it don't need a module either...

Cheers
Jeremy

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Sat Dec 19, 2009 3:01 pm
by smansman
thanks for sharing very interesting

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Sat Feb 06, 2010 5:59 am
by suthex
Installing your module, notice it has a pre-req of CMSms 1.6.5 ... are there special CMSms features that require such a "current" version, or will I get away with installing into 1.6 ??


Doug

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Sat Feb 06, 2010 5:34 pm
by JeremyBASS
oh, I think nothing would stop it, but FWIW 1.6.6 is very stable, and it's super easy to upgrade to.  but, no I think it should work just fine, you have to change the version in the file by hand to override. Cheers -Jeremy

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Wed Apr 28, 2010 8:58 pm
by Gregor
Just playing around with the module and before importing the file in my agenda.... Is there a way to change the time zone to Europe?

This is the content of the agenda (cmsms v.1.7)
BEGIN:VCALENDAR
PRODID:-//NCITA//northcentralidaho.org 1.0//EN
VERSION:1.0
BEGIN:VEVENT
BEGIN:VTIMEZONE
TZID:US-Central
LAST-MODIFIED:19870101T000000Z
TZURL:http://zones.stds_r_us.net/tz/US-Central
BEGIN:STANDARD
DTSTART:20071104T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=11
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20070311T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=3
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
END:DAYLIGHT
END:VTIMEZONE
URL:http://www.ontwikkel.jwvdmeene.nl
ORGANIZER:MAILTO:
DTSTART;TZID=US-Central:
DTEND;TZID=US-Central:
LOCATION:
SUMMARY:
SEQUENCE:0
UID:1
CATEGORIES:
DESCRIPTION:
END:VEVENT
END:VCALENDAR
I'm missing a number of dates. Any idea on how to solve this? http://www.ontwikkel.jwvdmeene.nl/kalender/schoolkalender.html

Thnkx,
Gregor

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Thu Apr 29, 2010 2:22 pm
by JeremyBASS
I'll see what I can do to put this to rest... may-be over the weekend.. Cheers -Jeremy

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Wed May 12, 2010 7:01 am
by Gregor
Any luck yet Jeremy?

Gregor

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Wed May 12, 2010 1:35 pm
by JeremyBASS
oh sorry no.. Sadly I'm so upside down it's killing me lol.. I will get to it I just don't know when.. I'm trying to make ends meet and that is not going all that well either lol.. I'll get to it I promise it's on my list.. Cheers -Jeremy

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Posted: Fri Aug 20, 2010 7:39 am
by nicmare
very interesting user interface of the module…Now i know why you will go to Geek Moot for Ajax/CMSms :D :D
but is there maybe an update for european (->germany->berlin) users? :D
i used to use the ical url from cgcalendar but i got troubles with it. and now i am looking for something more reliable…
thanks!