phpScheduleIt
May 26, 2013, 05:21:21 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: formating of calendar export improved (v1.2.12)  (Read 1001 times)
aschloegl
Newbie
*

Karma: 0
Posts: 18


« on: November 17, 2011, 08:21:46 AM »

To export the calendar of various resources in to ics-files and make them readable to various clients (i.e. outlook), the following modifications were necessary:

- the title of each calendar has been changed in such a way that the title reflects the name of the resource. Previously, all calendars had the same title "phpScheduleIt",
which makes it difficult to distinguesh the calendars once they were imported into a calendar client.
- fix for Outlook import of ICS file is included.
- escaping of special characters has been fixed.
- export of individual events into an *.ics file can be done by anyone, not only the owner of that event.
- the use of vcal export has been disabled because it does not maintain the time zone information, ics is the better alternative and support by all relevant clients. 

Alois


Code:

diff -rc /usr/local/src/phpscheduleit/1.2.12/exports/ical.php /var/www-secure/scheduleit/exports/ical.php
*** /usr/local/src/phpscheduleit/1.2.12/exports/ical.php 2011-03-10 22:39:34.000000000 +0100
--- /var/www-secure/scheduleit/exports/ical.php 2011-11-08 16:22:50.000000000 +0100
***************
*** 18,25 ****
  require_once('../lib/Auth.class.php');

 

  define('ICAL', 'ical');

! define('VCAL','vcal');

!

  if (!Auth::is_logged_in()) {

  CmnFns::redirect('../ctrlpnl.php', 1, false);

  }

--- 18,24 ----
  require_once('../lib/Auth.class.php');

 

  define('ICAL', 'ical');

!

  if (!Auth::is_logged_in()) {

  CmnFns::redirect('../ctrlpnl.php', 1, false);

  }

diff -rc /usr/local/src/phpscheduleit/1.2.12/lib/icalendar/ICalExport.php /var/www-secure/scheduleit/lib/icalendar/ICalExport.php
*** /usr/local/src/phpscheduleit/1.2.12/lib/icalendar/ICalExport.php 2011-03-10 22:39:33.000000000 +0100
--- /var/www-secure/scheduleit/lib/icalendar/ICalExport.php 2011-03-07 12:02:53.000000000 +0100
***************
*** 31,48 ****
  return $builder->toString();

  }

 

! function toString() {

  $builder = new StringBuilder();

! $builder->append($this->getHeader());

  $builder->append($this->_parse());

  $builder->append($this->getFooter());

 

! return $builder->toString();

  }

 

! function getHeader() {

  global $conf;

! return "BEGIN:VCALENDAR\r\nCALSCALE:GREGORIAN\r\nMETHOD:PUBLISH\r\nPRODID:-//phpScheduleIt//{$conf['app']['version']}//EN\r\nX-WR-CALNAME;VALUE=TEXT:phpScheduleIt\r\nVERSION:2.0\r\n";

  }

 

  function getFooter() {

--- 31,48 ----
  return $builder->toString();

  }

 

! function toString($title = "phpScheduleIt") {

  $builder = new StringBuilder();

! $builder->append($this->getHeader($title));

  $builder->append($this->_parse());

  $builder->append($this->getFooter());

 

! return utf8_encode($builder->toString());

  }

 

