2000-08-18 05:24:22 +02:00
< ? php
/************************************************************************** \
* phpGroupWare - Calendar *
* http :// www . phpgroupware . org *
* Based on Webcalendar by Craig Knudsen < cknudsen @ radix . net > *
* http :// www . radix . net /~ cknudsen *
2001-01-17 13:35:43 +01:00
* Modified by Mark Peters < skeeter @ phpgroupware . org > *
2000-08-18 05:24:22 +02:00
* -------------------------------------------- *
* 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 . *
\ **************************************************************************/
2001-03-07 02:28:52 +01:00
/* $Id$ */
2000-08-18 05:24:22 +02:00
2001-03-07 02:28:52 +01:00
$phpgw_flags = array (
'currentapp' => 'calendar' ,
'enable_nextmatchs_class' => True
);
$phpgw_info [ 'flags' ] = $phpgw_flags ;
2001-02-14 03:58:46 +01:00
2001-03-07 02:28:52 +01:00
include ( '../header.inc.php' );
if ( ! ( $rights & PHPGW_ACL_READ ))
{
echo lang ( 'You do not have permission to read this record!' );
$phpgw -> common -> phpgw_footer ();
$phpgw -> common -> phpgw_exit ();
}
if ( $id < 1 )
{
echo lang ( 'Invalid entry id.' );
$phpgw -> common -> phpgw_footer ();
$phpgw -> common -> phpgw_exit ();
}
function add_day ( & $repeat_days , $day )
{
if ( $repeat_days )
{
$repeat_days .= ', ' ;
}
$repeat_days .= $day ;
}
function display_item ( $field , $data )
{
global $phpgw , $p ;
$p -> set_var ( 'field' , $field );
$p -> set_var ( 'data' , $data );
$p -> parse ( 'output' , 'list' , True );
}
$pri = Array (
1 => lang ( 'Low' ),
2 => lang ( 'Normal' ),
3 => lang ( 'High' )
);
$db = $phpgw -> db ;
$unapproved = FALSE ;
$cal_stream = $phpgw -> calendar -> open ( 'INBOX' , $owner , '' );
2001-03-10 05:48:19 +01:00
$event = $phpgw -> calendar -> fetch_event ( $cal_stream , $id );
2001-03-07 02:28:52 +01:00
2001-03-10 05:48:19 +01:00
reset ( $event -> participants );
2001-03-07 02:28:52 +01:00
$participating = False ;
2001-03-10 05:48:19 +01:00
for ( $j = 0 ; $j < count ( $event -> participants ); $j ++ )
2001-03-07 02:28:52 +01:00
{
2001-03-10 05:48:19 +01:00
if ( $event -> participants [ $j ] == $owner )
2001-03-07 02:28:52 +01:00
{
$participating = True ;
}
}
2001-02-14 03:58:46 +01:00
2001-03-07 02:28:52 +01:00
if ( $participating == False )
{
echo lang ( 'You do not have permission to read this record.' );
$phpgw -> common -> phpgw_exit ();
}
2001-02-14 03:58:46 +01:00
2001-03-10 05:48:19 +01:00
// $description = nl2br($event->description);
2001-03-07 02:28:52 +01:00
$p = CreateObject ( 'phpgwapi.Template' , $phpgw -> calendar -> template_dir );
$templates = Array (
'view_begin' => 'view.tpl' ,
'list' => 'list.tpl' ,
'view_end' => 'view.tpl' ,
'form_button' => 'form_button_script.tpl'
);
$p -> set_file ( $templates );
$var = Array (
'bg_text' => $phpgw_info [ 'theme' ][ 'bg_text' ],
2001-03-10 05:48:19 +01:00
'name' => $event -> name
2001-03-07 02:28:52 +01:00
);
$p -> set_var ( $var );
$p -> parse ( 'out' , 'view_begin' );
// Some browser add a \n when its entered in the database. Not a big deal
// this will be printed even though its not needed.
2001-03-10 05:48:19 +01:00
if ( nl2br ( $event -> description ))
2001-03-07 02:28:52 +01:00
{
2001-03-10 05:48:19 +01:00
display_item ( lang ( 'Description' ), nl2br ( $event -> description ));
2001-03-07 02:28:52 +01:00
}
2001-03-10 05:48:19 +01:00
$tz_offset = (( 60 * 60 ) * intval ( $phpgw_info [ 'user' ][ 'preferences' ][ 'common' ][ 'tz_offset' ]));
$start = mktime ( $event -> start -> hour , $event -> start -> min , $event -> start -> sec , $event -> start -> month , $event -> start -> mday , $event -> start -> year ) - $tz_offset ;
display_item ( lang ( 'Start Date/Time' ), $phpgw -> common -> show_date ( $start ));
2001-03-07 02:28:52 +01:00
// save date so the trailer links are for the same time period
$thisyear = $cal_info -> start -> year ;
$thismonth = $cal_info -> start -> month ;
$thisday = $cal_info -> start -> mday ;
2001-03-10 05:48:19 +01:00
$end = mktime ( $event -> end -> hour , $event -> end -> min , $event -> end -> sec , $event -> end -> month , $event -> end -> mday , $event -> end -> year ) - $tz_offset ;
display_item ( lang ( 'End Date/Time' ), $phpgw -> common -> show_date ( $end ));
2001-03-07 02:28:52 +01:00
2001-03-10 05:48:19 +01:00
display_item ( lang ( 'Priority' ), $pri [ $event -> priority ]);
2001-03-07 02:28:52 +01:00
$participate = False ;
2001-03-10 05:48:19 +01:00
for ( $i = 0 ; $i < count ( $event -> participants ); $i ++ )
2001-03-07 02:28:52 +01:00
{
2001-03-10 05:48:19 +01:00
if ( $event -> participants [ $i ] == $phpgw_info [ 'user' ][ 'account_id' ])
2001-03-07 02:28:52 +01:00
{
$participate = True ;
}
}
2001-03-10 05:48:19 +01:00
if ( $event -> owner == $phpgw_info [ 'user' ][ 'account_id' ] && $participate )
2001-03-07 02:28:52 +01:00
{
display_item ( lang ( 'Created by' ), '<a href="'
2001-03-10 05:48:19 +01:00
. $phpgw -> link ( '/' . $phpgw_info [ 'flags' ][ 'currentapp' ] . '/viewmatrix.php' , 'participants=' . $event -> owner . '&month=' . $event -> start -> month . '&day=' . $event -> start -> mday . '&year=' . $event -> start -> year . '&matrixtype=free/busy&owner=' . $owner )
. '">' . $phpgw -> common -> grab_owner_name ( $event -> owner ) . '</a>' );
2001-03-07 02:28:52 +01:00
}
else
{
2001-03-10 05:48:19 +01:00
display_item ( lang ( 'Created by' ), $phpgw -> common -> grab_owner_name ( $event -> owner ));
2001-03-07 02:28:52 +01:00
}
2001-03-10 05:48:19 +01:00
display_item ( lang ( 'Updated' ), $phpgw -> common -> show_date ( $event -> mdatetime ));
2001-03-07 02:28:52 +01:00
2001-03-10 05:48:19 +01:00
if ( $event -> groups [ 0 ])
2001-03-07 02:28:52 +01:00
{
$cal_grps = '' ;
2001-03-10 05:48:19 +01:00
for ( $i = 0 ; $i < count ( $event -> groups ); $i ++ )
2001-03-07 02:28:52 +01:00
{
if ( $i > 0 )
{
$cal_grps .= '<br>' ;
}
2001-03-10 05:48:19 +01:00
$cal_grps .= $phpgw -> accounts -> id2name ( $event -> groups [ $i ]);
2001-03-07 02:28:52 +01:00
}
display_item ( lang ( 'Groups' ), $cal_grps );
}
$str = '' ;
2001-03-10 05:48:19 +01:00
for ( $i = 0 ; $i < count ( $event -> participants ); $i ++ )
2001-03-07 02:28:52 +01:00
{
if ( $i )
{
$str .= '<br>' ;
}
2001-03-10 05:48:19 +01:00
switch ( $event -> status [ $i ])
2001-03-07 02:28:52 +01:00
{
case 'A' :
$status = 'Accepted' ;
break ;
case 'R' :
$status = 'Rejected' ;
break ;
case 'P' :
$status = 'Pending' ;
break ;
case 'U' :
$status = 'No Repsonse' ;
break ;
}
2001-03-10 05:48:19 +01:00
$str .= $phpgw -> common -> grab_owner_name ( $event -> participants [ $i ]) . ' (' . $status . ')' ;
2001-03-07 02:28:52 +01:00
}
display_item ( lang ( 'Participants' ), $str );
2000-11-22 05:16:18 +01:00
// Repeated Events
2001-03-10 05:48:19 +01:00
$str = $event -> rpt_type ;
if ( $event -> recur_type <> RECUR_NONE || ( $event -> recur_enddate -> mday != 0 && $event -> recur_enddate -> month != 0 && $event -> recur_enddate -> year != 0 ))
2001-03-07 02:28:52 +01:00
{
$str .= ' (' ;
2001-03-10 05:48:19 +01:00
$recur_end = mktime ( 0 , 0 , 0 , $event -> recur_enddate -> month , $event -> recur_enddate -> mday , $event -> recur_enddate -> year );
2001-03-07 02:28:52 +01:00
if ( $recur_end != 0 )
{
$str .= lang ( 'ends' ) . ': ' . $phpgw -> common -> show_date ( $recur_end , 'l, F d, Y' ) . ' ' ;
}
2001-03-10 05:48:19 +01:00
if ( $event -> recur_type == RECUR_WEEKLY || $event -> recur_type == RECUR_DAILY )
2001-03-07 02:28:52 +01:00
{
$repeat_days = '' ;
2001-03-10 05:48:19 +01:00
if ( $event -> recur_data & M_SUNDAY )
2001-03-07 02:28:52 +01:00
{
add_day ( $repeat_days , lang ( 'Sunday ' ));
}
2001-03-10 05:48:19 +01:00
if ( $event -> recur_data & M_MONDAY )
2001-03-07 02:28:52 +01:00
{
add_day ( $repeat_days , lang ( 'Monday ' ));
}
2001-03-10 05:48:19 +01:00
if ( $event -> recur_data & M_TUESDAY )
2001-03-07 02:28:52 +01:00
{
add_day ( $repeat_days , lang ( 'Tuesay ' ));
}
2001-03-10 05:48:19 +01:00
if ( $event -> recur_data & M_WEDNESDAY )
2001-03-07 02:28:52 +01:00
{
add_day ( $repeat_days , lang ( 'Wednesday ' ));
}
2001-03-10 05:48:19 +01:00
if ( $event -> recur_data & M_THURSDAY )
2001-03-07 02:28:52 +01:00
{
add_day ( $repeat_days , lang ( 'Thursday ' ));
}
2001-03-10 05:48:19 +01:00
if ( $event -> recur_data & M_FRIDAY )
2001-03-07 02:28:52 +01:00
{
add_day ( $repeat_days , lang ( 'Friday ' ));
}
2001-03-10 05:48:19 +01:00
if ( $event -> recur_data & M_SATURDAY )
2001-03-07 02:28:52 +01:00
{
add_day ( $repeat_days , lang ( 'Saturday ' ));
}
$str .= lang ( 'days repeated' ) . ': ' . $repeat_days ;
}
2001-03-10 05:48:19 +01:00
if ( $event -> recur_interval )
2001-03-07 02:28:52 +01:00
{
2001-03-10 05:48:19 +01:00
$str .= lang ( 'frequency' ) . ' ' . $event -> recur_interval ;
2001-03-07 02:28:52 +01:00
}
$str .= ')' ;
display_item ( lang ( 'Repetition' ), $str );
}
2001-03-10 05:48:19 +01:00
if (( $event -> owner == $owner ) && ( $rights & PHPGW_ACL_EDIT ))
2001-03-07 02:28:52 +01:00
{
2001-03-09 13:23:12 +01:00
$p -> set_var ( 'action_url_button' , $phpgw -> link ( '/' . $phpgw_info [ 'flags' ][ 'currentapp' ] . '/edit_entry.php' , 'id=' . $id . '&owner=' . $owner ));
2001-03-07 02:28:52 +01:00
$p -> set_var ( 'action_text_button' , ' ' . lang ( 'Edit' ) . ' ' );
$p -> set_var ( 'action_confirm_button' , '' );
$p -> parse ( 'edit_button' , 'form_button' );
}
else
{
$p -> set_var ( 'edit_button' , '' );
}
2001-03-10 05:48:19 +01:00
if (( $event -> owner == $owner ) && ( $rights & PHPGW_ACL_DELETE ))
2001-03-07 02:28:52 +01:00
{
2001-03-09 13:23:12 +01:00
$p -> set_var ( 'action_url_button' , $phpgw -> link ( '/' . $phpgw_info [ 'flags' ][ 'currentapp' ] . '/delete.php' , 'id=' . $id . '&owner=' . $owner ));
2001-03-07 02:28:52 +01:00
$p -> set_var ( 'action_text_button' , lang ( 'Delete' ));
$p -> set_var ( 'action_confirm_button' , " onClick= \" return confirm(' " . lang ( " Are you sure \\ nyou want to \\ ndelete this entry ? \\ n \\ nThis will delete \\ nthis entry for all users. " ) . " ') \" " );
$p -> parse ( 'delete_button' , 'form_button' );
}
else
{
$p -> set_var ( 'delete_button' , '' );
}
$p -> pparse ( 'out' , 'view_end' );
$phpgw -> common -> phpgw_footer ();
2000-08-18 05:24:22 +02:00
?>