[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] calendar/class.icalendar_vevent.php, 1.1.2.1
From: |
nomail |
Subject: |
[Phpgroupware-cvs] calendar/class.icalendar_vevent.php, 1.1.2.1 |
Date: |
Thu, 20 May 2004 21:50:15 -0000 |
Update of /calendar
Added Files:
Branch: proposal-branch
class.icalendar_vevent.php
date: 2004/04/16 21:21:51; author: seek3r; state: Exp; lines: +228 -0
Log Message:
bringing savannah cvs back up to date with what we were doing on our private
cvs server. We will not be doing dev from this cvs tree
=====================================================================
No syntax errors detected in -
=====================================================================
<?php
/**************************************************************************\
* phpGroupWare
*
* http://www.phpgroupware.org
*
* This file written by Mike Cochrane <address@hidden> *
* Ported from Horde by Dan Kuykendall <address@hidden> *
* Copyright (C) 2003 Mike Cochrane, Dan Kuykendall
*
*
-------------------------------------------------------------------------*
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\**************************************************************************/
/* $Id: class.icalendar_vevent.php,v 1.1.2.1 2004/04/16 21:21:51 seek3r
Exp $ */
/* $Source:
/cvsroot/phpgroupware/calendar/Attic/class.icalendar_vevent.php,v $ */
class calendar_icalendar_vevent extends calendar_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 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 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;
}
}
}
}
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] calendar/class.icalendar_vevent.php, 1.1.2.1,
nomail <=