[TYPO3-seminars] ICAL export for Seminars
Sönke Hartung
hartung.germany at gmail.com
Wed Jan 11 22:45:50 CET 2012
Hi Denny,
here is it. Keep it on a safe place, the file contains your DB-Password.
It's top secret, same as your /typo3conf/localconf.php!
Replace the Dummy-Data in the second line with your DB host and Login data.
Replace db-name with your database
<?php
$connection = mysql_connect("server.com","username","password") or die
("No connection. Wrong username or password?");
mysql_select_db("db-name") or die ("DB not found.");
# Query, excludes some seminars
# (special for my case, create your own for your one)
$query = "SELECT uid, begin_date, end_date, tstamp FROM
tx_seminars_seminars WHERE pid = '144' AND hidden = '0' AND deleted =
'0' AND uid NOT BETWEEN 357 AND 377";
$result = mysql_query($query);
$filename = "seminars_".time().".ics";
$file = fopen($filename, w);
fwrite($file, "BEGIN:VCALENDAR\n");
fwrite($file, "PRODID:PHP\n");
fwrite($file, "VERSION:2.0\n");
fwrite($file, "METHOD:REQUEST\n");
while($row = mysql_fetch_object($result))
{
#Find the UID of the organizers
$query_uid_organizer = "SELECT uid_foreign FROM
tx_seminars_seminars_organizers_mm WHERE uid_local = '$row->uid'";
$result_uid_organizer = mysql_query($query_uid_organizer);
while($row_uid_organizer = mysql_fetch_object($result_uid_organizer))
{
# UID of the organizer:
#echo $row_uid_organizer->uid_foreign;
# Find the name of the organizer
$query_name_organizer = "SELECT title FROM tx_seminars_organizers
WHERE uid = '$row_uid_organizer->uid_foreign'";
$result_name_organizer = mysql_query($query_name_organizer);
while($row_result_organizer = mysql_fetch_object($result_name_organizer))
{
# organizer name:
$name_organizer = $row_result_organizer->title;
#echo $name_organizer;
}
}
fwrite($file, "BEGIN:VEVENT\n");
fwrite($file, "DTSTART;TZID=Europe/Berlin:" .
date("Ymd",$row->begin_date) . "T" . date("His",$row->begin_date) . "\n");
fwrite($file, "DTEND;TZID=Europe/Berlin:" . date("Ymd",$row->end_date)
. "T" . date("His",$row->end_date) . "\n");
fwrite($file, "DTSTAMP;TZID=Europe/Berlin:" . date("Ymd",$row->tstamp)
. "T" . date("His",$row->tstamp) . "\n");
fwrite($file, "UID:$row->uid\n");
fwrite($file, "SEQUENCE:0\n");
fwrite($file, "SUMMARY:$name_organizer ($row->uid)\n");
fwrite($file, "DESCRIPTION:$name_organizer ($row->uid)\n");
#fwrite($file, "LOCATION:Place\n");
fwrite($file, "END:VEVENT\n");
}
fwrite($file, "END:VCALENDAR");
fclose($file);
echo "<a href=\"url/$filename\"> Download </a>";
?>
Execute the script via the URL of it. You get a link to the ICS file.
Secure the script execution e.g. with password protected folders.
Improvements are welcome!
Sönke
Am 04.01.2012 23:36, schrieb Denis Torgal:
> On 20.07.2011 19:48, Sönke Hartung wrote:
>> I wrote a quick-and-dirty php script to export seminars into ical
>> format. This gives me a better overview of overlapping seminars.
>
> Hello Sönke,
>
> could you provide this script? That would be very nice.
> Or can you tell more how you create it?
>
> Kind regards and thanks in advance
>
> Denny
More information about the TYPO3-project-seminars
mailing list