! function getHeader($title) {

  global $conf;

! return "BEGIN:VCALENDAR\r\nCALSCALE:GREGORIAN\r\nMETHOD:PUBLISH\r\nPRODID:-//phpScheduleIt//{$conf['app']['version']}//EN\r\nX-WR-CALNAME;VALUE=TEXT:".$title."\r\nVERSION:2.0\r\n";

  }

 

  function getFooter() {

diff -rc /usr/local/src/phpscheduleit/1.2.12/lib/icalendar/ICalReservationFormatter.php /var/www-secure/scheduleit/lib/icalendar/ICalReservationFormatter.php
*** /usr/local/src/phpscheduleit/1.2.12/lib/icalendar/ICalReservationFormatter.php 2011-03-10 22:39:33.000000000 +0100
--- /var/www-secure/scheduleit/lib/icalendar/ICalReservationFormatter.php 2011-09-05 09:43:42.000000000 +0200
***************
*** 6,11 ****
--- 6,12 ----
  * @package phpScheduleIt.iCalendar

  *

  * Copyright (C) 2003 - 2007 phpScheduleIt

+ * Copyright (C) 2011 Alois Schloegl, IST Austria

  * License: GPL, see LICENSE

  */

 

***************
*** 33,38 ****
--- 34,40 ----
  $builder->append($this->formatOwner());

  $builder->append($this->formatParticipants());

  $builder->append($this->formatSummary());

+ $builder->append($this->formatDescription());

  $builder->append($this->formatReminder());

  $builder->append($this->formatResources());

  $builder->append("END:VEVENT\r\n");

***************
*** 54,60 ****
 

  $adjusted_start = Time::getAdjustedMinutes($this->_reservation->start);

  $builder->append( sprintf(

! "DTSTART:%sT%s%s00\r\n",

  date('Ymd', Time::getAdjustedDate($this->_reservation->start_date, $this->_reservation->start)),

  Time::getHours($adjusted_start),

  Time::getMinutes($adjusted_start)

--- 56,62 ----
 

  $adjusted_start = Time::getAdjustedMinutes($this->_reservation->start);

  $builder->append( sprintf(

! "DTSTART:%sT%s%s00\r\n", /* added zerro seconds mond */

  date('Ymd', Time::getAdjustedDate($this->_reservation->start_date, $this->_reservation->start)),

  Time::getHours($adjusted_start),

  Time::getMinutes($adjusted_start)

***************
*** 62,68 ****
 

  $adjusted_end = Time::getAdjustedMinutes($this->_reservation->end);

  $builder->append( sprintf(

! "DTEND:%sT%s%s00\r\n",

  date('Ymd', Time::getAdjustedDate($this->_reservation->end_date, $this->_reservation->end)),

  Time::getHours($adjusted_end),

  Time::getMinutes($adjusted_end)

--- 64,70 ----
 

  $adjusted_end = Time::getAdjustedMinutes($this->_reservation->end);

  $builder->append( sprintf(

! "DTEND:%sT%s%s00\r\n", /* added zerro seconds mond */

  date('Ymd', Time::getAdjustedDate($this->_reservation->end_date, $this->_reservation->end)),

  Time::getHours($adjusted_end),

  Time::getMinutes($adjusted_end)

***************
*** 109,115 ****
  $builder = new StringBuilder();

 

  $summary = (!empty($this->_reservation->summary)) ? $this->_reservation->summary : $this->_reservation->resource->properties['name'];

! $builder->append("SUMMARY:$summary\r\n");

 

  return $builder->toString();

  }

--- 111,141 ----
  $builder = new StringBuilder();

 

  $summary = (!empty($this->_reservation->summary)) ? $this->_reservation->summary : $this->_reservation->resource->properties['name'];

! $summary = strtok($summary, "\r\n");

!

! return $builder->toString();

! }

!

! function formatDescription() {

! $builder = new StringBuilder();

!

! $desc = (!empty($this->_reservation->summary)) ? $this->_reservation->summary : $this->_reservation->resource->properties['name'];

!

! // parse each line and replace each <CR><LINE>  with <space><LINE><CR><LF> in order to avoid errors in Outlook import

!                 $desc = strtok($this->_reservation->summary,"\r\n");

!                 $builder->append("DESCRIPTION:$desc\r\n");

! $desc = strtok("\r\n");

!                 while (!empty($desc)) {

!                  $builder->append(" $desc\r\n");

!                  $desc = strtok("\r\n");

!                 }

!

! // add Resources in Description

! $builder->append(" Resources:{$this->_reservation->resource->properties['name']}\r\n");

!

! for ($i = 0; $i < count($this->_reservation->resources); $i++) {

! $builder->append(" {$this->_reservation->resources[$i]['name']}\r\n");

! }

 

  return $builder->toString();

  }

diff -rc /usr/local/src/phpscheduleit/1.2.12/templates/export.template.php /var/www-secure/scheduleit/templates/export.template.php
*** /usr/local/src/phpscheduleit/1.2.12/templates/export.template.php 2011-03-10 22:39:34.000000000 +0100
--- /var/www-secure/scheduleit/templates/export.template.php 2011-11-08 16:20:12.000000000 +0100
***************
*** 34,40 ****
  <td width="120">

  <select name="type" id="type" class="textbox">

  <option value="ical">iCalendar</option>

- <option value="vcal">vCalendar</option>

  </select>

  </td>

  </tr>

--- 34,39 ----
diff -rc /usr/local/src/phpscheduleit/1.2.12/templates/mycalendar.template.php /var/www-secure/scheduleit/templates/mycalendar.template.php
*** /usr/local/src/phpscheduleit/1.2.12/templates/mycalendar.template.php 2011-03-10 22:39:34.000000000 +0100
--- /var/www-secure/scheduleit/templates/mycalendar.template.php 2011-09-22 09:11:03.000000000 +0200
***************
*** 326,332 ****
  $html .= $res['name'] . ' @ ' .  $res['location'] . '<br/>';

  $html .= $res['fname'] . ' ' . $res['lname'] . '<br/>';

  if (!empty($res['summary'])) {

! $html .= '<br/><br/><i>' . preg_replace("/[\n\r]+/", '<br/>', addslashes($res['summary'])) . '</i>';

  }

  return $html;

  }

--- 326,332 ----
  $html .= $res['name'] . ' @ ' .  $res['location'] . '<br/>';

  $html .= $res['fname'] . ' ' . $res['lname'] . '<br/>';

  if (!empty($res['summary'])) {

! $html .= '<br/><br/><i>' . preg_replace("/[\n\r]+/", '<br/>', htmlspecialchars($res['summary'])) . '</i>';

  }

  return $html;

  }

diff -rc /usr/local/src/phpscheduleit/1.2.12/templates/reserve.template.php /var/www-secure/scheduleit/templates/reserve.template.php
*** /usr/local/src/phpscheduleit/1.2.12/templates/reserve.template.php 2011-03-10 22:39:34.000000000 +0100
--- /var/www-secure/scheduleit/templates/reserve.template.php 2011-11-08 16:21:17.000000000 +0100
***************
*** 501,507 ****
  if ($type != RES_TYPE_VIEW) {

  echo '&nbsp;&nbsp;&nbsp;<input type="button" name="close" value="' . translate('Cancel') . '" class="button" onclick="window.close();" />';

  }

! if ($type != RES_TYPE_ADD && $is_owner) {

  echo '&nbsp;&nbsp;';

  print_export_button($res->id);

  }

--- 530,537 ----
  if ($type != RES_TYPE_VIEW) {

  echo '&nbsp;&nbsp;&nbsp;<input type="button" name="close" value="' . translate('Cancel') . '" class="button" onclick="window.close();" />';

  }

! if ($type != RES_TYPE_ADD) {

! # all users (not only owners) are allowed to export events into iCal.

  echo '&nbsp;&nbsp;';

  print_export_button($res->id);

  }

***************
*** 932,940 ****
  <tr>

  <td class="export_menu_out" onmouseover="switchStyle(this,'export_menu_over');" onmouseout="switchStyle(this, 'export_menu_out');" onclick="openExport('ical', '<?php echo $id ?>');">iCalendar</td>

  </tr>

- <tr>

- <td class="export_menu_out" onmouseover="switchStyle(this,'export_menu_over');" onmouseout="switchStyle(this, 'export_menu_out');" onclick="openExport('vcal', '<?php echo $id ?>');">vCalendar</td>

- </tr>

  </table>

  </div>

  <?php

--- 962,967 ----





Logged
BUGHUNTER
Newbie
*

Karma: 0
Posts: 5


« Reply #1 on: January 31, 2012, 02:23:26 PM »

Great, thank you - will this be part of the official source? Thanks!
Logged
Nick
Administrator
Hero Member
*****

Karma: 15
Posts: 5419


WWW
« Reply #2 on: February 07, 2012, 09:39:20 AM »

ics formatting has been fixed for 2.0. A calendar event link is sent with all reservation emails and you can add a reservation to Outlook directly from the reservation now.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!