package.xml 0000664 0001750 0001750 00000164046 12171301200 011275 0 ustar jan jan
Horde_Icalendarpear.horde.orgHorde_iCalendariCalendariCalendar APIAn API for dealing with iCalendar data.Jan Schneiderjanjan@horde.orgyesChuck Hagenbuchchuckchuck@horde.orgyesMichael J Rubinskymrubinskmrubinsk@horde.orgyes2013-07-162.0.71.1.0stablestableLGPL-2.1
* [jan] Fix generating DATE-TIME attributes with timezone information (Bug #12428).
* [jan] Fix returning multiple attribute properties of the same name (Bug #12329).
5.3.01.7.0Horde_Datepear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Exceptionpear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Mailpear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Mimepear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Supportpear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Translationpear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Utilpear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Testpear.horde.org2.1.03.0.0alpha13.0.0alpha10.0.10.0.1alphaalpha2003-07-03LGPL-2.1
Initial release as a PEAR package
0.0.20.0.2betabeta2004-12-05LGPL-2.1
Lots of improvements, bugfixes and support for more fields and members of the iCalendar family.
2006-05-080.0.30.0.3betabetaLGPL-2.1
* Converted to package.xml 2.0 for pear.horde.org.
2008-09-250.1.00.1.0betabetaLGPL-2.1
* 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.
1.0.0alpha11.0.0alphaalpha2011-03-08LGPL-2.1
* First alpha release for Horde 4.
1.0.0beta11.0.0betabeta2011-03-16LGPL-2.1
* First beta release for Horde 4.
1.0.0RC11.0.0betabeta2011-03-22LGPL-2.1
* First release candidate for Horde 4.
1.0.0RC21.0.0betabeta2011-03-29LGPL-2.1
* Second release candidate for Horde 4.
1.0.01.0.0stablestable2011-04-06LGPL-2.1
* First stable release for Horde 4.
1.0.11.0.0stablestable2011-07-05LGPL-2.1
* [jan] Speed up exporting of objects with binary content (Bug #9405).
1.0.21.0.0stablestable2011-07-27LGPL-2.1
* [jan] Fix exporting multiline attributes to vCard 2.1 and vCalendar 1.0.
* [jan] Update Latvian translation.
1.0.31.0.0stablestable2011-08-09LGPL-2.1
* [mjr] Fix fetching the version from an Icalendar object (Bug #10411).
1.0.41.0.0stablestable2011-08-30LGPL-2.1
* [mjr] Fix version access (Bug #10425).
* [jan] Avoid infinite loop when importing certain vCalendar 1.0/vCard 2.1 data.
1.0.51.0.0stablestable2011-11-22LGPL-2.1
* [jan] Fix generating VTIMEZONE components.
1.1.01.1.0stablestable2011-12-21LGPL-2.1
* [jan] Allow to pass multiple parameter values in setAttribute() (Bug #7248).
1.1.11.1.0stablestable2012-01-17LGPL-2.1
* [jan] Fix compatibility with Horde_SyncMl (Bug #10908).
1.1.21.1.0stablestable2012-06-29LGPL-2.1
* [mms] Trim UTF-8 BOM from vCal data.
1.1.31.1.0stablestable2012-06-29LGPL-2.1
*
2012-07-052.0.0alpha11.1.0alphastableLGPL-2.1
* First alpha release for Horde 5.
* [mms] Use new Horde_Mail API.
2.0.0beta11.1.0betastable2012-07-19LGPL-2.1
* First beta release for Horde 5.
2.0.0beta21.1.0betastable2012-08-29LGPL-2.1
*
2.0.0RC11.1.0betastable2012-10-26LGPL-2.1
* [jan] Fix parsing of VTIMEZONE components that use RDATE properties.
2.0.01.1.0stablestable2012-10-30LGPL-2.1
* First stable release for Horde 5.
2.0.11.1.0stablestable2012-11-06LGPL-2.1
* [jan] Update Dutch translation (Arjen de Korte <build+horde@de-korte.org>).
2.0.21.1.0stablestable2013-01-09LGPL-2.1
* [jan] Update Basque translation (Ibon Igartua <ibon.igartua@ehu.es>).
2.0.31.1.0stablestable2013-01-29LGPL-2.1
* [jan] Don't set METHOD property unconditionally (Bug #10741).
* [jan] Convert test suite to PHPUnit.
2.0.41.1.0stablestable2013-03-05LGPL-2.1
* [jan] Improve unit tests.
2.0.51.1.0stablestable2013-05-06LGPL-2.1
* [jan] Fix exporting of base64-encoded attribute values.
2.0.61.1.0stablestable2013-06-18LGPL-2.1
* [jan] Remove group identifiers from attribute types (Bug #12329).
2.0.71.1.0stablestable2013-07-16LGPL-2.1
* [jan] Fix generating DATE-TIME attributes with timezone information (Bug #12428).
* [jan] Fix returning multiple attribute properties of the same name (Bug #12329).
Horde_Icalendar-2.0.7/doc/Horde/Icalendar/examples/exchange.ics 0000644 0001750 0001750 00000002733 12171301177 022422 0 ustar jan jan BEGIN:VCALENDAR
METHOD:REQUEST
PRODID:Microsoft CDO for Microsoft Exchange
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Eastern Time (US & Canada)
X-MICROSOFT-CDO-TZID:10
BEGIN:STANDARD
DTSTART:16010101T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=4;BYDAY=1SU
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20011115T211047Z
DTSTART;TZID="Eastern Time (US & Canada)":20011116T140000
SUMMARY:internal final review of mmc site changes
UID:040000008200E00074C5B7101A82E00800000000B0549C15F06DC101000000000000000
0100000008BF784046BEC174CA6706A51BE3E8B33
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN="MHMN002"
:
MAILTO:MHMN002@bitgroup.com
ORGANIZER;CN="Ann Cave":MAILTO:acave@bitgroup.com
LOCATION:metcalfe
DTEND;TZID="Eastern Time (US & Canada)":20011116T143000
DESCRIPTION:Let's get together to finalize. Way to go team in the final hom
estretch!\N
SEQUENCE:0
PRIORITY:5
CLASS:
CREATED:20011115T212414Z
LAST-MODIFIED:20011115T212414Z
STATUS:CONFIRMED
TRANSP:OPAQUE
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:REMINDER
TRIGGER;RELATED=START:-PT00H15M00S
END:VALARM
END:VEVENT
END:VCALENDAR
Horde_Icalendar-2.0.7/doc/Horde/Icalendar/examples/exdate.ics 0000644 0001750 0001750 00000000654 12171301177 022112 0 ustar jan jan BEGIN:VCALENDAR
VERSION:2.0
X-WR-CALNAME:Nasa History
PRODID:-//Apple Computer\, Inc//iCal 1.0//EN
X-WR-RELCALID:7A58AF63-46A0-11D7-BCDE-000A95673266-CALP
X-WR-TIMEZONE;VALUE=TEXT:US/Central
CALSCALE:GREGORIAN
BEGIN:VEVENT
DURATION:P1D
EXDATE;VALUE=DATE:20030428
DTSTAMP:20030926T233021Z
UID:D2924923-RID
DTSTART;VALUE=DATE:20020428
SUMMARY:(1961) Little Joe 5B
RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=4
END:VEVENT
Horde_Icalendar-2.0.7/doc/Horde/Icalendar/examples/ical.ics 0000644 0001750 0001750 00000001764 12171301177 021553 0 ustar jan jan BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
BEGIN:VEVENT
DTSTAMP:19980309T231000Z
UID:guid-1.host1.com
ORGANIZER;ROLE=CHAIR:MAILTO:
ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:
DESCRIPTION:Project XYZ Review Meeting
CATEGORIES:MEETING
CLASS:PUBLIC
CREATED:19980309T130000Z
SUMMARY:XYZ Project Review
DTSTART;TZID=US-Eastern:19980312T083000
DTEND;TZID=US-Eastern:19980312T093000
LOCATION:1CP Conference Room 4350
END:VEVENT
BEGIN:VTODO
DTSTAMP:19980130T134500Z
SEQUENCE:2
UID:
ORGANIZER:MAILTO:
ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:
DUE:19980415T235959
STATUS:NEEDS-ACTION
SUMMARY:Submit Income Taxes
BEGIN:VALARM
ACTION:AUDIO
TRIGGER;VALUE=DATE-TIME:19980403T120000
ATTACH;FMTTYPE=audio/basic:http://host.com/pub/audio-files/ssbanner.aud
REPEAT:4
DURATION:PT1H
END:VALARM
END:VTODO
END:VCALENDAR
Horde_Icalendar-2.0.7/doc/Horde/Icalendar/examples/parser.php 0000755 0001750 0001750 00000002445 12171301177 022150 0 ustar jan jan #!/usr/bin/env php
fatal('No file specified on the command line.');
}
$input_file = $argv[1];
if (!file_exists($input_file)) {
$cli->fatal($input_file . ' does not exist.');
}
if (!is_readable($input_file)) {
$cli->fatal($input_file . ' is not readable.');
}
$cli->writeln($cli->blue('Parsing ' . $input_file . ' ...'));
$data = file_get_contents($input_file);
$ical = new Horde_Icalendar();
if (!$ical->parseVCalendar($data)) {
$cli->fatal('iCalendar parsing failed.');
}
$cli->writeln($cli->green('Parsing successful, found ' . $ical->getComponentCount() . ' component(s).'));
$components = $ical->getComponents();
foreach ($components as $component) {
var_dump($component->toHash(true));
}
Horde_Icalendar-2.0.7/doc/Horde/Icalendar/examples/test_recurring.vcs 0000644 0001750 0001750 00000003052 12171301177 023707 0 ustar jan jan BEGIN:VCALENDAR
X-LOTUS-CHARSET:UTF-8
VERSION:2.0
PRODID:-//Lotus Development Corporation//NONSGML Notes 6.0//EN
METHOD:REQUEST
BEGIN:VTIMEZONE
TZID:Central European
BEGIN:STANDARD
DTSTART:19501029T020000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
RRULE:FREQ=YEARLY;BYMINUTE=0;BYHOUR=2;BYDAY=-1SU;BYMONTH=10
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19500326T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
RRULE:FREQ=YEARLY;BYMINUTE=0;BYHOUR=2;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID="Central European":20040417T110000
DTEND;TZID="Central European":20040417T113000
TRANSP:OPAQUE
DTSTAMP:20040416T075254Z
SEQUENCE:0
ATTENDEE;ROLE=CHAIR;PARTSTAT=ACCEPTED;CN="XXXX/UNSA"
;RSVP=FALSE:mailto:XXXX@XXXX.ba
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE
:mailto:XXXX1@XXXX.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION
;CN="XXXX2";RSVP=TRUE:mailto:XXXX2@XXXX.ba
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION
;CN="XXXX3";RSVP=TRUE:mailto:XXXX3@XXXX.ba
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE
:mailto:XXXX4@XXXX.ba
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE
:mailto:vljubovic@smartnet.ba
CLASS:PUBLIC
SUMMARY:XXXStriked out XXX
ORGANIZER;CN="XXXX/UNSA":mailto:XXXX@XXXX.ba
UID:59A47452891243FCC1256E78002B082C-Lotus_Notes_Generated
X-LOTUS-BROADCAST:FALSE
X-LOTUS-UPDATE-SEQ:1
X-LOTUS-UPDATE-WISL:$S:1;$L:1;$B:1;$R:1;$E:1
X-LOTUS-NOTESVERSION:2
X-LOTUS-NOTICETYPE:I
X-LOTUS-CHILD_UID:59A47452891243FCC1256E78002B082C
END:VEVENT
END:VCALENDAR
Horde_Icalendar-2.0.7/doc/Horde/Icalendar/examples/vnote.txt 0000644 0001750 0001750 00000000313 12171301177 022024 0 ustar jan jan BEGIN:VNOTE
VERSION:1.1
DCREATED:20030523T192529Z
LAST-MODIFIED:20030523T211027Z
BODY;ENCODING=QUOTED-PRINTABLE:
food=0D=0Asoup=20540=0D=0Aduck=201690=0D=0Abeer=20590=0D=0A
END:VNOTE
Horde_Icalendar-2.0.7/doc/Horde/Icalendar/COPYING 0000664 0001750 0001750 00000057646 12171301177 017374 0 ustar jan jan GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Daylight.php 0000664 0001750 0001750 00000001623 12171301177 020600 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @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($text, $base = 'VCALENDAR', $clear = true)
{
parent::parsevCalendar($text, 'DAYLIGHT');
}
/**
* TODO
*
* @return TODO
*/
public function exportvCalendar()
{
return $this->_exportvData('DAYLIGHT');
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Exception.php 0000664 0001750 0001750 00000000760 12171301177 020772 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Icalendar
*/
class Horde_Icalendar_Exception extends Horde_Exception_Wrapped
{
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Standard.php 0000664 0001750 0001750 00000001655 12171301177 020600 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @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($text, $base = 'VCALENDAR', $clear = true)
{
parent::parsevCalendar($text, 'STANDARD');
}
/**
* TODO
*
* @return TODO
*/
public function exportvCalendar()
{
return $this->_exportvData('STANDARD');
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Translation.php 0000664 0001750 0001750 00000003256 12171301177 021335 0 ustar jan jan
* @package Icalendar
*/
class Horde_Icalendar_Translation extends Horde_Translation
{
/**
* Returns the translation of a message.
*
* @var string $message The string to translate.
*
* @return string The string translation, or the original string if no
* translation exists.
*/
static public function t($message)
{
self::$_domain = 'Horde_Icalendar';
self::$_directory = '@data_dir@' == '@'.'data_dir'.'@' ? __DIR__ . '/../../../locale' : '@data_dir@/Horde_Icalendar/locale';
return parent::t($message);
}
/**
* Returns the plural translation of a message.
*
* @param string $singular The singular version to translate.
* @param string $plural The plural version to translate.
* @param integer $number The number that determines singular vs. plural.
*
* @return string The string translation, or the original string if no
* translation exists.
*/
static public function ngettext($singular, $plural, $number)
{
self::$_domain = 'Horde_Icalendar';
self::$_directory = '@data_dir@' == '@'.'data_dir'.'@' ? __DIR__ . '/../../../locale' : '@data_dir@/Horde_Icalendar/locale';
return parent::ngettext($singular, $plural, $number);
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Valarm.php 0000664 0001750 0001750 00000001332 12171301177 020252 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @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');
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Vcard.php 0000664 0001750 0001750 00000006525 12171301177 020100 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @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)
{
$ob = new Horde_Mail_Rfc822_Address($address);
return $ob->bare_address;
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Vevent.php 0000664 0001750 0001750 00000020411 12171301177 020276 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Icalendar
*/
class Horde_Icalendar_Vevent extends Horde_Icalendar
{
/**
* The component type of this class.
*
* @var string
*/
public $type = 'vEvent';
/**
* TODO
*
* @return TODO
*/
public function exportvCalendar()
{
// Default values.
$requiredAttributes = array(
'DTSTAMP' => time(),
'UID' => strval(new Horde_Support_Uuid())
);
$method = null;
if (!empty($this->_container)) {
try {
$method = $this->_container->getAttribute('METHOD');
} catch (Horde_Icalendar_Exception $e) {
}
}
switch ($method) {
case 'PUBLISH':
$requiredAttributes['DTSTART'] = time();
$requiredAttributes['SUMMARY'] = '';
break;
case 'REQUEST':
$requiredAttributes['ATTENDEE'] = '';
$requiredAttributes['DTSTART'] = time();
$requiredAttributes['SUMMARY'] = '';
break;
case 'REPLY':
$requiredAttributes['ATTENDEE'] = '';
break;
case 'ADD':
$requiredAttributes['DTSTART'] = time();
$requiredAttributes['SEQUENCE'] = 1;
$requiredAttributes['SUMMARY'] = '';
break;
case 'CANCEL':
$requiredAttributes['ATTENDEE'] = '';
$requiredAttributes['SEQUENCE'] = 1;
break;
case 'REFRESH':
$requiredAttributes['ATTENDEE'] = '';
break;
default:
$requiredAttributes['DTSTART'] = time();
break;
}
foreach ($requiredAttributes as $name => $default_value) {
try {
$this->getAttribute($name);
} catch (Horde_Icalendar_Exception $e) {
$this->setAttribute($name, $default_value);
}
}
return $this->_exportvData('VEVENT');
}
/**
* Update the status of an attendee of an event.
*
* @param $email The email address of the attendee.
* @param $status The participant status to set.
* @param $fullname The full name of the participant to set.
*/
public function updateAttendee($email, $status, $fullname = '')
{
foreach ($this->_attributes as $key => $attribute) {
if ($attribute['name'] == 'ATTENDEE' &&
$attribute['value'] == 'mailto:' . $email) {
$this->_attributes[$key]['params']['PARTSTAT'] = $status;
if (!empty($fullname)) {
$this->_attributes[$key]['params']['CN'] = $fullname;
}
unset($this->_attributes[$key]['params']['RSVP']);
return;
}
}
$params = array('PARTSTAT' => $status);
if (!empty($fullname)) {
$params['CN'] = $fullname;
}
$this->setAttribute('ATTENDEE', 'mailto:' . $email, $params);
}
/**
* Return the organizer display name or email.
*
* @return string The organizer name to display for this event.
*/
public function organizerName()
{
try {
$organizer = $this->getAttribute('ORGANIZER', true);
} catch (Horde_Icalendar_Exception $e) {
return Horde_Icalendar_Translation::t("An unknown person");
}
if (isset($organizer[0]['CN'])) {
return $organizer[0]['CN'];
}
$organizer = parse_url($this->getAttribute('ORGANIZER'));
return $organizer['path'];
}
/**
* Update this event with details from another event.
*
* @param Horde_Icalendar_Vevent $vevent The vEvent with latest details.
*/
public function updateFromvEvent($vevent)
{
$newAttributes = $vevent->getAllAttributes();
foreach ($newAttributes as $newAttribute) {
try {
$this->getAttribute($newAttribute['name']);
} catch (Horde_Icalendar_Exception $e) {
// Already exists so just add it.
$this->setAttribute($newAttribute['name'],
$newAttribute['value'],
$newAttribute['params']);
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']) {
$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;
}
}
}
}
}
/**
* Update just the attendess of event with details from another
* event.
*
* @param Horde_Icalendar_Vevent $vevent The vEvent with latest details
*/
public function updateAttendeesFromvEvent($vevent)
{
$newAttributes = $vevent->getAllAttributes();
foreach ($newAttributes as $newAttribute) {
if ($newAttribute['name'] != 'ATTENDEE') {
continue;
}
try {
$this->getAttribute($newAttribute['name']);
} catch (Horde_Icalendar_Exception $e) {
// Already exists so just add it.
$this->setAttribute($newAttribute['name'],
$newAttribute['value'],
$newAttribute['params']);
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']) {
$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;
}
}
}
}
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Vfreebusy.php 0000664 0001750 0001750 00000041744 12171301177 021015 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Icalendar
*/
class Horde_Icalendar_Vfreebusy extends Horde_Icalendar
{
/**
* The component type of this class.
*
* @var string
*/
public $type = 'vFreebusy';
/**
* 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
*/
public function parsevCalendar($data, $type = null, $charset = null)
{
parent::parsevCalendar($data, 'VFREEBUSY', $charset);
// Do something with all the busy periods.
foreach ($this->_attributes as $key => $attribute) {
if ($attribute['name'] != 'FREEBUSY') {
continue;
}
foreach ($attribute['values'] as $value) {
$params = isset($attribute['params'])
? $attribute['params']
: array();
if (isset($value['duration'])) {
$this->addBusyPeriod('BUSY', $value['start'], null,
$value['duration'], $params);
} else {
$this->addBusyPeriod('BUSY', $value['start'],
$value['end'], null, $params);
}
}
unset($this->_attributes[$key]);
}
}
/**
* Returns the component exported as string.
*
* @return string The exported vFreeBusy information according to the
* iCalendar format specification.
*/
public function exportvCalendar()
{
foreach ($this->_busyPeriods as $start => $end) {
$periods = array(array('start' => $start, 'end' => $end));
$this->setAttribute('FREEBUSY', $periods,
isset($this->_extraParams[$start])
? $this->_extraParams[$start] : array());
}
$res = $this->_exportvData('VFREEBUSY');
foreach ($this->_attributes as $key => $attribute) {
if ($attribute['name'] == 'FREEBUSY') {
unset($this->_attributes[$key]);
}
}
return $res;
}
/**
* Returns a display name for this object.
*
* @return string A clear text name for displaying this object.
*/
public function getName()
{
$name = '';
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';
}
try {
$name = $this->getAttribute($attr, true);
if (isset($name[0]['CN'])) {
return $name[0]['CN'];
}
} catch (Horde_Icalendar_Exception $e) {}
try {
$name = parse_url($this->getAttribute($attr));
return $name['path'];
} catch (Horde_Icalendar_Exception $e) {
return '';
}
}
/**
* Returns the email address for this object.
*
* @return string The email address of this object's owner.
*/
public function getEmail()
{
$name = '';
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';
}
try {
$name = parse_url($this->getAttribute($attr));
return $name['path'];
} catch (Horde_Icalendar_Exception $e) {
return '';
}
}
/**
* Returns the busy periods.
*
* @return array All busy periods.
*/
public function getBusyPeriods()
{
return $this->_busyPeriods;
}
/**
* Returns any additional freebusy parameters.
*
* @return array Additional parameters of the freebusy periods.
*/
public function getExtraParams()
{
return $this->_extraParams;
}
/**
* Returns all the free periods of time in a given period.
*
* @param integer $startStamp The start timestamp.
* @param integer $endStamp The end timestamp.
*
* @return array A hash with free time periods, the start times as the
* keys and the end times as the values.
*/
public function getFreePeriods($startStamp, $endStamp)
{
$this->simplify();
$periods = array();
// Check that we have data for some part of this period.
if ($this->getEnd() < $startStamp || $this->getStart() > $endStamp) {
return $periods;
}
// Locate the first time in the requested period we have data for.
$nextstart = max($startStamp, $this->getStart());
// Check each busy period and add free periods in between.
foreach ($this->_busyPeriods as $start => $end) {
if ($start <= $endStamp && $end >= $nextstart) {
if ($nextstart <= $start) {
$periods[$nextstart] = min($start, $endStamp);
}
$nextstart = min($end, $endStamp);
}
}
// If we didn't read the end of the requested period but still have
// data then mark as free to the end of the period or available data.
if ($nextstart < $endStamp && $nextstart < $this->getEnd()) {
$periods[$nextstart] = min($this->getEnd(), $endStamp);
}
return $periods;
}
/**
* Adds a busy period to the info.
*
* This function may throw away data in case you add a period with a start
* date that already exists. The longer of the two periods will be chosen
* (and all information associated with the shorter one will be removed).
*
* @param string $type The type of the period. Either 'FREE' or
* 'BUSY'; only 'BUSY' supported at the moment.
* @param integer $start The start timestamp of the period.
* @param integer $end The end timestamp of the period.
* @param integer $duration The duration of the period. If specified, the
* $end parameter will be ignored.
* @param array $extra Additional parameters for this busy period.
*/
public function addBusyPeriod($type, $start, $end = null, $duration = null,
$extra = array())
{
if ($type == 'FREE') {
// Make sure this period is not marked as busy.
return false;
}
// Calculate the end time if duration was specified.
$tempEnd = is_null($duration) ? $end : $start + $duration;
// Make sure the period length is always positive.
$end = max($start, $tempEnd);
$start = min($start, $tempEnd);
if (isset($this->_busyPeriods[$start])) {
// Already a period starting at this time. Change the current
// period only if the new one is longer. This might be a problem
// if the callee assumes that there is no simplification going
// on. But since the periods are stored using the start time of
// the busy periods we have to throw away data here.
if ($end > $this->_busyPeriods[$start]) {
$this->_busyPeriods[$start] = $end;
$this->_extraParams[$start] = $extra;
}
} else {
// Add a new busy period.
$this->_busyPeriods[$start] = $end;
$this->_extraParams[$start] = $extra;
}
return true;
}
/**
* Returns the timestamp of the start of the time period this free busy
* information covers.
*
* @return integer A timestamp.
*/
public function getStart()
{
try {
return $this->getAttribute('DTSTART');
} catch (Horde_Icalendar_Exception $e) {
return count($this->_busyPeriods)
? min(array_keys($this->_busyPeriods))
: false;
}
}
/**
* Returns the timestamp of the end of the time period this free busy
* information covers.
*
* @return integer A timestamp.
*/
public function getEnd()
{
try {
return $this->getAttribute('DTEND');
} 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
* 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 boolean $simplify If true, simplify() will
* called after the merge.
*/
public function merge(Horde_Icalendar_Vfreebusy $freebusy,
$simplify = true)
{
$extra = $freebusy->getExtraParams();
foreach ($freebusy->getBusyPeriods() as $start => $end) {
// This might simplify the busy periods without taking the
// "simplify" flag into account.
$this->addBusyPeriod('BUSY', $start, $end, null,
isset($extra[$start])
? $extra[$start] : array());
}
foreach (array('DTSTART', 'DTEND') as $val) {
try {
$thisattr = $this->getAttribute($val);
} catch (Horde_Icalendar_Exception $e) {
$thisattr = null;
}
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);
}
}
}
if ($simplify) {
$this->simplify();
}
return true;
}
/**
* Removes all overlaps and simplifies the busy periods array as much as
* possible.
*/
public function simplify()
{
$clean = false;
$busy = array($this->_busyPeriods, $this->_extraParams);
while (!$clean) {
$result = $this->_simplify($busy[0], $busy[1]);
$clean = $result === $busy;
$busy = $result;
}
ksort($result[1], SORT_NUMERIC);
$this->_extraParams = $result[1];
ksort($result[0], SORT_NUMERIC);
$this->_busyPeriods = $result[0];
}
/**
* TODO
*
* @param $busyPeriods TODO
* @param array $extraParams TODO
*
* @return array TODO
*/
protected function _simplify($busyPeriods, $extraParams = array())
{
$checked = $checkedExtra = array();
$checkedEmpty = true;
foreach ($busyPeriods as $start => $end) {
if ($checkedEmpty) {
$checked[$start] = $end;
$checkedExtra[$start] = isset($extraParams[$start])
? $extraParams[$start]
: array();
$checkedEmpty = false;
} else {
$added = false;
foreach ($checked as $testStart => $testEnd) {
// Replace old period if the new period lies around the
// old period.
if ($start <= $testStart && $end >= $testEnd) {
// Remove old period entry.
unset($checked[$testStart]);
unset($checkedExtra[$testStart]);
// Add replacing entry.
$checked[$start] = $end;
$checkedExtra[$start] = isset($extraParams[$start])
? $extraParams[$start]
: array();
$added = true;
} elseif ($start >= $testStart && $end <= $testEnd) {
// The new period lies fully within the old
// period. Just forget about it.
$added = true;
} elseif (($end <= $testEnd && $end >= $testStart) ||
($start >= $testStart && $start <= $testEnd)) {
// Now we are in trouble: Overlapping time periods. If
// we allow for additional parameters we cannot simply
// choose one of the two parameter sets. It's better
// to leave two separated time periods.
$extra = isset($extraParams[$start])
? $extraParams[$start]
: array();
$testExtra = isset($checkedExtra[$testStart])
? $checkedExtra[$testStart]
: array();
// Remove old period entry.
unset($checked[$testStart]);
unset($checkedExtra[$testStart]);
// We have two periods overlapping. Are their
// additional parameters the same or different?
$newStart = min($start, $testStart);
$newEnd = max($end, $testEnd);
if ($extra === $testExtra) {
// Both periods have the same information. So we
// can just merge.
$checked[$newStart] = $newEnd;
$checkedExtra[$newStart] = $extra;
} else {
// Extra parameters are different. Create one
// period at the beginning with the params of the
// first period and create a trailing period with
// the params of the second period. The break
// point will be the end of the first period.
$break = min($end, $testEnd);
$checked[$newStart] = $break;
$checkedExtra[$newStart] =
isset($extraParams[$newStart])
? $extraParams[$newStart]
: array();
$checked[$break] = $newEnd;
$highStart = max($start, $testStart);
$checkedExtra[$break] =
isset($extraParams[$highStart])
? $extraParams[$highStart]
: array();
// Ensure we also have the extra data in the
// extraParams.
$extraParams[$break] =
isset($extraParams[$highStart])
? $extraParams[$highStart]
: array();
}
$added = true;
}
if ($added) {
break;
}
}
if (!$added) {
$checked[$start] = $end;
$checkedExtra[$start] = isset($extraParams[$start])
? $extraParams[$start]
: array();
}
}
}
return array($checked, $checkedExtra);
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Vjournal.php 0000664 0001750 0001750 00000001343 12171301177 020632 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @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');
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Vnote.php 0000664 0001750 0001750 00000003206 12171301177 020125 0 ustar jan jan
* @author Karsten Fourmont
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Icalendar
*/
class Horde_Icalendar_Vnote extends Horde_Icalendar
{
/**
* The component type of this class.
*
* @var string
*/
public $type = 'vNote';
/**
* Constructor.
*/
public function __construct($version = '1.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 < 1;
$this->_version = $version;
}
/**
* Unlike vevent and vtodo, a vnote is normally not enclosed in an
* iCalendar container. (BEGIN..END)
*
* @return TODO
*/
public function exportvCalendar()
{
$requiredAttributes['BODY'] = '';
$requiredAttributes['VERSION'] = '1.1';
foreach ($requiredAttributes as $name => $default_value) {
try {
$this->getAttribute($name);
} catch (Horde_Icalendar_Exception $e) {
$this->setAttribute($name, $default_value);
}
}
return $this->_exportvData('VNOTE');
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Vtimezone.php 0000664 0001750 0001750 00000012241 12171301177 021011 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Icalendar
*/
class Horde_Icalendar_Vtimezone extends Horde_Icalendar
{
/**
* The component type of this class.
*
* @var string
*/
public $type = 'vTimeZone';
/**
* TODO
*
* @return TODO
*/
public function exportvCalendar()
{
return $this->_exportvData('VTIMEZONE');
}
/**
* Parse child components of the vTimezone component. Returns an
* 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
*/
public function parseChild(&$child, $year)
{
// Make sure 'time' key is first for sort().
$result['time'] = 0;
try {
$t = $child->getAttribute('TZOFFSETFROM');
} catch (Horde_Icalendar_Exception $e) {
return array();
}
$result['from'] = ($t['hour'] * 60 * 60 + $t['minute'] * 60) * ($t['ahead'] ? 1 : -1);
try {
$t = $child->getAttribute('TZOFFSETTO');
} catch (Horde_Icalendar_Exception $e) {
return array();
}
$result['to'] = ($t['hour'] * 60 * 60 + $t['minute'] * 60) * ($t['ahead'] ? 1 : -1);
try {
$start = $child->getAttribute('DTSTART');
} catch (Horde_Icalendar_Exception $e) {
return array();
}
if (!is_int($start)) {
return array();
}
$start = getdate($start);
if ($start['year'] > $year) {
return array();
}
$results = array();
try {
$rdates = $child->getAttributeValues('RDATE');
foreach ($rdates as $rdate) {
if ($rdate['year'] == $year || $rdate['year'] == $year - 1) {
$result['time'] = gmmktime(
$start['hours'], $start['minutes'], $start['seconds'],
$rdate['month'], $rdate['mday'], $rdate['year']);
$results[] = $result;
}
}
} catch (Horde_Icalendar_Exception $e) {
}
try {
$rrules = $child->getAttribute('RRULE');
} catch (Horde_Icalendar_Exception $e) {
if (!$results) {
$result['time'] = $start[0];
$results[] = $result;
}
return $results;
}
$rrules = explode(';', $rrules);
foreach ($rrules as $rrule) {
$t = explode('=', $rrule);
switch ($t[0]) {
case 'FREQ':
if ($t[1] != 'YEARLY') {
return array();
}
break;
case 'INTERVAL':
if ($t[1] != '1') {
return array();
}
break;
case 'BYMONTH':
$month = intval($t[1]);
break;
case 'BYDAY':
$len = strspn($t[1], '1234567890-+');
if ($len == 0) {
return array();
}
$weekday = substr($t[1], $len);
$weekdays = array(
'SU' => 0,
'MO' => 1,
'TU' => 2,
'WE' => 3,
'TH' => 4,
'FR' => 5,
'SA' => 6
);
$weekday = $weekdays[$weekday];
$which = intval(substr($t[1], 0, $len));
break;
case 'UNTIL':
if (intval($year) > intval(substr($t[1], 0, 4))) {
return array();
}
break;
}
}
if (empty($month) || !isset($weekday)) {
return array();
}
// Get the timestamp for the first day of $month.
$when = gmmktime($start['hours'], $start['minutes'], $start['seconds'],
$month, 1, $year);
// Get the day of the week for the first day of $month.
$first_of_month_weekday = intval(gmstrftime('%w', $when));
// Go to the first $weekday before first day of $month.
if ($weekday >= $first_of_month_weekday) {
$weekday -= 7;
}
$when -= ($first_of_month_weekday - $weekday) * 60 * 60 * 24;
// If going backwards go to the first $weekday after last day
// of $month.
if ($which < 0) {
do {
$when += 60*60*24*7;
} while (intval(gmstrftime('%m', $when)) == $month);
}
// Calculate $weekday number $which.
$when += $which * 60 * 60 * 24 * 7;
$result['time'] = $when;
$results[] = $result;
return $results;
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar/Vtodo.php 0000664 0001750 0001750 00000005003 12171301177 020122 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Icalendar
*/
class Horde_Icalendar_Vtodo extends Horde_Icalendar
{
/**
* The component type of this class.
*
* @var string
*/
public $type = 'vTodo';
/**
* TODO
*
* @return TODO
*/
public function exportvCalendar()
{
return $this->_exportvData('VTODO');
}
/**
* Convert this todo to an array of attributes.
*
* @return array Array containing the details of the todo in a hash
* as used by Horde applications.
*/
public function toArray()
{
$todo = array();
try {
$name = $this->getAttribute('SUMMARY');
if (!is_array($name)) {
$todo['name'] = $name;
}
} catch (Horde_Icalendar_Exception $e) {}
try {
$desc = $this->getAttribute('DESCRIPTION');
if (!is_array($desc)) {
$todo['desc'] = $desc;
}
} catch (Horde_Icalendar_Exception $e) {}
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;
}
/**
* Set the attributes for this todo item from an array.
*
* @param array $todo Array containing the details of the todo in
* the same format that toArray() exports.
*/
public function fromArray($todo)
{
if (isset($todo['name'])) {
$this->setAttribute('SUMMARY', $todo['name']);
}
if (isset($todo['desc'])) {
$this->setAttribute('DESCRIPTION', $todo['desc']);
}
if (isset($todo['priority'])) {
$this->setAttribute('PRIORITY', $todo['priority']);
}
if (isset($todo['due'])) {
$this->setAttribute('DTSTAMP', $todo['due']);
}
}
}
Horde_Icalendar-2.0.7/lib/Horde/Icalendar.php 0000664 0001750 0001750 00000146056 12171301177 017045 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Icalendar
*/
class Horde_Icalendar
{
/**
* The component type of this class.
*
* @var string
*/
public $type = 'vcalendar';
/**
* The parent (containing) iCalendar object.
*
* @var Horde_Icalendar
*/
protected $_container = false;
/**
* The name/value pairs of attributes for this object (UID,
* DTSTART, etc.). Which are present depends on the object and on
* what kind of component it is.
*
* @var array
*/
protected $_attributes = array();
/**
* Any children (contained) iCalendar components of this object.
*
* @var array
*/
protected $_components = array();
/**
* According to RFC 2425, we should always use CRLF-terminated lines.
*
* @var string
*/
protected $_newline = "\r\n";
/**
* iCalendar format version (different behavior for 1.0 and 2.0 especially
* with recurring events).
*
* @var string
*/
protected $_version;
/**
* Whether entry is vcalendar 1.0, vcard 2.1 or vnote 1.1.
*
* These 'old' formats are defined by www.imc.org. The 'new' (non-old)
* formats icalendar 2.0 and vcard 3.0 are defined in rfc2426 and rfc2445
* respectively.
*/
protected $_oldFormat = true;
/**
* Constructor.
*
* @var string $version Version.
*/
public function __construct($version = '2.0')
{
$this->setAttribute('VERSION', $version);
}
/**
* 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
* will be associated with.
*
* @return object Reference to a Horde_Icalendar_* object as specified.
*/
static public function newComponent($type, $container)
{
$type = Horde_String::lower($type);
$class = __CLASS__ . '_' . Horde_String::ucfirst($type);
if (class_exists($class)) {
$component = new $class();
if ($container !== false) {
$component->_container = $container;
// Use version of container, not default set by component
// constructor.
$component->setVersion($container->getAttribute('VERSION'));
}
} else {
// Should return an dummy x-unknown type class here.
$component = false;
}
return $component;
}
/**
* Sets the version of this component.
*
* @see $version
* @see $oldFormat
*
* @param string $version A float-like version string.
*/
public function setVersion($version)
{
$this->_oldFormat = $version < 2;
$this->_version = $version;
}
/**
* Sets the value of an attribute.
*
* @param string $name The name of the attribute.
* @param string $value The value of the attribute.
* @param array $params Array containing any addition parameters for
* this attribute.
* @param boolean $append True to append the attribute, False to replace
* the first matching attribute found.
* @param array $values Array representation of $value. For
* comma/semicolon seperated lists of values. If
* not set use $value as single array element.
*/
public function setAttribute($name, $value, $params = array(),
$append = true, $values = false)
{
// Make sure we update the internal format version if
// setAttribute('VERSION', ...) is called.
if ($name == 'VERSION') {
$this->setVersion($value);
if ($this->_container !== false) {
$this->_container->setVersion($value);
}
}
if (!$values) {
$values = array($value);
}
$found = false;
if (!$append) {
foreach (array_keys($this->_attributes) as $key) {
if ($this->_attributes[$key]['name'] == Horde_String::upper($name)) {
$this->_attributes[$key]['params'] = $params;
$this->_attributes[$key]['value'] = $value;
$this->_attributes[$key]['values'] = $values;
$found = true;
break;
}
}
}
if ($append || !$found) {
$this->_attributes[] = array(
'name' => Horde_String::upper($name),
'params' => $params,
'value' => $value,
'values' => $values
);
}
}
/**
* Sets parameter(s) for an (already existing) attribute. The
* parameter set is merged into the existing set.
*
* @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.
*/
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);
return true;
}
}
return false;
}
/**
* Get the value of an attribute.
*
* @param string $name The name of the attribute.
* @param boolean $params Return the parameters for this attribute instead
* of its value.
*
* @return mixed (string) The value of the attribute.
* (array) The parameters for the attribute or
* multiple values for an attribute.
* @throws Horde_Icalendar_Exception
*/
public function getAttribute($name, $params = false)
{
if ($name == 'VERSION') {
return $this->_version;
}
$result = array();
foreach ($this->_attributes as $attribute) {
if ($attribute['name'] == $name) {
$result[] = $params
? $attribute['params']
: $attribute['value'];
}
}
if (!count($result)) {
throw new Horde_Icalendar_Exception('Attribute "' . $name . '" Not Found');
} elseif (count($result) == 1 && !$params) {
return $result[0];
}
return $result;
}
/**
* Gets the values of an attribute as an array. Multiple values
* are possible due to:
*
* 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 array Multiple values for an attribute.
* @throws Horde_Icalendar_Exception
*/
public function getAttributeValues($name)
{
$result = array();
foreach ($this->_attributes as $attribute) {
if ($attribute['name'] == $name) {
$result = array_merge($attribute['values'], $result);
}
}
if (!count($result)) {
throw new Horde_Icalendar_Exception('Attribute "' . $name . '" Not Found');
}
return $result;
}
/**
* Returns the value of an attribute, or a specified default value
* if the attribute does not exist.
*
* @param string $name The name of the attribute.
* @param mixed $default What to return if the attribute specified by
* $name does not exist.
*
* @return mixed (string) The value of $name.
* (mixed) $default if $name does not exist.
*/
public function getAttributeDefault($name, $default = '')
{
try {
return $this->getAttribute($name);
} catch (Horde_Icalendar_Exception $e) {
return $default;
}
}
/**
* Remove all occurences of an attribute.
*
* @param string $name The name of the attribute.
*/
public function removeAttribute($name)
{
foreach (array_keys($this->_attributes) as $key) {
if ($this->_attributes[$key]['name'] == $name) {
unset($this->_attributes[$key]);
}
}
}
/**
* Get attributes for all tags or for a given tag.
*
* @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.
*/
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
* of them.
*/
public function addComponent($components)
{
if (!is_array($components)) {
$components = array($components);
}
foreach ($components as $component) {
if ($component instanceof Horde_Icalendar) {
$component->_container = $this;
$this->_components[] = $component;
}
}
}
/**
* Retrieve all the components.
*
* @return array Array of Horde_Icalendar objects.
*/
public function getComponents()
{
return $this->_components;
}
/**
* TODO
*
* @return TODO
*/
public function getType()
{
return $this->type;
}
/**
* Return the classes (entry types) we have.
*
* @return array Hash with class names Horde_Icalendar_xxx as keys
* and number of components of this class as value.
*/
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];
}
}
return $r;
}
/**
* Number of components in this container.
*
* @return integer Number of components in this container.
*/
public function getComponentCount()
{
return count($this->_components);
}
/**
* Retrieve a specific component.
*
* @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.
*/
public function getComponent($idx)
{
return isset($this->_components[$idx])
? $this->_components[$idx]
: false;
}
/**
* Locates the first child component of the specified class, and returns a
* reference to it.
*
* @param string $type The type of component to find.
*
* @return boolean|Horde_Icalendar_* False if no subcomponent of the
* specified class exists or the
* requested component.
*/
public function findComponent($childclass)
{
$childclass = __CLASS__ . '_' . Horde_String::lower($childclass);
foreach (array_keys($this->_components) as $key) {
if ($this->_components[$key] instanceof $childclass) {
return $this->_components[$key];
}
}
return false;
}
/**
* Locates the first matching child component of the specified class, and
* returns a reference to it.
*
* @param string $childclass The type of component to find.
* @param string $attribute This attribute must be set in the component
* 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
* the requested component.
*/
public function findComponentByAttribute($childclass, $attribute,
$value = null)
{
$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 (is_null($value) || $value == $attr) {
return $this->_components[$key];
}
}
}
return false;
}
/**
* Clears the iCalendar object (resets the components and attributes
* arrays).
*/
public function clear()
{
$this->_attributes = $this->_components = array();
}
/**
* Export as vCalendar format.
*
* @return TODO
*/
public function exportvCalendar()
{
// Default values.
// TODO: HORDE_VERSION does not exist.
$requiredAttributes['PRODID'] = '-//The Horde Project//Horde iCalendar Library' . (defined('HORDE_VERSION') ? ', Horde ' . constant('HORDE_VERSION') : '') . '//EN';
foreach ($requiredAttributes as $name => $default_value) {
try {
$this->getAttribute($name);
} catch (Horde_Icalendar_Exception $e) {
$this->setAttribute($name, $default_value);
}
}
return $this->_exportvData('VCALENDAR');
}
/**
* 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'
*
* @return array A hash array with tag names as keys.
*/
public function toHash($paramsInKeys = false)
{
$hash = array();
foreach ($this->_attributes as $a) {
$k = $a['name'];
if ($paramsInKeys && is_array($a['params'])) {
foreach ($a['params'] as $p => $v) {
$k .= ";$p=$v";
}
}
$hash[$k] = $a['value'];
}
return $hash;
}
/**
* Parses a string containing vCalendar data.
*
* @todo This method doesn't work well at all, if $base is VCARD.
*
* @param string $text The data to parse.
* @param string $base The type of the base object.
* @param boolean $clear If true clears this object before parsing.
*
* @return boolean True on successful import, false otherwise.
* @throws Horde_Icalendar_Exception
*/
public function parsevCalendar($text, $base = 'VCALENDAR', $clear = true)
{
if ($clear) {
$this->clear();
}
$text = Horde_String::trimUtf8Bom($text);
if (preg_match('/^BEGIN:' . $base . '(.*)^END:' . $base . '/ism', $text, $matches)) {
$container = true;
$vCal = $matches[1];
} else {
// Text isn't enclosed in BEGIN:VCALENDAR
// .. END:VCALENDAR. We'll try to parse it anyway.
$container = false;
$vCal = $text;
}
$vCal = trim($vCal);
// Extract all subcomponents.
$matches = $components = null;
if (preg_match_all('/^BEGIN:(.*)\s*?(\r\n|\r|\n)(.*)^END:\1\s*?/Uims', $vCal, $components)) {
foreach ($components[0] as $key => $data) {
// Remove from the vCalendar data.
$vCal = str_replace($data, '', $vCal);
}
} elseif (!$container) {
return false;
}
// Unfold "quoted printable" folded lines like:
// BODY;ENCODING=QUOTED-PRINTABLE:=
// another=20line=
// last=20line
while (preg_match_all('/^([^:]+;\s*(ENCODING=)?QUOTED-PRINTABLE(.*=\r?\n)+(.*[^=])?(\r?\n|$))/mU', $vCal, $matches)) {
foreach ($matches[1] as $s) {
$r = preg_replace('/=\r?\n/', '', $s);
$vCal = str_replace($s, $r, $vCal);
}
}
// Unfold any folded lines.
$vCal = preg_replace('/[\r\n]+[ \t]/', '', $vCal);
// Parse the remaining attributes.
if (preg_match_all('/^((?:[^":]+|(?:"[^"]*")+)*):([^\r\n]*)\r?$/m', $vCal, $matches)) {
foreach ($matches[0] as $attribute) {
preg_match('/([^;^:]*)((;(?:[^":]+|(?:"[^"]*")+)*)?):([^\r\n]*)[\r\n]*/', $attribute, $parts);
$tag = trim(preg_replace('/^.*\./', '', Horde_String::upper($parts[1])));
$value = $parts[4];
$params = array();
// Parse parameters.
if (!empty($parts[2])) {
preg_match_all('/;(([^;=]*)(=("[^"]*"|[^;]*))?)/', $parts[2], $param_parts);
foreach ($param_parts[2] as $key => $paramName) {
$paramName = Horde_String::upper($paramName);
$paramValue = $param_parts[4][$key];
if ($paramName == 'TYPE') {
$paramValue = preg_split('/(? $tmp) {
if (preg_match('/"([^"]*)"/', $tmp, $parts)) {
$paramValue[$k] = $parts[1];
}
}
}
if (isset($params[$paramName])) {
if (is_array($params[$paramName])) {
$params[$paramName][] = $paramValue;
} else {
$params[$paramName] = array($params[$paramName], $paramValue);
}
} else {
$params[$paramName] = $paramValue;
}
}
}
// Charset and encoding handling.
if ((isset($params['ENCODING']) &&
Horde_String::upper($params['ENCODING']) == 'QUOTED-PRINTABLE') ||
isset($params['QUOTED-PRINTABLE'])) {
$value = quoted_printable_decode($value);
if (isset($params['CHARSET'])) {
$value = Horde_String::convertCharset($value, $params['CHARSET'], 'UTF-8');
}
} elseif (isset($params['CHARSET'])) {
$value = Horde_String::convertCharset($value, $params['CHARSET'], 'UTF-8');
}
// Get timezone info for date fields from $params.
$tzid = isset($params['TZID']) ? trim($params['TZID'], '\"') : false;
switch ($tag) {
// Date fields.
case 'COMPLETED':
case 'CREATED':
case 'LAST-MODIFIED':
case 'X-MOZ-LASTACK':
case 'X-MOZ-SNOOZE-TIME':
$this->setAttribute($tag, $this->_parseDateTime($value, $tzid), $params);
break;
case 'BDAY':
case 'X-ANNIVERSARY':
$this->setAttribute($tag, $this->_parseDate($value), $params);
break;
case 'DTEND':
case 'DTSTART':
case 'DTSTAMP':
case 'DUE':
case 'AALARM':
case 'RECURRENCE-ID':
// types like AALARM may contain additional data after a ;
// ignore these.
$ts = explode(';', $value);
if (isset($params['VALUE']) && $params['VALUE'] == 'DATE') {
$this->setAttribute($tag, $this->_parseDate($ts[0]), $params);
} else {
$this->setAttribute($tag, $this->_parseDateTime($ts[0], $tzid), $params);
}
break;
case 'TRIGGER':
if (isset($params['VALUE']) &&
$params['VALUE'] == 'DATE-TIME') {
$this->setAttribute($tag, $this->_parseDateTime($value, $tzid), $params);
} else {
$this->setAttribute($tag, $this->_parseDuration($value), $params);
}
break;
// Comma seperated dates.
case 'EXDATE':
case 'RDATE':
if (!strlen($value)) {
break;
}
$dates = array();
$separator = $this->_oldFormat ? ';' : ',';
preg_match_all('/' . $separator . '([^' . $separator . ']*)/', $separator . $value, $values);
foreach ($values[1] as $value) {
$stamp = $this->_parseDateTime($value);
if (!is_int($stamp)) {
continue;
}
$dates[] = array('year' => date('Y', $stamp),
'month' => date('m', $stamp),
'mday' => date('d', $stamp));
}
$this->setAttribute($tag, isset($dates[0]) ? $dates[0] : null, $params, true, $dates);
break;
// Duration fields.
case 'DURATION':
$this->setAttribute($tag, $this->_parseDuration($value), $params);
break;
// Period of time fields.
case 'FREEBUSY':
$periods = array();
preg_match_all('/,([^,]*)/', ',' . $value, $values);
foreach ($values[1] as $value) {
$periods[] = $this->_parsePeriod($value);
}
$this->setAttribute($tag, isset($periods[0]) ? $periods[0] : null, $params, true, $periods);
break;
// UTC offset fields.
case 'TZOFFSETFROM':
case 'TZOFFSETTO':
$this->setAttribute($tag, $this->_parseUtcOffset($value), $params);
break;
// Integer fields.
case 'PERCENT-COMPLETE':
case 'PRIORITY':
case 'REPEAT':
case 'SEQUENCE':
$this->setAttribute($tag, intval($value), $params);
break;
// Geo fields.
case 'GEO':
if ($value) {
if ($this->_oldFormat) {
$floats = explode(',', $value);
$value = array('latitude' => floatval($floats[1]),
'longitude' => floatval($floats[0]));
} else {
$floats = explode(';', $value);
$value = array('latitude' => floatval($floats[0]),
'longitude' => floatval($floats[1]));
}
}
$this->setAttribute($tag, $value, $params);
break;
// Recursion fields.
case 'EXRULE':
case 'RRULE':
$this->setAttribute($tag, trim($value), $params);
break;
// ADR, ORG and N are lists seperated by unescaped semicolons
// with a specific number of slots.
case 'ADR':
case 'N':
case 'ORG':
$value = trim($value);
// As of rfc 2426 2.4.2 semicolon, comma, and colon must
// be escaped (comma is unescaped after splitting below).
$value = str_replace(array('\\n', '\\N', '\\;', '\\:'),
array($this->_newline, $this->_newline, ';', ':'),
$value);
// Split by unescaped semicolons:
$values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values);
break;
// String fields.
default:
if ($this->_oldFormat) {
// vCalendar 1.0 and vCard 2.1 only escape semicolons
// and use unescaped semicolons to create lists.
$value = trim($value);
// Split by unescaped semicolons:
$values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values);
} else {
$value = trim($value);
// As of rfc 2426 2.4.2 semicolon, comma, and colon
// must be escaped (comma is unescaped after splitting
// below).
$value = str_replace(array('\\n', '\\N', '\\;', '\\:', '\\\\'),
array($this->_newline, $this->_newline, ';', ':', '\\'),
$value);
// Split by unescaped commas.
$values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values);
}
break;
}
}
}
// Process all components.
if ($components) {
// vTimezone components are processed first. They are
// needed to process vEvents that may use a TZID.
foreach ($components[0] as $key => $data) {
$type = trim($components[1][$key]);
if ($type != 'VTIMEZONE') {
continue;
}
$component = $this->newComponent($type, $this);
if ($component === false) {
throw new Horde_Icalendar_Exception('Unable to create object for type ' . $type);
}
$component->parsevCalendar($data, $type);
$this->addComponent($component);
// Remove from the vCalendar data.
$vCal = str_replace($data, '', $vCal);
}
// Now process the non-vTimezone components.
foreach ($components[0] as $key => $data) {
$type = trim($components[1][$key]);
if ($type == 'VTIMEZONE') {
continue;
}
$component = $this->newComponent($type, $this);
if ($component === false) {
throw new Horde_Icalendar_Exception('Unable to create object for type ' . $type);
}
$component->parsevCalendar($data, $type);
$this->addComponent($component);
}
}
return true;
}
/**
* Export this component in vCal format.
*
* @param string $base The type of the base object.
*
* @return string vCal format data.
*/
protected function _exportvData($base = 'VCALENDAR')
{
$result = 'BEGIN:' . Horde_String::upper($base) . $this->_newline;
// VERSION is not allowed for entries enclosed in VCALENDAR/ICALENDAR,
// as it is part of the enclosing VCALENDAR/ICALENDAR. See rfc2445
if ($base !== 'VEVENT' && $base !== 'VTODO' && $base !== 'VALARM' &&
$base !== 'VJOURNAL' && $base !== 'VFREEBUSY' &&
$base != 'VTIMEZONE' && $base != 'STANDARD' && $base != 'DAYLIGHT') {
// Ensure that version is the first attribute.
$result .= 'VERSION:' . $this->_version . $this->_newline;
}
foreach ($this->_attributes as $attribute) {
$name = $attribute['name'];
if ($name == 'VERSION') {
// Already done.
continue;
}
$params_str = '';
$params = $attribute['params'];
if ($params) {
foreach ($params as $param_name => $param_value) {
/* Skip CHARSET for iCalendar 2.0 data, not allowed. */
if ($param_name == 'CHARSET' && !$this->_oldFormat) {
continue;
}
/* Skip VALUE=DATE for vCalendar 1.0 data, not allowed. */
if ($this->_oldFormat &&
$param_name == 'VALUE' && $param_value == 'DATE') {
continue;
}
if ($param_value === null) {
$params_str .= ";$param_name";
} else {
if (!is_array($param_value)) {
$param_value = array($param_value);
}
foreach ($param_value as &$one_param_value) {
$len = strlen($one_param_value);
$safe_value = '';
$quote = false;
for ($i = 0; $i < $len; ++$i) {
$ord = ord($one_param_value[$i]);
// Accept only valid characters.
if ($ord == 9 || $ord == 32 || $ord == 33 ||
($ord >= 35 && $ord <= 126) ||
$ord >= 128) {
$safe_value .= $one_param_value[$i];
// Characters above 128 do not need to be
// quoted as per RFC2445 but Outlook requires
// this.
if ($ord == 44 || $ord == 58 || $ord == 59 ||
$ord >= 128) {
$quote = true;
}
}
}
if ($quote) {
$safe_value = '"' . $safe_value . '"';
}
$one_param_value = $safe_value;
}
$params_str .= ";$param_name=" . implode(',', $param_value);
}
}
}
$value = $attribute['value'];
switch ($name) {
// Date fields.
case 'COMPLETED':
case 'CREATED':
case 'DCREATED':
case 'LAST-MODIFIED':
case 'X-MOZ-LASTACK':
case 'X-MOZ-SNOOZE-TIME':
$value = $this->_exportDateTime($value);
break;
case 'DTEND':
case 'DTSTART':
case 'DTSTAMP':
case 'DUE':
case 'AALARM':
case 'RECURRENCE-ID':
$floating = $base == 'STANDARD'
|| $base == 'DAYLIGHT'
|| isset($params['TZID']);
if (isset($params['VALUE'])) {
if ($params['VALUE'] == 'DATE') {
// VCALENDAR 1.0 uses T000000 - T235959 for all day events:
if ($this->_oldFormat && $name == 'DTEND') {
$d = new Horde_Date($value);
$value = new Horde_Date(array(
'year' => $d->year,
'month' => $d->month,
'mday' => $d->mday - 1));
$value = $this->_exportDate($value, '235959');
} else {
$value = $this->_exportDate($value, '000000');
}
} else {
$value = $this->_exportDateTime($value, $floating);
}
} else {
$value = $this->_exportDateTime($value, $floating);
}
break;
// Comma seperated dates.
case 'EXDATE':
case 'RDATE':
$floating = $base == 'STANDARD' || $base == 'DAYLIGHT';
$dates = array();
foreach ($value as $date) {
if (isset($params['VALUE'])) {
if ($params['VALUE'] == 'DATE') {
$dates[] = $this->_exportDate($date, '000000');
} elseif ($params['VALUE'] == 'PERIOD') {
$dates[] = $this->_exportPeriod($date);
} else {
$dates[] = $this->_exportDateTime($date, $floating);
}
} else {
$dates[] = $this->_exportDateTime($date, $floating);
}
}
$value = implode($this->_oldFormat ? ';' : ',', $dates);
break;
case 'TRIGGER':
if (isset($params['VALUE'])) {
if ($params['VALUE'] == 'DATE-TIME') {
$value = $this->_exportDateTime($value);
} elseif ($params['VALUE'] == 'DURATION') {
$value = $this->_exportDuration($value);
}
} else {
$value = $this->_exportDuration($value);
}
break;
// Duration fields.
case 'DURATION':
$value = $this->_exportDuration($value);
break;
// Period of time fields.
case 'FREEBUSY':
$value_str = '';
foreach ($value as $period) {
$value_str .= empty($value_str) ? '' : ',';
$value_str .= $this->_exportPeriod($period);
}
$value = $value_str;
break;
// UTC offset fields.
case 'TZOFFSETFROM':
case 'TZOFFSETTO':
$value = $this->_exportUtcOffset($value);
break;
// Integer fields.
case 'PERCENT-COMPLETE':
case 'PRIORITY':
case 'REPEAT':
case 'SEQUENCE':
$value = "$value";
break;
// Geo fields.
case 'GEO':
if ($this->_oldFormat) {
$value = $value['longitude'] . ',' . $value['latitude'];
} else {
$value = $value['latitude'] . ';' . $value['longitude'];
}
break;
// Recurrence fields.
case 'EXRULE':
case 'RRULE':
break;
default:
if ($this->_oldFormat) {
if (is_array($attribute['values']) &&
count($attribute['values']) > 1) {
$values = $attribute['values'];
if ($name == 'N' || $name == 'ADR' || $name == 'ORG') {
$glue = ';';
} else {
$glue = ',';
}
$values = str_replace(';', '\\;', $values);
$value = implode($glue, $values);
} else {
/* vcard 2.1 and vcalendar 1.0 escape only
* semicolons */
$value = str_replace(';', '\\;', $value);
}
// Text containing newlines or ASCII >= 127 must be BASE64
// or QUOTED-PRINTABLE encoded. Currently we use
// QUOTED-PRINTABLE as default.
if (preg_match("/[^\x20-\x7F]/", $value) &&
empty($params['ENCODING'])) {
$params['ENCODING'] = 'QUOTED-PRINTABLE';
$params_str .= ';ENCODING=QUOTED-PRINTABLE';
// Add CHARSET as well. At least the synthesis client
// gets confused otherwise
if (empty($params['CHARSET'])) {
$params['CHARSET'] = 'UTF-8';
$params_str .= ';CHARSET=' . $params['CHARSET'];
}
}
} else {
if (is_array($attribute['values']) &&
count($attribute['values'])) {
$values = $attribute['values'];
if ($name == 'N' || $name == 'ADR' || $name == 'ORG') {
$glue = ';';
} else {
$glue = ',';
}
// As of rfc 2426 2.5 semicolon and comma must be
// escaped.
$values = str_replace(array('\\', ';', ','),
array('\\\\', '\\;', '\\,'),
$values);
$value = implode($glue, $values);
} else {
// As of rfc 2426 2.5 semicolon and comma must be
// escaped.
$value = str_replace(array('\\', ';', ','),
array('\\\\', '\\;', '\\,'),
$value);
}
$value = preg_replace('/\r?\n/', '\n', $value);
}
break;
}
$value = str_replace("\r", '', $value);
if (!empty($params['ENCODING']) &&
$params['ENCODING'] == 'QUOTED-PRINTABLE' &&
strlen(trim($value))) {
$result .= $name . $params_str . ':'
. preg_replace(array('/(?_newline;
} else {
$attr_string = $name . $params_str . ':' . $value;
if (!$this->_oldFormat) {
if (isset($params['ENCODING']) && $params['ENCODING'] == 'b') {
$attr_string = trim(chunk_split($attr_string, 75, $this->_newline . ' '));
} else {
$attr_string = Horde_String::wordwrap($attr_string, 75, $this->_newline . ' ', true, true);
}
}
$result .= $attr_string . $this->_newline;
}
}
foreach ($this->_components as $component) {
$result .= $component->exportvCalendar();
}
return $result . 'END:' . $base . $this->_newline;
}
/**
* Parse a UTC Offset field.
*
* @param $text TODO
*
* @return TODO
*/
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]);
$offset['minute'] = intval($timeParts[3]);
if (isset($timeParts[4])) {
$offset['second'] = intval($timeParts[4]);
}
return $offset;
}
return false;
}
/**
* Export a UTC Offset field.
*
* @param $value TODO
*
* @return TODO
*/
function _exportUtcOffset($value)
{
$offset = ($value['ahead'] ? '+' : '-') .
sprintf('%02d%02d', $value['hour'], $value['minute']);
if (isset($value['second'])) {
$offset .= sprintf('%02d', $value['second']);
}
return $offset;
}
/**
* Parse a Time Period field.
*
* @param $text TODO
*
* @return array TODO
*/
protected function _parsePeriod($text)
{
$periodParts = explode('/', $text);
$start = $this->_parseDateTime($periodParts[0]);
if ($duration = $this->_parseDuration($periodParts[1])) {
return array('start' => $start, 'duration' => $duration);
} elseif ($end = $this->_parseDateTime($periodParts[1])) {
return array('start' => $start, 'end' => $end);
}
}
/**
* Export a Time Period field.
*
* @param $value TODO
*
* @return TODO
*/
protected function _exportPeriod($value)
{
$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
*/
protected function _parseTZID($date, $time, $tzid)
{
$vtimezone = $this->_container->findComponentByAttribute('vtimezone', 'TZID', $tzid);
if (!$vtimezone) {
return false;
}
$change_times = array();
foreach ($vtimezone->getComponents() as $o) {
$change_times = array_merge(
$change_times,
$vtimezone->parseChild($o, $date['year'])
);
}
if (!$change_times) {
return false;
}
sort($change_times);
// Time is arbitrarily based on UTC for comparison.
$t = @gmmktime($time['hour'], $time['minute'], $time['second'],
$date['month'], $date['mday'], $date['year']);
if ($t < $change_times[0]['time']) {
return $change_times[0]['from'];
}
for ($i = 0, $n = count($change_times); $i < $n - 1; $i++) {
if (($t >= $change_times[$i]['time']) &&
($t < $change_times[$i + 1]['time'])) {
return $change_times[$i]['to'];
}
}
if ($t >= $change_times[$n - 1]['time']) {
return $change_times[$n - 1]['to'];
}
return false;
}
/**
* Parses a DateTime field and returns a unix timestamp. If the
* field cannot be parsed then the original text is returned
* unmodified.
*
* @todo This function should be moved to Horde_Date and made public.
*
* @param $time TODO
* @param $tzid TODO
*
* @return TODO
*/
public function _parseDateTime($text, $tzid = false)
{
$dateParts = explode('T', $text);
if (count($dateParts) != 2 && !empty($text)) {
// Not a datetime field but may be just a date field.
if (!preg_match('/^(\d{4})-?(\d{2})-?(\d{2})$/', $text)) {
// Or not
return $text;
}
$dateParts = array($text, '000000');
}
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;
if ($time['zone'] == 'UTC' || $tzoffset !== false) {
$result = @gmmktime($time['hour'], $time['minute'], $time['second'],
$date['month'], $date['mday'], $date['year']);
if ($result !== false && $tzoffset) {
$result -= $tzoffset;
}
} else {
// We don't know the timezone so assume local timezone.
$result = @mktime($time['hour'], $time['minute'], $time['second'],
$date['month'], $date['mday'], $date['year']);
}
return ($result !== false) ? $result : $text;
}
/**
* 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 integer|object|array $value The time value to export (either a
* Horde_Date, array, or timestamp).
* @param boolean $floating Whether to return a floating
* date-time (without time zone
* information).
*
* @return string The string representation of the datetime value.
*/
public function _exportDateTime($value, $floating = false)
{
$date = new Horde_Date($value);
return $date->toICalendar($floating);
}
/**
* Parses a Time field.
*
* @param $text TODO
*
* @return TODO
*/
protected function _parseTime($text)
{
if (!preg_match('/([0-9]{2})([0-9]{2})([0-9]{2})(Z)?/', $text, $timeParts)) {
return false;
}
return array(
'hour' => $timeParts[1],
'minute' => $timeParts[2],
'second' => $timeParts[3],
'zone' => isset($timeParts[4]) ? 'UTC' : 'Local'
);
}
/**
* Parses a Date field.
*
* @param $text TODO
*
* @return array TODO
*/
public function _parseDate($text)
{
$parts = explode('T', $text);
if (count($parts) == 2) {
$text = $parts[0];
}
if (!preg_match('/^(\d{4})-?(\d{2})-?(\d{2})$/', $text, $match)) {
return false;
}
return array(
'year' => $match[1],
'month' => $match[2],
'mday' => $match[3]
);
}
/**
* Exports a date field.
*
* @param object|array $value Date object or hash.
* @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
*/
protected function _exportDate($value, $autoconvert = false)
{
if (is_object($value)) {
$value = array('year' => $value->year, 'month' => $value->month, 'mday' => $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']);
}
/**
* Parses a DURATION value field.
*
* @param string $text A DURATION value.
*
* @return integer The duration in seconds.
*/
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)) {
return false;
}
// Weeks.
$duration = 7 * 86400 * intval($durvalue[3]);
if (count($durvalue) > 4) {
// Days.
$duration += 86400 * intval($durvalue[4]);
}
if (count($durvalue) > 5) {
// Hours.
$duration += 3600 * intval($durvalue[7]);
// Mins.
if (isset($durvalue[8])) {
$duration += 60 * intval($durvalue[8]);
}
// Secs.
if (isset($durvalue[9])) {
$duration += intval($durvalue[9]);
}
}
// Sign.
if ($durvalue[1] == "-") {
$duration *= -1;
}
return $duration;
}
/**
* Export a duration value.
*
* @param $value TODO
*/
protected function _exportDuration($value)
{
$duration = '';
if ($value < 0) {
$value *= -1;
$duration .= '-';
}
$duration .= 'P';
$weeks = floor($value / (7 * 86400));
$value = $value % (7 * 86400);
if ($weeks) {
$duration .= $weeks . 'W';
}
$days = floor($value / (86400));
$value = $value % (86400);
if ($days) {
$duration .= $days . 'D';
}
if ($value) {
$duration .= 'T';
$hours = floor($value / 3600);
$value = $value % 3600;
if ($hours) {
$duration .= $hours . 'H';
}
$mins = floor($value / 60);
$value = $value % 60;
if ($mins) {
$duration .= $mins . 'M';
}
if ($value) {
$duration .= $value . 'S';
}
}
return $duration;
}
}
Horde_Icalendar-2.0.7/locale/ar/LC_MESSAGES/Horde_Icalendar.mo 0000644 0001750 0001750 00000000600 12171301177 021607 0 ustar jan jan $ , 8 F 9 Project-Id-Version: Horde_Icalendar
Report-Msgid-Bugs-To: dev@lists.horde.org
POT-Creation-Date: 2010-10-13 01:27+0200
PO-Revision-Date: 2010-10-13 01:27+0200
Last-Translator: Automatically generated
Language-Team: i18n@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Horde_Icalendar-2.0.7/locale/ar/LC_MESSAGES/Horde_Icalendar.po 0000664 0001750 0001750 00000001246 12171301177 021623 0 ustar jan jan # Arabic translations for Horde_Icalendar module.
# Copyright 2010-2013 Horde LLC (http://www.horde.org/)
# This file is distributed under the same license as the Horde_Icalendar module.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Horde_Icalendar\n"
"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
"POT-Creation-Date: 2010-10-13 01:27+0200\n"
"PO-Revision-Date: 2010-10-13 01:27+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: i18n@lists.horde.org\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: lib/Horde/Icalendar/Vevent.php:122
msgid "An unknown person"
msgstr ""
Horde_Icalendar-2.0.7/locale/bg/LC_MESSAGES/Horde_Icalendar.mo 0000644 0001750 0001750 00000000600 12171301177 021575 0 ustar jan jan $ , 8 F 9 Project-Id-Version: Horde_Icalendar
Report-Msgid-Bugs-To: dev@lists.horde.org
POT-Creation-Date: 2010-10-13 01:27+0200
PO-Revision-Date: 2010-10-13 01:27+0200
Last-Translator: Automatically generated
Language-Team: i18n@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Horde_Icalendar-2.0.7/locale/bg/LC_MESSAGES/Horde_Icalendar.po 0000664 0001750 0001750 00000001251 12171301177 021605 0 ustar jan jan # Bulgarian translations for Horde_Icalendar module.
# Copyright 2010-2013 Horde LLC (http://www.horde.org/)
# This file is distributed under the same license as the Horde_Icalendar module.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Horde_Icalendar\n"
"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
"POT-Creation-Date: 2010-10-13 01:27+0200\n"
"PO-Revision-Date: 2010-10-13 01:27+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: i18n@lists.horde.org\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: lib/Horde/Icalendar/Vevent.php:122
msgid "An unknown person"
msgstr ""
Horde_Icalendar-2.0.7/locale/bs/LC_MESSAGES/Horde_Icalendar.mo 0000644 0001750 0001750 00000000600 12171301177 021611 0 ustar jan jan $ , 8 F 9 Project-Id-Version: Horde_Icalendar
Report-Msgid-Bugs-To: dev@lists.horde.org
POT-Creation-Date: 2010-10-13 01:27+0200
PO-Revision-Date: 2010-10-13 01:27+0200
Last-Translator: Automatically generated
Language-Team: i18n@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Horde_Icalendar-2.0.7/locale/bs/LC_MESSAGES/Horde_Icalendar.po 0000664 0001750 0001750 00000001247 12171301177 021626 0 ustar jan jan # Bosnian translations for Horde_Icalendar module.
# Copyright 2010-2013 Horde LLC (http://www.horde.org/)
# This file is distributed under the same license as the Horde_Icalendar module.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Horde_Icalendar\n"
"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
"POT-Creation-Date: 2010-10-13 01:27+0200\n"
"PO-Revision-Date: 2010-10-13 01:27+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: i18n@lists.horde.org\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: lib/Horde/Icalendar/Vevent.php:122
msgid "An unknown person"
msgstr ""
Horde_Icalendar-2.0.7/locale/ca/LC_MESSAGES/Horde_Icalendar.mo 0000644 0001750 0001750 00000000600 12171301177 021570 0 ustar jan jan $ , 8 F 9 Project-Id-Version: Horde_Icalendar
Report-Msgid-Bugs-To: dev@lists.horde.org
POT-Creation-Date: 2010-10-13 01:27+0200
PO-Revision-Date: 2010-10-13 01:27+0200
Last-Translator: Automatically generated
Language-Team: i18n@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Horde_Icalendar-2.0.7/locale/ca/LC_MESSAGES/Horde_Icalendar.po 0000664 0001750 0001750 00000001322 12171301177 021577 0 ustar jan jan # Catalan translations for Horde_Icalendar module.
# Copyright 2010-2013 Horde LLC (http://www.horde.org/)
# This file is distributed under the same license as the Horde_Icalendar module.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Horde_Icalendar\n"
"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
"POT-Creation-Date: 2010-10-13 01:27+0200\n"
"PO-Revision-Date: 2010-10-13 01:27+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: i18n@lists.horde.org\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: lib/Horde/Icalendar/Vevent.php:122
#, fuzzy
msgid "An unknown person"
msgstr "S'ha produït un error desconegut."
Horde_Icalendar-2.0.7/locale/cs/LC_MESSAGES/Horde_Icalendar.mo 0000644 0001750 0001750 00000000706 12171301177 021621 0 ustar jan jan $ , 8 9 Project-Id-Version: Horde_Icalendar
Report-Msgid-Bugs-To: dev@lists.horde.org
POT-Creation-Date: 2010-10-13 01:27+0200
PO-Revision-Date: 2010-10-13 01:27+0200
Last-Translator: Automatically generated
Language-Team: i18n@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;
Horde_Icalendar-2.0.7/locale/cs/LC_MESSAGES/Horde_Icalendar.po 0000664 0001750 0001750 00000001420 12171301177 021620 0 ustar jan jan # Czech translations for Horde_Icalendar module.
# Copyright 2010-2013 Horde LLC (http://www.horde.org/)
# This file is distributed under the same license as the Horde_Icalendar module.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Horde_Icalendar\n"
"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
"POT-Creation-Date: 2010-10-13 01:27+0200\n"
"PO-Revision-Date: 2010-10-13 01:27+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: i18n@lists.horde.org\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
#: lib/Horde/Icalendar/Vevent.php:122
#, fuzzy
msgid "An unknown person"
msgstr "Nastala neznámá chyba."
Horde_Icalendar-2.0.7/locale/da/LC_MESSAGES/Horde_Icalendar.mo 0000644 0001750 0001750 00000000653 12171301177 021601 0 ustar jan jan $ , 8 q 9 Project-Id-Version: Horde_Icalendar
Report-Msgid-Bugs-To: dev@lists.horde.org
POT-Creation-Date: 2010-10-13 01:27+0200
PO-Revision-Date: 2010-10-13 01:27+0200
Last-Translator: Automatically generated
Language-Team: i18n@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Plural-Forms: nplurals=2; plural=(n != 1);
Horde_Icalendar-2.0.7/locale/da/LC_MESSAGES/Horde_Icalendar.po 0000664 0001750 0001750 00000001351 12171301177 021602 0 ustar jan jan # Danish translations for Horde_Icalendar module.
# Copyright 2010-2013 Horde LLC (http://www.horde.org/)
# This file is distributed under the same license as the Horde_Icalendar module.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Horde_Icalendar\n"
"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
"POT-Creation-Date: 2010-10-13 01:27+0200\n"
"PO-Revision-Date: 2010-10-13 01:27+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: i18n@lists.horde.org\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: lib/Horde/Icalendar/Vevent.php:122
#, fuzzy
msgid "An unknown person"
msgstr "ukendt fejl"
Horde_Icalendar-2.0.7/locale/de/LC_MESSAGES/Horde_Icalendar.mo 0000664 0001750 0001750 00000000767 12171301177 021615 0 ustar jan jan , <