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 . *
\ **************************************************************************/
/* $Id$ */
2001-02-14 03:58:46 +01:00
$phpgw_flags = array (
'currentapp' => 'calendar' ,
'enable_nextmatchs_class' => True
);
2001-02-18 23:33:10 +01:00
$phpgw_info [ 'flags' ] = $phpgw_flags ;
2001-02-14 03:58:46 +01:00
include ( '../header.inc.php' );
if ( ! ( $rights & PHPGW_ACL_READ ))
{
2001-02-18 23:33:10 +01:00
echo lang ( 'You do not have permission to read this record!' );
2001-02-14 03:58:46 +01:00
$phpgw -> common -> phpgw_exit ();
2000-11-16 13:20:37 +01:00
}
2001-02-14 03:58:46 +01:00
if ( $id < 1 )
{
2001-02-18 23:33:10 +01:00
echo lang ( 'Invalid entry id.' );
2001-02-14 03:58:46 +01:00
$phpgw -> common -> phpgw_exit ();
}
function add_day ( & $repeat_days , $day )
{
2001-02-18 23:33:10 +01:00
if ( $repeat_days ) $repeat_days .= ', ' ;
2000-12-01 04:36:39 +01:00
$repeat_days .= $day ;
2000-08-18 05:24:22 +02:00
}
2000-12-23 17:33:22 +01:00
function display_item ( $field , $data ) {
global $phpgw ;
2001-02-14 03:58:46 +01:00
$phpgw -> template -> set_var ( 'field' , $field );
$phpgw -> template -> set_var ( 'data' , $data );
$phpgw -> template -> parse ( 'output' , 'list' , True );
2000-12-23 17:33:22 +01:00
}
2001-02-14 03:58:46 +01:00
$pri = Array (
1 => lang ( 'Low' ),
2 => lang ( 'Normal' ),
3 => lang ( 'High' )
);
2000-08-18 05:24:22 +02:00
2000-12-01 04:36:39 +01:00
$db = $phpgw -> db ;
2000-08-18 05:24:22 +02:00
$unapproved = FALSE ;
2000-11-25 04:48:10 +01:00
$cal = $phpgw -> calendar -> getevent ( intval ( $id ));
2000-08-18 05:24:22 +02:00
2000-11-22 05:16:18 +01:00
$cal_info = $cal [ 0 ];
2000-08-18 05:24:22 +02:00
2001-02-14 03:58:46 +01:00
reset ( $cal_info -> participants );
$participating = False ;
2001-02-18 23:33:10 +01:00
for ( $j = 0 ; $j < count ( $cal_info -> participants ); $j ++ )
2001-02-14 03:58:46 +01:00
{
2001-02-18 23:33:10 +01:00
if ( $cal_info -> participants [ $j ] == $owner )
2001-02-14 03:58:46 +01:00
{
$participating = True ;
}
}
2001-02-18 23:33:10 +01:00
if ( $participating == False )
2001-02-14 03:58:46 +01:00
{
2001-02-18 23:33:10 +01:00
echo lang ( 'You do not have permission to read this record.' );
2001-02-14 03:58:46 +01:00
$phpgw -> common -> phpgw_exit ();
}
2000-11-22 05:16:18 +01:00
$description = nl2br ( $description );
2000-08-18 05:24:22 +02:00
2001-02-14 03:58:46 +01:00
$templates = Array (
'view_begin' => 'view.tpl' ,
'list' => 'list.tpl' ,
'view_end' => 'view.tpl' ,
'form_button' => 'form_button_script.tpl'
);
$phpgw -> template -> set_file ( $templates );
2000-08-18 05:24:22 +02:00
2001-02-18 23:33:10 +01:00
// $phpgw->template->set_block('view_begin','list','view_end','form_button');
2000-08-18 05:24:22 +02:00
2001-02-14 03:58:46 +01:00
$phpgw -> template -> set_var ( 'bg_text' , $phpgw_info [ 'theme' ][ 'bg_text' ]);
$phpgw -> template -> set_var ( 'name' , $cal_info -> name );
$phpgw -> template -> parse ( 'out' , 'view_begin' );
2000-08-18 05:24:22 +02:00
// Some browser add a \n when its entered in the database. Not a big deal
// this will be printed even though its not needed.
2000-11-22 05:16:18 +01:00
if ( nl2br ( $cal_info -> description )) {
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Description " ), nl2br ( $cal_info -> description ));
2000-08-18 05:24:22 +02:00
}
2001-02-14 03:58:46 +01:00
display_item ( lang ( 'Start Date/Time' ), $phpgw -> common -> show_date ( $cal_info -> datetime ));
2000-08-18 05:24:22 +02:00
// save date so the trailer links are for the same time period
2000-11-22 05:16:18 +01:00
$thisyear = ( int ) $cal_info -> year ;
$thismonth = ( int ) $cal_info -> month ;
$thisday = ( int ) $cal_info -> day ;
2001-02-14 03:58:46 +01:00
display_item ( lang ( 'End Date/Time' ), $phpgw -> common -> show_date ( $cal_info -> edatetime ));
2000-08-18 05:24:22 +02:00
2001-02-14 03:58:46 +01:00
display_item ( lang ( 'Priority' ), $pri [ $cal_info -> priority ]);
2000-11-22 05:16:18 +01:00
2001-02-14 03:58:46 +01:00
$phpgw -> template -> set_var ( 'field' , lang ( 'Created by' ));
2000-11-26 19:03:20 +01:00
$participate = False ;
for ( $i = 0 ; $i < count ( $cal_info -> participants ); $i ++ ) {
2001-02-14 03:58:46 +01:00
if ( $cal_info -> participants [ $i ] == $phpgw_info [ 'user' ][ 'account_id' ]) {
2000-11-26 19:03:20 +01:00
$participate = True ;
}
}
2001-02-14 03:58:46 +01:00
if ( $cal_info -> owner == $phpgw_info [ 'user' ][ 'account_id' ] && $participate )
{
display_item ( lang ( 'Created by' ), '<a href="'
. $phpgw -> link ( 'viewmatrix.php' , 'participants=' . $cal_info -> owner . '&date=' . $cal_info -> year . $cal_info -> month . $cal_info -> day . '&matrixtype=free/busy&owner=' . $owner )
. '">' . $phpgw -> common -> grab_owner_name ( $cal_info -> owner ) . '</a>' );
}
2000-11-22 05:37:02 +01:00
else
2001-02-14 03:58:46 +01:00
{
display_item ( lang ( 'Created by' ), $phpgw -> common -> grab_owner_name ( $cal_info -> owner ));
}
2000-11-22 05:16:18 +01:00
2001-02-14 03:58:46 +01:00
display_item ( lang ( 'Updated' ), $phpgw -> common -> show_date ( $cal_info -> mdatetime ));
2000-11-22 05:16:18 +01:00
2000-12-01 04:36:39 +01:00
if ( $cal_info -> groups [ 0 ]) {
2001-02-14 03:58:46 +01:00
$cal_grps = '' ;
2000-12-01 04:36:39 +01:00
for ( $i = 0 ; $i < count ( $cal_info -> groups ); $i ++ ) {
2001-02-14 03:58:46 +01:00
if ( $i > 0 ) $cal_grps .= '<br>' ;
$cal_grps .= $phpgw -> accounts -> id2name ( $cal_info -> groups [ $i ]);
2000-11-22 05:16:18 +01:00
}
2001-02-14 03:58:46 +01:00
display_item ( lang ( 'Groups' ), $cal_grps );
2000-09-01 09:55:24 +02:00
}
2000-08-18 05:24:22 +02:00
2001-02-14 03:58:46 +01:00
$str = '' ;
2000-11-22 05:16:18 +01:00
for ( $i = 0 ; $i < count ( $cal_info -> participants ); $i ++ ) {
2001-02-14 03:58:46 +01:00
if ( $i ) $str .= '<br>' ;
2000-11-22 05:16:18 +01:00
$str .= $phpgw -> common -> grab_owner_name ( $cal_info -> participants [ $i ]);
}
2001-02-14 03:58:46 +01:00
display_item ( lang ( 'Participants' ), $str );
2000-11-22 05:16:18 +01:00
// Repeated Events
$str = $cal_info -> rpt_type ;
2001-02-14 03:58:46 +01:00
if ( $str <> 'none' || $cal_info -> rpt_use_end ) {
$str .= ' (' ;
if ( $cal_info -> rpt_use_end )
{
$str .= lang ( 'ends' ) . ': ' . $phpgw -> common -> show_date ( $cal_info -> rpt_end , 'l, F d, Y' ) . ' ' ;
}
if ( $cal_info -> rpt_type == 'weekly' || $cal_info -> rpt_type == 'daily' )
{
$repeat_days = '' ;
2000-11-22 05:16:18 +01:00
if ( $cal_info -> rpt_sun )
2001-02-14 03:58:46 +01:00
{
add_day ( $repeat_days , lang ( 'Sunday ' ));
}
2000-11-22 05:16:18 +01:00
if ( $cal_info -> rpt_mon )
2001-02-14 03:58:46 +01:00
{
add_day ( $repeat_days , lang ( 'Monday ' ));
}
2000-11-22 05:16:18 +01:00
if ( $cal_info -> rpt_tue )
2001-02-14 03:58:46 +01:00
{
add_day ( $repeat_days , lang ( 'Tuesay ' ));
}
2000-11-22 05:16:18 +01:00
if ( $cal_info -> rpt_wed )
2001-02-14 03:58:46 +01:00
{
add_day ( $repeat_days , lang ( 'Wednesday ' ));
}
2000-11-22 05:16:18 +01:00
if ( $cal_info -> rpt_thu )
2001-02-14 03:58:46 +01:00
{
add_day ( $repeat_days , lang ( 'Thursday ' ));
}
2000-11-22 05:16:18 +01:00
if ( $cal_info -> rpt_fri )
2001-02-14 03:58:46 +01:00
{
add_day ( $repeat_days , lang ( 'Friday ' ));
}
2000-11-22 05:16:18 +01:00
if ( $cal_info -> rpt_sat )
2001-02-14 03:58:46 +01:00
{
add_day ( $repeat_days , lang ( 'Saturday ' ));
}
$str .= lang ( 'days repeated' ) . ': ' . $repeat_days ;
2000-08-18 05:24:22 +02:00
}
2001-02-14 03:58:46 +01:00
if ( $cal_info -> rpt_freq ) $str .= lang ( 'frequency' ) . ' ' . $cal_info -> rpt_freq ;
$str .= ')' ;
2000-08-18 05:24:22 +02:00
2001-02-14 03:58:46 +01:00
display_item ( lang ( 'Repetition' ), $str );
2000-08-18 05:24:22 +02:00
}
2001-02-18 23:33:10 +01:00
if (( $cal_info -> owner == $owner ) && ( $rights & PHPGW_ACL_EDIT ))
2001-02-14 03:58:46 +01:00
{
$phpgw -> template -> set_var ( 'action_url_button' , $phpgw -> link ( 'edit_entry.php' , 'id=' . $id . '&owner=' . $owner ));
$phpgw -> template -> set_var ( 'action_text_button' , ' ' . lang ( 'Edit' ) . ' ' );
$phpgw -> template -> set_var ( 'action_confirm_button' , '' );
$phpgw -> template -> parse ( 'edit_button' , 'form_button' );
}
else
{
$phpgw -> template -> set_var ( 'edit_button' , '' );
}
2000-11-23 02:37:50 +01:00
2001-02-18 23:33:10 +01:00
if (( $cal_info -> owner == $owner ) && ( $rights & PHPGW_ACL_DELETE ))
2001-02-14 03:58:46 +01:00
{
$phpgw -> template -> set_var ( 'action_url_button' , $phpgw -> link ( 'delete.php' , 'id=' . $id . '&owner=' . $owner ));
$phpgw -> template -> set_var ( 'action_text_button' , lang ( 'Delete' ));
$phpgw -> template -> 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. " ) . " ') \" " );
$phpgw -> template -> parse ( 'delete_button' , 'form_button' );
}
else
{
$phpgw -> template -> set_var ( 'delete_button' , '' );
2000-11-22 05:16:18 +01:00
}
2001-02-14 03:58:46 +01:00
$phpgw -> template -> pparse ( 'out' , 'view_end' );
2000-09-29 07:24:18 +02:00
$phpgw -> common -> phpgw_footer ();
2000-08-18 05:24:22 +02:00
?>