From 09a0ade1f7c7d156a3158532a338c7989498ddfb Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 3 Aug 2010 01:04:53 -0600 Subject: [PATCH] Convert Icalendar to H4. This removes the last use of PEAR_Errors in IMP. Yay. I've tried to go through framework, turba, and kronolith and convert to using Exceptions, but there is no guarantee that I caught all the locations we are using Icalendar objects. --- framework/Data/lib/Horde/Data/Imc.php | 8 +- framework/Data/lib/Horde/Data/Vcard.php | 2 +- framework/Data/lib/Horde/Data/Vnote.php | 4 +- framework/Data/package.xml | 6 +- framework/Date/lib/Horde/Date/Recurrence.php | 4 +- framework/Date/test/Horde/Date/RecurrenceTest.php | 12 +- .../examples/Horde/Icalendar}/exchange.ics | 0 .../examples/Horde/Icalendar}/exdate.ics | 0 .../examples/Horde/Icalendar}/ical.ics | 0 .../examples/Horde/Icalendar}/parser.php | 7 +- .../examples/Horde/Icalendar}/test_recurring.vcs | 0 .../examples/Horde/Icalendar}/vnote.txt | 0 .../lib/Horde/Icalendar.php} | 550 ++++++++++----------- .../Icalendar/lib/Horde/Icalendar/Daylight.php | 44 ++ .../Icalendar/lib/Horde/Icalendar/Exception.php | 17 + .../Icalendar/lib/Horde/Icalendar/Standard.php | 44 ++ framework/Icalendar/lib/Horde/Icalendar/Valarm.php | 34 ++ framework/Icalendar/lib/Horde/Icalendar/Vcard.php | 133 +++++ .../lib/Horde/Icalendar/Vevent.php} | 163 +++--- .../lib/Horde/Icalendar/Vfreebusy.php} | 225 +++++---- .../Icalendar/lib/Horde/Icalendar/Vjournal.php | 34 ++ .../lib/Horde/Icalendar/Vnote.php} | 31 +- .../lib/Horde/Icalendar/Vtimezone.php} | 92 ++-- .../lib/Horde/Icalendar/Vtodo.php} | 66 ++- framework/Icalendar/package.xml | 240 +++++++++ .../{iCalendar/tests => Icalendar/test}/.cvsignore | 0 .../test/Horde/Icalendar}/bug_7423.phpt | 4 +- .../test/Horde/Icalendar}/charset1.phpt | 4 +- .../test/Horde/Icalendar}/empty_data.phpt | 6 +- .../Icalendar}/fixtures/vTimezone/AuthorChats.ics | 0 .../Icalendar}/fixtures/vTimezone/MMMPseminar.ics | 0 .../Icalendar}/fixtures/vTimezone/Moon_Days.ics | 0 .../fixtures/vTimezone/ProjectCalendar.ics | 0 .../fixtures/vTimezone/SpanishHolidays.ics | 0 .../fixtures/vTimezone/allcategories.vcs | 0 .../Icalendar}/fixtures/vTimezone/arsenal32FC.ics | 0 .../Horde/Icalendar}/fixtures/vTimezone/events.ics | 2 +- .../Icalendar}/fixtures/vTimezone/exchange.ics | 0 .../Horde/Icalendar}/fixtures/vTimezone/exdate.ics | 0 .../Horde/Icalendar}/fixtures/vTimezone/iscw.ics | 0 .../Icalendar}/fixtures/vTimezone/meeting.ics | 0 .../fixtures/vTimezone/privacy_events.ics | 0 .../Icalendar}/fixtures/vTimezone/rfc2445.ics | 0 .../Horde/Icalendar}/fixtures/vTimezone/test.vcs | 0 .../Horde/Icalendar}/fixtures/vTimezone/test4.vcs | 0 .../fixtures/vTimezone/test_recurring.vcs | 0 .../Horde/Icalendar}/fixtures/vTimezone/wicca.ics | 0 .../test/Horde/Icalendar}/geo.phpt | 4 +- .../test/Horde/Icalendar}/iCalendar.phpt | 4 +- .../test/Horde/Icalendar}/line-folding.phpt | 55 +-- .../test/Horde/Icalendar}/quoted-params.phpt | 10 +- .../test/Horde/Icalendar}/read-escapes.phpt | 4 +- .../test/Horde/Icalendar}/read-vcard-org.phpt | 4 +- .../test/Horde/Icalendar}/read-write-escapes.phpt | 10 +- .../test/Horde/Icalendar}/timezones.phpt | 5 +- .../test/Horde/Icalendar}/vcal20.phpt | 4 +- .../test/Horde/Icalendar}/vfreebusy.phpt | 10 +- .../test/Horde/Icalendar}/write-escapes.phpt | 10 +- .../lib/Horde/Kolab/Filter/Outlook.php | 4 +- framework/Kolab_Filter/package.xml | 4 +- .../test/Horde/Kolab/Filter/ResourceTest.php | 60 +-- .../lib/Horde/Kolab/FreeBusy/Cache.php | 8 +- .../Horde/Kolab/FreeBusy/Driver/Freebusy/Base.php | 4 +- .../lib/Horde/Kolab/FreeBusy/Imap.php | 8 +- .../lib/Horde/Kolab/FreeBusy/View.php | 4 +- framework/Kolab_FreeBusy/package.xml | 2 +- .../Kolab_Resource/lib/Horde/Kolab/Resource.php | 10 +- .../lib/Horde/Kolab/Resource/Freebusy.php | 10 +- .../lib/Horde/Kolab/Resource/Freebusy/Kolab.php | 4 +- .../lib/Horde/Kolab/Resource/Freebusy/Mock.php | 4 +- .../lib/Horde/Kolab/Resource/Itip.php | 8 +- framework/Kolab_Resource/package.xml | 2 +- .../Mime_Viewer/lib/Horde/Mime/Viewer/Vcard.php | 32 +- framework/Mime_Viewer/package.xml | 2 +- framework/SyncML/SyncML/Device.php | 4 +- framework/SyncML/SyncML/Device/Sync4j.php | 142 +++--- framework/SyncML/SyncML/Device/Synthesis.php | 2 +- framework/SyncML/tests/sif.phpt | 2 +- framework/iCalendar/iCalendar/valarm.php | 27 - framework/iCalendar/iCalendar/vcard.php | 141 ------ framework/iCalendar/iCalendar/vjournal.php | 27 - framework/iCalendar/package.xml | 166 ------- imp/lib/Mime/Viewer/Itip.php | 192 +++---- kronolith/data.php | 12 +- kronolith/lib/Api.php | 41 +- kronolith/lib/Driver/Ical.php | 4 +- kronolith/lib/Event.php | 252 +++++----- kronolith/lib/Event/Ical.php | 42 +- kronolith/lib/FreeBusy.php | 24 +- kronolith/lib/FreeBusy/View.php | 10 +- kronolith/lib/Kronolith.php | 2 +- kronolith/lib/Storage/kolab.php | 4 +- kronolith/lib/Storage/sql.php | 4 +- kronolith/lib/View/ExportEvent.php | 2 +- kronolith/lib/tests/allday.phpt | 6 +- kronolith/lib/tests/bug7068.phpt | 6 +- kronolith/lib/tests/toicalendar.phpt | 16 +- kronolith/scripts/import_squirrelmail_calendar.php | 9 +- turba/data.php | 2 +- turba/lib/Api.php | 10 +- turba/lib/Driver.php | 148 +++--- turba/lib/tests/tohash.phpt | 4 +- 102 files changed, 1806 insertions(+), 1513 deletions(-) rename framework/{iCalendar/docs/examples => Icalendar/examples/Horde/Icalendar}/exchange.ics (100%) rename framework/{iCalendar/docs/examples => Icalendar/examples/Horde/Icalendar}/exdate.ics (100%) rename framework/{iCalendar/docs/examples => Icalendar/examples/Horde/Icalendar}/ical.ics (100%) rename framework/{iCalendar/docs/examples => Icalendar/examples/Horde/Icalendar}/parser.php (91%) rename framework/{iCalendar/docs/examples => Icalendar/examples/Horde/Icalendar}/test_recurring.vcs (100%) rename framework/{iCalendar/docs/examples => Icalendar/examples/Horde/Icalendar}/vnote.txt (100%) rename framework/{iCalendar/iCalendar.php => Icalendar/lib/Horde/Icalendar.php} (78%) create mode 100644 framework/Icalendar/lib/Horde/Icalendar/Daylight.php create mode 100644 framework/Icalendar/lib/Horde/Icalendar/Exception.php create mode 100644 framework/Icalendar/lib/Horde/Icalendar/Standard.php create mode 100644 framework/Icalendar/lib/Horde/Icalendar/Valarm.php create mode 100644 framework/Icalendar/lib/Horde/Icalendar/Vcard.php rename framework/{iCalendar/iCalendar/vevent.php => Icalendar/lib/Horde/Icalendar/Vevent.php} (56%) rename framework/{iCalendar/iCalendar/vfreebusy.php => Icalendar/lib/Horde/Icalendar/Vfreebusy.php} (72%) create mode 100644 framework/Icalendar/lib/Horde/Icalendar/Vjournal.php rename framework/{iCalendar/iCalendar/vnote.php => Icalendar/lib/Horde/Icalendar/Vnote.php} (62%) rename framework/{iCalendar/iCalendar/vtimezone.php => Icalendar/lib/Horde/Icalendar/Vtimezone.php} (76%) rename framework/{iCalendar/iCalendar/vtodo.php => Icalendar/lib/Horde/Icalendar/Vtodo.php} (50%) create mode 100644 framework/Icalendar/package.xml rename framework/{iCalendar/tests => Icalendar/test}/.cvsignore (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/bug_7423.phpt (84%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/charset1.phpt (91%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/empty_data.phpt (70%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/AuthorChats.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/MMMPseminar.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/Moon_Days.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/ProjectCalendar.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/SpanishHolidays.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/allcategories.vcs (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/arsenal32FC.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/events.ics (88%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/exchange.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/exdate.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/iscw.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/meeting.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/privacy_events.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/rfc2445.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/test.vcs (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/test4.vcs (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/test_recurring.vcs (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/fixtures/vTimezone/wicca.ics (100%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/geo.phpt (86%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/iCalendar.phpt (89%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/line-folding.phpt (81%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/quoted-params.phpt (85%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/read-escapes.phpt (94%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/read-vcard-org.phpt (80%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/read-write-escapes.phpt (87%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/timezones.phpt (99%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/vcal20.phpt (98%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/vfreebusy.phpt (97%) rename framework/{iCalendar/tests => Icalendar/test/Horde/Icalendar}/write-escapes.phpt (87%) delete mode 100644 framework/iCalendar/iCalendar/valarm.php delete mode 100644 framework/iCalendar/iCalendar/vcard.php delete mode 100644 framework/iCalendar/iCalendar/vjournal.php delete mode 100644 framework/iCalendar/package.xml diff --git a/framework/Data/lib/Horde/Data/Imc.php b/framework/Data/lib/Horde/Data/Imc.php index ab2f6b93c..c4729c55c 100644 --- a/framework/Data/lib/Horde/Data/Imc.php +++ b/framework/Data/lib/Horde/Data/Imc.php @@ -27,7 +27,7 @@ class Horde_Data_Imc extends Horde_Data_Base */ public function importData($text) { - $this->_iCal = new Horde_iCalendar(); + $this->_iCal = new Horde_Icalendar(); if (!$this->_iCal->parsevCalendar($text)) { throw new Horde_Data_Exception('There was an error importing the iCalendar data.'); } @@ -39,7 +39,7 @@ class Horde_Data_Imc extends Horde_Data_Base * Builds an iCalendar file from a given data structure and * returns it as a string. * - * @param array $data An array containing Horde_iCalendar_vevent + * @param array $data An array containing Horde_Icalendar_Vevent * objects * @param string $method The iTip method to use. * @@ -47,7 +47,7 @@ class Horde_Data_Imc extends Horde_Data_Base */ public function exportData($data, $method = 'REQUEST') { - $this->_iCal = new Horde_iCalendar(); + $this->_iCal = new Horde_Icalendar(); $this->_iCal->setAttribute('METHOD', $method); foreach ($data as $event) { @@ -63,7 +63,7 @@ class Horde_Data_Imc extends Horde_Data_Base * only outputs the correct headers and data. * * @param string $filename The name of the file to be downloaded. - * @param array $data An array containing Horde_iCalendar_vevents + * @param array $data An array containing Horde_Icalendar_Vevents */ public function exportFile($filename, $data) { diff --git a/framework/Data/lib/Horde/Data/Vcard.php b/framework/Data/lib/Horde/Data/Vcard.php index 89f6b8d5f..143a973a7 100644 --- a/framework/Data/lib/Horde/Data/Vcard.php +++ b/framework/Data/lib/Horde/Data/Vcard.php @@ -17,7 +17,7 @@ class Horde_Data_Vcard extends Horde_Data_Imc { * Exports vcalendar data as a string. Unlike vEvent, vCard data * is not enclosed in BEGIN|END:vCalendar. * - * @param array $data An array containing Horde_iCalendar_Vcard + * @param array $data An array containing Horde_Icalendar_Vcard * objects. * @param string $method The iTip method to use. * diff --git a/framework/Data/lib/Horde/Data/Vnote.php b/framework/Data/lib/Horde/Data/Vnote.php index 068ce153f..696654331 100644 --- a/framework/Data/lib/Horde/Data/Vnote.php +++ b/framework/Data/lib/Horde/Data/Vnote.php @@ -18,7 +18,7 @@ class Horde_Data_Vnote extends Horde_Data_Imc * Exports vcalendar data as a string. Unlike vEvent, vNote data * is not enclosed in BEGIN|END:vCalendar. * - * @param array $data An array containing Horde_iCalendar_Vnote + * @param array $data An array containing Horde_Icalendar_Vnote * objects. * @param string $method The iTip method to use. * @@ -26,7 +26,7 @@ class Horde_Data_Vnote extends Horde_Data_Imc */ public function exportData($data, $method = 'REQUEST') { - $this->_iCal = new Horde_iCalendar(); + $this->_iCal = new Horde_Icalendar(); $this->_iCal->setAttribute('METHOD', $method); $s = ''; diff --git a/framework/Data/package.xml b/framework/Data/package.xml index 65f616147..21a7f9a28 100644 --- a/framework/Data/package.xml +++ b/framework/Data/package.xml @@ -89,15 +89,15 @@ http://pear.php.net/dtd/package-2.0.xsd"> pear.horde.org - Mime + Icalendar pear.horde.org - Util + Mime pear.horde.org - iCalendar + Util pear.horde.org diff --git a/framework/Date/lib/Horde/Date/Recurrence.php b/framework/Date/lib/Horde/Date/Recurrence.php index 1d475a950..86476e3a1 100644 --- a/framework/Date/lib/Horde/Date/Recurrence.php +++ b/framework/Date/lib/Horde/Date/Recurrence.php @@ -958,7 +958,7 @@ class Horde_Date_Recurrence * @link http://www.imc.org/pdi/vcal-10.txt * @link http://www.shuchow.com/vCalAddendum.html * - * @param Horde_iCalendar $calendar A Horde_iCalendar object instance. + * @param Horde_Icalendar $calendar A Horde_Icalendar object instance. * * @return string A vCalendar 1.0 conform RRULE value. */ @@ -1124,7 +1124,7 @@ class Horde_Date_Recurrence * @link http://rfc.net/rfc2445.html#s4.8.5 * @link http://www.shuchow.com/vCalAddendum.html * - * @param Horde_iCalendar $calendar A Horde_iCalendar object instance. + * @param Horde_Icalendar $calendar A Horde_Icalendar object instance. * * @return string An iCalendar 2.0 conform RRULE value. */ diff --git a/framework/Date/test/Horde/Date/RecurrenceTest.php b/framework/Date/test/Horde/Date/RecurrenceTest.php index e9eaefdd8..85d2cf264 100644 --- a/framework/Date/test/Horde/Date/RecurrenceTest.php +++ b/framework/Date/test/Horde/Date/RecurrenceTest.php @@ -7,7 +7,7 @@ require_once 'Horde/String.php'; require_once 'Horde/Util.php'; -require_once 'Horde/iCalendar.php'; +require_once 'Horde/Icalendar.php'; require_once dirname(__FILE__) . '/../../../lib/Horde/Date.php'; require_once dirname(__FILE__) . '/../../../lib/Horde/Date/Recurrence.php'; require_once dirname(__FILE__) . '/../../../lib/Horde/Date/Utils.php'; @@ -22,7 +22,7 @@ class Horde_Date_RecurrenceTest extends PHPUnit_Framework_TestCase protected function setUp() { Horde_String::setDefaultCharset('UTF-8'); - $this->ical = new Horde_iCalendar(); + $this->ical = new Horde_Icalendar(); $this->_oldTimezone = date_default_timezone_get(); date_default_timezone_set('Europe/Berlin'); } @@ -911,14 +911,14 @@ class Horde_Date_RecurrenceTest extends PHPUnit_Framework_TestCase { require_once 'PEAR.php'; - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); $iCal->parsevCalendar(file_get_contents(dirname(__FILE__) . '/fixtures/bug2813.ics')); $components = $iCal->getComponents(); date_default_timezone_set('US/Eastern'); foreach ($components as $content) { - if ($content instanceof Horde_iCalendar_vevent) { + if ($content instanceof Horde_Icalendar_Vevent) { $start = new Horde_Date($content->getAttribute('DTSTART')); $end = new Horde_Date($content->getAttribute('DTEND')); $rrule = $content->getAttribute('RRULE'); @@ -946,8 +946,8 @@ class Horde_Date_RecurrenceTest extends PHPUnit_Framework_TestCase $rrule->setRecurType(Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY); $rrule->setRecurOnDay(Horde_Date::MASK_SATURDAY); - $this->assertEquals('MP1 1+ SA #0', $rrule->toRRule10(new Horde_iCalendar())); - $this->assertEquals('FREQ=MONTHLY;INTERVAL=1;BYDAY=1SA', $rrule->toRRule20(new Horde_iCalendar())); + $this->assertEquals('MP1 1+ SA #0', $rrule->toRRule10(new Horde_Icalendar())); + $this->assertEquals('FREQ=MONTHLY;INTERVAL=1;BYDAY=1SA', $rrule->toRRule20(new Horde_Icalendar())); } } diff --git a/framework/iCalendar/docs/examples/exchange.ics b/framework/Icalendar/examples/Horde/Icalendar/exchange.ics similarity index 100% rename from framework/iCalendar/docs/examples/exchange.ics rename to framework/Icalendar/examples/Horde/Icalendar/exchange.ics diff --git a/framework/iCalendar/docs/examples/exdate.ics b/framework/Icalendar/examples/Horde/Icalendar/exdate.ics similarity index 100% rename from framework/iCalendar/docs/examples/exdate.ics rename to framework/Icalendar/examples/Horde/Icalendar/exdate.ics diff --git a/framework/iCalendar/docs/examples/ical.ics b/framework/Icalendar/examples/Horde/Icalendar/ical.ics similarity index 100% rename from framework/iCalendar/docs/examples/ical.ics rename to framework/Icalendar/examples/Horde/Icalendar/ical.ics diff --git a/framework/iCalendar/docs/examples/parser.php b/framework/Icalendar/examples/Horde/Icalendar/parser.php similarity index 91% rename from framework/iCalendar/docs/examples/parser.php rename to framework/Icalendar/examples/Horde/Icalendar/parser.php index ee4ab1f6e..6f69c457e 100755 --- a/framework/iCalendar/docs/examples/parser.php +++ b/framework/Icalendar/examples/Horde/Icalendar/parser.php @@ -5,11 +5,12 @@ * finds. Intended for use in debugging the iCalendar parser's behavior with * problem files or for adding new features. * - * @package Horde_iCalendar + * @category Horde + * @package Icalendar */ require_once 'Horde/Cli.php'; -require_once 'Horde/iCalendar.php'; +require_once 'Horde/Icalendar.php'; // This only works on the command line. if (!Horde_Cli::runningFromCLI()) { @@ -35,7 +36,7 @@ if (!is_readable($input_file)) { $cli->writeln($cli->blue('Parsing ' . $input_file . ' ...')); $data = file_get_contents($input_file); -$ical = new Horde_iCalendar(); +$ical = new Horde_Icalendar(); if (!$ical->parseVCalendar($data)) { $cli->fatal('iCalendar parsing failed.'); } diff --git a/framework/iCalendar/docs/examples/test_recurring.vcs b/framework/Icalendar/examples/Horde/Icalendar/test_recurring.vcs similarity index 100% rename from framework/iCalendar/docs/examples/test_recurring.vcs rename to framework/Icalendar/examples/Horde/Icalendar/test_recurring.vcs diff --git a/framework/iCalendar/docs/examples/vnote.txt b/framework/Icalendar/examples/Horde/Icalendar/vnote.txt similarity index 100% rename from framework/iCalendar/docs/examples/vnote.txt rename to framework/Icalendar/examples/Horde/Icalendar/vnote.txt diff --git a/framework/iCalendar/iCalendar.php b/framework/Icalendar/lib/Horde/Icalendar.php similarity index 78% rename from framework/iCalendar/iCalendar.php rename to framework/Icalendar/lib/Horde/Icalendar.php index 874e7c78b..8ee462f01 100644 --- a/framework/iCalendar/iCalendar.php +++ b/framework/Icalendar/lib/Horde/Icalendar.php @@ -1,6 +1,7 @@ - * @package Horde_iCalendar + * @author Mike Cochrane + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar */ -class Horde_iCalendar { - +class Horde_Icalendar +{ /** * The component type of this class. * * @var string */ - var $type = 'vcalendar'; + public $type = 'vcalendar'; /** * The parent (containing) iCalendar object. * - * @var Horde_iCalendar + * @var Horde_Icalendar */ - var $_container = false; + protected $_container = false; /** * The name/value pairs of attributes for this object (UID, @@ -37,21 +40,21 @@ class Horde_iCalendar { * * @var array */ - var $_attributes = array(); + protected $_attributes = array(); /** * Any children (contained) iCalendar components of this object. * * @var array */ - var $_components = array(); + protected $_components = array(); /** * According to RFC 2425, we should always use CRLF-terminated lines. * * @var string */ - var $_newline = "\r\n"; + protected $_newline = "\r\n"; /** * iCalendar format version (different behavior for 1.0 and 2.0 especially @@ -59,7 +62,7 @@ class Horde_iCalendar { * * @var string */ - var $version; + protected $version; /** * Whether entry is vcalendar 1.0, vcard 2.1 or vnote 1.1. @@ -68,9 +71,14 @@ class Horde_iCalendar { * formats icalendar 2.0 and vcard 3.0 are defined in rfc2426 and rfc2445 * respectively. */ - var $oldFormat = true; + protected $oldFormat = true; - function Horde_iCalendar($version = '2.0') + /** + * Constructor. + * + * @var string $version Version. + */ + public function __construct($version = '2.0') { $this->setAttribute('VERSION', $version); } @@ -78,25 +86,21 @@ class Horde_iCalendar { /** * Return a reference to a new component. * - * @param string $type The type of component to return - * @param Horde_iCalendar $container A container that this component + * @param string $type The type of component to return + * @param Horde_Icalendar $container A container that this component * will be associated with. * - * @return object Reference to a Horde_iCalendar_* object as specified. - * - * @static + * @return object Reference to a Horde_Icalendar_* object as specified. */ - function &newComponent($type, &$container) + static public function newComponent($type, $container) { $type = Horde_String::lower($type); - $class = 'Horde_iCalendar_' . $type; - if (!class_exists($class)) { - include 'Horde/iCalendar/' . $type . '.php'; - } + $class = __CLASS__ . '_' . Horde_String::ucfirst($type); + if (class_exists($class)) { $component = new $class(); if ($container !== false) { - $component->_container = &$container; + $component->_container = $container; // Use version of container, not default set by component // constructor. $component->setVersion($container->version); @@ -115,9 +119,9 @@ class Horde_iCalendar { * @see $version * @see $oldFormat * - * @param string A float-like version string. + * @param string $version A float-like version string. */ - function setVersion($version) + public function setVersion($version) { $this->oldFormat = $version < 2; $this->version = $version; @@ -136,8 +140,8 @@ class Horde_iCalendar { * comma/semicolon seperated lists of values. If * not set use $value as single array element. */ - function setAttribute($name, $value, $params = array(), $append = true, - $values = false) + public function setAttribute($name, $value, $params = array(), + $append = true, $values = false) { // Make sure we update the internal format version if // setAttribute('VERSION', ...) is called. @@ -152,6 +156,7 @@ class Horde_iCalendar { $values = array($value); } $found = false; + if (!$append) { foreach (array_keys($this->_attributes) as $key) { if ($this->_attributes[$key]['name'] == Horde_String::upper($name)) { @@ -181,15 +186,15 @@ class Horde_iCalendar { * @param string $name The name of the attribute. * @param array $params Array containing any additional parameters for * this attribute. + * * @return boolean True on success, false if no attribute $name exists. */ - function setParameter($name, $params = array()) + public function setParameter($name, $params = array()) { $keys = array_keys($this->_attributes); foreach ($keys as $key) { if ($this->_attributes[$key]['name'] == $name) { - $this->_attributes[$key]['params'] = - array_merge($this->_attributes[$key]['params'], $params); + $this->_attributes[$key]['params'] = array_merge($this->_attributes[$key]['params'], $params); return true; } } @@ -204,47 +209,47 @@ class Horde_iCalendar { * @param boolean $params Return the parameters for this attribute instead * of its value. * - * @return mixed (object) PEAR_Error if the attribute does not exist. - * (string) The value of the attribute. + * @return mixed (string) The value of the attribute. * (array) The parameters for the attribute or * multiple values for an attribute. + * @throws Horde_Icalendar_Exception */ - function getAttribute($name, $params = false) + public function getAttribute($name, $params = false) { $result = array(); foreach ($this->_attributes as $attribute) { if ($attribute['name'] == $name) { - if ($params) { - $result[] = $attribute['params']; - } else { - $result[] = $attribute['value']; - } + $result[] = $params + ? $attribute['params'] + : $attribute['value']; } } + if (!count($result)) { - return new PEAR_Error('Attribute "' . $name . '" Not Found'); - } if (count($result) == 1 && !$params) { + throw new Horde_Icalendar_Exception('Attribute "' . $name . '" Not Found'); + } elseif (count($result) == 1 && !$params) { return $result[0]; - } else { - return $result; } + + return $result; } /** * Gets the values of an attribute as an array. Multiple values * are possible due to: * - * a) multiplce occurences of 'name' + * a) multiple occurences of 'name' * b) (unsecapd) comma seperated lists. * * So for a vcard like "KEY:a,b\nKEY:c" getAttributesValues('KEY') * will return array('a', 'b', 'c'). * - * @param string $name The name of the attribute. - * @return mixed (object) PEAR_Error if the attribute does not exist. - * (array) Multiple values for an attribute. + * @param string $name The name of the attribute. + * + * @return array Multiple values for an attribute. + * @throws Horde_Icalendar_Exception */ - function getAttributeValues($name) + public function getAttributeValues($name) { $result = array(); foreach ($this->_attributes as $attribute) { @@ -252,9 +257,11 @@ class Horde_iCalendar { $result = array_merge($attribute['values'], $result); } } + if (!count($result)) { - return PEAR::raiseError('Attribute "' . $name . '" Not Found'); + throw new Horde_Icalendar_Exception('Attribute "' . $name . '" Not Found'); } + return $result; } @@ -269,10 +276,13 @@ class Horde_iCalendar { * @return mixed (string) The value of $name. * (mixed) $default if $name does not exist. */ - function getAttributeDefault($name, $default = '') + public function getAttributeDefault($name, $default = '') { - $value = $this->getAttribute($name); - return is_a($value, 'PEAR_Error') ? $default : $value; + try { + return $this->getAttribute($name); + } catch (Horde_Icalendar_Exception $e) { + return $default; + } } /** @@ -280,10 +290,9 @@ class Horde_iCalendar { * * @param string $name The name of the attribute. */ - function removeAttribute($name) + public function removeAttribute($name) { - $keys = array_keys($this->_attributes); - foreach ($keys as $key) { + foreach (array_keys($this->_attributes) as $key) { if ($this->_attributes[$key]['name'] == $name) { unset($this->_attributes[$key]); } @@ -293,40 +302,42 @@ class Horde_iCalendar { /** * Get attributes for all tags or for a given tag. * - * @param string $tag Return attributes for this tag, or all attributes if - * not given. + * @param string $tag Return attributes for this tag, or all attributes + * if not given. * * @return array An array containing all the attributes and their types. */ - function getAllAttributes($tag = false) + public function getAllAttributes($tag = false) { if ($tag === false) { return $this->_attributes; } + $result = array(); foreach ($this->_attributes as $attribute) { if ($attribute['name'] == $tag) { $result[] = $attribute; } } + return $result; } /** * Add a vCalendar component (eg vEvent, vTimezone, etc.). * - * @param mixed Either a Horde_iCalendar component (subclass) or an array + * @param mixed Either a Horde_Icalendar component (subclass) or an array * of them. */ - function addComponent($components) + public function addComponent($components) { if (!is_array($components)) { $components = array($components); } foreach ($components as $component) { - if ($component instanceOf Horde_iCalendar) { - $component->_container = &$this; + if ($component instanceof Horde_Icalendar) { + $component->_container = $this; $this->_components[] = $component; } } @@ -335,14 +346,19 @@ class Horde_iCalendar { /** * Retrieve all the components. * - * @return array Array of Horde_iCalendar objects. + * @return array Array of Horde_Icalendar objects. */ - function getComponents() + public function getComponents() { return $this->_components; } - function getType() + /** + * TODO + * + * @return TODO + */ + public function getType() { return $this->type; } @@ -350,18 +366,19 @@ class Horde_iCalendar { /** * Return the classes (entry types) we have. * - * @return array Hash with class names Horde_iCalendar_xxx as keys + * @return array Hash with class names Horde_Icalendar_xxx as keys * and number of components of this class as value. */ - function getComponentClasses() + public function getComponentClasses() { $r = array(); + foreach ($this->_components as $c) { $cn = strtolower(get_class($c)); if (empty($r[$cn])) { $r[$cn] = 1; } else { - $r[$cn]++; + ++$r[$cn]; } } @@ -373,7 +390,7 @@ class Horde_iCalendar { * * @return integer Number of components in this container. */ - function getComponentCount() + public function getComponentCount() { return count($this->_components); } @@ -383,16 +400,14 @@ class Horde_iCalendar { * * @param integer $idx The index of the object to retrieve. * - * @return mixed (boolean) False if the index does not exist. - * (Horde_iCalendar_*) The requested component. + * @return mixed (boolean) False if the index does not exist. + * (Horde_Icalendar_*) The requested component. */ - function getComponent($idx) + public function getComponent($idx) { - if (isset($this->_components[$idx])) { - return $this->_components[$idx]; - } else { - return false; - } + return isset($this->_components[$idx]) + ? $this->_components[$idx] + : false; } /** @@ -401,22 +416,21 @@ class Horde_iCalendar { * * @param string $type The type of component to find. * - * @return boolean|Horde_iCalendar_* False if no subcomponent of the - * specified class exists or a reference - * to the requested component. + * @return boolean|Horde_Icalendar_* False if no subcomponent of the + * specified class exists or the + * requested component. */ - function &findComponent($childclass) + public function findComponent($childclass) { - $childclass = 'Horde_iCalendar_' . Horde_String::lower($childclass); - $keys = array_keys($this->_components); - foreach ($keys as $key) { - if (is_a($this->_components[$key], $childclass)) { + $childclass = __CLASS__ . '_' . Horde_String::lower($childclass); + + foreach (array_keys($this->_components) as $key) { + if ($this->_components[$key] instanceof $childclass) { return $this->_components[$key]; } } - $component = false; - return $component; + return false; } /** @@ -428,60 +442,57 @@ class Horde_iCalendar { * for it to match. * @param string $value Optional value that $attribute must match. * - * @return boolean|Horde_iCalendar_* False if no matching subcomponent of - * the specified class exists, or a - * reference to the requested component. + * @return boolean|Horde_Icalendar_* False if no matching subcomponent + * of the specified class exists, or + * the requested component. */ - function &findComponentByAttribute($childclass, $attribute, $value = null) + public function findComponentByAttribute($childclass, $attribute, + $value = null) { - $childclass = 'Horde_iCalendar_' . Horde_String::lower($childclass); - $keys = array_keys($this->_components); - foreach ($keys as $key) { - if ($this->_components[$key] instanceOf $childclass) { - $attr = $this->_components[$key]->getAttribute($attribute); - if ($attr instanceOf PEAR_Error) { + $childclass = __CLASS__ . '_' . Horde_String::lower($childclass); + + foreach (array_keys($this->_components) as $key) { + if ($this->_components[$key] instanceof $childclass) { + try { + $attr = $this->_components[$key]->getAttribute($attribute); + } catch (Horde_Icalendar_Exception $e) { continue; } - if ($value !== null && $value != $attr) { - continue; + + if (is_null($value) || $value == $attr) { + return $this->_components[$key]; } - return $this->_components[$key]; } } - $component = false; - return $component; + return false; } /** * Clears the iCalendar object (resets the components and attributes * arrays). */ - function clear() - { - $this->_components = array(); - $this->_attributes = array(); - } - - /** - * @deprecated - */ - function isOldFormat() + public function clear() { - return $this->oldFormat; + $this->_attributes = $this->_components = array(); } /** * Export as vCalendar format. + * + * @return TODO */ - function exportvCalendar() + public function exportvCalendar() { // Default values. - $requiredAttributes['PRODID'] = '-//The Horde Project//Horde_iCalendar Library' . (defined('HORDE_VERSION') ? ', Horde ' . constant('HORDE_VERSION') : '') . '//EN'; + // TODO: HORDE_VERSION does not exist. + $requiredAttributes['PRODID'] = '-//The Horde Project//Horde iCalendar Library' . (defined('HORDE_VERSION') ? ', Horde ' . constant('HORDE_VERSION') : '') . '//EN'; $requiredAttributes['METHOD'] = 'PUBLISH'; foreach ($requiredAttributes as $name => $default_value) { - if (is_a($this->getattribute($name), 'PEAR_Error')) { + try { + $this->getAttribute($name); + } catch (Horde_Icalendar_Exception $e) { $this->setAttribute($name, $default_value); } } @@ -492,19 +503,23 @@ class Horde_iCalendar { /** * Export this entry as a hash array with tag names as keys. * - * @param boolean $paramsInKeys - * If false, the operation can be quite lossy as the - * parameters are ignored when building the array keys. - * So if you export a vcard with - * LABEL;TYPE=WORK:foo - * LABEL;TYPE=HOME:bar - * the resulting hash contains only one label field! - * If set to true, array keys look like 'LABEL;TYPE=WORK' + * @param boolean $paramsInKeys If false, the operation can be quite + * lossy as the parameters are ignored when + * building the array keys. + * So if you export a vcard with + * LABEL;TYPE=WORK:foo + * LABEL;TYPE=HOME:bar + * the resulting hash contains only one + * label field! + * If set to true, array keys look like + * 'LABEL;TYPE=WORK' + * * @return array A hash array with tag names as keys. */ - function toHash($paramsInKeys = false) + public function toHash($paramsInKeys = false) { $hash = array(); + foreach ($this->_attributes as $a) { $k = $a['name']; if ($paramsInKeys && is_array($a['params'])) { @@ -530,13 +545,15 @@ class Horde_iCalendar { * @param boolean $clear If true clears the iCal object before parsing. * * @return boolean True on successful import, false otherwise. + * @throws Horde_Icalendar_Exception */ - function parsevCalendar($text, $base = 'VCALENDAR', $charset = null, - $clear = true) + public function parsevCalendar($text, $base = 'VCALENDAR', + $charset = null, $clear = true) { if ($clear) { $this->clear(); } + if (preg_match('/^BEGIN:' . $base . '(.*)^END:' . $base . '/ism', $text, $matches)) { $container = true; $vCal = $matches[1]; @@ -558,9 +575,9 @@ class Horde_iCalendar { if ($type != 'VTIMEZONE') { continue; } - $component = &Horde_iCalendar::newComponent($type, $this); + $component = $this->newComponent($type, $this); if ($component === false) { - return PEAR::raiseError("Unable to create object for type $type"); + throw new Horde_Icalendar_Exception('Unable to create object for type ' . $type); } $component->parsevCalendar($data, $type, $charset); @@ -576,9 +593,9 @@ class Horde_iCalendar { if ($type == 'VTIMEZONE') { continue; } - $component = &Horde_iCalendar::newComponent($type, $this); + $component = $this->newComponent($type, $this); if ($component === false) { - return PEAR::raiseError("Unable to create object for type $type"); + throw new Horde_Icalendar_Exception('Unable to create object for type ' . $type); } $component->parsevCalendar($data, $type, $charset); @@ -603,11 +620,7 @@ class Horde_iCalendar { } // Unfold any folded lines. - if ($this->isOldFormat()) { - $vCal = preg_replace('/[\r\n]+([ \t])/', '$1', $vCal); - } else { - $vCal = preg_replace('/[\r\n]+[ \t]/', '', $vCal); - } + $vCal = preg_replace('/[\r\n]+[ \t]/', '', $vCal); // Parse the remaining attributes. if (preg_match_all('/^((?:[^":]+|(?:"[^"]*")+)*):([^\r\n]*)\r?$/m', $vCal, $matches)) { @@ -821,7 +834,7 @@ class Horde_iCalendar { * * @return string vCal format data. */ - function _exportvData($base = 'VCALENDAR') + protected function _exportvData($base = 'VCALENDAR') { $result = 'BEGIN:' . Horde_String::upper($base) . $this->_newline; @@ -1062,7 +1075,7 @@ class Horde_iCalendar { strlen(trim($value))) { $result .= $name . $params_str . ':' . str_replace('=0A', '=0D=0A', - $this->_quotedPrintableEncode($value)) + Horde_Mime::quotedPrintableEncode($value)) . $this->_newline; } else { $attr_string = $name . $params_str . ':' . $value; @@ -1083,10 +1096,15 @@ class Horde_iCalendar { /** * Parse a UTC Offset field. + * + * @param $text TODO + * + * @return TODO */ - function _parseUtcOffset($text) + protected function _parseUtcOffset($text) { $offset = array(); + if (preg_match('/(\+|-)([0-9]{2})([0-9]{2})([0-9]{2})?/', $text, $timeParts)) { $offset['ahead'] = (bool)($timeParts[1] == '+'); $offset['hour'] = intval($timeParts[2]); @@ -1095,19 +1113,23 @@ class Horde_iCalendar { $offset['second'] = intval($timeParts[4]); } return $offset; - } else { - return false; } + + return false; } /** * Export a UTC Offset field. + * + * @param $value TODO + * + * @return TODO */ function _exportUtcOffset($value) { - $offset = $value['ahead'] ? '+' : '-'; - $offset .= sprintf('%02d%02d', - $value['hour'], $value['minute']); + $offset = ($value['ahead'] ? '+' : '-') . + sprintf('%02d%02d', $value['hour'], $value['minute']); + if (isset($value['second'])) { $offset .= sprintf('%02d', $value['second']); } @@ -1117,11 +1139,14 @@ class Horde_iCalendar { /** * Parse a Time Period field. + * + * @param $text TODO + * + * @return array TODO */ - function _parsePeriod($text) + protected function _parsePeriod($text) { $periodParts = explode('/', $text); - $start = $this->_parseDateTime($periodParts[0]); if ($duration = $this->_parseDuration($periodParts[1])) { @@ -1133,24 +1158,31 @@ class Horde_iCalendar { /** * Export a Time Period field. + * + * @param $value TODO + * + * @return TODO */ - function _exportPeriod($value) + protected function _exportPeriod($value) { - $period = $this->_exportDateTime($value['start']); - $period .= '/'; - if (isset($value['duration'])) { - $period .= $this->_exportDuration($value['duration']); - } else { - $period .= $this->_exportDateTime($value['end']); - } - return $period; + $period = $this->_exportDateTime($value['start']) . '/'; + + return isset($value['duration']) + ? $period . $this->_exportDuration($value['duration']) + : $period . $this->_exportDateTime($value['end']); } /** * Grok the TZID and return an offset in seconds from UTC for this * date and time. + * + * @param $date TODO + * @param $time TODO + * @param $tzid TODO + * + * @return TODO */ - function _parseTZID($date, $time, $tzid) + protected function _parseTZID($date, $time, $tzid) { $vtimezone = $this->_container->findComponentByAttribute('vtimezone', 'TZID', $tzid); if (!$vtimezone) { @@ -1199,8 +1231,13 @@ class Horde_iCalendar { * unmodified. * * @todo This function should be moved to Horde_Date and made public. + * + * @param $time TODO + * @param $tzid TODO + * + * @return TODO */ - function _parseDateTime($text, $tzid = false) + protected function _parseDateTime($text, $tzid = false) { $dateParts = explode('T', $text); if (count($dateParts) != 2 && !empty($text)) { @@ -1212,17 +1249,16 @@ class Horde_iCalendar { $dateParts = array($text, '000000'); } - if (!$date = Horde_iCalendar::_parseDate($dateParts[0])) { - return $text; - } - if (!$time = Horde_iCalendar::_parseTime($dateParts[1])) { + if (!($date = $this->_parseDate($dateParts[0])) || + !($time = $this->_parseTime($dateParts[1]))) { return $text; } // Get timezone info for date fields from $tzid and container. $tzoffset = ($time['zone'] == 'Local' && $tzid && - $this->_container instanceOf Horde_iCalendar) - ? $this->_parseTZID($date, $time, $tzid) : false; + ($this->_container instanceof Horde_Icalendar)) + ? $this->_parseTZID($date, $time, $tzid) + : false; if ($time['zone'] == 'UTC' || $tzoffset !== false) { $result = @gmmktime($time['hour'], $time['minute'], $time['second'], $date['month'], $date['mday'], $date['year']); @@ -1242,8 +1278,15 @@ class Horde_iCalendar { /** * Export a DateTime field. + * + * @todo A bunch of code calls this function outside this class, so it + * needs to be marked public for now. + * + * @param $value TODO + * + * @return TODO */ - function _exportDateTime($value) + public function _exportDateTime($value) { $temp = array(); if (!is_object($value) && !is_array($value)) { @@ -1260,54 +1303,59 @@ class Horde_iCalendar { $temp['second'] = date('s', $value); } else { $dateOb = new Horde_Date($value); - return Horde_iCalendar::_exportDateTime($dateOb->timestamp()); + return $this->_exportDateTime($dateOb->timestamp()); } - return Horde_iCalendar::_exportDate($temp) . 'T' . Horde_iCalendar::_exportTime($temp); + return $this->_exportDate($temp) . 'T' . $this->_exportTime($temp); } /** * Parses a Time field. * - * @static + * @param $text TODO + * + * @return TODO */ - function _parseTime($text) + protected function _parseTime($text) { if (!preg_match('/([0-9]{2})([0-9]{2})([0-9]{2})(Z)?/', $text, $timeParts)) { return false; } - $time = array('hour' => $timeParts[1], - 'minute' => $timeParts[2], - 'second' => $timeParts[3]); - if (isset($timeParts[4])) { - $time['zone'] = 'UTC'; - } else { - $time['zone'] = 'Local'; - } - - return $time; + return array( + 'hour' => $timeParts[1], + 'minute' => $timeParts[2], + 'second' => $timeParts[3], + 'zone' => isset($timeParts[4]) ? 'UTC' : 'Local' + ); } /** * Exports a Time field. + * + * @param $value TODO + * + * @return TODO */ - function _exportTime($value) + protected function _exportTime($value) { $time = sprintf('%02d%02d%02d', $value['hour'], $value['minute'], $value['second']); if ($value['zone'] == 'UTC') { $time .= 'Z'; } + return $time; } /** * Parses a Date field. * - * @static + * @param $text TODO + * + * @return array TODO */ - function _parseDate($text) + protected function _parseDate($text) { $parts = explode('T', $text); if (count($parts) == 2) { @@ -1318,9 +1366,11 @@ class Horde_iCalendar { return false; } - return array('year' => $match[1], - 'month' => $match[2], - 'mday' => $match[3]); + return array( + 'year' => $match[1], + 'month' => $match[2], + 'mday' => $match[3] + ); } /** @@ -1330,62 +1380,70 @@ class Horde_iCalendar { * @param string $autoconvert If set, use this as time part to export the * date as datetime when exporting to Vcalendar * 1.0. Examples: '000000' or '235959' + * + * @return TODO */ - function _exportDate($value, $autoconvert = false) + protected function _exportDate($value, $autoconvert = false) { if (is_object($value)) { $value = array('year' => $value->year, 'month' => $value->month, 'mday' => $value->mday); } - if ($autoconvert !== false && $this->oldFormat) { - return sprintf('%04d%02d%02dT%s', $value['year'], $value['month'], $value['mday'], $autoconvert); - } else { - return sprintf('%04d%02d%02d', $value['year'], $value['month'], $value['mday']); - } + + return ($autoconvert !== false && $this->oldFormat) + ? sprintf('%04d%02d%02dT%s', $value['year'], $value['month'], $value['mday'], $autoconvert) + : sprintf('%04d%02d%02d', $value['year'], $value['month'], $value['mday']); } /** * Parse a Duration Value field. + * + * @param $text TODO + * + * @return TODO */ - function _parseDuration($text) + protected function _parseDuration($text) { - if (preg_match('/([+]?|[-])P(([0-9]+W)|([0-9]+D)|)(T(([0-9]+H)|([0-9]+M)|([0-9]+S))+)?/', trim($text), $durvalue)) { - // Weeks. - $duration = 7 * 86400 * intval($durvalue[3]); + if (!preg_match('/([+]?|[-])P(([0-9]+W)|([0-9]+D)|)(T(([0-9]+H)|([0-9]+M)|([0-9]+S))+)?/', trim($text), $durvalue)) { + return false; + } - if (count($durvalue) > 4) { - // Days. - $duration += 86400 * intval($durvalue[4]); - } - if (count($durvalue) > 5) { - // Hours. - $duration += 3600 * intval($durvalue[7]); + // Weeks. + $duration = 7 * 86400 * intval($durvalue[3]); - // Mins. - if (isset($durvalue[8])) { - $duration += 60 * intval($durvalue[8]); - } + if (count($durvalue) > 4) { + // Days. + $duration += 86400 * intval($durvalue[4]); + } - // Secs. - if (isset($durvalue[9])) { - $duration += intval($durvalue[9]); - } + if (count($durvalue) > 5) { + // Hours. + $duration += 3600 * intval($durvalue[7]); + + // Mins. + if (isset($durvalue[8])) { + $duration += 60 * intval($durvalue[8]); } - // Sign. - if ($durvalue[1] == "-") { - $duration *= -1; + // Secs. + if (isset($durvalue[9])) { + $duration += intval($durvalue[9]); } + } - return $duration; - } else { - return false; + // Sign. + if ($durvalue[1] == "-") { + $duration *= -1; } + + return $duration; } /** * Export a duration value. + * + * @param $value TODO */ - function _exportDuration($value) + protected function _exportDuration($value) { $duration = ''; if ($value < 0) { @@ -1429,62 +1487,4 @@ class Horde_iCalendar { return $duration; } - /** - * Converts an 8bit string to a quoted-printable string according to RFC - * 2045, section 6.7. - * - * imap_8bit() does not apply all necessary rules. - * - * @param string $input The string to be encoded. - * - * @return string The quoted-printable encoded string. - */ - function _quotedPrintableEncode($input = '') - { - $output = $line = ''; - $len = strlen($input); - - for ($i = 0; $i < $len; ++$i) { - $ord = ord($input[$i]); - // Encode non-printable characters (rule 2). - if ($ord == 9 || - ($ord >= 32 && $ord <= 60) || - ($ord >= 62 && $ord <= 126)) { - $chunk = $input[$i]; - } else { - // Quoted printable encoding (rule 1). - $chunk = '=' . Horde_String::upper(sprintf('%02X', $ord)); - } - $line .= $chunk; - // Wrap long lines (rule 5) - if (strlen($line) + 1 > 76) { - $line = Horde_String::wordwrap($line, 75, "=\r\n", true, 'us-ascii', true); - $newline = strrchr($line, "\r\n"); - if ($newline !== false) { - $output .= substr($line, 0, -strlen($newline) + 2); - $line = substr($newline, 2); - } else { - $output .= $line; - } - continue; - } - // Wrap at line breaks for better readability (rule 4). - if (substr($line, -3) == '=0A') { - $output .= $line . "=\r\n"; - $line = ''; - } - } - $output .= $line; - - // Trailing whitespace must be encoded (rule 3). - $lastpos = strlen($output) - 1; - if ($output[$lastpos] == chr(9) || - $output[$lastpos] == chr(32)) { - $output[$lastpos] = '='; - $output .= Horde_String::upper(sprintf('%02X', ord($output[$lastpos]))); - } - - return $output; - } - } diff --git a/framework/Icalendar/lib/Horde/Icalendar/Daylight.php b/framework/Icalendar/lib/Horde/Icalendar/Daylight.php new file mode 100644 index 000000000..590851882 --- /dev/null +++ b/framework/Icalendar/lib/Horde/Icalendar/Daylight.php @@ -0,0 +1,44 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar + */ +class Horde_Icalendar_Daylight extends Horde_Icalendar +{ + /** + * The component type of this class. + * + * @var string + */ + public $type = 'daylight'; + + /** + * TODO + * + * @param $data TODO + */ + public function parsevCalendar($data) + { + parent::parsevCalendar($data, 'DAYLIGHT'); + } + + /** + * TODO + * + * @return TODO + */ + public function exportvCalendar() + { + return $this->_exportvData('DAYLIGHT'); + } + +} diff --git a/framework/Icalendar/lib/Horde/Icalendar/Exception.php b/framework/Icalendar/lib/Horde/Icalendar/Exception.php new file mode 100644 index 000000000..5409068bc --- /dev/null +++ b/framework/Icalendar/lib/Horde/Icalendar/Exception.php @@ -0,0 +1,17 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar + */ +class Horde_Icalendar_Exception extends Horde_Exception_Prior +{ +} diff --git a/framework/Icalendar/lib/Horde/Icalendar/Standard.php b/framework/Icalendar/lib/Horde/Icalendar/Standard.php new file mode 100644 index 000000000..90dad1f9d --- /dev/null +++ b/framework/Icalendar/lib/Horde/Icalendar/Standard.php @@ -0,0 +1,44 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar + */ +class Horde_Icalendar_Standard extends Horde_Icalendar +{ + /** + * The component type of this class. + * + * @var string + */ + public $type = 'standard'; + + /** + * TODO + * + * @param $data TODO + */ + public function parsevCalendar($data) + { + parent::parsevCalendar($data, 'STANDARD'); + } + + /** + * TODO + * + * @return TODO + */ + public function exportvCalendar() + { + return $this->_exportvData('STANDARD'); + } + +} diff --git a/framework/Icalendar/lib/Horde/Icalendar/Valarm.php b/framework/Icalendar/lib/Horde/Icalendar/Valarm.php new file mode 100644 index 000000000..da2d4b035 --- /dev/null +++ b/framework/Icalendar/lib/Horde/Icalendar/Valarm.php @@ -0,0 +1,34 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar + */ +class Horde_Icalendar_Valarm extends Horde_Icalendar +{ + /** + * The component type of this class. + * + * @var string + */ + public $type = 'vAlarm'; + + /** + * TODO + * + * @return TODO + */ + public function exportvCalendar() + { + return $this->_exportvData('VALARM'); + } + +} diff --git a/framework/Icalendar/lib/Horde/Icalendar/Vcard.php b/framework/Icalendar/lib/Horde/Icalendar/Vcard.php new file mode 100644 index 000000000..eb4cff10e --- /dev/null +++ b/framework/Icalendar/lib/Horde/Icalendar/Vcard.php @@ -0,0 +1,133 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar + */ +class Horde_Icalendar_Vcard extends Horde_Icalendar +{ + // The following were shamelessly yoinked from Contact_Vcard_Build + // Part numbers for N components. + const N_FAMILY = 0; + const N_GIVEN = 1; + const N_ADDL = 2; + const N_PREFIX = 3; + const N_SUFFIX = 4; + + // Part numbers for ADR components. + const ADR_POB = 0; + const ADR_EXTEND = 1; + const ADR_STREET = 2; + const ADR_LOCALITY = 3; + const ADR_REGION = 4; + const ADR_POSTCODE = 5; + const ADR_COUNTRY = 6; + + // Part numbers for GEO components. + const GEO_LAT = 0; + const GEO_LON = 1; + + /** + * The component type of this class. + * + * @var string + */ + public $type = 'vcard'; + + /** + * Constructor. + */ + public function __construct($version = '2.1') + { + parent::__construct($version); + } + + /** + * Sets the version of this component. + * + * @see $version + * @see $oldFormat + * + * @param string A float-like version string. + */ + public function setVersion($version) + { + $this->oldFormat = $version < 3; + $this->version = $version; + } + + /** + * Unlike vevent and vtodo, a vcard is normally not enclosed in an + * iCalendar container. (BEGIN..END) + * + * @return TODO + */ + public function exportvCalendar() + { + $requiredAttributes['VERSION'] = $this->version; + $requiredAttributes['N'] = ';;;;;;'; + if ($this->version == '3.0') { + $requiredAttributes['FN'] = ''; + } + + foreach ($requiredAttributes as $name => $default_value) { + try { + $this->getAttribute($name); + } catch (Horde_Icalendar_Exception $e) { + $this->setAttribute($name, $default_value); + } + } + + return $this->_exportvData('VCARD'); + } + + /** + * Returns the contents of the "N" tag as a printable Name: + * i.e. converts: + * + * N:Duck;Dagobert;T;Professor;Sen. + * to + * "Professor Dagobert T Duck Sen" + * + * @return string Full name of vcard "N" tag or null if no N tag. + */ + public function printableName() + { + try { + $name_parts = $this->getAttributeValues('N'); + } catch (Horde_Icalendar_Exception $e) { + return null; + } + + $name_arr = array(); + + foreach (array(self::N_PREFIX, self::N_GIVEN, self::N_ADDL, self::N_FAMILY, self::N_SUFFIX) as $val) { + if (!empty($name_parts[$val])) { + $name_arr[] = $name_parts[$val]; + } + } + + return implode(' ', $name_arr); + } + + /** + * Static function to make a given email address rfc822 compliant. + * + * @param string $address An email address. + * + * @return string The RFC822-formatted email address. + */ + static function getBareEmail($address) + { + return Horde_Mime_Address::bareAddress($address); + } + +} diff --git a/framework/iCalendar/iCalendar/vevent.php b/framework/Icalendar/lib/Horde/Icalendar/Vevent.php similarity index 56% rename from framework/iCalendar/iCalendar/vevent.php rename to framework/Icalendar/lib/Horde/Icalendar/Vevent.php index 3043c82a7..3c4d62559 100644 --- a/framework/iCalendar/iCalendar/vevent.php +++ b/framework/Icalendar/lib/Horde/Icalendar/Vevent.php @@ -7,27 +7,36 @@ * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. * - * @author Mike Cochrane - * @package Horde_iCalendar + * @author Mike Cochrane + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar */ -class Horde_iCalendar_vevent extends Horde_iCalendar { - +class Horde_Icalendar_Vevent extends Horde_Icalendar +{ /** * The component type of this class. * * @var string */ - var $type = 'vEvent'; + public $type = 'vEvent'; - function exportvCalendar() + /** + * TODO + * + * @return TODO + */ + public function exportvCalendar() { // Default values. - $requiredAttributes = array(); - $requiredAttributes['DTSTAMP'] = time(); - $requiredAttributes['UID'] = strval(new Horde_Support_Uuid()); + $requiredAttributes = array( + 'DTSTAMP' => time(), + 'UID' => strval(new Horde_Support_Uuid()) + ); - $method = !empty($this->_container) ? - $this->_container->getAttribute('METHOD') : 'PUBLISH'; + $method = !empty($this->_container) + ? $this->_container->getAttribute('METHOD') + : 'PUBLISH'; switch ($method) { case 'PUBLISH': @@ -62,12 +71,14 @@ class Horde_iCalendar_vevent extends Horde_iCalendar { } foreach ($requiredAttributes as $name => $default_value) { - if (is_a($this->getAttribute($name), 'PEAR_Error')) { + try { + $this->getAttribute($name); + } catch (Horde_Icalendar_Exception $e) { $this->setAttribute($name, $default_value); } } - return parent::_exportvData('VEVENT'); + return $this->_exportvData('VEVENT'); } /** @@ -77,7 +88,7 @@ class Horde_iCalendar_vevent extends Horde_iCalendar { * @param $status The participant status to set. * @param $fullname The full name of the participant to set. */ - function updateAttendee($email, $status, $fullname = '') + public function updateAttendee($email, $status, $fullname = '') { foreach ($this->_attributes as $key => $attribute) { if ($attribute['name'] == 'ATTENDEE' && @@ -102,10 +113,11 @@ class Horde_iCalendar_vevent extends Horde_iCalendar { * * @return string The organizer name to display for this event. */ - function organizerName() + public function organizerName() { - $organizer = $this->getAttribute('ORGANIZER', true); - if (is_a($organizer, 'PEAR_Error')) { + try { + $organizer = $this->getAttribute('ORGANIZER', true); + } catch (Horde_Icalendar_Exception $e) { return _("An unknown person"); } @@ -121,50 +133,52 @@ class Horde_iCalendar_vevent extends Horde_iCalendar { /** * Update this event with details from another event. * - * @param Horde_iCalendar_vEvent $vevent The vEvent with latest details. + * @param Horde_Icalendar_Vevent $vevent The vEvent with latest details. */ - function updateFromvEvent($vevent) + public function updateFromvEvent($vevent) { $newAttributes = $vevent->getAllAttributes(); foreach ($newAttributes as $newAttribute) { - $currentValue = $this->getAttribute($newAttribute['name']); - if (is_a($currentValue, 'PEAR_error')) { + try { + $currentValue = $this->getAttribute($newAttribute['name']); + } catch (Horde_Icalendar_Exception $e) { // Already exists so just add it. $this->setAttribute($newAttribute['name'], $newAttribute['value'], $newAttribute['params']); - } else { - // Already exists so locate and modify. - $found = false; + continue; + } - // Try matching the attribte name and value incase - // only the params changed (eg attendee updating - // status). + // Already exists so locate and modify. + $found = false; + + // Try matching the attribte name and value incase + // only the params changed (eg attendee updating + // status). + foreach ($this->_attributes as $id => $attr) { + if ($attr['name'] == $newAttribute['name'] && + $attr['value'] == $newAttribute['value']) { + // merge the params + foreach ($newAttribute['params'] as $param_id => $param_name) { + $this->_attributes[$id]['params'][$param_id] = $param_name; + } + $found = true; + break; + } + } + if (!$found) { + // Else match the first attribute with the same + // name (eg changing start time). foreach ($this->_attributes as $id => $attr) { - if ($attr['name'] == $newAttribute['name'] && - $attr['value'] == $newAttribute['value']) { - // merge the params + if ($attr['name'] == $newAttribute['name']) { + $this->_attributes[$id]['value'] = $newAttribute['value']; + // Merge the params. foreach ($newAttribute['params'] as $param_id => $param_name) { $this->_attributes[$id]['params'][$param_id] = $param_name; } - $found = true; break; } } - if (!$found) { - // Else match the first attribute with the same - // name (eg changing start time). - foreach ($this->_attributes as $id => $attr) { - if ($attr['name'] == $newAttribute['name']) { - $this->_attributes[$id]['value'] = $newAttribute['value']; - // Merge the params. - foreach ($newAttribute['params'] as $param_id => $param_name) { - $this->_attributes[$id]['params'][$param_id] = $param_name; - } - break; - } - } - } } } } @@ -173,53 +187,56 @@ class Horde_iCalendar_vevent extends Horde_iCalendar { * Update just the attendess of event with details from another * event. * - * @param Horde_iCalendar_vEvent $vevent The vEvent with latest details + * @param Horde_Icalendar_Vevent $vevent The vEvent with latest details */ - function updateAttendeesFromvEvent($vevent) + public function updateAttendeesFromvEvent($vevent) { $newAttributes = $vevent->getAllAttributes(); foreach ($newAttributes as $newAttribute) { if ($newAttribute['name'] != 'ATTENDEE') { continue; } - $currentValue = $this->getAttribute($newAttribute['name']); - if (is_a($currentValue, 'PEAR_error')) { + + try { + $currentValue = $this->getAttribute($newAttribute['name']); + } catch (Horde_Icalendar_Exception $e) { // Already exists so just add it. $this->setAttribute($newAttribute['name'], $newAttribute['value'], $newAttribute['params']); - } else { - // Already exists so locate and modify. - $found = false; - // Try matching the attribte name and value incase - // only the params changed (eg attendee updating - // status). + continue; + } + + // Already exists so locate and modify. + $found = false; + // Try matching the attribte name and value incase + // only the params changed (eg attendee updating + // status). + foreach ($this->_attributes as $id => $attr) { + if ($attr['name'] == $newAttribute['name'] && + $attr['value'] == $newAttribute['value']) { + // Merge the params. + foreach ($newAttribute['params'] as $param_id => $param_name) { + $this->_attributes[$id]['params'][$param_id] = $param_name; + } + $found = true; + break; + } + } + + if (!$found) { + // Else match the first attribute with the same + // name (eg changing start time). foreach ($this->_attributes as $id => $attr) { - if ($attr['name'] == $newAttribute['name'] && - $attr['value'] == $newAttribute['value']) { + if ($attr['name'] == $newAttribute['name']) { + $this->_attributes[$id]['value'] = $newAttribute['value']; // Merge the params. foreach ($newAttribute['params'] as $param_id => $param_name) { $this->_attributes[$id]['params'][$param_id] = $param_name; } - $found = true; break; } } - - if (!$found) { - // Else match the first attribute with the same - // name (eg changing start time). - foreach ($this->_attributes as $id => $attr) { - if ($attr['name'] == $newAttribute['name']) { - $this->_attributes[$id]['value'] = $newAttribute['value']; - // Merge the params. - foreach ($newAttribute['params'] as $param_id => $param_name) { - $this->_attributes[$id]['params'][$param_id] = $param_name; - } - break; - } - } - } } } } diff --git a/framework/iCalendar/iCalendar/vfreebusy.php b/framework/Icalendar/lib/Horde/Icalendar/Vfreebusy.php similarity index 72% rename from framework/iCalendar/iCalendar/vfreebusy.php rename to framework/Icalendar/lib/Horde/Icalendar/Vfreebusy.php index 730beef9a..f66f4e41d 100644 --- a/framework/iCalendar/iCalendar/vfreebusy.php +++ b/framework/Icalendar/lib/Horde/Icalendar/Vfreebusy.php @@ -9,27 +9,42 @@ * * @todo Don't use timestamps * - * @author Mike Cochrane - * @package Horde_iCalendar + * @author Mike Cochrane + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar */ -class Horde_iCalendar_vfreebusy extends Horde_iCalendar { - +class Horde_ICalendar_Vfreebusy extends Horde_Icalendar +{ /** * The component type of this class. * * @var string */ - var $type = 'vFreebusy'; + public $type = 'vFreebusy'; - var $_busyPeriods = array(); - var $_extraParams = array(); + /** + * TODO + * + * @var array + */ + protected $_busyPeriods = array(); + + /** + * TODO + * + * @var array + */ + protected $_extraParams = array(); /** * Parses a string containing vFreebusy data. * * @param string $data The data to parse. + * @param $type TODO + * @param $charset TODO */ - function parsevCalendar($data, $type = null, $charset = null) + public function parsevCalendar($data, $type = null, $charset = null) { parent::parsevCalendar($data, 'VFREEBUSY', $charset); @@ -58,9 +73,9 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * Returns the component exported as string. * * @return string The exported vFreeBusy information according to the - * iCalender format specification. + * iCalendar format specification. */ - function exportvCalendar() + public function exportvCalendar() { foreach ($this->_busyPeriods as $start => $end) { $periods = array(array('start' => $start, 'end' => $end)); @@ -69,7 +84,7 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { ? $this->_extraParams[$start] : array()); } - $res = parent::_exportvData('VFREEBUSY'); + $res = $this->_exportvData('VFREEBUSY'); foreach ($this->_attributes as $key => $attribute) { if ($attribute['name'] == 'FREEBUSY') { @@ -85,29 +100,35 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * * @return string A clear text name for displaying this object. */ - function getName() + public function getName() { $name = ''; - $method = !empty($this->_container) ? - $this->_container->getAttribute('METHOD') : 'PUBLISH'; - if (is_a($method, 'PEAR_Error') || $method == 'PUBLISH') { + try { + $method = !empty($this->_container) + ? $this->_container->getAttribute('METHOD') + : 'PUBLISH'; + if ($method == 'PUBLISH') { + $attr = 'ORGANIZER'; + } elseif ($method == 'REPLY') { + $attr = 'ATTENDEE'; + } + } catch (Horde_Icalendar_Exception $e) { $attr = 'ORGANIZER'; - } elseif ($method == 'REPLY') { - $attr = 'ATTENDEE'; } - $name = $this->getAttribute($attr, true); - if (!is_a($name, 'PEAR_Error') && isset($name[0]['CN'])) { - return $name[0]['CN']; - } + try { + $name = $this->getAttribute($attr, true); + if (isset($name[0]['CN'])) { + return $name[0]['CN']; + } + } catch (Horde_Icalendar_Exception $e) {} - $name = $this->getAttribute($attr); - if (is_a($name, 'PEAR_Error')) { - return ''; - } else { - $name = parse_url($name); + try { + $name = parse_url($this->getAttribute($attr)); return $name['path']; + } catch (Horde_Icalendar_Exception $e) { + return ''; } } @@ -116,24 +137,28 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * * @return string The email address of this object's owner. */ - function getEmail() + public function getEmail() { $name = ''; - $method = !empty($this->_container) - ? $this->_container->getAttribute('METHOD') : 'PUBLISH'; - if (is_a($method, 'PEAR_Error') || $method == 'PUBLISH') { + try { + $method = !empty($this->_container) + ? $this->_container->getAttribute('METHOD') + : 'PUBLISH'; + if ($method == 'PUBLISH') { + $attr = 'ORGANIZER'; + } elseif ($method == 'REPLY') { + $attr = 'ATTENDEE'; + } + } catch (Horde_Icalendar_Exception $e) { $attr = 'ORGANIZER'; - } elseif ($method == 'REPLY') { - $attr = 'ATTENDEE'; } - $name = $this->getAttribute($attr); - if (is_a($name, 'PEAR_Error')) { - return ''; - } else { - $name = parse_url($name); + try { + $name = parse_url($this->getAttribute($attr)); return $name['path']; + } catch (Horde_Icalendar_Exception $e) { + return ''; } } @@ -142,7 +167,7 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * * @return array All busy periods. */ - function getBusyPeriods() + public function getBusyPeriods() { return $this->_busyPeriods; } @@ -152,7 +177,7 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * * @return array Additional parameters of the freebusy periods. */ - function getExtraParams() + public function getExtraParams() { return $this->_extraParams; } @@ -166,7 +191,7 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * @return array A hash with free time periods, the start times as the * keys and the end times as the values. */ - function getFreePeriods($startStamp, $endStamp) + public function getFreePeriods($startStamp, $endStamp) { $this->simplify(); $periods = array(); @@ -213,8 +238,8 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * $end parameter will be ignored. * @param array $extra Additional parameters for this busy period. */ - function addBusyPeriod($type, $start, $end = null, $duration = null, - $extra = array()) + public function addBusyPeriod($type, $start, $end = null, $duration = null, + $extra = array()) { if ($type == 'FREE') { // Make sure this period is not marked as busy. @@ -253,14 +278,14 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * * @return integer A timestamp. */ - function getStart() + public function getStart() { - if (!is_a($this->getAttribute('DTSTART'), 'PEAR_Error')) { + try { return $this->getAttribute('DTSTART'); - } elseif (count($this->_busyPeriods)) { - return min(array_keys($this->_busyPeriods)); - } else { - return false; + } catch (Horde_Icalendar_Exception $e) { + return count($this->_busyPeriods) + ? min(array_keys($this->_busyPeriods)) + : false; } } @@ -270,35 +295,32 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * * @return integer A timestamp. */ - function getEnd() + public function getEnd() { - if (!is_a($this->getAttribute('DTEND'), 'PEAR_Error')) { + try { return $this->getAttribute('DTEND'); - } elseif (count($this->_busyPeriods)) { - return max(array_values($this->_busyPeriods)); - } else { - return false; + } catch (Horde_Icalendar_Exception $e) { + return count($this->_busyPeriods) + ? max(array_values($this->_busyPeriods)) + : false; } } /** - * Merges the busy periods of another Horde_iCalendar_vfreebusy object + * Merges the busy periods of another Horde_Icalendar_Vfreebusy object * into this one. * * This might lead to simplification no matter what you specify for the * "simplify" flag since periods with the same start date will lead to the * shorter period being removed (see addBusyPeriod). * - * @param Horde_iCalendar_vfreebusy $freebusy A freebusy object. + * @param Horde_Icalendar_Vfreebusy $freebusy A freebusy object. * @param boolean $simplify If true, simplify() will * called after the merge. */ - function merge($freebusy, $simplify = true) + public function merge(Horde_Icalendar_Vfreebusy $freebusy, + $simplify = true) { - if (!is_a($freebusy, 'Horde_iCalendar_vfreebusy')) { - return false; - } - $extra = $freebusy->getExtraParams(); foreach ($freebusy->getBusyPeriods() as $start => $end) { // This might simplify the busy periods without taking the @@ -308,23 +330,35 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { ? $extra[$start] : array()); } - $thisattr = $this->getAttribute('DTSTART'); - $thatattr = $freebusy->getAttribute('DTSTART'); - if (is_a($thisattr, 'PEAR_Error') && !is_a($thatattr, 'PEAR_Error')) { - $this->setAttribute('DTSTART', $thatattr, array(), false); - } elseif (!is_a($thatattr, 'PEAR_Error')) { - if ($thatattr < $thisattr) { - $this->setAttribute('DTSTART', $thatattr, array(), false); + foreach (array('DTSTART', 'DTEND') as $val) { + try { + $thisattr = $this->getAttribute($val); + } catch (Horde_Icalendar_Exception $e) { + $thisattr = null; } - } - $thisattr = $this->getAttribute('DTEND'); - $thatattr = $freebusy->getAttribute('DTEND'); - if (is_a($thisattr, 'PEAR_Error') && !is_a($thatattr, 'PEAR_Error')) { - $this->setAttribute('DTEND', $thatattr, array(), false); - } elseif (!is_a($thatattr, 'PEAR_Error')) { - if ($thatattr > $thisattr) { - $this->setAttribute('DTEND', $thatattr, array(), false); + try { + $thatattr = $freebusy->getAttribute($val); + } catch (Horde_Icalendar_Exception $e) { + $thatattr = null; + } + + if (is_null($thisattr) && !is_null($thatattr)) { + $this->setAttribute($val, $thatattr, array(), false); + } elseif (!is_null($thatattr)) { + switch ($val) { + case 'DTSTART': + $set = ($thatattr < $thisattr); + break; + + case 'DTEND': + $set = ($thatattr > $thisattr); + break; + } + + if ($set) { + $this->setAttribute($val, $thatattr, array(), false); + } } } @@ -339,7 +373,7 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { * Removes all overlaps and simplifies the busy periods array as much as * possible. */ - function simplify() + public function simplify() { $clean = false; $busy = array($this->_busyPeriods, $this->_extraParams); @@ -356,17 +390,25 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { $this->_busyPeriods = $result[0]; } - function _simplify($busyPeriods, $extraParams = array()) + /** + * TODO + * + * @param $busyPeriods TODO + * @param array $extraParams TODO + * + * @return array TODO + */ + protected function _simplify($busyPeriods, $extraParams = array()) { - $checked = array(); - $checkedExtra = array(); + $checked = $checkedExtra = array(); $checkedEmpty = true; foreach ($busyPeriods as $start => $end) { if ($checkedEmpty) { $checked[$start] = $end; $checkedExtra[$start] = isset($extraParams[$start]) - ? $extraParams[$start] : array(); + ? $extraParams[$start] + : array(); $checkedEmpty = false; } else { $added = false; @@ -380,7 +422,8 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { // Add replacing entry. $checked[$start] = $end; $checkedExtra[$start] = isset($extraParams[$start]) - ? $extraParams[$start] : array(); + ? $extraParams[$start] + : array(); $added = true; } elseif ($start >= $testStart && $end <= $testEnd) { // The new period lies fully within the old @@ -393,9 +436,11 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { // choose one of the two parameter sets. It's better // to leave two separated time periods. $extra = isset($extraParams[$start]) - ? $extraParams[$start] : array(); + ? $extraParams[$start] + : array(); $testExtra = isset($checkedExtra[$testStart]) - ? $checkedExtra[$testStart] : array(); + ? $checkedExtra[$testStart] + : array(); // Remove old period entry. unset($checked[$testStart]); unset($checkedExtra[$testStart]); @@ -418,18 +463,21 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { $checked[$newStart] = $break; $checkedExtra[$newStart] = isset($extraParams[$newStart]) - ? $extraParams[$newStart] : array(); + ? $extraParams[$newStart] + : array(); $checked[$break] = $newEnd; $highStart = max($start, $testStart); $checkedExtra[$break] = isset($extraParams[$highStart]) - ? $extraParams[$highStart] : array(); + ? $extraParams[$highStart] + : array(); // Ensure we also have the extra data in the // extraParams. $extraParams[$break] = isset($extraParams[$highStart]) - ? $extraParams[$highStart] : array(); + ? $extraParams[$highStart] + : array(); } $added = true; } @@ -442,7 +490,8 @@ class Horde_iCalendar_vfreebusy extends Horde_iCalendar { if (!$added) { $checked[$start] = $end; $checkedExtra[$start] = isset($extraParams[$start]) - ? $extraParams[$start] : array(); + ? $extraParams[$start] + : array(); } } } diff --git a/framework/Icalendar/lib/Horde/Icalendar/Vjournal.php b/framework/Icalendar/lib/Horde/Icalendar/Vjournal.php new file mode 100644 index 000000000..5dcbee11c --- /dev/null +++ b/framework/Icalendar/lib/Horde/Icalendar/Vjournal.php @@ -0,0 +1,34 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar + */ +class Horde_Icalendar_Vjournal extends Horde_Icalendar { + + /** + * The component type of this class. + * + * @var string + */ + public $type = 'vJournal'; + + /** + * TODO + * + * @return TODO + */ + public function exportvCalendar() + { + return $this->_exportvData('VJOURNAL'); + } + +} diff --git a/framework/iCalendar/iCalendar/vnote.php b/framework/Icalendar/lib/Horde/Icalendar/Vnote.php similarity index 62% rename from framework/iCalendar/iCalendar/vnote.php rename to framework/Icalendar/lib/Horde/Icalendar/Vnote.php index f2418e314..95558e120 100644 --- a/framework/iCalendar/iCalendar/vnote.php +++ b/framework/Icalendar/lib/Horde/Icalendar/Vnote.php @@ -7,22 +7,27 @@ * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. * - * @author Mike Cochrane - * @author Karsten Fourmont - * @package Horde_iCalendar + * @author Mike Cochrane + * @author Karsten Fourmont + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar */ -class Horde_iCalendar_vnote extends Horde_iCalendar { - +class Horde_Icalendar_Vnote extends Horde_Icalendar +{ /** * The component type of this class. * * @var string */ - var $type = 'vNote'; + public $type = 'vNote'; - function Horde_iCalendar_vnote($version = '1.1') + /** + * Constructor. + */ + public function __construct($version = '1.1') { - return parent::Horde_iCalendar($version); + parent::__construct($version); } /** @@ -33,7 +38,7 @@ class Horde_iCalendar_vnote extends Horde_iCalendar { * * @param string A float-like version string. */ - function setVersion($version) + public function setVersion($version) { $this->oldFormat = $version < 1; $this->version = $version; @@ -42,14 +47,18 @@ class Horde_iCalendar_vnote extends Horde_iCalendar { /** * Unlike vevent and vtodo, a vnote is normally not enclosed in an * iCalendar container. (BEGIN..END) + * + * @return TODO */ - function exportvCalendar() + public function exportvCalendar() { $requiredAttributes['BODY'] = ''; $requiredAttributes['VERSION'] = '1.1'; foreach ($requiredAttributes as $name => $default_value) { - if (is_a($this->getattribute($name), 'PEAR_Error')) { + try { + $this->getAttribute($name); + } catch (Horde_Icalendar_Exception $e) { $this->setAttribute($name, $default_value); } } diff --git a/framework/iCalendar/iCalendar/vtimezone.php b/framework/Icalendar/lib/Horde/Icalendar/Vtimezone.php similarity index 76% rename from framework/iCalendar/iCalendar/vtimezone.php rename to framework/Icalendar/lib/Horde/Icalendar/Vtimezone.php index bcb883a87..6c63a5b88 100644 --- a/framework/iCalendar/iCalendar/vtimezone.php +++ b/framework/Icalendar/lib/Horde/Icalendar/Vtimezone.php @@ -7,21 +7,28 @@ * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. * - * @author Mike Cochrane - * @package Horde_iCalendar + * @author Mike Cochrane + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar */ -class Horde_iCalendar_vtimezone extends Horde_iCalendar { - +class Horde_Icalendar_Vtimezone extends Horde_Icalendar +{ /** * The component type of this class. * * @var string */ - var $type = 'vTimeZone'; + public $type = 'vTimeZone'; - function exportvCalendar() + /** + * TODO + * + * @return TODO + */ + public function exportvCalendar() { - return parent::_exportvData('VTIMEZONE'); + return $this->_exportvData('VTIMEZONE'); } /** @@ -29,31 +36,40 @@ class Horde_iCalendar_vtimezone extends Horde_iCalendar { * array with the exact time of the time change as well as the * 'from' and 'to' offsets around the change. Time is arbitrarily * based on UTC for comparison. + * + * @param &$child TODO + * @param $year TODO + * + * @return TODO */ - function parseChild(&$child, $year) + public function parseChild(&$child, $year) { // Make sure 'time' key is first for sort(). $result['time'] = 0; - $t = $child->getAttribute('TZOFFSETFROM'); - if ($t instanceOf PEAR_Error) { + try { + $t = $child->getAttribute('TZOFFSETFROM'); + } catch (Horde_Icalendar_Exception $e) { return false; } $result['from'] = ($t['hour'] * 60 * 60 + $t['minute'] * 60) * ($t['ahead'] ? 1 : -1); - $t = $child->getAttribute('TZOFFSETTO'); - if ($t instanceOf PEAR_Error) { + try { + $t = $child->getAttribute('TZOFFSETTO'); + } catch (Horde_Icalendar_Exception $e) { return false; } $result['to'] = ($t['hour'] * 60 * 60 + $t['minute'] * 60) * ($t['ahead'] ? 1 : -1); - $switch_time = $child->getAttribute('DTSTART'); - if ($switch_time instanceOf PEAR_Error) { + try { + $switch_time = $child->getAttribute('DTSTART'); + } catch (Horde_Icalendar_Exception $e) { return false; } - $rrules = $child->getAttribute('RRULE'); - if ($rrules instanceOf PEAR_Error) { + try { + $rrules = $child->getAttribute('RRULE'); + } catch (Horde_Icalendar_Exception $e) { if (!is_int($switch_time)) { return false; } @@ -159,47 +175,3 @@ class Horde_iCalendar_vtimezone extends Horde_iCalendar { } } - -/** - * @package Horde_iCalendar - */ -class Horde_iCalendar_standard extends Horde_iCalendar { - - function getType() - { - return 'standard'; - } - - function parsevCalendar($data) - { - parent::parsevCalendar($data, 'STANDARD'); - } - - function exportvCalendar() - { - return parent::_exportvData('STANDARD'); - } - -} - -/** - * @package Horde_iCalendar - */ -class Horde_iCalendar_daylight extends Horde_iCalendar { - - function getType() - { - return 'daylight'; - } - - function parsevCalendar($data) - { - parent::parsevCalendar($data, 'DAYLIGHT'); - } - - function exportvCalendar() - { - return parent::_exportvData('DAYLIGHT'); - } - -} diff --git a/framework/iCalendar/iCalendar/vtodo.php b/framework/Icalendar/lib/Horde/Icalendar/Vtodo.php similarity index 50% rename from framework/iCalendar/iCalendar/vtodo.php rename to framework/Icalendar/lib/Horde/Icalendar/Vtodo.php index ef81d505a..dd7be532e 100644 --- a/framework/iCalendar/iCalendar/vtodo.php +++ b/framework/Icalendar/lib/Horde/Icalendar/Vtodo.php @@ -7,21 +7,28 @@ * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. * - * @author Mike Cochrane - * @package Horde_iCalendar + * @author Mike Cochrane + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Icalendar */ -class Horde_iCalendar_vtodo extends Horde_iCalendar { - +class Horde_Icalendar_Vtodo extends Horde_Icalendar +{ /** * The component type of this class. * * @var string */ - var $type = 'vTodo'; + public $type = 'vTodo'; - function exportvCalendar() + /** + * TODO + * + * @return TODO + */ + public function exportvCalendar() { - return parent::_exportvData('VTODO'); + return $this->_exportvData('VTODO'); } /** @@ -30,28 +37,37 @@ class Horde_iCalendar_vtodo extends Horde_iCalendar { * @return array Array containing the details of the todo in a hash * as used by Horde applications. */ - function toArray() + public function toArray() { $todo = array(); - $name = $this->getAttribute('SUMMARY'); - if (!is_array($name) && !is_a($name, 'PEAR_Error')) { - $todo['name'] = $name; - } - $desc = $this->getAttribute('DESCRIPTION'); - if (!is_array($desc) && !is_a($desc, 'PEAR_Error')) { - $todo['desc'] = $desc; - } + try { + $name = $this->getAttribute('SUMMARY'); + if (!is_array($name)) { + $todo['name'] = $name; + } + } catch (Horde_Icalendar_Exception $e) {} - $priority = $this->getAttribute('PRIORITY'); - if (!is_array($priority) && !is_a($priority, 'PEAR_Error')) { - $todo['priority'] = $priority; - } + try { + $desc = $this->getAttribute('DESCRIPTION'); + if (!is_array($desc)) { + $todo['desc'] = $desc; + } + } catch (Horde_Icalendar_Exception $e) {} - $due = $this->getAttribute('DTSTAMP'); - if (!is_array($due) && !is_a($due, 'PEAR_Error')) { - $todo['due'] = $due; - } + try { + $priority = $this->getAttribute('PRIORITY'); + if (!is_array($priority)) { + $todo['priority'] = $priority; + } + } catch (Horde_Icalendar_Exception $e) {} + + try { + $due = $this->getAttribute('DTSTAMP'); + if (!is_array($due)) { + $todo['due'] = $due; + } + } catch (Horde_Icalendar_Exception $e) {} return $todo; } @@ -62,7 +78,7 @@ class Horde_iCalendar_vtodo extends Horde_iCalendar { * @param array $todo Array containing the details of the todo in * the same format that toArray() exports. */ - function fromArray($todo) + public function fromArray($todo) { if (isset($todo['name'])) { $this->setAttribute('SUMMARY', $todo['name']); diff --git a/framework/Icalendar/package.xml b/framework/Icalendar/package.xml new file mode 100644 index 000000000..8756e9914 --- /dev/null +++ b/framework/Icalendar/package.xml @@ -0,0 +1,240 @@ + + + Icalendar + pear.horde.org + iCalendar API + This package provides an API for dealing with iCalendar data. + + Chuck Hagenbuch + chuck + chuck@horde.org + yes + + + Jan Schneider + jan + jan@horde.org + yes + + 2010-08-02 + + 0.2.0 + 0.2.0 + + + beta + beta + + LGPL + * Initial Horde 4 package. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.2.0 + + + 1.7.0 + + + Exception + pear.horde.org + + + Mime + pear.horde.org + + + Support + pear.horde.org + + + Util + pear.horde.org + + + + + + + + + + + + + + + + + + + + 2008-09-25 + + 0.1.0 + 0.1.0 + + + beta + beta + + LGPL + * Fix vFreebusy merging (Bug #4807). + * Implement handling of vTimezones in iCalendar data (lists-horde@carlthompson.net, Bug #4399). + * Correctly produce vcard parameters without value, like "ADR;WORK:...". + * Support departments in vCard's ORG properties (martin@matuska.org, Bug #4285). + * Fixed _parseDateTime() (wrobel@pardus.de, Bug #4808). + * Fix exporting of recurring exceptions (Bug #4627). + * Use lowercase mailto: for better Apple iCal compatibility. + * We must *not* escape colons per RFC in param values. + * Fix encoding issues with iCalendar 2.0 exports. + * Move version specific vCalendar/iCalendar export to Kronolith_Event. + * Use QUOTED-PRINTABLE when there's a newline in VNOTE data. + * Anniversary support (ntai@smartfruit.com, Request #5059). + * Support for all day events with VCALENDAR 1.0. + * Use ISO-8559-1 as default vCalendar 1.0 and vCard 2.1. + * Fix unreliably overwriting a variable with itself (rsalmon@mbpgroup.com, Bug #5652). + * Handle AALARM data with parameters (delimited by a ";"). + * Fix GEO parsing and generation. + * Refactor line folding and quoted-printable encoding. + * Add missing softline break (Bug #6541). + * Don't require a newline after END (Bug #6641, #6706). + * Fix detecting of "old" formats when parsing vCalendar/vCard data. + * Request charset on the fly, because it depends on the VERSION property. + * Fix passing value arrays with only one element. + * Correctly parse quoted parameters (Bug #7031) + * Set the correct version if none provided through the vcard data. + * BODY is not required, but N is, and FN for vcard3.0. + * Return the passed address unmodified if Mail_RFC822::validateMailbox() fails. + * Fixed importing of several events at once. + * Removed required calendar component properties in vevent.php. + * Fix generation of UIDs with PHP 5.2+. + * Fix generation of free periods with overlapping events (cedric.parent@multitel.be). + * Add support for extended vfreebusy parameters (wrobel@gentoo.org, Request #4690). + * Ensure vnotes and vcards are created with a valid default version number. + + + + 2006-05-08 + + 0.0.3 + 0.0.3 + + + beta + beta + + LGPL + * Converted to package.xml 2.0 for pear.horde.org. + + + + + 0.0.2 + 0.0.2 + + + beta + beta + + 2004-12-05 + LGPL + Lots of improvements, bugfixes and support for more fields and members of the iCalendar family. + + + + + 0.0.1 + 0.0.1 + + + alpha + alpha + + 2003-07-03 + LGPL + Initial release as a PEAR package + + + + diff --git a/framework/iCalendar/tests/.cvsignore b/framework/Icalendar/test/.cvsignore similarity index 100% rename from framework/iCalendar/tests/.cvsignore rename to framework/Icalendar/test/.cvsignore diff --git a/framework/iCalendar/tests/bug_7423.phpt b/framework/Icalendar/test/Horde/Icalendar/bug_7423.phpt similarity index 84% rename from framework/iCalendar/tests/bug_7423.phpt rename to framework/Icalendar/test/Horde/Icalendar/bug_7423.phpt index 56cc9a273..cf3e3a8fb 100644 --- a/framework/iCalendar/tests/bug_7423.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/bug_7423.phpt @@ -3,8 +3,8 @@ Bug #7423: Leading space on attribute names --FILE-- parseVCalendar($data)); diff --git a/framework/iCalendar/tests/fixtures/vTimezone/AuthorChats.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/AuthorChats.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/AuthorChats.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/AuthorChats.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/MMMPseminar.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/MMMPseminar.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/MMMPseminar.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/MMMPseminar.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/Moon_Days.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/Moon_Days.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/Moon_Days.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/Moon_Days.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/ProjectCalendar.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/ProjectCalendar.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/ProjectCalendar.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/ProjectCalendar.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/SpanishHolidays.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/SpanishHolidays.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/SpanishHolidays.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/SpanishHolidays.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/allcategories.vcs b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/allcategories.vcs similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/allcategories.vcs rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/allcategories.vcs diff --git a/framework/iCalendar/tests/fixtures/vTimezone/arsenal32FC.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/arsenal32FC.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/arsenal32FC.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/arsenal32FC.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/events.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/events.ics similarity index 88% rename from framework/iCalendar/tests/fixtures/vTimezone/events.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/events.ics index d54c36238..d422cb135 100644 --- a/framework/iCalendar/tests/fixtures/vTimezone/events.ics +++ b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/events.ics @@ -1,7 +1,7 @@ BEGIN:VCALENDAR VERSION:2.0 X-WR-CALNAME:Carl Thompson's Calendar -PRODID:-//The Horde Project//Horde_iCalendar Library//EN +PRODID:-//The Horde Project//Horde iCalendar Library//EN METHOD:PUBLISH BEGIN:VEVENT DTSTART:20060905T130000Z diff --git a/framework/iCalendar/tests/fixtures/vTimezone/exchange.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/exchange.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/exchange.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/exchange.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/exdate.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/exdate.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/exdate.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/exdate.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/iscw.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/iscw.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/iscw.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/iscw.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/meeting.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/meeting.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/meeting.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/meeting.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/privacy_events.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/privacy_events.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/privacy_events.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/privacy_events.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/rfc2445.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/rfc2445.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/rfc2445.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/rfc2445.ics diff --git a/framework/iCalendar/tests/fixtures/vTimezone/test.vcs b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/test.vcs similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/test.vcs rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/test.vcs diff --git a/framework/iCalendar/tests/fixtures/vTimezone/test4.vcs b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/test4.vcs similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/test4.vcs rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/test4.vcs diff --git a/framework/iCalendar/tests/fixtures/vTimezone/test_recurring.vcs b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/test_recurring.vcs similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/test_recurring.vcs rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/test_recurring.vcs diff --git a/framework/iCalendar/tests/fixtures/vTimezone/wicca.ics b/framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/wicca.ics similarity index 100% rename from framework/iCalendar/tests/fixtures/vTimezone/wicca.ics rename to framework/Icalendar/test/Horde/Icalendar/fixtures/vTimezone/wicca.ics diff --git a/framework/iCalendar/tests/geo.phpt b/framework/Icalendar/test/Horde/Icalendar/geo.phpt similarity index 86% rename from framework/iCalendar/tests/geo.phpt rename to framework/Icalendar/test/Horde/Icalendar/geo.phpt index a02df3ed3..fa9d5e7a7 100644 --- a/framework/iCalendar/tests/geo.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/geo.phpt @@ -3,8 +3,8 @@ GEO test --FILE-- parseVCalendar($data); diff --git a/framework/iCalendar/tests/line-folding.phpt b/framework/Icalendar/test/Horde/Icalendar/line-folding.phpt similarity index 81% rename from framework/iCalendar/tests/line-folding.phpt rename to framework/Icalendar/test/Horde/Icalendar/line-folding.phpt index 2b551db76..f7762ecc4 100644 --- a/framework/iCalendar/tests/line-folding.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/line-folding.phpt @@ -3,10 +3,10 @@ Line folding tests. --FILE-- setAttribute('UID', 'XXX'); $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); @@ -15,8 +15,8 @@ $ical->addComponent($event); echo $ical->exportVCalendar(); echo "\n"; -$ical = new Horde_iCalendar('1.0'); -$event = Horde_iCalendar::newComponent('vevent', $ical); +$ical = new Horde_Icalendar('1.0'); +$event = Horde_Icalendar::newComponent('vevent', $ical); $event->setAttribute('UID', 'XXX'); $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); @@ -25,8 +25,8 @@ $ical->addComponent($event); echo $ical->exportVCalendar(); echo "\n"; -$ical = new Horde_iCalendar(); -$event = Horde_iCalendar::newComponent('vevent', $ical); +$ical = new Horde_Icalendar(); +$event = Horde_Icalendar::newComponent('vevent', $ical); $event->setAttribute('UID', 'XXX'); $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); @@ -35,8 +35,8 @@ $ical->addComponent($event); echo $ical->exportVCalendar(); echo "\n"; -$ical = new Horde_iCalendar('1.0'); -$event = Horde_iCalendar::newComponent('vevent', $ical); +$ical = new Horde_Icalendar('1.0'); +$event = Horde_Icalendar::newComponent('vevent', $ical); $event->setAttribute('UID', 'XXX'); $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); @@ -45,8 +45,8 @@ $ical->addComponent($event); echo $ical->exportVCalendar(); echo "\n"; -$ical = new Horde_iCalendar('1.0'); -$event = Horde_iCalendar::newComponent('vevent', $ical); +$ical = new Horde_Icalendar('1.0'); +$event = Horde_Icalendar::newComponent('vevent', $ical); $event->setAttribute('UID', 'XXX'); $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); @@ -55,8 +55,8 @@ $ical->addComponent($event); echo $ical->exportVCalendar(); echo "\n"; -$ical = new Horde_iCalendar(); -$event = Horde_iCalendar::newComponent('vevent', $ical); +$ical = new Horde_Icalendar(); +$event = Horde_Icalendar::newComponent('vevent', $ical); $event->setAttribute('UID', 'XXX'); $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE')); @@ -80,7 +80,7 @@ echo $ical->exportVCalendar(); --EXPECT-- BEGIN:VCALENDAR VERSION:2.0 -PRODID:-//The Horde Project//Horde_iCalendar Library//EN +PRODID:-//The Horde Project//Horde iCalendar Library//EN METHOD:PUBLISH BEGIN:VEVENT UID:XXX @@ -94,7 +94,7 @@ END:VCALENDAR BEGIN:VCALENDAR VERSION:1.0 -PRODID:-//The Horde Project//Horde_iCalendar Library//EN +PRODID:-//The Horde Project//Horde iCalendar Library//EN METHOD:PUBLISH BEGIN:VEVENT UID:XXX @@ -107,7 +107,7 @@ END:VCALENDAR BEGIN:VCALENDAR VERSION:2.0 -PRODID:-//The Horde Project//Horde_iCalendar Library//EN +PRODID:-//The Horde Project//Horde iCalendar Library//EN METHOD:PUBLISH BEGIN:VEVENT UID:XXX @@ -121,40 +121,39 @@ END:VCALENDAR BEGIN:VCALENDAR VERSION:1.0 -PRODID:-//The Horde Project//Horde_iCalendar Library//EN +PRODID:-//The Horde Project//Horde iCalendar Library//EN METHOD:PUBLISH BEGIN:VEVENT UID:XXX DTSTART:20080101T000000 DTSTAMP:20080101T000000 -DESCRIPTION;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:L=C3=B6rem ips=C3=BCm d=C3=B6l=C3=B6r sit =C3=A4met,= - c=C3=B6nsectet=C3=BCer =C3=A4dipiscing elit. Aliq=C3=BC=C3=A4m= - s=C3=B6llicit=C3=BCdin f=C3=A4=C3=BCcib=C3=BCs m=C3=A4=C3=BCris =C3=A4met. +DESCRIPTION;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:L=C3=B6rem ips=C3=BCm d=C3=B6l=C3=B6r sit =C3=A4met, c=C3=B6nsectet=C3=BCer = +=C3=A4dipiscing elit. Aliq=C3=BC=C3=A4m s=C3=B6llicit=C3=BCdin f=C3=A4=C3=BC= +cib=C3=BCs m=C3=A4=C3=BCris =C3=A4met. SUMMARY: END:VEVENT END:VCALENDAR BEGIN:VCALENDAR VERSION:1.0 -PRODID:-//The Horde Project//Horde_iCalendar Library//EN +PRODID:-//The Horde Project//Horde iCalendar Library//EN METHOD:PUBLISH BEGIN:VEVENT UID:XXX DTSTART:20080101T000000 DTSTAMP:20080101T000000 -DESCRIPTION;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:L=C3=B6remips=C3=BCmd=C3=B6l=C3=B6rsit=C3=A4met,c=C3=B6nsectet=C3=BCer=C3=A= -4dipiscingelit.Aliq=C3=BC=C3=A4ms=C3=B6llicit=C3=BCdinf=C3=A4=C3=BCcib=C3=B= -Csm=C3=A4=C3=BCris=C3=A4met.= - L=C3=B6remips=C3=BCmd=C3=B6l=C3=B6rsit=C3=A4met,c=C3=B6nsectet=C3=BCer=C3== -A4dipiscingelit.Aliq=C3=BC=C3=A4ms=C3=B6llicit=C3=BCdinf=C3=A4=C3=BCcib=C3== -BCsm=C3=A4=C3=BCris=C3=A4met. +DESCRIPTION;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:L=C3=B6remips=C3=BCmd=C3=B6l=C3=B6rsit=C3=A4met,c=C3=B6nsectet=C3=BCer=C3=A4= +dipiscingelit.Aliq=C3=BC=C3=A4ms=C3=B6llicit=C3=BCdinf=C3=A4=C3=BCcib=C3=BCs= +m=C3=A4=C3=BCris=C3=A4met. L=C3=B6remips=C3=BCmd=C3=B6l=C3=B6rsit=C3=A4met,c= +=C3=B6nsectet=C3=BCer=C3=A4dipiscingelit.Aliq=C3=BC=C3=A4ms=C3=B6llicit=C3= +=BCdinf=C3=A4=C3=BCcib=C3=BCsm=C3=A4=C3=BCris=C3=A4met. SUMMARY: END:VEVENT END:VCALENDAR BEGIN:VCALENDAR VERSION:2.0 -PRODID:-//The Horde Project//Horde_iCalendar Library//EN +PRODID:-//The Horde Project//Horde iCalendar Library//EN METHOD:PUBLISH BEGIN:VEVENT UID:XXX diff --git a/framework/iCalendar/tests/quoted-params.phpt b/framework/Icalendar/test/Horde/Icalendar/quoted-params.phpt similarity index 85% rename from framework/iCalendar/tests/quoted-params.phpt rename to framework/Icalendar/test/Horde/Icalendar/quoted-params.phpt index f9d011daf..b9c587840 100644 --- a/framework/iCalendar/tests/quoted-params.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/quoted-params.phpt @@ -3,11 +3,11 @@ Ensure parameters are correctly quoted. --FILE-- setAttribute('UID', '20041120-8550-innerjoin-org'); $event1->setAttribute('DTSTART', array('year' => 2005, 'month' => 5, 'mday' => 3), array('VALUE' => 'DATE')); @@ -28,7 +28,7 @@ echo $attr[0]['CN']; --EXPECT-- BEGIN:VCALENDAR VERSION:2.0 -PRODID:-//The Horde Project//Horde_iCalendar Library//EN +PRODID:-//The Horde Project//Horde iCalendar Library//EN METHOD:PUBLISH BEGIN:VEVENT UID:20041120-8550-innerjoin-org diff --git a/framework/iCalendar/tests/read-escapes.phpt b/framework/Icalendar/test/Horde/Icalendar/read-escapes.phpt similarity index 94% rename from framework/iCalendar/tests/read-escapes.phpt rename to framework/Icalendar/test/Horde/Icalendar/read-escapes.phpt index e829c5cd6..8a17ed887 100644 --- a/framework/iCalendar/tests/read-escapes.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/read-escapes.phpt @@ -3,8 +3,8 @@ Read data with escaped values test. --FILE-- parseVCalendar($data); $card = $ical->getComponent(0); var_dump($card->getAttributeValues('ORG')); diff --git a/framework/iCalendar/tests/read-write-escapes.phpt b/framework/Icalendar/test/Horde/Icalendar/read-write-escapes.phpt similarity index 87% rename from framework/iCalendar/tests/read-write-escapes.phpt rename to framework/Icalendar/test/Horde/Icalendar/read-write-escapes.phpt index 7ffb244c0..72f99ea47 100644 --- a/framework/iCalendar/tests/read-write-escapes.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/read-write-escapes.phpt @@ -3,12 +3,12 @@ Read/write values with proper escaping test --FILE-- setAttribute('UID', '20041120-8550-innerjoin-org'); $event1->setAttribute('DTSTART', array('year' => 2005, 'month' => 5, 'mday' => 3), array('VALUE' => 'DATE')); diff --git a/framework/iCalendar/tests/timezones.phpt b/framework/Icalendar/test/Horde/Icalendar/timezones.phpt similarity index 99% rename from framework/iCalendar/tests/timezones.phpt rename to framework/Icalendar/test/Horde/Icalendar/timezones.phpt index 5db270102..dc6fca8e1 100644 --- a/framework/iCalendar/tests/timezones.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/timezones.phpt @@ -3,14 +3,13 @@ Timezone handling --FILE-- parsevCalendar(file_get_contents($file)); foreach ($ical->getComponents() as $component) { if ($component->getType() != 'vEvent') { diff --git a/framework/iCalendar/tests/vcal20.phpt b/framework/Icalendar/test/Horde/Icalendar/vcal20.phpt similarity index 98% rename from framework/iCalendar/tests/vcal20.phpt rename to framework/Icalendar/test/Horde/Icalendar/vcal20.phpt index 2930143c3..7543dd3ae 100644 --- a/framework/iCalendar/tests/vcal20.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/vcal20.phpt @@ -34,8 +34,8 @@ END:VEVENT END:VCALENDAR VCARD; -require_once 'Horde/iCalendar.php'; -$ical = new Horde_iCalendar(); +require_once dirname(__FILE__) . '/common.php'; +$ical = new Horde_Icalendar(); $ical->parsevCalendar($data); var_export($ical->getAllAttributes()); echo "\n"; diff --git a/framework/iCalendar/tests/vfreebusy.phpt b/framework/Icalendar/test/Horde/Icalendar/vfreebusy.phpt similarity index 97% rename from framework/iCalendar/tests/vfreebusy.phpt rename to framework/Icalendar/test/Horde/Icalendar/vfreebusy.phpt index a2ac7731c..eb01d3ce2 100644 --- a/framework/iCalendar/tests/vfreebusy.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/vfreebusy.phpt @@ -3,7 +3,7 @@ Test parsing of vFreeBusy information. --FILE-- parseVCalendar($data); @@ -76,7 +76,7 @@ var_dump($vfb->getBusyPeriods()); var_dump($vfb->getExtraParams()); // Create new freebusy object for merging -$mfb = new Horde_iCalendar_vfreebusy(); +$mfb = new Horde_Icalendar_Vfreebusy(); // 1. 3:55 / 10 minutes; summary "test4" $mfb->addBusyPeriod('BUSY',1164254100,null,600, array('X-SUMMARY' => 'dGVzdDQ=')); // 2. 4:00 / 1 hours 5 Minutes; summary "test3" @@ -139,7 +139,7 @@ print "Start:" . $vfb->_exportDateTime(1164254700) . " End:" . $vfb->_exportDate print "Start:" . $vfb->_exportDateTime(1164258300) . " End:" . $vfb->_exportDateTime($busy[1164258300]) . " Summary:" . base64_decode($extra[1164258300]['X-SUMMARY']) . "\n"; // 4. 6:00 / 5 Minutes / test5 print "Start:" . $vfb->_exportDateTime(1164261600) . " End:" . $vfb->_exportDateTime($busy[1164261600]) . " Summary:" . base64_decode($extra[1164261600]['X-SUMMARY']) . "\n"; -// 5. 7:55 / 2 hours 10 Minutes +// 5. 7:55 / 2 hours 10 Minutes print "Start:" . $vfb->_exportDateTime(1164268500) . " End:" . $vfb->_exportDateTime($busy[1164268500]) . " Summary:\n"; // 6. 11:00 / 4 hours / test2 print "Start:" . $vfb->_exportDateTime(1164279600) . " End:" . $vfb->_exportDateTime($busy[1164279600]) . " Summary:" . base64_decode($extra[1164279600]['X-SUMMARY']) . "\n"; diff --git a/framework/iCalendar/tests/write-escapes.phpt b/framework/Icalendar/test/Horde/Icalendar/write-escapes.phpt similarity index 87% rename from framework/iCalendar/tests/write-escapes.phpt rename to framework/Icalendar/test/Horde/Icalendar/write-escapes.phpt index b56accfff..8a6b0848c 100644 --- a/framework/iCalendar/tests/write-escapes.phpt +++ b/framework/Icalendar/test/Horde/Icalendar/write-escapes.phpt @@ -3,11 +3,11 @@ Write values with proper escaping test --FILE-- setAttribute('UID', '20041120-8550-innerjoin-org'); $event1->setAttribute('DTSTART', array('year' => 2005, 'month' => 5, 'mday' => 3), array('VALUE' => 'DATE')); @@ -30,7 +30,7 @@ echo $ical->exportVCalendar(); --EXPECT-- BEGIN:VCALENDAR VERSION:2.0 -PRODID:-//The Horde Project//Horde_iCalendar Library//EN +PRODID:-//The Horde Project//Horde iCalendar Library//EN METHOD:PUBLISH BEGIN:VEVENT UID:20041120-8550-innerjoin-org diff --git a/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Outlook.php b/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Outlook.php index 94ce53d62..1de94669d 100644 --- a/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Outlook.php +++ b/framework/Kolab_Filter/lib/Horde/Kolab/Filter/Outlook.php @@ -4,7 +4,7 @@ */ /* Load the iCal handling */ -require_once 'Horde/iCalendar.php'; +require_once 'Horde/Icalendar.php'; /* Load MIME handlers */ require_once 'Horde/MIME.php'; @@ -96,7 +96,7 @@ class Kolab_Filter_Outlook $email_domain = 'localhost'; } - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); $iCal->parsevCalendar($icaltxt); $vevent =& $iCal->findComponent('VEVENT'); if ($vevent) { diff --git a/framework/Kolab_Filter/package.xml b/framework/Kolab_Filter/package.xml index 7146a159a..8b1287c9c 100644 --- a/framework/Kolab_Filter/package.xml +++ b/framework/Kolab_Filter/package.xml @@ -44,7 +44,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> * Extended iTip reply delivery to support different transport mechanisms. * Splitted Free/Busy functionality in a separate driver class. * kolab/issue4257 ("Always accept" policy doesn't set atendee status to - "accepted") + "accepted") * kolab/issue3962 (Names of config variables for "untrusted" text missleading) * kolab/issue3967 (UNTRUSTED vs. UNAUTHENTICATED, distinction considered harmful) @@ -196,7 +196,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> 0.0.2 - Horde_iCalendar + Icalendar pear.horde.org 0.0.3 diff --git a/framework/Kolab_Filter/test/Horde/Kolab/Filter/ResourceTest.php b/framework/Kolab_Filter/test/Horde/Kolab/Filter/ResourceTest.php index 5fa0fbd27..69d1274ea 100644 --- a/framework/Kolab_Filter/test/Horde/Kolab/Filter/ResourceTest.php +++ b/framework/Kolab_Filter/test/Horde/Kolab/Filter/ResourceTest.php @@ -13,8 +13,8 @@ require_once 'Horde/Kolab/Test/Filter.php'; require_once 'Horde.php'; require_once 'Horde/Kolab/Resource.php'; require_once 'Horde/Kolab/Filter/Incoming.php'; -require_once 'Horde/iCalendar.php'; -require_once 'Horde/iCalendar/vfreebusy.php'; +require_once 'Horde/Icalendar.php'; +require_once 'Horde/Icalendar/Vfreebusy.php'; /** * Test resource handling @@ -103,9 +103,9 @@ class Horde_Kolab_Filter_ResourceTest extends Horde_Kolab_Test_Filter { $this->markTestIncomplete('Fails for unknown reason.'); - $GLOBALS['KOLAB_FILTER_TESTING'] = &new Horde_iCalendar_vfreebusy(); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_iCalendar::_parseDateTime('20080926T000000Z')); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_iCalendar::_parseDateTime('20081126T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING'] = new Horde_Icalendar_Vfreebusy(); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_Icalendar::_parseDateTime('20080926T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_Icalendar::_parseDateTime('20081126T000000Z')); $params = array('unmodified_content' => true, 'incoming' => true); @@ -134,10 +134,10 @@ class Horde_Kolab_Filter_ResourceTest extends Horde_Kolab_Test_Filter { $this->markTestIncomplete('Fails for unknown reason.'); - require_once 'Horde/iCalendar/vfreebusy.php'; - $GLOBALS['KOLAB_FILTER_TESTING'] = &new Horde_iCalendar_vfreebusy(); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_iCalendar::_parseDateTime('20080926T000000Z')); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_iCalendar::_parseDateTime('20081126T000000Z')); + require_once 'Horde/Icalendar/Vfreebusy.php'; + $GLOBALS['KOLAB_FILTER_TESTING'] = new Horde_Icalendar_Vfreebusy(); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_Icalendar::_parseDateTime('20080926T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_Icalendar::_parseDateTime('20081126T000000Z')); $params = array('unmodified_content' => true, 'incoming' => true); @@ -168,10 +168,10 @@ class Horde_Kolab_Filter_ResourceTest extends Horde_Kolab_Test_Filter */ public function testWholeDayInvitation() { - require_once 'Horde/iCalendar/vfreebusy.php'; - $GLOBALS['KOLAB_FILTER_TESTING'] = &new Horde_iCalendar_vfreebusy(); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_iCalendar::_parseDateTime('20090401T000000Z')); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_iCalendar::_parseDateTime('20090601T000000Z')); + require_once 'Horde/Icalendar/Vfreebusy.php'; + $GLOBALS['KOLAB_FILTER_TESTING'] = new Horde_Icalendar_Vfreebusy(); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_Icalendar::_parseDateTime('20090401T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_Icalendar::_parseDateTime('20090601T000000Z')); $params = array('unmodified_content' => true, 'incoming' => true); @@ -202,10 +202,10 @@ class Horde_Kolab_Filter_ResourceTest extends Horde_Kolab_Test_Filter */ public function testInvitationWithPlusAddressing() { - require_once 'Horde/iCalendar/vfreebusy.php'; - $GLOBALS['KOLAB_FILTER_TESTING'] = &new Horde_iCalendar_vfreebusy(); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_iCalendar::_parseDateTime('20090401T000000Z')); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_iCalendar::_parseDateTime('20090601T000000Z')); + require_once 'Horde/Icalendar/Vfreebusy.php'; + $GLOBALS['KOLAB_FILTER_TESTING'] = new Horde_Icalendar_Vfreebusy(); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_Icalendar::_parseDateTime('20090401T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_Icalendar::_parseDateTime('20090601T000000Z')); $params = array('unmodified_content' => true, 'incoming' => true); @@ -236,9 +236,9 @@ class Horde_Kolab_Filter_ResourceTest extends Horde_Kolab_Test_Filter */ public function testRecurrenceNodefault() { - $GLOBALS['KOLAB_FILTER_TESTING'] = &new Horde_iCalendar_vfreebusy(); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_iCalendar::_parseDateTime('20080926T000000Z')); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_iCalendar::_parseDateTime('20081126T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING'] = new Horde_Icalendar_Vfreebusy(); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_Icalendar::_parseDateTime('20080926T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_Icalendar::_parseDateTime('20081126T000000Z')); $params = array('unmodified_content' => true, 'incoming' => true); @@ -258,9 +258,9 @@ class Horde_Kolab_Filter_ResourceTest extends Horde_Kolab_Test_Filter { $this->markTestIncomplete('Fails for unknown reason.'); - $GLOBALS['KOLAB_FILTER_TESTING'] = &new Horde_iCalendar_vfreebusy(); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_iCalendar::_parseDateTime('20090901T000000Z')); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_iCalendar::_parseDateTime('20091101T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING'] = new Horde_Icalendar_Vfreebusy(); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_Icalendar::_parseDateTime('20090901T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_Icalendar::_parseDateTime('20091101T000000Z')); $params = array('unmodified_content' => true, 'incoming' => true); @@ -287,9 +287,9 @@ class Horde_Kolab_Filter_ResourceTest extends Horde_Kolab_Test_Filter */ public function testAllDay() { - $GLOBALS['KOLAB_FILTER_TESTING'] = &new Horde_iCalendar_vfreebusy(); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_iCalendar::_parseDateTime('20090901T000000Z')); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_iCalendar::_parseDateTime('20091101T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING'] = new Horde_Icalendar_Vfreebusy(); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_Icalendar::_parseDateTime('20090901T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_Icalendar::_parseDateTime('20091101T000000Z')); $params = array('unmodified_content' => true, 'incoming' => true); @@ -320,10 +320,10 @@ class Horde_Kolab_Filter_ResourceTest extends Horde_Kolab_Test_Filter { $this->markTestIncomplete('Sends mail'); - require_once 'Horde/iCalendar/vfreebusy.php'; - $GLOBALS['KOLAB_FILTER_TESTING'] = &new Horde_iCalendar_vfreebusy(); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_iCalendar::_parseDateTime('20080926T000000Z')); - $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_iCalendar::_parseDateTime('20081126T000000Z')); + require_once 'Horde/Icalendar/Vfreebusy.php'; + $GLOBALS['KOLAB_FILTER_TESTING'] = new Horde_Icalendar_Vfreebusy(); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_Icalendar::_parseDateTime('20080926T000000Z')); + $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_Icalendar::_parseDateTime('20081126T000000Z')); $params = array('unmodified_content' => true, 'incoming' => true); diff --git a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Cache.php b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Cache.php index 8d135daa8..bf42cdaf0 100644 --- a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Cache.php +++ b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Cache.php @@ -6,8 +6,8 @@ */ /** We require the iCalendar library to build the free/busy list */ -require_once 'Horde/iCalendar.php'; -require_once 'Horde/iCalendar/vfreebusy.php'; +require_once 'Horde/Icalendar.php'; +require_once 'Horde/Icalendar/Vfreebusy.php'; /** * The Horde_Kolab_FreeBusy_Cache:: class provides functionality to store @@ -191,7 +191,7 @@ class Horde_Kolab_FreeBusy_Cache { * @param boolean $extended Should the data hold the extended * free/busy information? * - * @return Horde_iCalendar|PEAR_Error The free/busy data of a + * @return Horde_Icalendar|PEAR_Error The free/busy data of a * single calendar. */ function &loadPartial(&$access, $extended) @@ -297,7 +297,7 @@ class Horde_Kolab_FreeBusy_Cache { Horde::logMessage($message, 'INFO'); } - $rvCal = new Horde_iCalendar(); + $rvCal = new Horde_Icalendar(); $result = $rvCal->parsevCalendar($remote); if (is_a($result, 'PEAR_Error')) { diff --git a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Driver/Freebusy/Base.php b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Driver/Freebusy/Base.php index 295e7e885..8dff13fc4 100644 --- a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Driver/Freebusy/Base.php +++ b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Driver/Freebusy/Base.php @@ -87,12 +87,12 @@ class Horde_Kolab_FreeBusy_Driver_Freebusy_Base extends Horde_Kolab_FreeBusy_Dri } // Create the new iCalendar. - $vCal = new Horde_iCalendar(); + $vCal = new Horde_Icalendar(); $vCal->setAttribute('PRODID', '-//kolab.org//NONSGML Kolab Server 2//EN'); $vCal->setAttribute('METHOD', 'PUBLISH'); // Create new vFreebusy. - $vFb = &Horde_iCalendar::newComponent('vfreebusy', $vCal); + $vFb = Horde_Icalendar::newComponent('vfreebusy', $vCal); $params = array(); $cn = $access->owner_object->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_CN); diff --git a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php index c10d607f6..aaac73bbd 100644 --- a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php +++ b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php @@ -304,14 +304,14 @@ class Horde_Kolab_FreeBusy_Imap { * @param string $user Set organizer to this user. * @param string $cn Set the common name of this user. * - * @return Horde_iCalendar The iCal object or a PEAR error. + * @return Horde_Icalendar The iCal object or a PEAR error. */ function &generate($startstamp = null, $endstamp = null, $fbpast = 0, $fbfuture = 60, $user = null, $cn = null) { /* Get the iCalendar library at this point */ - require_once 'Horde/iCalendar.php'; + require_once 'Horde/Icalendar.php'; /* Default the start date to today. */ if (is_null($startstamp)) { @@ -347,12 +347,12 @@ class Horde_Kolab_FreeBusy_Imap { } /* Create the new iCalendar. */ - $vCal = new Horde_iCalendar(); + $vCal = new Horde_Icalendar(); $vCal->setAttribute('PRODID', '-//kolab.org//NONSGML Kolab Server 2//EN'); $vCal->setAttribute('METHOD', 'PUBLISH'); /* Create new vFreebusy. */ - $vFb = &Horde_iCalendar::newComponent('vfreebusy', $vCal); + $vFb = Horde_Icalendar::newComponent('vfreebusy', $vCal); $params = array(); if ($cn) { $params['cn'] = $cn; diff --git a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/View.php b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/View.php index 85cc25c2c..4930689ce 100644 --- a/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/View.php +++ b/framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/View.php @@ -62,7 +62,7 @@ class Horde_Kolab_FreeBusy_View_vfb extends Horde_Kolab_FreeBusy_View { /** * The free/busy data that should be displayed. * - * @var Horde_iCalendar + * @var Horde_Icalendar */ var $_vfb; @@ -76,7 +76,7 @@ class Horde_Kolab_FreeBusy_View_vfb extends Horde_Kolab_FreeBusy_View { /** * Constructor. * - * @param Horde_iCalendar $vfb The free/busy data to display. + * @param Horde_Icalendar $vfb The free/busy data to display. */ function Horde_Kolab_FreeBusy_View_vfb(&$data) { diff --git a/framework/Kolab_FreeBusy/package.xml b/framework/Kolab_FreeBusy/package.xml index f699b5c21..029b63492 100644 --- a/framework/Kolab_FreeBusy/package.xml +++ b/framework/Kolab_FreeBusy/package.xml @@ -139,7 +139,7 @@ pear.horde.org - Horde_iCalendar + Icalendar pear.horde.org diff --git a/framework/Kolab_Resource/lib/Horde/Kolab/Resource.php b/framework/Kolab_Resource/lib/Horde/Kolab/Resource.php index 3f2624067..623f3bba8 100644 --- a/framework/Kolab_Resource/lib/Horde/Kolab/Resource.php +++ b/framework/Kolab_Resource/lib/Horde/Kolab/Resource.php @@ -13,7 +13,7 @@ */ /** Load the iCal handling */ -require_once 'Horde/iCalendar.php'; +require_once 'Horde/Icalendar.php'; /** Load MIME handlers */ require_once 'Horde/MIME.php'; @@ -163,7 +163,7 @@ class Kolab_Resource if ($conttype == 'text/calendar') { $part = $mime->getPart($mimeid); - $iCalendar = new Horde_iCalendar(); + $iCalendar = new Horde_Icalendar(); $iCalendar->parsevCalendar($part->transferDecode()); return $iCalendar; @@ -613,7 +613,7 @@ class Kolab_Resource * @param string $cn Common name to be used in the iTip * response. * @param string $resource Resource we send the reply for. - * @param string $Horde_iCalendar_vevent The iTip information. + * @param string $Horde_Icalendar_Vevent The iTip information. * @param int $type Type of response. * @param string $organiser The event organiser. * @param string $uid The UID of the event. @@ -626,13 +626,13 @@ class Kolab_Resource $cn, $resource, get_class($itip), $type), 'DEBUG'); // Build the reply. - $vCal = new Horde_iCalendar(); + $vCal = new Horde_Icalendar(); $vCal->setAttribute('PRODID', '-//kolab.org//NONSGML Kolab Server 2//EN'); $vCal->setAttribute('METHOD', 'REPLY'); $summary = _('No summary available'); - $itip_reply =& Horde_iCalendar::newComponent('VEVENT', $vCal); + $itip_reply = Horde_Icalendar::newComponent('VEVENT', $vCal); $itip_reply->setAttribute('UID', $uid); if (!is_a($itip->getAttribute('SUMMARY'), 'PEAR_error')) { $itip_reply->setAttribute('SUMMARY', $itip->getAttribute('SUMMARY')); diff --git a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy.php b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy.php index 8ba2806b5..e13149993 100644 --- a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy.php +++ b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy.php @@ -3,7 +3,7 @@ * Provides methods to retrieve free/busy data for resources. * * PHP version 5 - * + * * @todo Merge this class with Kolab_FreeBusy and Kronolith_FreeBusy into a * single Horde_Freebusy handler. * @@ -151,16 +151,16 @@ class Horde_Kolab_Resource_Freebusy * @param string $resource Fetch the Free/Busy data for this resource * (usually a mail address). * - * @return Horde_iCalendar_vfreebusy The Free/Busy data. + * @return Horde_Icalendar_vfreebusy The Free/Busy data. */ public function get($resource) { /* Return an empty VFB object. */ - $vCal = new Horde_iCalendar(); - $vFb = Horde_iCalendar::newComponent('vfreebusy', $vCal); + $vCal = new Horde_Icalendar(); + $vFb = Horde_Icalendar::newComponent('vfreebusy', $vCal); $vFb->setAttribute('ORGANIZER', $resource); return $vFb; } -} \ No newline at end of file +} diff --git a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Kolab.php b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Kolab.php index 0560bc5b7..23bfcc08b 100644 --- a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Kolab.php +++ b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Kolab.php @@ -50,7 +50,7 @@ class Horde_Kolab_Resource_Freebusy_Kolab extends Horde_Kolab_Resource_Freebusy * * @param string $resource Fetch the Free/Busy data for this resource. * - * @return Horde_iCalendar_vfreebusy The Free/Busy data. + * @return Horde_Icalendar_Vfreebusy The Free/Busy data. */ public function get($resource) { @@ -100,7 +100,7 @@ class Horde_Kolab_Resource_Freebusy_Kolab extends Horde_Kolab_Resource_Freebusy $charset = 'UTF-8'; } - $iCal = new Horde_iCalendar; + $iCal = new Horde_Icalendar(); $iCal->parsevCalendar($vfb_text, 'VCALENDAR', $charset); $vfb = &$iCal->findComponent('VFREEBUSY'); diff --git a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Mock.php b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Mock.php index 9169b051b..75ba126ff 100644 --- a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Mock.php +++ b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Mock.php @@ -46,10 +46,10 @@ class Horde_Kolab_Resource_Freebusy_Mock extends Horde_Kolab_Resource_Freebusy * @param string $resource Fetch the Free/Busy data for this resource * (usually a mail address). * - * @return Horde_iCalendar_vfreebusy The Free/Busy data. + * @return Horde_Icalendar_Vfreebusy The Free/Busy data. */ public function get($resource) { return $this->_params['data']; } -} \ No newline at end of file +} diff --git a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Itip.php b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Itip.php index fea369788..9d0926a1a 100644 --- a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Itip.php +++ b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Itip.php @@ -32,16 +32,16 @@ class Horde_Kolab_Resource_Itip { /** - * Reference to the iCalendar iTip object. + * Reference to the Icalendar iTip object. * - * @var Horde_iCalendar_vevent + * @var Horde_Icalendar_Vevent */ private $_itip; /** * Constructor. * - * @param Horde_iCalendar_vevent $itip Reference to the iCalendar iTip object. + * @param Horde_Icalendar_Vevent $itip An iCalendar iTip object. */ public function __construct($itip) { @@ -254,4 +254,4 @@ class Horde_Kolab_Resource_Itip } } -} \ No newline at end of file +} diff --git a/framework/Kolab_Resource/package.xml b/framework/Kolab_Resource/package.xml index 2b4694af1..a2e6e0c88 100644 --- a/framework/Kolab_Resource/package.xml +++ b/framework/Kolab_Resource/package.xml @@ -92,7 +92,7 @@ 0.0.2 - Horde_iCalendar + Icalendar pear.horde.org 0.0.3 diff --git a/framework/Mime_Viewer/lib/Horde/Mime/Viewer/Vcard.php b/framework/Mime_Viewer/lib/Horde/Mime/Viewer/Vcard.php index 4394cb07c..c7c90e4a8 100644 --- a/framework/Mime_Viewer/lib/Horde/Mime/Viewer/Vcard.php +++ b/framework/Mime_Viewer/lib/Horde/Mime/Viewer/Vcard.php @@ -69,7 +69,7 @@ class Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base $import_msg = null; $title = _("vCard"); - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) { $notification->push(_("There was an error reading the contact data."), 'horde.error'); } @@ -80,7 +80,7 @@ class Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base $source = Horde_Util::getFormData('source'); $count = 0; foreach ($iCal->getComponents() as $c) { - if ($c instanceof Horde_iCalendar_vcard) { + if ($c->getType() == 'vcard') { try { $contacts = $registry->call('contacts/import', array($c, null, $source)); ++$count; @@ -207,23 +207,23 @@ class Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base } else { $item['params']['TYPE'] = array_keys($item['params']); } + $address = $item['values']; $a = array(); - if (isset($address[VCARD_ADR_STREET])) { - $a[] = $address[VCARD_ADR_STREET]; - } - if (isset($address[VCARD_ADR_LOCALITY])) { - $a[] = $address[VCARD_ADR_LOCALITY]; - } - if (isset($address[VCARD_ADR_REGION])) { - $a[] = $address[VCARD_ADR_REGION]; - } - if (isset($address[VCARD_ADR_POSTCODE])) { - $a[] = $address[VCARD_ADR_POSTCODE]; - } - if (isset($address[VCARD_ADR_COUNTRY])) { - $a[] = $address[VCARD_ADR_COUNTRY]; + $a_list = array( + Horde_Icalendar_Vcard::ADR_STREET, + Horde_Icalendar_Vcard::ADR_LOCALITY, + Horde_Icalendar_Vcard::ADR_REGION, + Horde_Icalendar_Vcard::ADR_POSTCODE, + Horde_Icalendar_Vcard::ADR_COUNTRY + ); + + foreach ($a_list as $val) { + if (isset($address[$val])) { + $a[] = $address[$val]; + } } + $types = array(); foreach ($item['params']['TYPE'] as $type) { switch(Horde_String::upper($type)) { diff --git a/framework/Mime_Viewer/package.xml b/framework/Mime_Viewer/package.xml index 757aef40d..1a85f0ca8 100644 --- a/framework/Mime_Viewer/package.xml +++ b/framework/Mime_Viewer/package.xml @@ -132,7 +132,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> pear.horde.org - iCalendar + Icalendar pear.horde.org diff --git a/framework/SyncML/SyncML/Device.php b/framework/SyncML/SyncML/Device.php index 93a121cff..85b421099 100644 --- a/framework/SyncML/SyncML/Device.php +++ b/framework/SyncML/SyncML/Device.php @@ -270,8 +270,8 @@ class SyncML_Device { function convertUTC2LocalTime($utc) { $dateParts = explode('T', $utc[0]); - $date = Horde_iCalendar::_parseDate($dateParts[0]); - $time = Horde_iCalendar::_parseTime($dateParts[1]); + $date = Horde_Icalendar::_parseDate($dateParts[0]); + $time = Horde_Icalendar::_parseTime($dateParts[1]); // We don't know the timezone so assume local timezone. $ts = @gmmktime($time['hour'], $time['minute'], $time['second'], diff --git a/framework/SyncML/SyncML/Device/Sync4j.php b/framework/SyncML/SyncML/Device/Sync4j.php index 8f436b08f..cef52c60a 100644 --- a/framework/SyncML/SyncML/Device/Sync4j.php +++ b/framework/SyncML/SyncML/Device/Sync4j.php @@ -7,7 +7,7 @@ require_once 'Horde/Date.php'; /** Horde_iCalendar */ -require_once 'Horde/iCalendar.php'; +require_once 'Horde/Icalendar.php'; /** * Sync4j (www.sync4j.org) @@ -224,12 +224,12 @@ class SyncML_Device_sync4j extends SyncML_Device { { $a = SyncML_Device_sync4j::sif2array($sif); - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); $iCal->setAttribute('VERSION', '1.1'); $iCal->setAttribute('PRODID', '-//The Horde Project//SyncML//EN'); $iCal->setAttribute('METHOD', 'PUBLISH'); - $vnote = &Horde_iCalendar::newComponent('vnote', $iCal); + $vnote = Horde_Icalendar::newComponent('vnote', $iCal); $vnote->setAttribute('BODY', isset($a['Body']) ? $a['Body'] : ''); if (isset($a['Subject'])) { $vnote->setAttribute('SUMMARY', $a['Subject']); @@ -245,12 +245,12 @@ class SyncML_Device_sync4j extends SyncML_Device { { $a = SyncML_Device_sync4j::sif2array($sif); - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); $iCal->setAttribute('VERSION', '3.0'); $iCal->setAttribute('PRODID', '-//The Horde Project//SyncML//EN'); $iCal->setAttribute('METHOD', 'PUBLISH'); - $vcard = &Horde_iCalendar::newComponent('vcard', $iCal); + $vcard = Horde_Icalendar::newComponent('vcard', $iCal); $map = array( 'FileAs' => array('FN'), @@ -295,44 +295,44 @@ class SyncML_Device_sync4j extends SyncML_Device { $map = array( array( 'N', - array(VCARD_N_FAMILY => 'LastName', - VCARD_N_GIVEN => 'FirstName', - VCARD_N_ADDL => 'MiddleName', - VCARD_N_PREFIX => 'Title', - VCARD_N_SUFFIX => 'Suffix'), + array(Horde_Icalendar_Vcard::N_FAMILY => 'LastName', + Horde_Icalendar_Vcard::N_GIVEN => 'FirstName', + Horde_Icalendar_Vcard::N_ADDL => 'MiddleName', + Horde_Icalendar_Vcard::N_PREFIX => 'Title', + Horde_Icalendar_Vcard::N_SUFFIX => 'Suffix'), array(), false), array( 'ADR', - array(VCARD_ADR_POB => 'HomeAddressPostOfficeBox', - VCARD_ADR_EXTEND => '', - VCARD_ADR_STREET => 'HomeAddressStreet', - VCARD_ADR_LOCALITY => 'HomeAddressCity', - VCARD_ADR_REGION => 'HomeAddressState', - VCARD_ADR_POSTCODE => 'HomeAddressPostalCode', - VCARD_ADR_COUNTRY => 'HomeAddressCountry'), + array(Horde_Icalendar_Vcard::ADR_POB => 'HomeAddressPostOfficeBox', + Horde_Icalendar_Vcard::ADR_EXTEND => '', + Horde_Icalendar_Vcard::ADR_STREET => 'HomeAddressStreet', + Horde_Icalendar_Vcard::ADR_LOCALITY => 'HomeAddressCity', + Horde_Icalendar_Vcard::ADR_REGION => 'HomeAddressState', + Horde_Icalendar_Vcard::ADR_POSTCODE => 'HomeAddressPostalCode', + Horde_Icalendar_Vcard::ADR_COUNTRY => 'HomeAddressCountry'), array('TYPE' => 'HOME'), true), array( 'ADR', - array(VCARD_ADR_POB => 'BusinessAddressPostOfficeBox', - VCARD_ADR_EXTEND => '', - VCARD_ADR_STREET => 'BusinessAddressStreet', - VCARD_ADR_LOCALITY => 'BusinessAddressCity', - VCARD_ADR_REGION => 'BusinessAddressState', - VCARD_ADR_POSTCODE => 'BusinessAddressPostalCode', - VCARD_ADR_COUNTRY => 'BusinessAddressCountry'), + array(Horde_Icalendar_Vcard::ADR_POB => 'BusinessAddressPostOfficeBox', + Horde_Icalendar_Vcard::ADR_EXTEND => '', + Horde_Icalendar_Vcard::ADR_STREET => 'BusinessAddressStreet', + Horde_Icalendar_Vcard::ADR_LOCALITY => 'BusinessAddressCity', + Horde_Icalendar_Vcard::ADR_REGION => 'BusinessAddressState', + Horde_Icalendar_Vcard::ADR_POSTCODE => 'BusinessAddressPostalCode', + Horde_Icalendar_Vcard::ADR_COUNTRY => 'BusinessAddressCountry'), array('TYPE' => 'WORK'), true), array( 'ADR', - array(VCARD_ADR_POB => 'OtherAddressPostOfficeBox', - VCARD_ADR_EXTEND => '', - VCARD_ADR_STREET => 'OtherAddressStreet', - VCARD_ADR_LOCALITY => 'OtherAddressCity', - VCARD_ADR_REGION => 'OtherAddressState', - VCARD_ADR_POSTCODE => 'OtherAddressPostalCode', - VCARD_ADR_COUNTRY => 'OtherAddressCountry'), + array(Horde_Icalendar_Vcard::ADR_POB => 'OtherAddressPostOfficeBox', + Horde_Icalendar_Vcard::ADR_EXTEND => '', + Horde_Icalendar_Vcard::ADR_STREET => 'OtherAddressStreet', + Horde_Icalendar_Vcard::ADR_LOCALITY => 'OtherAddressCity', + Horde_Icalendar_Vcard::ADR_REGION => 'OtherAddressState', + Horde_Icalendar_Vcard::ADR_POSTCODE => 'OtherAddressPostalCode', + Horde_Icalendar_Vcard::ADR_COUNTRY => 'OtherAddressCountry'), array(), true), ); @@ -369,11 +369,11 @@ class SyncML_Device_sync4j extends SyncML_Device { { $a = SyncML_Device_sync4j::sif2array($sif); - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); $iCal->setAttribute('PRODID', '-//The Horde Project//SyncML//EN'); $iCal->setAttribute('METHOD', 'PUBLISH'); - $vEvent = &Horde_iCalendar::newComponent('vevent', $iCal); + $vEvent = Horde_Icalendar::newComponent('vevent', $iCal); $vEvent->setAttribute('DTSTAMP', time()); $map = array('Subject' => 'SUMMARY', @@ -546,11 +546,11 @@ class SyncML_Device_sync4j extends SyncML_Device { { $a = SyncML_Device_sync4j::sif2array($sif); - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); $iCal->setAttribute('PRODID', '-//The Horde Project//SyncML//EN'); $iCal->setAttribute('METHOD', 'PUBLISH'); - $vtodo = &Horde_iCalendar::newComponent('vtodo', $iCal); + $vtodo = Horde_Icalendar::newComponent('vtodo', $iCal); $vtodo->setAttribute('SUMMARY', $a['Subject']); $vtodo->setAttribute('DESCRIPTION', $a['Body']); @@ -603,7 +603,7 @@ class SyncML_Device_sync4j extends SyncML_Device { function vnote2sif($vnote) { - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); if (!$iCal->parsevCalendar($vnote)) { // handle plain text: $a = array('Body' => $vnote); @@ -628,7 +628,7 @@ class SyncML_Device_sync4j extends SyncML_Device { function vcard2sif($vcard) { - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); if (!$iCal->parsevCalendar($vcard)) { // @TODO: NEVER use die() in a library. die("There was an error importing the data."); @@ -662,11 +662,11 @@ class SyncML_Device_sync4j extends SyncML_Device { case 'N': $name = $item['values']; - $hash['LastName'] = $name[VCARD_N_FAMILY]; - $hash['FirstName'] = $name[VCARD_N_GIVEN]; - $hash['MiddleName'] = $name[VCARD_N_ADDL]; - $hash['Title'] = $name[VCARD_N_PREFIX]; - $hash['Suffix'] = $name[VCARD_N_SUFFIX]; + $hash['LastName'] = $name[Horde_Icalendar_Vcard::N_FAMILY]; + $hash['FirstName'] = $name[Horde_Icalendar_Vcard::N_GIVEN]; + $hash['MiddleName'] = $name[Horde_Icalendar_Vcard::N_ADDL]; + $hash['Title'] = $name[Horde_Icalendar_Vcard::N_PREFIX]; + $hash['Suffix'] = $name[Horde_Icalendar_Vcard::N_SUFFIX]; break; case 'NICKNAME': @@ -706,28 +706,28 @@ class SyncML_Device_sync4j extends SyncML_Device { if ($prefix) { $hash[$prefix . 'Street'] = - isset($address[VCARD_ADR_STREET]) - ? $address[VCARD_ADR_STREET] + isset($address[Horde_Icalendar_Vcard::ADR_STREET]) + ? $address[Horde_Icalendar_Vcard::ADR_STREET] : null; $hash[$prefix . 'City'] = - isset($address[VCARD_ADR_LOCALITY]) - ? $address[VCARD_ADR_LOCALITY] + isset($address[Horde_Icalendar_Vcard::ADR_LOCALITY]) + ? $address[Horde_Icalendar_Vcard::ADR_LOCALITY] : null; $hash[$prefix . 'State'] = - isset($address[VCARD_ADR_REGION]) - ? $address[VCARD_ADR_REGION] + isset($address[Horde_Icalendar_Vcard::ADR_REGION]) + ? $address[Horde_Icalendar_Vcard::ADR_REGION] : null; $hash[$prefix . 'PostalCode'] = - isset($address[VCARD_ADR_POSTCODE]) - ? $address[VCARD_ADR_POSTCODE] + isset($address[Horde_Icalendar_Vcard::ADR_POSTCODE]) + ? $address[Horde_Icalendar_Vcard::ADR_POSTCODE] : null; $hash[$prefix . 'Country'] = - isset($address[VCARD_ADR_COUNTRY]) - ? $address[VCARD_ADR_COUNTRY] + isset($address[Horde_Icalendar_Vcard::ADR_COUNTRY]) + ? $address[Horde_Icalendar_Vcard::ADR_COUNTRY] : null; $hash[$prefix . 'PostOfficeBox'] = - isset($address[VCARD_ADR_POB]) - ? $address[VCARD_ADR_POB] + isset($address[Horde_Icalendar_Vcard::ADR_POB]) + ? $address[Horde_Icalendar_Vcard::ADR_POB] : null; } } @@ -775,28 +775,28 @@ class SyncML_Device_sync4j extends SyncML_Device { $email_set = false; if (isset($item['params']['HOME']) && (!isset($hash['Email2Address']) || isset($item['params']['PREF']))) { - $hash['Email2Address'] = Horde_iCalendar_vcard::getBareEmail($item['value']); + $hash['Email2Address'] = Horde_Icalendar_Vcard::getBareEmail($item['value']); $email_set = true; - } elseif (isset($item['params']['WORK']) && (!isset($hash['Email3Address']) || + } elseif (isset($item['params']['WORK']) && (!isset($hash['Email3Address']) || isset($item['params']['PREF']))) { - $hash['Email3Address'] = Horde_iCalendar_vcard::getBareEmail($item['value']); + $hash['Email3Address'] = Horde_Icalendar_Vcard::getBareEmail($item['value']); $email_set = true; } elseif (isset($item['params']['TYPE'])) { if (!is_array($item['params']['TYPE'])) { $item['params']['TYPE'] = array($item['params']['TYPE']); } - if (in_array('HOME', $item['params']['TYPE']) && + if (in_array('HOME', $item['params']['TYPE']) && (!isset($hash['Email2Address']) || in_array('PREF', $item['params']['TYPE']))) { - $hash['Email2Address'] = Horde_iCalendar_vcard::getBareEmail($item['value']); + $hash['Email2Address'] = Horde_Icalendar_Vcard::getBareEmail($item['value']); $email_set = true; } elseif (in_array('WORK', $item['params']['TYPE']) && (!isset($hash['Email3Address']) || in_array('PREF', $item['params']['TYPE']))) { - $hash['Email3Address'] = Horde_iCalendar_vcard::getBareEmail($item['value']); + $hash['Email3Address'] = Horde_Icalendar_Vcard::getBareEmail($item['value']); $email_set = true; } } if (!$email_set && (!isset($hash['Email1Address']) || isset($item['params']['PREF']))) { - $hash['Email1Address'] = Horde_iCalendar_vcard::getBareEmail($item['value']); + $hash['Email1Address'] = Horde_Icalendar_Vcard::getBareEmail($item['value']); } break; @@ -869,7 +869,7 @@ class SyncML_Device_sync4j extends SyncML_Device { } // @TODO: else: handle case with DTEND= T240000 } - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); if (!$iCal->parsevCalendar($vcard)) { // @TODO: NEVER use die() in a library. die("There was an error importing the data."); @@ -910,7 +910,7 @@ class SyncML_Device_sync4j extends SyncML_Device { $start['value']['year']); } else { $hash['AllDayEvent'] = 0; - $hash['Start'] = Horde_iCalendar::_exportDateTime($start); + $hash['Start'] = Horde_Icalendar::_exportDateTime($start); $start = $start; } } @@ -938,7 +938,7 @@ class SyncML_Device_sync4j extends SyncML_Device { $end = $date->datestamp(); } else { $hash['AllDayEvent'] = 0; - $hash['End'] = Horde_iCalendar::_exportDateTime($item['value']); + $hash['End'] = Horde_Icalendar::_exportDateTime($item['value']); $end = $item['value']; } break; @@ -1091,7 +1091,7 @@ class SyncML_Device_sync4j extends SyncML_Device { $d->correct(); $hash['Exceptions'][] = array('ExcludeDate' => $d->format('Y-m-d')); } else { - $hash['Exceptions'][] = array('ExcludeDate' => Horde_iCalendar::_exportDate($date)); + $hash['Exceptions'][] = array('ExcludeDate' => Horde_Icalendar::_exportDate($date)); } } break; @@ -1104,7 +1104,7 @@ class SyncML_Device_sync4j extends SyncML_Device { } else { // Parse VALARM components. foreach ($content->getComponents() as $component) { - if (!is_a($component, 'Horde_iCalendar_valarm') || + if ($component->getType != 'vAlarm') || is_a($trigger = $component->getAttribute('TRIGGER'), 'PEAR_Error') || is_array($trigger) || empty($trigger)) { @@ -1132,7 +1132,7 @@ class SyncML_Device_sync4j extends SyncML_Device { function vtodo2sif($vcard) { - $iCal = new Horde_iCalendar(); + $iCal = new Horde_Icalendar(); if (!$iCal->parsevCalendar($vcard)) { return PEAR::raiseError('There was an error importing the data.'); } @@ -1176,11 +1176,11 @@ class SyncML_Device_sync4j extends SyncML_Device { break; case 'DTSTART': - $hash['StartDate'] = Horde_iCalendar::_exportDateTime($item['value']); + $hash['StartDate'] = Horde_Icalendar::_exportDateTime($item['value']); break; case 'DUE': - $hash['DueDate'] = Horde_iCalendar::_exportDateTime($item['value']); + $hash['DueDate'] = Horde_Icalendar::_exportDateTime($item['value']); $due = $item['value']; break; @@ -1218,14 +1218,14 @@ class SyncML_Device_sync4j extends SyncML_Device { if ($due && !isset($hash['ReminderSet'])) { // Parse VALARM components. foreach ($content->getComponents() as $component) { - if (!is_a($component, 'Horde_iCalendar_valarm') || + if ($component->getType() != 'vAlarm' || is_a($trigger = $component->getAttribute('TRIGGER'), 'PEAR_Error') || is_array($trigger) || empty($trigger)) { continue; } $hash['ReminderSet'] = 1; - $hash['ReminderTime'] = Horde_iCalendar::_exportDateTime($due - $trigger); + $hash['ReminderTime'] = Horde_Icalendar::_exportDateTime($due - $trigger); } } diff --git a/framework/SyncML/SyncML/Device/Synthesis.php b/framework/SyncML/SyncML/Device/Synthesis.php index 53ef72271..da1ab8803 100644 --- a/framework/SyncML/SyncML/Device/Synthesis.php +++ b/framework/SyncML/SyncML/Device/Synthesis.php @@ -98,7 +98,7 @@ class SyncML_Device_Synthesis extends SyncML_Device { */ function UTC2LocalDate($s) { - $t = Horde_iCalendar::_parseDateTime($s); + $t = Horde_Icalendar::_parseDateTime($s); return date('Ymd', $t) . 'T000000'; } } diff --git a/framework/SyncML/tests/sif.phpt b/framework/SyncML/tests/sif.phpt index 36dc0e7cb..8c36b66af 100644 --- a/framework/SyncML/tests/sif.phpt +++ b/framework/SyncML/tests/sif.phpt @@ -17,7 +17,7 @@ $data = << - * @package Horde_iCalendar - */ -class Horde_iCalendar_valarm extends Horde_iCalendar -{ - /** - * The component type of this class. - * - * @var string - */ - var $type = 'vAlarm'; - - function exportvCalendar() - { - return parent::_exportvData('VALARM'); - } - -} diff --git a/framework/iCalendar/iCalendar/vcard.php b/framework/iCalendar/iCalendar/vcard.php deleted file mode 100644 index bc4d3338f..000000000 --- a/framework/iCalendar/iCalendar/vcard.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @package Horde_iCalendar - */ -class Horde_iCalendar_vcard extends Horde_iCalendar { - - /** - * The component type of this class. - * - * @var string - */ - var $type = 'vcard'; - - function Horde_iCalendar_vcard($version = '2.1') - { - return parent::Horde_iCalendar($version); - } - - /** - * Sets the version of this component. - * - * @see $version - * @see $oldFormat - * - * @param string A float-like version string. - */ - function setVersion($version) - { - $this->oldFormat = $version < 3; - $this->version = $version; - } - - /** - * Unlike vevent and vtodo, a vcard is normally not enclosed in an - * iCalendar container. (BEGIN..END) - */ - function exportvCalendar() - { - $requiredAttributes['VERSION'] = $this->version; - $requiredAttributes['N'] = ';;;;;;'; - if ($this->version == '3.0') { - $requiredAttributes['FN'] = ''; - } - - foreach ($requiredAttributes as $name => $default_value) { - if (is_a($this->getAttribute($name), 'PEAR_Error')) { - $this->setAttribute($name, $default_value); - } - } - - return $this->_exportvData('VCARD'); - } - - /** - * Returns the contents of the "N" tag as a printable Name: - * i.e. converts: - * - * N:Duck;Dagobert;T;Professor;Sen. - * to - * "Professor Dagobert T Duck Sen" - * - * @return string Full name of vcard "N" tag or null if no N tag. - */ - function printableName() - { - $name_parts = $this->getAttributeValues('N'); - if (is_a($name_parts, 'PEAR_Error')) { - return null; - } - - $name_arr = array(); - - if (!empty($name_parts[VCARD_N_PREFIX])) { - $name_arr[] = $name_parts[VCARD_N_PREFIX]; - } - if (!empty($name_parts[VCARD_N_GIVEN])) { - $name_arr[] = $name_parts[VCARD_N_GIVEN]; - } - if (!empty($name_parts[VCARD_N_ADDL])) { - $name_arr[] = $name_parts[VCARD_N_ADDL]; - } - if (!empty($name_parts[VCARD_N_FAMILY])) { - $name_arr[] = $name_parts[VCARD_N_FAMILY]; - } - if (!empty($name_parts[VCARD_N_SUFFIX])) { - $name_arr[] = $name_parts[VCARD_N_SUFFIX]; - } - - return implode(' ', $name_arr); - } - - /** - * Static function to make a given email address rfc822 compliant. - * - * @param string $address An email address. - * - * @return string The RFC822-formatted email address. - */ - static function getBareEmail($address) - { - // Empty values are still empty. - if (!$address) { - return $address; - } - - $rfc822 = new Horde_Mail_Rfc822(); - return $rfc822->validateMailbox($address) - ? Horde_Mime_Address::writeAddress($address->mailbox, $address->host) - : $address; - } - -} diff --git a/framework/iCalendar/iCalendar/vjournal.php b/framework/iCalendar/iCalendar/vjournal.php deleted file mode 100644 index 94e07b45b..000000000 --- a/framework/iCalendar/iCalendar/vjournal.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @package Horde_iCalendar - */ -class Horde_iCalendar_vjournal extends Horde_iCalendar { - - /** - * The component type of this class. - * - * @var string - */ - var $type = 'vJournal'; - - function exportvCalendar() - { - return parent::_exportvData('VJOURNAL'); - } - -} diff --git a/framework/iCalendar/package.xml b/framework/iCalendar/package.xml deleted file mode 100644 index dd19af553..000000000 --- a/framework/iCalendar/package.xml +++ /dev/null @@ -1,166 +0,0 @@ - - - iCalendar - pear.horde.org - iCalendar API - This package provides an API for dealing with iCalendar data. - - Chuck Hagenbuch - chuck - chuck@horde.org - yes - - - Jan Schneider - jan - jan@horde.org - yes - - 2008-09-25 - - 0.1.0 - 0.1.0 - - - beta - beta - - LGPL - * Fix vFreebusy merging (Bug #4807). -* Implement handling of vTimezones in iCalendar data (lists-horde@carlthompson.net, Bug #4399). -* Correctly produce vcard parameters without value, like "ADR;WORK:...". -* Support departments in vCard's ORG properties (martin@matuska.org, Bug #4285). -* Fixed _parseDateTime() (wrobel@pardus.de, Bug #4808). -* Fix exporting of recurring exceptions (Bug #4627). -* Use lowercase mailto: for better Apple iCal compatibility. -* We must *not* escape colons per RFC in param values. -* Fix encoding issues with iCalendar 2.0 exports. -* Move version specific vCalendar/iCalendar export to Kronolith_Event. -* Use QUOTED-PRINTABLE when there's a newline in VNOTE data. -* Anniversary support (ntai@smartfruit.com, Request #5059). -* Support for all day events with VCALENDAR 1.0. -* Use ISO-8559-1 as default vCalendar 1.0 and vCard 2.1. -* Fix unreliably overwriting a variable with itself (rsalmon@mbpgroup.com, Bug #5652). -* Handle AALARM data with parameters (delimited by a ";"). -* Fix GEO parsing and generation. -* Refactor line folding and quoted-printable encoding. -* Add missing softline break (Bug #6541). -* Don't require a newline after END (Bug #6641, #6706). -* Fix detecting of "old" formats when parsing vCalendar/vCard data. -* Request charset on the fly, because it depends on the VERSION property. -* Fix passing value arrays with only one element. -* Correctly parse quoted parameters (Bug #7031) -* Set the correct version if none provided through the vcard data. -* BODY is not required, but N is, and FN for vcard3.0. -* Return the passed address unmodified if Mail_RFC822::validateMailbox() fails. -* Fixed importing of several events at once. -* Removed required calendar component properties in vevent.php. -* Fix generation of UIDs with PHP 5.2+. -* Fix generation of free periods with overlapping events (cedric.parent@multitel.be). -* Add support for extended vfreebusy parameters (wrobel@gentoo.org, Request #4690). -* Ensure vnotes and vcards are created with a valid default version number. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4.3.0 - - - 1.5.4 - - - Mail - pear.horde.org - - - Support - pear.horde.org - - - Util - pear.horde.org - - - - - - - 2006-05-08 - - 0.0.3 - 0.0.3 - - - beta - beta - - LGPL - * Converted to package.xml 2.0 for pear.horde.org. - - - - - 0.0.2 - 0.0.2 - - - beta - beta - - 2004-12-05 - LGPL - Lots of improvements, bugfixes and support for more fields and members of the iCalendar family. - - - - - 0.0.1 - 0.0.1 - - - alpha - alpha - - 2003-07-03 - LGPL - Initial release as a PEAR package - - - - diff --git a/imp/lib/Mime/Viewer/Itip.php b/imp/lib/Mime/Viewer/Itip.php index 5f63be0ff..260be4b91 100644 --- a/imp/lib/Mime/Viewer/Itip.php +++ b/imp/lib/Mime/Viewer/Itip.php @@ -80,7 +80,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base $mime_id = $this->_mimepart->getMimeId(); // Parse the iCal file. - $vCal = new Horde_iCalendar(); + $vCal = new Horde_Icalendar(); if (!$vCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) { return array( $mime_id => array( @@ -98,8 +98,9 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base } // Get the method type. - $method = $vCal->getAttribute('METHOD'); - if ($method instanceof PEAR_Error) { + try { + $method = $vCal->getAttribute('METHOD'); + } catch (Horde_Icalendar_Exception $e) { $method = ''; } @@ -116,8 +117,9 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base if ($registry->hasMethod('calendar/delete')) { $guid = $components[$key]->getAttribute('UID'); $deleteParams = array('guid' => $guid); - $instance = $components[$key]->getAttribute('RECURRENCE-ID'); - if (!($instance instanceof PEAR_Error)) { + try { + $instance = $components[$key]->getAttribute('RECURRENCE-ID'); + } catch (Horde_Icalendar_Exception $e) { // This is a cancellation of a recurring event instance. $deleteParams['recurrenceId'] = $instance; } @@ -244,8 +246,9 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base $vEvent = $components[$key]; // Get the organizer details. - $organizer = $vEvent->getAttribute('ORGANIZER'); - if ($organizer instanceof PEAR_Error) { + try { + $organizer = $vEvent->getAttribute('ORGANIZER'); + } catch (Horde_Icalendar_Exception $e) { break; } $organizer = parse_url($organizer); @@ -255,30 +258,34 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base // Build the reply. $msg_headers = new Horde_Mime_Headers(); - $vCal = new Horde_iCalendar(); + $vCal = new Horde_Icalendar(); $vCal->setAttribute('PRODID', '-//The Horde Project//' . $msg_headers->getUserAgent() . '//EN'); $vCal->setAttribute('METHOD', 'REPLY'); - $vEvent_reply = Horde_iCalendar::newComponent('vevent', $vCal); + $vEvent_reply = Horde_Icalendar::newComponent('vevent', $vCal); $vEvent_reply->setAttribute('UID', $vEvent->getAttribute('UID')); - if (!($vEvent->getAttribute('SUMMARY') instanceof PEAR_Error)) { + try { + $vEvent->getAttribute('SUMMARY'); $vEvent_reply->setAttribute('SUMMARY', $vEvent->getAttribute('SUMMARY')); - } - if (!($vEvent->getAttribute('DESCRIPTION') instanceof PEAR_Error)) { + } catch (Horde_Icalendar_Exception $e) {} + try { + $vEvent->getAttribute('DESCRIPTION'); $vEvent_reply->setAttribute('DESCRIPTION', $vEvent->getAttribute('DESCRIPTION')); - } + } catch (Horde_Icalendar_Exception $e) {} $dtstart = $vEvent->getAttribute('DTSTART', true); $vEvent_reply->setAttribute('DTSTART', $vEvent->getAttribute('DTSTART'), array_pop($dtstart)); - if (!($vEvent->getAttribute('DTEND') instanceof PEAR_Error)) { + try { + $vEvent->getAttribute('DTEND'); $dtend = $vEvent->getAttribute('DTEND', true); $vEvent_reply->setAttribute('DTEND', $vEvent->getAttribute('DTEND'), array_pop($dtend)); - } else { + } catch (Horde_Icalendar_Exception $e) { $duration = $vEvent->getAttribute('DURATION', true); $vEvent_reply->setAttribute('DURATION', $vEvent->getAttribute('DURATION'), array_pop($duration)); } - if (!($vEvent->getAttribute('SEQUENCE') instanceof PEAR_Error)) { + try { + $vEvent->getAttribute('SEQUENCE'); $vEvent_reply->setAttribute('SEQUENCE', $vEvent->getAttribute('SEQUENCE')); - } + } catch (Horde_Icalendar_Exception $e) {} $vEvent_reply->setAttribute('ORGANIZER', $vEvent->getAttribute('ORGANIZER'), array_pop($organizer)); // Find out who we are and update status. @@ -388,8 +395,9 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base $vFb = $components[$key]; // Get the organizer details. - $organizer = $vFb->getAttribute('ORGANIZER'); - if ($organizer instanceof PEAR_Error) { + try { + $organizer = $vFb->getAttribute('ORGANIZER'); + } catch (Horde_Icalendar_Exception $e) { break; } $organizer = parse_url($organizer); @@ -401,17 +409,22 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base $startStamp = time(); $endStamp = $startStamp + (60 * 24 * 3600); } else { - $startStamp = $vFb->getAttribute('DTSTART'); - if ($startStamp instanceof PEAR_Error) { + try { + $startStamp = $vFb->getAttribute('DTSTART'); + } catch (Horde_Icalendar_Exception $e) { $startStamp = time(); } - $endStamp = $vFb->getAttribute('DTEND'); - if ($endStamp instanceof PEAR_Error) { - $duration = $vFb->getAttribute('DURATION'); - if ($duration instanceof PEAR_Error) { - $endStamp = $startStamp + (60 * 24 * 3600); - } else { + + try { + $endStamp = $vFb->getAttribute('DTEND'); + } catch (Horde_Icalendar_Exception $e) {} + + if (!$endStamp) { + try { + $duration = $vFb->getAttribute('DURATION'); $endStamp = $startStamp + $duration; + } catch (Horde_Icalendar_Exception $e) { + $endStamp = $startStamp + (60 * 24 * 3600); } } } @@ -424,7 +437,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base // Build the reply. $msg_headers = new Horde_Mime_Headers(); - $vCal = new Horde_iCalendar(); + $vCal = new Horde_Icalendar(); $vCal->setAttribute('PRODID', '-//The Horde Project//' . $msg_headers->getUserAgent() . '//EN'); $vCal->setAttribute('METHOD', 'REPLY'); $vCal->addComponent($vfb_reply); @@ -570,23 +583,23 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base $html .= '

