Skip to content

vCalendar support #100

@sproctor

Description

@sproctor

integrate script from Christian Toepp.

<?php
/*
 * Copyright 2014 Christian Toepp <c.toepp@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


$dbUser = "...";
$dbPass = "...";
$dbHost = "...";
$dbName = "...";
header('Content-type: text/calendar');
?>
BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
CALSCALE:GREGORIAN
<?php
$sql = "select e.eid, e.subject,e.description, date_format(e.ctime,'%Y%m%dT%k%i%sZ') as ctime".
       ",date_format(o.start_ts,'%Y%m%dT%k%i%sZ') as start_ts ,date_format(o.end_ts,'%Y%m%dT%k%i%sZ') ".
       "as end_ts from phpc_events as e,phpc_occurrences as o where e.eid=o.eid";
$db = mysql_pconnect($dbHost,$dbUser,$dbPass);
mysql_select_db($dbName,$db);
$res = mysql_query($sql, $db);
while($row = mysql_fetch_assoc($res)){
  error_log('START:'.$row['start_ts']);
  if(empty($row['start_ts'])){
    $res2 = mysql_query("select date_format(start_date,'%Y%m%d') as start, ".
                        "date_format(end_date,'%Y%m%d') as end from ".
                        "phpc_occurrences where eid=".$row['eid'], $db);
    if($row2 = mysql_fetch_assoc($res2)){
      $row['start_ts'] = 'DTSTART;VALUE=DATE:'.$row2['start'];
      $row['end_ts'] = 'DTEND;VALUE=DATE:'.$row2['end'];
    }
  }else{
    $row['start_ts'] = 'DTSTART:'.$row['start_ts'];
    $row['end_ts'] = 'DTEND:'.$row['end_ts'];
  }
  echo "BEGIN:VEVENT\r\n";
  echo 'CREATED:' . $row['ctime'] ."\r\n";
  echo 'SUMMARY:' . $row['subject'] . "\r\n";
  echo 'DESCRIPTION:'.$row['description']."\r\n";
  echo $row['start_ts'] . "\r\n";
  echo $row['end_ts'] . "\r\n";
  echo "END:VEVENT\r\n";
}
?>
END:VCALENDAR

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions