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 *
* -------------------------------------------- *
* 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$ */
2000-12-26 21:13:34 +01:00
$phpgw_info [ " flags " ] = array ( " currentapp " => " calendar " , " noheader " => True , " nonavbar " => True , " enable_nextmatchs_class " => True , " noappheader " => True , " noappfooter " => True );
2000-08-18 05:24:22 +02:00
include ( " ../header.inc.php " );
2000-11-23 14:28:37 +01:00
$cal_info = new calendar_item ;
2000-08-18 05:24:22 +02:00
2000-12-09 05:08:54 +01:00
function validate ( $cal_info ) {
$error = 0 ;
// do a little form verifying
if ( $cal_info -> name == " " ) {
$error = 40 ;
} elseif (( $cal_info -> hour < 0 || $cal_info -> hour > 23 ) || ( $cal_info -> end_hour < 0 || $cal_info -> end_hour > 23 )) {
$error = 41 ;
} elseif (( $cal_info -> minute < 0 || $cal_info -> minute > 59 ) || ( $cal_info -> end_minute < 0 || $cal_info -> minute > 59 )) {
$error = 41 ;
} elseif (( $cal_info -> year == $cal_info -> end_year ) && ( $cal_info -> month == $cal_info -> end_month ) && ( $cal_info -> day == $cal_info -> end_day )) {
if ( $cal_info -> hour > $cal_info -> end_hour ) {
$error = 42 ;
} elseif (( $cal_info -> hour == $cal_info -> end_hour ) && ( $cal_info -> minute > $cal_info -> end_minute )) {
$error = 42 ;
}
} elseif (( $cal_info -> year == $cal_info -> end_year ) && ( $cal_info -> month == $cal_info -> end_month ) && ( $cal_info -> day > $cal_info -> end_day )) {
$error = 42 ;
} elseif (( $cal_info -> year == $cal_info -> end_year ) && ( $cal_info -> month > $cal_info -> end_month )) {
$error = 42 ;
} elseif ( $cal_info -> year > $cal_info -> end_year ) {
$error = 42 ;
}
return $error ;
}
2000-11-24 23:51:43 +01:00
if ( ! isset ( $readsess )) {
2000-12-09 05:08:54 +01:00
for ( reset ( $cal ); $key = key ( $cal ); next ( $cal )) {
$data = $cal [ $key ];
2000-12-18 02:36:18 +01:00
$cal_info -> set ( $key , $data );
2000-11-24 23:51:43 +01:00
}
2000-11-26 19:03:20 +01:00
$participating = False ;
if ( $phpgw_info [ " user " ][ " account_id " ] == $cal_info -> participants [ count ( $cal_info -> participants ) - 1 ]) {
$participating = True ;
}
if ( ! $participating && count ( $cal_info -> participants ) == 1 ) {
$cal_info -> owner = $cal_info -> participants [ 0 ];
}
2000-12-14 03:37:58 +01:00
if ( $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " timeformat " ] == " 12 " ) {
if ( $cal_info -> ampm == " pm " && $cal_info -> hour <> 12 ) {
$cal_info -> hour += 12 ;
}
if ( $cal_info -> end_ampm == " pm " && $cal_info -> end_hour <> 12 ) {
$cal_info -> end_hour += 12 ;
}
}
$cal_info -> datetime = mktime ( $cal_info -> hour , $cal_info -> minute , 0 , $cal_info -> month , $cal_info -> day , $cal_info -> year ) - (( 60 * 60 ) * $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " tz_offset " ]);
$cal_info -> edatetime = mktime ( $cal_info -> end_hour , $cal_info -> end_minute , 0 , $cal_info -> end_month , $cal_info -> end_day , $cal_info -> end_year ) - (( 60 * 60 ) * $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " tz_offset " ]);
$cal_info -> rpt_end = mktime ( 12 , 0 , 0 , $cal_info -> rpt_month , $cal_info -> rpt_day , $cal_info -> rpt_year ) - (( 60 * 60 ) * $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " tz_offset " ]);
2000-12-18 02:36:18 +01:00
$cal_info = $phpgw -> common -> appsession ( $cal_info );
2000-12-09 05:08:54 +01:00
$datetime_check = validate ( $cal_info );
2000-12-14 03:37:58 +01:00
if ( $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " timeformat " ] == " 12 " ) {
if ( $cal_info -> hour >= 12 ) {
$cal_info -> ampm = " " ;
}
if ( $cal_info -> end_hour >= 12 ) {
$cal_info -> end_ampm = " " ;
}
}
$cal_info -> datetime += (( 60 * 60 ) * $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " tz_offset " ]);
$cal_info -> edatetime += (( 60 * 60 ) * $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " tz_offset " ]);
$overlapping_events = $phpgw -> calendar -> overlap ( $cal_info -> datetime , $cal_info -> edatetime , $cal_info -> participants , $cal_info -> groups , $cal_info -> owner , $cal_info -> id );
2000-11-24 23:51:43 +01:00
} else {
$cal_info = $phpgw -> common -> appsession ();
2000-08-18 05:24:22 +02:00
}
2000-12-09 05:08:54 +01:00
if ( $datetime_check ) {
Header ( " Location: " . $phpgw -> link ( " edit_entry.php " , " readsess= " . $cal_info -> id . " &cd= " . $datetime_check ));
} elseif ( $overlapping_events ) {
2000-11-24 23:51:43 +01:00
$phpgw -> common -> phpgw_header ();
$phpgw -> common -> navbar ();
$phpgw -> template -> set_file ( array ( " overlap " => " overlap.tpl " ,
" form_button " => " form_button_script.tpl " ));
$phpgw -> template -> set_block ( " overlap " , " form_button " );
2000-08-18 05:24:22 +02:00
2000-11-24 23:51:43 +01:00
$phpgw -> template -> set_var ( " color " , $phpgw_info [ " theme " ][ " bg_text " ]);
2000-08-18 05:24:22 +02:00
2000-11-24 23:51:43 +01:00
$calendar_overlaps = $phpgw -> calendar -> getevent ( $overlapping_events );
2000-11-23 14:28:37 +01:00
2000-12-14 03:37:58 +01:00
$format = $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " dateformat " ] . " - " ;
2000-12-04 02:11:53 +01:00
if ( $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " timeformat " ] == " 12 " ) {
2000-12-14 03:37:58 +01:00
$format .= " h:i:s a " ;
2000-12-04 02:11:53 +01:00
} else {
2000-12-14 03:37:58 +01:00
$format .= " H:i:s " ;
2000-12-04 02:11:53 +01:00
}
2000-11-24 23:51:43 +01:00
$overlap = " " ;
for ( $i = 0 ; $i < count ( $calendar_overlaps ); $i ++ ) {
$cal_over = $calendar_overlaps [ $i ];
if ( $cal_over ) {
$overlap .= " <li> " ;
if ( strtoupper ( $cal_over -> access ) == " PRIVATE " )
$overlap .= " (PRIVATE) " ;
else
$overlap .= $phpgw -> calendar -> link_to_entry ( $cal_over -> id , " circle.gif " , $cal_over -> name );
2000-12-14 03:37:58 +01:00
$overlap .= " ( " . $phpgw -> common -> show_date ( $cal_over -> datetime ) . " - " . $phpgw -> common -> show_date ( $cal_over -> edatetime ) . " )<br> " ;
2000-11-24 23:51:43 +01:00
}
}
if ( strlen ( $overlap )) {
2000-12-14 03:37:58 +01:00
$phpgw -> template -> set_var ( " overlap_text " , lang ( " Your suggested time of <B> x - x </B> conflicts with the following existing calendar entries: " , date ( $format , $cal_info -> datetime ), date ( $format , $cal_info -> edatetime )));
2000-11-24 23:51:43 +01:00
$phpgw -> template -> set_var ( " overlap_list " , $overlap );
} else {
$phpgw -> template -> set_var ( " overlap_text " , " " );
$phpgw -> template -> set_var ( " overlap_list " , " " );
}
2000-08-18 05:24:22 +02:00
2000-11-24 23:51:43 +01:00
$phpgw -> template -> set_var ( " action_url_button " , $phpgw -> link ( " " , " readsess= " . $cal_info -> id ));
$phpgw -> template -> set_var ( " action_text_button " , lang ( " Ignore Conflict " ));
$phpgw -> template -> set_var ( " action_confirm_button " , " " );
$phpgw -> template -> parse ( " resubmit_button " , " form_button " );
$phpgw -> template -> set_var ( " action_url_button " , $phpgw -> link ( " edit_entry.php " , " readsess= " . $cal_info -> id ));
2000-11-25 03:24:43 +01:00
$phpgw -> template -> set_var ( " action_text_button " , lang ( " Re-Edit Event " ));
2000-11-24 23:51:43 +01:00
$phpgw -> template -> set_var ( " action_confirm_button " , " " );
$phpgw -> template -> parse ( " reedit_button " , " form_button " );
$phpgw -> template -> pparse ( " out " , " overlap " );
} else {
$phpgw -> calendar -> add ( $cal_info , $cal_info -> id );
Header ( " Location: " . $phpgw -> link ( " index.php " , " year= $year &month= $month &cd=14 " ));
}
$phpgw -> common -> phpgw_footer ();
2000-10-09 21:09:44 +02:00
?>
2000-08-18 05:24:22 +02:00