webcalendar

Check-in [490daaaec6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Get ical export working. Add option to pull all user-selected layers. (Damn it's slow, but it works.)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:490daaaec6e1697d1333f9133d3b3125cb3e1421fab5371182491bba479e98b7
User & Date: ajv-899-334-8894@vsta.org 2017-05-29 22:44:23
Context
2017-05-29
22:55
Add some Github goodies check-in: 814a656a3e user: ajv-899-334-8894@vsta.org tags: master, trunk
22:44
Get ical export working. Add option to pull all user-selected layers. (Damn it's slow, but it works.) check-in: 490daaaec6 user: ajv-899-334-8894@vsta.org tags: master, trunk
22:43
Snapshot, latest Webcalendar into git check-in: 8f1b474690 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to icalclient.php.

1
2
3
4
5
6
7
8
9
...
187
188
189
190
191
192
193




194
195
196
197
198
199
200
<?php
/* $Id: icalclient.php,v 1.1 2017/05/26 14:40:39 vandys Exp $
 *
 *               WARNING * WARNING * WARNING * WARNING * WARNING
 *                 This script is still considered alpha level.
 *                 Please backup your database before using it.
 *               WARNING * WARNING * WARNING * WARNING * WARNING
 *
 * Description:
................................................................................
    break;

  case 'GET':
    // do_debug ( "Exporting updated remote calendar" );
    header ( 'Content-Type: text/calendar' );
    header ( 'Content-Disposition: attachment; filename="' . $login . '.ics"' );
    $use_all_dates = true;




    echo export_ical ();
    break;

  case 'OPTIONS';
    header ( 'Allow: GET, PUT, OPTIONS' );
    break;


|







 







>
>
>
>







1
2
3
4
5
6
7
8
9
...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
/* $Id: icalclient.php,v 1.1 2017/05/26 14:40:39 vandys Exp vandys $
 *
 *               WARNING * WARNING * WARNING * WARNING * WARNING
 *                 This script is still considered alpha level.
 *                 Please backup your database before using it.
 *               WARNING * WARNING * WARNING * WARNING * WARNING
 *
 * Description:
................................................................................
    break;

  case 'GET':
    // do_debug ( "Exporting updated remote calendar" );
    header ( 'Content-Type: text/calendar' );
    header ( 'Content-Disposition: attachment; filename="' . $login . '.ics"' );
    $use_all_dates = true;
    if ($_GET["layers"]) {
	load_user_layers();
	$include_layers = true;
    }
    echo export_ical ();
    break;

  case 'OPTIONS';
    header ( 'Allow: GET, PUT, OPTIONS' );
    break;

Changes to includes/xcal.php.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
237
238
239
240
241
242
243

244
245
246
247
248
249
250
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
...
276
277
278
279
280
281
282

283


284
285
286
287
288
289
290
291
292
293
294
<?php
/**
* All of WebCalendar's ical/vcal functions
*
* @author Craig Knudsen <cknudsen@cknudsen.com>
* @copyright Craig Knudsen, <cknudsen@cknudsen.com>, http://www.k5n.us/cknudsen
* @license http://www.gnu.org/licenses/gpl.html GNU GPL
* @version $Id: xcal.php,v 1.1 2017/05/24 16:32:31 vandys Exp $
* @package WebCalendar
*/

/*
 * Generate Product ID string
 *
 */
................................................................................
function export_time ( $date, $duration, $time, $texport, $vtype = 'E' ) {
  global $TIMEZONE, $vtimezone_data, $use_vtimezone;
  $ret = $vtimezone_exists = '';
  $eventstart = date_to_epoch ( $date . ( $time > 0 ? $time : 0 ), $time>0 );
  $eventend = $eventstart + ( $duration * 60 );
  if ( $time == 0 && $duration == 1440 && strcmp( $texport, 'ical' ) == 0  ) {
    // all day.

    if ( $use_vtimezone && ( $vtimezone_data = get_vtimezone ( $TIMEZONE, $dtstart ) ) ) {
      $vtimezone_exists = true;
      $dtstart = $date . 'T000000';
      $ret .= 'DTSTART;TZID=' . $TIMEZONE . ':' . $dtstart. "\r\n";
     }else
      $ret .= "DTSTART;VALUE=DATE:$date\r\n";
  } else if ( $time == -1 ) {
................................................................................
    // timed  event
    $utc_start = export_ts_utc_date ( $eventstart );
    $dtstart = $date . 'T000000';
    if ( $use_vtimezone && ( $vtimezone_data = get_vtimezone ( $TIMEZONE, $dtstart ) ) ) {
      $vtimezone_exists = true;
      $ret .= 'DTSTART;TZID=' . $TIMEZONE . ':' . $utc_start . "\r\n";
    } else {
    $ret .= "DTSTART:$utc_start\r\n";
  }
  }
  if ( strcmp( $texport, 'ical' ) == 0 ) {
    $utc_dtstamp = export_ts_utc_date ( time () );
    $ret .= "DTSTAMP:$utc_dtstamp\r\n";
    // We don' want DTEND for VTODOs
    if ( $vtype == 'T' || $vtype == 'N' ) return $ret;
    if ( $time == 0 && $duration == 1440 ) {
................................................................................
      $ret .= 'DTEND;VALUE=DATE:' . gmdate ( 'Ymd', $eventend ) . "\r\n";
    }
    else  if ( $time == -1 )
    // untimed event   
     $ret .= "DTEND;VALUE=DATE:$date\r\n";
    else if ( $time > 0 ) {
      // timed  event

      if ( $vtimezone_exists ) {


        $ret .= 'DTEND;TZID=' . $TIMEZONE . ':' . date ( 'Ymd', $eventend ) . "T000000\r\n";
      }else {
      $utc_end = export_ts_utc_date ( $eventend );
      $ret .= "DTEND:$utc_end\r\n";
      }
    }
  } elseif ( strcmp( $texport, 'vcal' ) == 0 ) {
      $utc_end = export_ts_utc_date ( $eventend );
      $ret .= "DTEND:$utc_end\r\n";
  } else {
    $ret .= "DURATION:P$str_duration\r\n";







|







 







>







 







|
|







 







>

>
>
|
|
<
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
...
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
...
277
278
279
280
281
282
283
284
285
286
287
288
289

290
291
292
293
294
295
296
297
<?php
/**
* All of WebCalendar's ical/vcal functions
*
* @author Craig Knudsen <cknudsen@cknudsen.com>
* @copyright Craig Knudsen, <cknudsen@cknudsen.com>, http://www.k5n.us/cknudsen
* @license http://www.gnu.org/licenses/gpl.html GNU GPL
* @version $Id: xcal.php,v 1.1 2017/05/24 16:32:31 vandys Exp vandys $
* @package WebCalendar
*/

/*
 * Generate Product ID string
 *
 */
................................................................................
function export_time ( $date, $duration, $time, $texport, $vtype = 'E' ) {
  global $TIMEZONE, $vtimezone_data, $use_vtimezone;
  $ret = $vtimezone_exists = '';
  $eventstart = date_to_epoch ( $date . ( $time > 0 ? $time : 0 ), $time>0 );
  $eventend = $eventstart + ( $duration * 60 );
  if ( $time == 0 && $duration == 1440 && strcmp( $texport, 'ical' ) == 0  ) {
    // all day.
    $dtstart = $date . 'T000000';
    if ( $use_vtimezone && ( $vtimezone_data = get_vtimezone ( $TIMEZONE, $dtstart ) ) ) {
      $vtimezone_exists = true;
      $dtstart = $date . 'T000000';
      $ret .= 'DTSTART;TZID=' . $TIMEZONE . ':' . $dtstart. "\r\n";
     }else
      $ret .= "DTSTART;VALUE=DATE:$date\r\n";
  } else if ( $time == -1 ) {
................................................................................
    // timed  event
    $utc_start = export_ts_utc_date ( $eventstart );
    $dtstart = $date . 'T000000';
    if ( $use_vtimezone && ( $vtimezone_data = get_vtimezone ( $TIMEZONE, $dtstart ) ) ) {
      $vtimezone_exists = true;
      $ret .= 'DTSTART;TZID=' . $TIMEZONE . ':' . $utc_start . "\r\n";
    } else {
      $ret .= "DTSTART:$utc_start\r\n";
    }
  }
  if ( strcmp( $texport, 'ical' ) == 0 ) {
    $utc_dtstamp = export_ts_utc_date ( time () );
    $ret .= "DTSTAMP:$utc_dtstamp\r\n";
    // We don' want DTEND for VTODOs
    if ( $vtype == 'T' || $vtype == 'N' ) return $ret;
    if ( $time == 0 && $duration == 1440 ) {
................................................................................
      $ret .= 'DTEND;VALUE=DATE:' . gmdate ( 'Ymd', $eventend ) . "\r\n";
    }
    else  if ( $time == -1 )
    // untimed event   
     $ret .= "DTEND;VALUE=DATE:$date\r\n";
    else if ( $time > 0 ) {
      // timed  event
      $utc_end = export_ts_utc_date ( $eventend );
      if ( $vtimezone_exists ) {
	// f*ck Sunbird, we need to see the time at which the event ends,
	//  not a T000000.  Even if it's under a timezone.
        $ret .= 'DTEND;TZID=' . $TIMEZONE . ':' . $utc_end . "\r\n";
      } else {

        $ret .= "DTEND:$utc_end\r\n";
      }
    }
  } elseif ( strcmp( $texport, 'vcal' ) == 0 ) {
      $utc_end = export_ts_utc_date ( $eventend );
      $ret .= "DTEND:$utc_end\r\n";
  } else {
    $ret .= "DURATION:P$str_duration\r\n";