' . Horde::img('alerts/' . $msg[0] . '.png') . $msg[1] . '

'; } - $start = $vfb->getAttribute('DTSTART'); - if (!($start instanceof PEAR_Error)) { + try { + $start = $vfb->getAttribute('DTSTART'); if (is_array($start)) { $html .= '

' . _("Start:") . ' ' . strftime($prefs->getValue('date_format'), mktime(0, 0, 0, $start['month'], $start['mday'], $start['year'])) . '

'; } else { $html .= '

' . _("Start:") . ' ' . strftime($prefs->getValue('date_format'), $start) . ' ' . date($prefs->getValue('twentyFour') ? ' G:i' : ' g:i a', $start) . '

'; } - } + } catch (Horde_Icalendar_Exception $e) {} - $end = $vfb->getAttribute('DTEND'); - if (!($end instanceof PEAR_Error)) { + try { + $end = $vfb->getAttribute('DTEND'); if (is_array($end)) { $html .= '

' . _("End:") . ' ' . strftime($prefs->getValue('date_format'), mktime(0, 0, 0, $end['month'], $end['mday'], $end['year'])) . '

'; } else { $html .= '

' . _("End:") . ' ' . strftime($prefs->getValue('date_format'), $end) . ' ' . date($prefs->getValue('twentyFour') ? ' G:i' : ' g:i a', $end) . '

'; } - } + } catch (Horde_Icalendar_Exception $e) {} $html .= '

' . _("Actions") . '

' . '