steffen: server/kolab-horde-framework/kolab-horde-framework/iCalendar/iCalendar valarm.php, NONE, 1.1 vevent.php, NONE, 1.1 vfreebusy.php, NONE, 1.1 vjournal.php, NONE, 1.1 vtimezone.php, NONE, 1.1 vtodo.php, NONE, 1.1
cvs at intevation.de
cvs at intevation.de
Fri Oct 14 16:33:18 CEST 2005
- Previous message: steffen: server/kolab-horde-framework/kolab-horde-framework/iCalendar iCalendar.php, NONE, 1.1 package.xml, NONE, 1.1
- Next message: steffen: server/kolab-resource-handlers/kolab-resource-handlers/fbview/fbview/framework .htaccess, 1.1.1.1, NONE install-packages.bat, 1.1.1.1, NONE install-packages.php, 1.3, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: steffen
Update of /kolabrepository/server/kolab-horde-framework/kolab-horde-framework/iCalendar/iCalendar
In directory doto:/tmp/cvs-serv28903/kolab-horde-framework/kolab-horde-framework/iCalendar/iCalendar
Added Files:
valarm.php vevent.php vfreebusy.php vjournal.php vtimezone.php
vtodo.php
Log Message:
Separated Horde Framework from kolab-resource-handlers
--- NEW FILE: valarm.php ---
<?php
/**
* Class representing vAlarms.
*
* $Horde: framework/iCalendar/iCalendar/valarm.php,v 1.6 2004/01/01 15:14:47 jan Exp $
*
* Copyright 2003-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 3.0
* @package Horde_iCalendar
*/
class Horde_iCalendar_valarm extends Horde_iCalendar {
function getType()
{
return 'vAlarm';
}
function parsevCalendar($data)
{
parent::parsevCalendar($data, 'VALARM');
}
function exportvCalendar(&$container)
{
return parent::_exportvData('VALARM');
}
}
--- NEW FILE: vevent.php ---
<?php
/**
* Class representing vEvents.
*
* $Horde: framework/iCalendar/iCalendar/vevent.php,v 1.28 2004/03/10 18:48:57 chuck Exp $
*
* Copyright 2003-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 3.0
* @package Horde_iCalendar
*/
class Horde_iCalendar_vevent extends Horde_iCalendar {
function getType()
{
return 'vEvent';
}
function parsevCalendar($data)
{
parent::parsevCalendar($data, 'VEVENT');
}
function exportvCalendar(&$container)
{
// Default values.
$requiredAttributes = array();
$requiredAttributes['DTSTAMP'] = time();
$requiredAttributes['ORGANIZER'] = 'Unknown Organizer';
$requiredAttributes['UID'] = $this->_exportDateTime(time()) . '@' . $_SERVER['SERVER_NAME'];
switch ($container->getAttribute('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;
}
foreach ($requiredAttributes as $name => $default_value) {
if (is_a($this->getAttribute($name), 'PEAR_Error')) {
$this->setAttribute($name, $default_value);
}
}
return parent::_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.
*/
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.
*/
function organizerName()
{
$organizer = $this->getAttribute('ORGANIZER', true);
if (is_a($organizer, 'PEAR_Error')) {
return null;
}
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 object Horde_iCalendar_vEvent $vevent The vEvent with latest details.
*/
function updateFromvEvent($vevent)
{
$newAttributes = $vevent->getAllAttributes();
foreach ($newAttributes as $newAttribute) {
$currentValue = $this->getAttribute($newAttribute['name']);
if (is_a($currentValue, 'PEAR_error')) {
// Already exists so just add it.
$this->setAttribute($newAttribute['name'], $newAttribute['value'], $newAttribute['params']);
} else {
// Already exists so locate and modify.
$found = false;
// Try matching the attribte name and value incase
// only the params changed (eg attendee updating
// status).
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 object Horde_iCalendar_vEvent $vevent The vEvent with latest details
*/
function updateAttendeesFromvEvent($vevent)
{
$newAttributes = $vevent->getAllAttributes();
foreach ($newAttributes as $newAttribute) {
if (!$newAttribute['name'] == 'ATTENDEE') {
continue;
}
$currentValue = $this->getAttribute($newAttribute['name']);
if (is_a($currentValue, 'PEAR_error')) {
// Already exists so just add it.
$this->setAttribute($newAttribute['name'], $newAttribute['value'], $newAttribute['params']);
} else {
// Already exists so locate and modify.
$found = false;
// Try matching the attribte name and value incase
// only the params changed (eg attendee updating
// status).
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;
}
}
}
}
}
}
}
--- NEW FILE: vfreebusy.php ---
<?php
/**
* Class representing vFreebusys.
*
* $Horde: framework/iCalendar/iCalendar/vfreebusy.php,v 1.12 2004/01/01 15:14:48 jan Exp $
*
* Copyright 2003-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 3.0
* @package Horde_iCalendar
*/
class Horde_iCalendar_vfreebusy extends Horde_iCalendar {
var $_busyPeriods = array();
var $_extraParams = array();
function Horde_iCalendar_vfreebusy(&$container)
{
$this->_container = $container;
}
function getType()
{
return 'vFreebusy';
}
function parsevCalendar($data)
{
parent::parsevCalendar($data, 'VFREEBUSY');
// do something with all the busy periods
foreach ($this->_attributes as $key => $attribute) {
if ($attribute['name'] == 'FREEBUSY') {
foreach ($attribute['value'] as $value) {
if (array_key_exists('duration', $attribute['value'])) {
$this->addBusyPeriod('BUSY', $value['start'], null, $value['duration'], (array_key_exists('params', $attribute) ? $attribute['params'] : array()));
} else {
$this->addBusyPeriod('BUSY', $value['start'], $value['end'], null, (array_key_exists('params', $attribute) ? $attribute['params'] : array()));
}
}
unset($this->_attributes[$key]);
}
}
}
function exportvCalendar(&$container)
{
foreach ($this->_busyPeriods as $start => $end) {
$periods = array(array('start' => $start, 'end' => $end));
$this->setAttribute('FREEBUSY', $periods, (array_key_exists($start, $this->_extraParams) ? $this->_extraParams[$start] : array()));
}
$res = parent::_exportvData('VFREEBUSY');
foreach ($this->_attributes as $key => $attribute) {
if ($attribute['name'] == 'FREEBUSY') {
unset($this->_attributes[$key]);
}
}
return $res;
}
/**
* Get a display name for this object.
*/
function getName()
{
$name = '';
$method = $this->_container->getAttribute('METHOD');
if (is_a($method, 'PEAR_Error') || $method == 'PUBLISH') {
$attr = 'ORGANIZER';
} else if ($method == 'REPLY') {
$attr = 'ATTENDEE';
}
$name = $this->getAttribute($attr, true);
if (array_key_exists('CN', $name[0])) {
return $name[0]['CN'];
}
$name = $this->getAttribute($attr);
if (is_a($name, 'PEAR_Error')) {
return '';
} else {
$name = parse_url($name);
return $name['path'];
}
}
/**
* Get the email address for this object.
*/
function getEmail()
{
$name = '';
$method = $this->_container->getAttribute('METHOD');
if (is_a($method, 'PEAR_Error') || $method == 'PUBLISH') {
$attr = 'ORGANIZER';
} else if ($method == 'REPLY') {
$attr = 'ATTENDEE';
}
$name = $this->getAttribute($attr);
if (is_a($name, 'PEAR_Error')) {
return '';
} else {
$name = parse_url($name);
return $name['path'];
}
}
function getBusyPeriods()
{
return $this->_busyPeriods;
}
function getExtraParams()
{
return $this->_extraParams;
}
/**
* Return all the free periods of time in a given period.
*/
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) {
$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;
}
/**
* Add a busy period to the info.
*/
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 is 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. Extend to the
// length of the longest of the two.
$this->_busyPeriods[$start] = max($end, $this->_busyPeriods[$start]);
} else {
// Add a new busy period.
$this->_busyPeriods[$start] = $end;
}
$this->_extraParams[$start] = $extra;
return true;
}
/**
* Get the timestamp of the start of the time period this free
* busy information covers.
*/
function getStart()
{
if (!is_a($this->getAttribute('DTSTART'), 'PEAR_Error')) {
return $this->getAttribute('DTSTART');
} else if (count($this->_busyPeriods)) {
return min(array_keys($this->_busyPeriods));
} else {
return false;
}
}
/**
* Get the timestamp of the end of the time period this free busy
* information covers.
*/
function getEnd()
{
if (!is_a($this->getAttribute('DTEND'), 'PEAR_Error')) {
return $this->getAttribute('DTEND');
} else if (count($this->_busyPeriods)) {
return max(array_values($this->_busyPeriods));
} else {
return false;
}
}
/**
* Merge the busy periods of another VFreebusy into this one.
*/
function merge($freebusy, $simplify = true)
{
if (!is_a($freebusy, 'Horde_iCalendar_vfreebusy')) {
return false;
}
$extra = $freebusy->getExtraParams();
foreach ($freebusy->getBusyPeriods() as $start => $end) {
$this->addBusyPeriod('BUSY', $start, $end, null, (array_key_exists($start, $extra) ? $extra[$start] : array()));
}
if ($simplify) {
$this->simplify();
}
return true;
}
/**
* Remove all overlaps and simplify the busy periods array as much
* as possible.
*/
function simplify()
{
$checked = array();
$checkedExtra = array();
$checkedEmpty = true;
foreach ($this->_busyPeriods as $start => $end) {
if ($checkedEmpty) {
$checked[$start] = $end;
$checkedExtra[$start] = (array_key_exists($start, $this->_extraParams) ? $this->_extraParams[$start] : array());
$checkedEmpty = false;
} else {
$added = false;
foreach ($checked as $testStart => $testEnd) {
if ($start == $testStart) {
$checked[$testStart] = max($testEnd, $end);
$checkedExtra[$testStart] = (array_key_exists($testStart, $this->_extraParams) ? $this->_extraParams[$testStart] : array());
$added = true;
} else if ($end <= $testEnd && $end >= $testStart) {
unset($checked[$testStart]);
if (array_key_exists($testStart, $checkedExtra)) {
unset($checkedExtra[$testStart]);
}
$m = min($testStart, $start);
$checked[$m] = max($testEnd, $end);
$checkedExtra[$m] = (array_key_exists($start, $this->_extraParams) ? $this->_extraParams[$start] : array());
$added = true;
}
if ($added) {
break;
}
}
if (!$added) {
$checked[$start] = $end;
$checkedExtra[$start] = (array_key_exists($start, $this->_extraParams) ? $this->_extraParams[$start] : array());
}
}
}
ksort($checked, SORT_NUMERIC);
ksort($checkedExtra, SORT_NUMERIC);
$this->_busyPeriods = $checked;
$this->_extraParams = $checkedExtra;
}
}
--- NEW FILE: vjournal.php ---
<?php
/**
* Class representing vJournals.
*
* $Horde: framework/iCalendar/iCalendar/vjournal.php,v 1.6 2004/01/01 15:14:48 jan Exp $
*
* Copyright 2003-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 3.0
* @package Horde_iCalendar
*/
class Horde_iCalendar_vjournal extends Horde_iCalendar {
function getType()
{
return 'vJournal';
}
function parsevCalendar($data)
{
parent::parsevCalendar($data, 'VJOURNAL');
}
function exportvCalendar(&$container)
{
return parent::_exportvData('VJOURNAL');
}
}
--- NEW FILE: vtimezone.php ---
<?php
/**
* Class representing vTimezones.
*
* $Horde: framework/iCalendar/iCalendar/vtimezone.php,v 1.6 2004/01/01 15:14:48 jan Exp $
*
* Copyright 2003-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 3.0
* @package Horde_iCalendar
*/
class Horde_iCalendar_vtimezone extends Horde_iCalendar {
function getType()
{
return 'vTimeZone';
}
function parsevCalendar($data)
{
parent::parsevCalendar($data, 'VTIMEZONE');
}
function exportvCalendar(&$container)
{
return parent::_exportvData('VTIMEZONE');
}
}
class Horde_iCalendar_standard extends Horde_iCalendar {
function getType()
{
return 'standard';
}
function parsevCalendar($data)
{
parent::parsevCalendar($data, 'STANDARD');
}
function exportvCalendar(&$container)
{
return parent::_exportvData('STANDARD');
}
}
class Horde_iCalendar_daylight extends Horde_iCalendar {
function getType()
{
return 'daylight';
}
function parsevCalendar($data)
{
parent::parsevCalendar($data, 'DAYLIGHT');
}
function exportvCalendar(&$container)
{
return parent::_exportvData('DAYLIGHT');
}
}
--- NEW FILE: vtodo.php ---
<?php
/**
* Class representing vTodos.
*
* $Horde: framework/iCalendar/iCalendar/vtodo.php,v 1.11 2004/03/04 21:25:43 chuck Exp $
*
* Copyright 2003-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 3.0
* @package Horde_iCalendar
*/
class Horde_iCalendar_vtodo extends Horde_iCalendar {
function getType()
{
return 'vTodo';
}
function parsevCalendar($data)
{
parent::parsevCalendar($data, 'VTODO');
}
function exportvCalendar(&$container)
{
return parent::_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.
*/
function toArray()
{
$todo = array();
$name = $this->getAttribute('SUMMARY');
if (!is_array($name) && !is_a($name, 'PEAR_Error')) {
$todo['name'] = $name;
}
$desc = $this->getAttribute('DESCRIPTION');
if (!is_array($desc) && !is_a($desc, 'PEAR_Error')) {
$todo['desc'] = $desc;
}
$priority = $this->getAttribute('PRIORITY');
if (!is_array($priority) && !is_a($priority, 'PEAR_Error')) {
$todo['priority'] = $priority;
}
$due = $this->getAttribute('DTSTAMP');
if (!is_array($due) && !is_a($due, 'PEAR_Error')) {
$todo['due'] = $due;
}
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.
*/
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']);
}
}
}
- Previous message: steffen: server/kolab-horde-framework/kolab-horde-framework/iCalendar iCalendar.php, NONE, 1.1 package.xml, NONE, 1.1
- Next message: steffen: server/kolab-resource-handlers/kolab-resource-handlers/fbview/fbview/framework .htaccess, 1.1.1.1, NONE install-packages.bat, 1.1.1.1, NONE install-packages.php, 1.3, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the commits
mailing list