2001-02-12 05:58:36 +01:00
< ? php
/************************************************************************** \
* phpGroupWare - ICal Calendar *
* http :// www . phpgroupware . org *
* Created by Mark Peters < skeeter @ phpgroupware . org > *
* -------------------------------------------- *
* 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$ */
2001-02-24 16:56:52 +01:00
2001-05-15 06:21:16 +02:00
if ( isset ( $phpgw_info [ 'flags' ][ 'included_classes' ][ 'calendar_' ]) &&
$phpgw_info [ 'flags' ][ 'included_classes' ][ 'calendar_' ] == True )
2001-03-17 20:39:56 +01:00
{
return ;
}
$phpgw_info [ 'flags' ][ 'included_classes' ][ 'calendar_' ] = True ;
2001-03-09 13:23:12 +01:00
class calendar_ extends calendar__
{
2001-02-24 16:56:52 +01:00
function open ( $calendar = '' , $user = '' , $passwd = '' , $options = '' )
{
global $phpgw , $phpgw_info ;
if ( $user == '' )
{
2001-03-15 06:37:52 +01:00
$user = $phpgw_info [ 'user' ][ 'account_lid' ];
2001-02-24 16:56:52 +01:00
}
elseif ( is_int ( $user ))
{
$this -> user = $phpgw -> accounts -> id2name ( $user );
}
elseif ( is_string ( $user ))
{
$this -> user = $user ;
}
if ( $options != '' )
{
$this -> stream = mcal_open ( '{' . $phpgw_info [ 'server' ][ 'icap_server' ] . '/' . $phpgw_info [ 'server' ][ 'icap_type' ] . '}' . $calendar , $this -> user , $passwd , $options );
}
else
{
$this -> stream = mcal_open ( '{' . $phpgw_info [ 'server' ][ 'icap_server' ] . '/' . $phpgw_info [ 'server' ][ ' icap_type '].' } ' . $calendar , $this -> user , $passwd );
}
}
function popen ( $calendar = '' , $user = '' , $passwd = '' , $options = '' )
{
global $phpgw , $phpgw_info ;
if ( $user == '' )
{
$this -> user = $phpgw_info [ 'user' ][ 'account_lid' ];
}
elseif ( is_int ( $user ))
{
$this -> user = $phpgw -> accounts -> id2name ( $user );
}
elseif ( is_string ( $user ))
{
$this -> user = $user ;
}
if ( $options != '' )
{
$this -> stream = mcal_popen ( '{' . $phpgw_info [ 'server' ][ 'icap_server' ] . '/' . $phpgw_info [ 'server' ][ 'icap_type' ] . '}' . $calendar , $this -> user , $passwd , $options );
}
else
{
$this -> stream = mcal_popen ( '{' . $phpgw_info [ 'server' ][ 'icap_server' ] . '/' . $phpgw_info [ 'server' ][ 'icap_type' ] . '}' . $calendar , $this -> user , $passwd );
}
}
function reopen ( $calendar , $options = '' )
{
if ( $options != '' )
{
$this -> stream = mcal_reopen ( $calendar , $options );
}
else
{
$this -> stream = mcal_reopen ( $calendar );
}
}
2001-02-12 05:58:36 +01:00
2001-05-20 03:20:40 +02:00
function close ( $options = '' )
2001-02-12 05:58:36 +01:00
{
2001-02-24 16:56:52 +01:00
if ( $options != '' )
{
2001-05-20 03:20:40 +02:00
return mcal_close ( $this -> stream , $options );
2001-02-24 16:56:52 +01:00
}
else
{
2001-05-20 03:20:40 +02:00
return mcal_close ( $this -> stream );
2001-02-24 16:56:52 +01:00
}
2001-02-12 05:58:36 +01:00
}
2001-05-20 03:20:40 +02:00
function create_calendar ( $calendar )
2001-02-12 05:58:36 +01:00
{
2001-05-20 03:20:40 +02:00
return mcal_create_calendar ( $this -> stream , $calendar );
2001-02-12 05:58:36 +01:00
}
2001-05-20 03:20:40 +02:00
function rename_calendar ( $old_name , $new_name )
2001-02-24 16:56:52 +01:00
{
2001-05-20 03:20:40 +02:00
return mcal_rename_calendar ( $this -> stream , $old_name , $new_name );
2001-02-24 16:56:52 +01:00
}
2001-02-12 05:58:36 +01:00
2001-05-20 03:20:40 +02:00
function delete_calendar ( $calendar )
2001-02-24 16:56:52 +01:00
{
2001-05-20 03:20:40 +02:00
return mcal_delete_calendar ( $this -> stream , $calendar );
2001-02-24 16:56:52 +01:00
}
2001-02-12 05:58:36 +01:00
2001-05-20 03:20:40 +02:00
function fetch_event ( $event_id , $options = '' )
2001-02-12 05:58:36 +01:00
{
2001-02-24 16:56:52 +01:00
if ( ! isset ( $this -> stream ))
{
return False ;
}
2001-02-12 05:58:36 +01:00
2001-02-24 16:56:52 +01:00
$this -> event = CreateObject ( 'calendar.calendar_item' );
2001-02-12 05:58:36 +01:00
2001-02-24 16:56:52 +01:00
if ( $options != '' )
{
2001-05-20 03:20:40 +02:00
$this -> event = mcal_fetch_event ( $this -> stream , $event_id , $options );
2001-02-24 16:56:52 +01:00
}
else
{
2001-05-20 03:20:40 +02:00
$this -> event = mcal_fetch_event ( $this -> stream , $event_id );
2001-02-24 16:56:52 +01:00
}
2001-03-02 05:20:41 +01:00
// Need to load the $this->event variable with the $event structure from
// the mcal_fetch_event() call
// Use http://www.php.net/manual/en/function.mcal-fetch-event.php as the reference
// This only needs legacy support
2001-02-24 16:56:52 +01:00
return $this -> event ;
}
2001-05-20 03:20:40 +02:00
function list_events ( $startYear , $startMonth , $startDay , $endYear = '' , $endMonth = '' , $endYear = '' )
2001-02-24 16:56:52 +01:00
{
if ( $endYear != '' && $endMonth != '' && $endDay != '' )
{
2001-05-20 03:20:40 +02:00
$events = mcal_list_events ( $this -> stream , $startYear , $startMonth , $startDay , $endYear , $endMonth , $endYear );
2001-02-24 16:56:52 +01:00
}
else
{
2001-05-20 03:20:40 +02:00
$events = mcal_list_events ( $this -> stream , $startYear , $startMonth , $startDay );
2001-02-24 16:56:52 +01:00
}
2001-05-20 03:20:40 +02:00
return $events ;
2001-02-12 05:58:36 +01:00
}
2001-05-20 03:20:40 +02:00
function append_event ()
2001-03-01 04:49:13 +01:00
{
2001-05-20 03:20:40 +02:00
return mcal_append_event ( $this -> stream );
2001-03-01 04:49:13 +01:00
}
2001-05-20 03:20:40 +02:00
function store_event ()
2001-03-01 05:13:30 +01:00
{
2001-05-20 03:20:40 +02:00
return mcal_store_event ( $this -> stream );
2001-03-01 05:13:30 +01:00
}
2001-05-20 03:20:40 +02:00
function delete_event ( $event_id )
2001-03-01 05:13:30 +01:00
{
2001-05-20 03:20:40 +02:00
return mcal_delete_event ( $this -> stream , $event_id );
2001-03-01 05:13:30 +01:00
}
2001-05-20 03:20:40 +02:00
function snooze ( $event_id )
2001-03-01 05:13:30 +01:00
{
2001-05-20 03:20:40 +02:00
return mcal_snooze ( $this -> stream , $event_id );
2001-03-01 05:13:30 +01:00
}
2001-05-20 03:20:40 +02:00
function list_alarms ( $begin_year = '' , $begin_month = '' , $begin_day = '' , $end_year = '' , $end_month = '' , $end_day = '' )
2001-03-01 05:13:30 +01:00
{
if ( $end_day == '' )
{
if ( $end_month == '' )
{
if ( $end_year == '' )
{
if ( $begin_day == '' )
{
if ( $begin_month == '' )
{
if ( $begin_year == '' )
{
2001-05-20 03:20:40 +02:00
return mcal_list_alarms ( $this -> stream );
2001-03-01 05:13:30 +01:00
}
else
{
2001-05-20 03:20:40 +02:00
return mcal_list_alarms ( $this -> stream , $begin_year );
2001-03-01 05:13:30 +01:00
}
}
else
{
2001-05-20 03:20:40 +02:00
return mcal_list_alarms ( $this -> stream , $begin_year , $begin_month );
2001-03-01 05:13:30 +01:00
}
}
else
{
2001-05-20 03:20:40 +02:00
return mcal_list_alarms ( $this -> stream , $begin_year , $begin_month , $begin_day );
2001-03-01 05:13:30 +01:00
}
}
else
{
2001-05-20 03:20:40 +02:00
return mcal_list_alarms ( $this -> stream , $begin_year , $begin_month , $begin_day , $end_year );
2001-03-01 05:13:30 +01:00
}
}
else
{
2001-05-20 03:20:40 +02:00
return mcal_list_alarms ( $this -> stream , $begin_year , $begin_month , $begin_day , $end_year , $end_month );
2001-03-01 05:13:30 +01:00
}
}
else
{
2001-05-20 03:20:40 +02:00
return mcal_list_alarms ( $this -> stream , $begin_year , $begin_month , $begin_day , $end_year , $end_month , $end_day );
2001-03-01 05:13:30 +01:00
}
}
2001-05-20 03:20:40 +02:00
function event_init ()
2001-03-01 04:49:13 +01:00
{
2001-03-02 05:20:41 +01:00
$this -> event = CreateObject ( 'calendar.calendar_item' );
2001-05-20 03:20:40 +02:00
return mcal_event_init ( $this -> stream );
2001-03-01 04:49:13 +01:00
}
2001-05-20 23:11:52 +02:00
function set_category ( $category = '' )
2001-03-02 05:20:41 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_category ( $category );
return mcal_event_set_category ( $this -> stream , $category );
2001-03-02 05:20:41 +01:00
}
2001-05-20 23:11:52 +02:00
function set_title ( $title = '' )
2001-03-02 05:20:41 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_title ( $title );
return mcal_event_set_title ( $this -> stream , $title );
2001-03-02 05:20:41 +01:00
}
2001-05-20 23:11:52 +02:00
function set_description ( $description = '' )
2001-03-02 05:20:41 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_description ( $description );
return mcal_event_set_description ( $this -> stream , $description );
2001-03-02 05:20:41 +01:00
}
2001-05-20 23:11:52 +02:00
function set_start ( $year , $month , $day = 0 , $hour = 0 , $min = 0 , $sec = 0 )
2001-03-02 05:20:41 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_start ( $year , $month , $day , $hour , $min , $sec );
return mcal_event_set_start ( $this -> stream , $year , $month , $day , $hour , $min , $sec );
2001-03-02 05:20:41 +01:00
}
2001-05-20 23:11:52 +02:00
function set_end ( $year , $month , $day = 0 , $hour = 0 , $min = 0 , $sec = 0 )
{
calendar__ :: set_end ( $year , $month , $day , $hour , $min , $sec );
return mcal_event_set_end ( $this -> stream , $year , $month , $day , $hour , $min , $sec );
2001-03-02 05:20:41 +01:00
}
2001-03-04 05:13:04 +01:00
2001-05-20 23:11:52 +02:00
function set_alarm ( $alarm )
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_alarm ( $alarm );
2001-05-20 03:20:40 +02:00
return mcal_event_set_alarm ( $this -> stream , $alarm );
2001-03-04 05:13:04 +01:00
}
2001-05-20 23:11:52 +02:00
function set_class ( $class )
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_class ( $class );
2001-05-20 03:20:40 +02:00
return mcal_event_set_class ( $this -> stream , $class );
2001-03-04 05:13:04 +01:00
}
// The function definition doesn't look correct...
// Need more information for this function
2001-05-20 03:20:40 +02:00
function next_recurrence ( $weekstart , $next )
2001-03-04 05:13:04 +01:00
{
2001-05-20 03:20:40 +02:00
return mcal_next_recurrence ( $this -> stream , $weekstart , $next );
2001-03-04 05:13:04 +01:00
}
2001-05-20 23:11:52 +02:00
function set_recur_none ()
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_recur_none ();
2001-05-20 03:20:40 +02:00
return mcal_event_set_recur_none ( $this -> stream );
2001-03-04 05:13:04 +01:00
}
2001-05-20 23:11:52 +02:00
function set_recur_daily ( $year , $month , $day , $interval )
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_recur_daily ( $year , $month , $day , $interval );
2001-05-20 03:20:40 +02:00
return mcal_event_set_recur_daily ( $this -> stream , $year , $month , $day , $interval );
2001-03-04 05:13:04 +01:00
}
2001-05-20 23:11:52 +02:00
function set_recur_weekly ( $year , $month , $day , $interval , $weekdays )
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_recur_weekly ( $year , $month , $day , $interval , $weekdays );
2001-05-20 03:20:40 +02:00
return mcal_event_set_recur_weekly ( $this -> stream , $year , $month , $day , $interval , $weekdays );
2001-03-04 05:13:04 +01:00
}
2001-05-20 23:11:52 +02:00
function set_recur_monthly_mday ( $year , $month , $day , $interval )
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_recur_monthly_mday ( $year , $month , $day , $interval );
2001-05-20 03:20:40 +02:00
return mcal_event_set_recur_monthly_mday ( $this -> stream , $year , $month , $day , $interval );
2001-03-04 05:13:04 +01:00
}
2001-05-20 23:11:52 +02:00
function set_recur_monthly_wday ( $year , $month , $day , $interval )
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_recur_monthly_wday ( $year , $month , $day , $interval );
2001-05-20 03:20:40 +02:00
return mcal_event_set_recur_monthly_wday ( $this -> stream , $year , $month , $day , $interval );
2001-03-04 05:13:04 +01:00
}
2001-05-20 23:11:52 +02:00
function set_recur_yearly ( $year , $month , $day , $interval )
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: set_recur_yearly ( $year , $month , $day , $interval );
2001-05-20 03:20:40 +02:00
return mcal_event_set_recur_yearly ( $this -> stream , $year , $month , $day , $interval );
2001-03-04 05:13:04 +01:00
}
2001-05-20 03:20:40 +02:00
function fetch_current_stream_event ()
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
$this -> event = mcal_fetch_current_stream_event ( $this -> stream );
return $this -> event
2001-03-04 05:13:04 +01:00
}
2001-05-20 23:11:52 +02:00
function add_attribute ( $attribute , $value )
2001-03-04 05:13:04 +01:00
{
2001-05-20 23:11:52 +02:00
calendar__ :: add_attribute ( $attribute , $value );
return mcal_event_add_attribute ( $this -> stream , $attribute , $value );
2001-03-04 05:13:04 +01:00
}
2001-05-20 03:20:40 +02:00
function expunge ()
2001-03-04 05:13:04 +01:00
{
2001-05-20 03:20:40 +02:00
return mcal_expunge ( $this -> stream );
2001-03-04 05:13:04 +01:00
}
/**************** Local functions for ICAL based Calendar *****************/
2001-03-12 04:18:02 +01:00
function set_status ( $id , $owner , $status )
{
$status_code_short = Array (
REJECTED => 'R' ,
NO_RESPONSE => 'U' ,
TENTATIVE => 'T' ,
ACCEPTED => 'A'
);
2001-05-31 06:34:00 +02:00
$this -> add_attribute ( 'status[' . $owner . ']' , $status_code_short [ $status ]);
2001-03-12 04:18:02 +01:00
// $this->stream->query("UPDATE calendar_entry_user SET cal_status='".$status_code_short[$status]."' WHERE cal_id=".$id." AND cal_login=".$owner,__LINE__,__FILE__);
return True ;
}
2001-02-24 16:56:52 +01:00
}