Skip to content

Commit

Permalink
Incoming: Bennu library to be used for iCal imports/exports.
Browse files Browse the repository at this point in the history
  • Loading branch information
defacer committed Jan 13, 2006
1 parent 5eedb21 commit f3b6ac1
Show file tree
Hide file tree
Showing 11 changed files with 3,495 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/bennu/CHANGELOG.txt
@@ -0,0 +1 @@
No changelog yet, sorry.
22 changes: 22 additions & 0 deletions lib/bennu/COPYRIGHT.txt
@@ -0,0 +1,22 @@
Bennu - An object-oriented iCalendar (RFC2445) implementation in PHP
http://bennu.sourceforge.net

Bennu is copyright (C) 2005 by Ioannis Papaioannou (pj@moodle.org).

The full text of the LGLP license is included in LICENSE.txt

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to:
The Free Software Foundation, Inc.
51 Franklin St, Fifth Floor
Boston, MA 02110-1301 USA
504 changes: 504 additions & 0 deletions lib/bennu/LICENSE.txt

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions lib/bennu/README.txt
@@ -0,0 +1,148 @@
Bennu - An object-oriented iCalendar (RFC2445) implementation in PHP
http://bennu.sourceforge.net

Bennu is copyright (C) 2005 by Ioannis Papaioannou (pj@moodle.org).

=======================================================================
TABLE OF CONTENTS
=======================================================================

1. About Bennu
1.1. What is Bennu?
1.2. What is iCalendar?
1.3. Bennu license

2. Using Bennu
2.1. Integrating Bennu in your application
2.2. Usage examples

3. Bugs and limitations
3.1. Known limitations

4. Contact information

=======================================================================

-----------------------------------------------------------------------
1. About Bennu
-----------------------------------------------------------------------

1.1. What is Bennu?

Bennu is a software library written in PHP that implements the
functionality of the IETF iCalendar 2.0 specification (RFC 2445).
Its purpose is to enable applications which have an interest in
this format (e.g. calendaring, scheduler and organizer programs)
to support iCalendar in an easy, powerful, and extensible way.

In other words, Bennu exists so that developers working on such
applications don't have to waste painful hours going through the
standard and writing the code to implement it. Instead, they can
include this library in their application and get to the fun part
already: coding THEIR program.

1.2. What is iCalendar?

The iCalendar specification is a result of the work of the IETF
(Internet Engineering Task Force), Calendaring and Scheduling
Working Group. It was authored by Frank Dawson of Lotus
Development Corporation and Derik Stenerson of Microsoft
Corporation. iCalendar is heavily based on the earlier vCalendar
industry specification by the Internet Mail Consortium (IMC),
which it extends and seeks to replace.

In practical terms, iCalendar is the number one format used today
by calendaring and scheduler applications to import and export
data. Applications which provide support for iCalendar include:

* Microsoft Outlook
* Apple iCal
* Mozilla Calendar (and Mozilla Sunbird)
* Mulberry
* Korganizer
* Ximian Evolution

Effectively, this means that iCalendar is akin to a "common
language" which all these applications speak. If you are writing
an application which includes scheduling or calendaring elements,
and you want it to be able to synchronize with other such
programs, you need to support iCalendar. Bennu is an easy way to
do exactly that, as long as you are coding in PHP.

1.3. Bennu license

Bennu is released under the GNU Lesser General Public License
(LGPL). In short, this means that:

* You are allowed to distribute and/or modify the source code of
Bennu
* You are allowed to use Bennu or any modified version of it in a
commercial application
* You do not have to pay any fees to use, modify, or distribute
Bennu
* You can charge others for distributing Bennu or derived versions
* However, in ALL OF THE ABOVE CASES, you MUST provide the source
code for Bennu (or any modified version you may have produced),
and that source code MUST be provided under the GNU GPL -or- the
GNU LGPL license. Furthermore, you MUST include the original
copyright notices and credits that you received the source code
with when you distribute it INTACT.
* In any case, the copyright to Bennu is retained by me,
Ioannis Papaioannou.

##################
## DISCLAIMER ##
##################

Please be advised that the above is a very short and to the point
explanation of the GNU LGPL terms, as I understand it, and it is
only my personal opinion. IT IS NOT THE ACTUAL LICENSE UNDER WHICH
BENNU IS RELEASED. It is STRONGLY RECOMMENDED that you read the
full text of the LGPL in order to avoid any misunderstandings
which may be caused by reading my interpretation of it. You can
find the full text of the LGPL in the file LICENSE.TXT, which you
must have received as part of the Bennu distribution. If you have
not received such a file, please email me mentioning where you
obtained your copy of Bennu.

-----------------------------------------------------------------------
2. Using Bennu
-----------------------------------------------------------------------

2.1. Integrating Bennu in your application

To include Bennu in your application, you only need to include one
PHP file, like this:

<?php
include($path_to_bennu.'/library/lib/bennu.inc.php');

// the rest of your code goes here
?>

2.2. Usage examples

Please look at the /examples/ directory for ready-to-run examples
illustrating how Bennu is to be used. This section will be
revisited and properly written when the source code reaches an
acceptable level of features and meturity (no, I don't know when
that will be).

-----------------------------------------------------------------------
3. Bugs and limitations
-----------------------------------------------------------------------

3.1. Known limitations

* LANGUAGE property parameters aren't semantically checked.

-----------------------------------------------------------------------
4. Contact information
-----------------------------------------------------------------------

You can contact me at the email address pj@moodle.org for any
suggestions, ideas, or bug reports regarding Bennu.

At some point there will also be a site which you can use to do
anything related to Bennu, but sadly not today. If you want to
volunteer and give a hand, I 'll be happy to collaborate.
2 changes: 2 additions & 0 deletions lib/bennu/TODO.txt
@@ -0,0 +1,2 @@

* Take a look at all those text values. Control chars shouldn't be allowed.
59 changes: 59 additions & 0 deletions lib/bennu/bennu.class.php
@@ -0,0 +1,59 @@
<?php // $Id$

/**
* BENNU - PHP iCalendar library
* (c) 2005-2006 Ioannis Papaioannou (pj@moodle.org). All rights reserved.
*
* Released under the LGPL.
*
* See http://bennu.sourceforge.net/ for more information and downloads.
*
* @author Ioannis Papaioannou
* @version $Id$
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/

class Bennu {
function timestamp_to_datetime($t = NULL) {
if($t === NULL) {
$t = time();
}
return gmstrftime('%Y%m%dT%H%M%SZ', $t);
}

function generate_guid() {
// Implemented as per the Network Working Group draft on UUIDs and GUIDs

// These two octets get special treatment
$time_hi_and_version = sprintf('%02x', (1 << 6) + mt_rand(0, 15)); // 0100 plus 4 random bits
$clock_seq_hi_and_reserved = sprintf('%02x', (1 << 7) + mt_rand(0, 63)); // 10 plus 6 random bits

// Need another 14 random octects
$pool = '';
for($i = 0; $i < 7; ++$i) {
$pool .= sprintf('%04x', mt_rand(0, 65535));
}

// time_low = 4 octets
$random = substr($pool, 0, 8).'-';

// time_mid = 2 octets
$random .= substr($pool, 8, 4).'-';

// time_high_and_version = 2 octets
$random .= $time_hi_and_version.substr($pool, 12, 2).'-';

// clock_seq_high_and_reserved = 1 octet
$random .= $clock_seq_hi_and_reserved;

// clock_seq_low = 1 octet
$random .= substr($pool, 13, 2).'-';

// node = 6 octets
$random .= substr($pool, 14, 12);

return $random;
}
}

?>
25 changes: 25 additions & 0 deletions lib/bennu/bennu.inc.php
@@ -0,0 +1,25 @@
<?php // $Id$

/**
* BENNU - PHP iCalendar library
* (c) 2005-2006 Ioannis Papaioannou (pj@moodle.org). All rights reserved.
*
* Released under the LGPL.
*
* See http://bennu.sourceforge.net/ for more information and downloads.
*
* @author Ioannis Papaioannou
* @version $Id$
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/

if(!defined('_BENNU_VERSION')) {
define('_BENNU_VERSION', '0.1');
include('bennu.class.php');
include('iCalendar_rfc2445.php');
include('iCalendar_components.php');
include('iCalendar_properties.php');
include('iCalendar_parameters.php');
}

?>

0 comments on commit f3b6ac1

Please sign in to comment.