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-18 23:33:10 +01:00
$phpgw_flags = Array (
2001-02-26 13:23:48 +01:00
'currentapp' => 'calendar' ,
'enable_nextmatchs_class' => True ,
'noheader' => True ,
'nonavbar' => True ,
'noappheader' => True ,
'noappfooter' => True
2001-02-18 23:33:10 +01:00
);
$phpgw_info [ 'flags' ] = $phpgw_flags ;
include ( '../header.inc.php' );
$sb = CreateObject ( 'phpgwapi.sbox' );
$cal_info = CreateObject ( 'calendar.calendar_item' );
function display_item ( $field , $data )
{
global $p ;
$p -> set_var ( 'field' , $field );
$p -> set_var ( 'data' , $data );
$p -> parse ( 'output' , 'list' , True );
}
if ( $phpgw_info [ 'user' ][ 'preferences' ][ 'common' ][ 'timeformat' ] == '12' )
{
$hourformat = 'h' ;
}
else
{
$hourformat = 'H' ;
}
if ( $id > 0 )
{
2001-03-09 13:23:12 +01:00
$cal_stream = $phpgw -> calendar -> open ( 'INBOX' , intval ( $cal_info -> owner ), '' );
$event = $phpgw -> calendar -> fetch_event ( $cal_stream , intval ( $id ));
2001-02-18 23:33:10 +01:00
$can_edit = False ;
2001-03-09 13:23:12 +01:00
if (( $event -> owner == $owner ) && ( $phpgw -> calendar -> check_perms ( PHPGW_ACL_EDIT ) == True ))
2001-02-18 23:33:10 +01:00
{
2001-03-09 13:23:12 +01:00
if ( $event -> public != True )
2001-03-02 05:19:58 +01:00
{
if ( $phpgw -> calendar -> check_perms ( 16 ) == True )
{
$can_edit = True ;
}
}
else
{
$can_edit = True ;
}
2001-02-18 23:33:10 +01:00
}
if ( $can_edit == False )
{
2001-03-09 13:23:12 +01:00
header ( 'Location: ' . $phpgw -> link ( '/' . $phpgw_info [ 'flags' ][ 'currentapp' ] . '/view.php' , 'id=' . $id . '&owner=' . $owner ));
2001-02-18 23:33:10 +01:00
}
2001-03-09 13:23:12 +01:00
if ( $event -> rpt_end_use == False )
2001-02-18 23:33:10 +01:00
{
2001-03-09 13:23:12 +01:00
$event -> rpt_end = mktime ( $event -> start -> hour , $event -> start -> min , $event -> start -> sec , $event -> start -> month , $event -> start -> mday , $event -> start -> year ) + 86400 ;
2001-02-18 23:33:10 +01:00
}
}
elseif ( isset ( $readsess ))
{
2001-03-09 13:23:12 +01:00
$event = $phpgw -> session -> appsession ( 'entry' , 'calendar' );
2001-02-18 23:33:10 +01:00
2001-03-09 13:23:12 +01:00
if ( $event -> owner == 0 )
2001-02-18 23:33:10 +01:00
{
2001-03-09 13:23:12 +01:00
$event -> owner = $owner ;
2001-02-18 23:33:10 +01:00
}
$can_edit = True ;
}
else
{
if ( $phpgw -> calendar -> check_perms ( PHPGW_ACL_ADD ) == False )
{
2001-03-09 13:23:12 +01:00
header ( 'Location: ' . $phpgw -> link ( '/' . $phpgw_info [ 'flags' ][ 'currentapp' ] . '/view.php' , 'id=' . $id . '&owner=' . $owner ));
2001-02-18 23:33:10 +01:00
}
2001-03-09 13:23:12 +01:00
$cal_stream = $phpgw -> calendar -> open ( 'INBOX' , intval ( $cal_info -> owner ), '' );
$phpgw -> calendar -> event_init ( $cal_stream );
$phpgw -> calendar -> event -> id = 0 ;
2001-02-18 23:33:10 +01:00
$can_edit = True ;
if ( ! isset ( $hour ))
{
$thishour = 0 ;
}
else
{
$thishour = ( int ) $hour ;
}
if ( ! isset ( $minute ))
{
$thisminute = 00 ;
}
else
{
$thisminute = ( int ) $minute ;
}
2001-03-09 13:23:12 +01:00
$phpgw -> calendar -> event_set_start ( $cal_stream , $thisyear , $thismonth , $thisday , $thishour , $this -> minute , 0 );
$phpgw -> calendar -> event_set_end ( $cal_stream , $thisyear , $thismonth , $thisday , $thishour , $this -> minute , 0 );
$phpgw -> calendar -> event_set_title ( $cal_stream , '' );
$phpgw -> calendar -> event_set_description ( $cal_stream , '' );
$phpgw -> calendar -> event -> priority = 2 ;
2001-02-18 23:33:10 +01:00
2001-03-09 13:23:12 +01:00
$phpgw -> calendar -> event_set_recur_none ( $cal_stream );
2001-02-18 23:33:10 +01:00
}
$phpgw -> common -> phpgw_header ();
echo parse_navbar ();
$p = CreateObject ( 'phpgwapi.Template' , $phpgw -> common -> get_tpl_dir ( 'calendar' ));
$templates = Array (
2001-03-09 13:23:12 +01:00
'edit_entry_begin' => 'edit.tpl' ,
'list' => 'list.tpl' ,
'hr' => 'hr.tpl' ,
'edit_entry_end' => 'edit.tpl' ,
'form_button' => 'form_button_script.tpl'
2001-02-18 23:33:10 +01:00
);
$p -> set_file ( $templates );
if ( $id > 0 )
{
$action = lang ( 'Calendar - Edit' );
}
else
{
$action = lang ( 'Calendar - Add' );
}
2001-03-09 13:23:12 +01:00
$common_hidden = '<input type="hidden" name="cal[id]" value="' . $phpgw -> calendar -> event -> id . '">' . " \n "
. '<input type="hidden" name="cal[owner]" value="' . $phpgw -> calendar -> event -> owner . '">' . " \n "
2001-02-18 23:33:10 +01:00
. '<input type="hidden" name="owner" value="' . $owner . '">' . " \n " ;
$vars = Array (
'bg_color' => $phpgw_info [ 'theme' ][ 'bg_text' ],
'calendar_action' => $action ,
2001-03-09 13:23:12 +01:00
'action_url' => $phpgw -> link ( '/' . $phpgw_info [ 'flags' ][ 'currentapp' ] . '/edit_entry_handler.php' ),
2001-02-18 23:33:10 +01:00
'common_hidden' => $common_hidden
);
$p -> set_var ( $vars );
$p -> parse ( 'out' , 'edit_entry_begin' );
2000-08-18 05:24:22 +02:00
2000-11-26 21:10:35 +01:00
// Brief Description
2001-03-09 13:23:12 +01:00
display_item ( lang ( 'Brief Description' ), '<input name="cal[name]" size="25" value="' . $phpgw -> calendar -> event -> title . '">' );
2000-11-26 21:10:35 +01:00
// Full Description
2001-03-09 13:23:12 +01:00
display_item ( lang ( 'Full Description' ), '<textarea name="cal[description]" rows="5" cols="40" wrap="virtual">' . $phpgw -> calendar -> event -> description . '</textarea>' );
2000-08-18 05:24:22 +02:00
2000-11-26 21:10:35 +01:00
// Date
2001-03-09 13:23:12 +01:00
$day_html = $sb -> getDays ( 'cal[day]' , intval ( $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> datetime , 'd' )));
$month_html = $sb -> getMonthText ( 'cal[month]' , intval ( $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> datetime , 'n' )));
$year_html = $sb -> getYears ( 'cal[year]' , intval ( $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> datetime , 'Y' )), intval ( $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> datetime , 'Y' )));
2001-02-18 23:33:10 +01:00
display_item ( lang ( 'Start Date' ), $phpgw -> common -> dateformatorder ( $year_html , $month_html , $day_html ));
2000-08-18 05:24:22 +02:00
2000-11-26 21:10:35 +01:00
// Time
2001-02-18 23:33:10 +01:00
$amsel = ' checked' ; $pmsel = '' ;
if ( $phpgw_info [ 'user' ][ 'preferences' ][ 'common' ][ 'timeformat' ] == '12' )
{
2001-03-09 13:23:12 +01:00
if ( $phpgw -> calendar -> event -> start -> hour >= 12 )
2001-02-18 23:33:10 +01:00
{
$amsel = '' ; $pmsel = ' checked' ;
}
}
2001-03-09 13:23:12 +01:00
$str = '<input name="cal[hour]" size="2" VALUE="' . $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> datetime , $hourformat ) . '" maxlength="2">:<input name="cal[minute]" size="2" value="' . $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> datetime , 'i' ) . '" maxlength="2">' ;
2001-02-18 23:33:10 +01:00
if ( $phpgw_info [ 'user' ][ 'preferences' ][ 'common' ][ 'timeformat' ] == '12' )
{
$str .= '<input type="radio" name="cal[ampm]" value="am"' . $amsel . '>am' ;
$str .= '<input type="radio" name="cal[ampm]" value="pm"' . $pmsel . '>pm' ;
}
2000-12-04 02:11:53 +01:00
2001-02-18 23:33:10 +01:00
display_item ( lang ( 'Start Time' ), $str );
2000-12-04 02:11:53 +01:00
2001-02-18 23:33:10 +01:00
// End Date
2001-03-09 13:23:12 +01:00
$day_html = $sb -> getDays ( 'cal[end_day]' , intval ( $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> edatetime , 'd' )));
$month_html = $sb -> getMonthText ( 'cal[end_month]' , intval ( $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> edatetime , 'n' )));
$year_html = $sb -> getYears ( 'cal[end_year]' , intval ( $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> edatetime , 'Y' )), intval ( $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> edatetime , 'Y' )));
2001-02-18 23:33:10 +01:00
display_item ( lang ( 'End Date' ), $phpgw -> common -> dateformatorder ( $year_html , $month_html , $day_html ));
2000-12-04 02:11:53 +01:00
// End Time
2001-02-18 23:33:10 +01:00
$amsel = ' checked' ; $pmsel = '' ;
if ( $phpgw_info [ 'user' ][ 'preferences' ][ 'common' ][ 'timeformat' ] == '12' )
{
2001-03-09 13:23:12 +01:00
if ( $phpgw -> calendar -> event -> end -> hour >= 12 )
2001-02-18 23:33:10 +01:00
{
$amsel = '' ; $pmsel = ' checked' ;
}
}
2001-03-09 13:23:12 +01:00
$str = '<input name="cal[end_hour]" size="2" VALUE="' . $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> edatetime , $hourformat ) . '" maxlength="2">:<input name="cal[end_minute]" size="2" value="' . $phpgw -> common -> show_date ( $phpgw -> calendar -> event -> edatetime , 'i' ) . '" maxlength="2">' ;
2001-02-18 23:33:10 +01:00
if ( $phpgw_info [ 'user' ][ 'preferences' ][ 'common' ][ 'timeformat' ] == '12' )
{
$str .= '<input type="radio" name="cal[end_ampm]" value="am"' . $amsel . '>am' ;
$str .= '<input type="radio" name="cal[end_ampm]" value="pm"' . $pmsel . '>pm' ;
}
2000-12-04 02:11:53 +01:00
2000-12-23 17:33:22 +01:00
display_item ( lang ( " End Time " ), $str );
2000-11-23 02:37:50 +01:00
2000-11-26 21:10:35 +01:00
// Priority
2001-03-09 13:23:12 +01:00
display_item ( lang ( 'Priority' ), $sb -> getPriority ( 'cal[priority]' , $phpgw -> calendar -> event -> priority ));
2000-11-23 02:37:50 +01:00
2000-12-23 17:33:22 +01:00
// Access
2001-02-18 23:33:10 +01:00
$str = '<input type="checkbox" name="cal[access]" value="private"' ;
2001-03-09 13:23:12 +01:00
if ( $phpgw -> calendar -> event -> public != True )
2001-02-18 23:33:10 +01:00
{
$str .= ' checked' ;
}
$str .= '>' ;
display_item ( lang ( 'Private' ), $str );
2000-11-23 02:37:50 +01:00
2000-11-26 21:10:35 +01:00
// Groups
2001-02-18 23:33:10 +01:00
// $user_groups = $phpgw->accounts->memberships(intval($owner));
// display_item(lang('Groups'),$sb->getGroups($user_groups,$cal_info->groups,'cal[groups][]'));
2000-11-23 02:37:50 +01:00
2000-11-26 19:03:20 +01:00
// Participants
2001-02-18 23:33:10 +01:00
// Start Here.....
$accounts = $phpgw -> acl -> get_ids_for_location ( 'run' , 1 , 'calendar' );
$users = Array ();
for ( $i = 0 ; $i < count ( $accounts ); $i ++ )
{
$user = $accounts [ $i ];
if ( $user != $owner && ! isset ( $users [ $user ]))
{
$users [ $user ] = $phpgw -> common -> grab_owner_name ( $user );
if ( $phpgw -> accounts -> get_type ( $user ) == 'g' )
{
$group_members = $phpgw -> acl -> get_ids_for_location ( $user , 1 , 'phpgw_group' );
if ( $group_members != False )
{
for ( $j = 0 ; $j < count ( $group_members ); $j ++ )
{
if ( $group_members [ $j ] != $owner && ! isset ( $users [ $group_members [ $j ]]))
{
$users [ $group_members [ $j ]] = $phpgw -> common -> grab_owner_name ( $group_members [ $j ]);
}
}
}
}
}
}
if ( $num_users > 50 )
{
$size = 15 ;
}
elseif ( $num_users > 5 )
{
$size = 5 ;
}
else
{
$size = $num_users ;
}
$str = " \n " . ' <select name="cal[participants][]" multiple size="5">' . " \n " ;
2001-03-09 13:23:12 +01:00
for ( $l = 0 ; $l < count ( $phpgw -> calendar -> event -> participants ); $l ++ )
2001-02-18 23:33:10 +01:00
{
2001-03-09 13:23:12 +01:00
$parts [ $phpgw -> calendar -> event -> participants [ $l ]] = ' selected' ;
2001-02-18 23:33:10 +01:00
}
2001-02-11 03:38:50 +01:00
2001-02-18 23:33:10 +01:00
@ asort ( $users );
@ reset ( $users );
while ( $user = each ( $users ))
{
if ( $user [ 0 ] != $owner && $phpgw -> accounts -> exists ( $user [ 0 ]) == True )
{
$str .= ' <option value="' . $user [ 0 ] . '"' . $parts [ $user [ 0 ]] . '>(' . $phpgw -> accounts -> get_type ( $user [ 0 ]) . ') ' . $user [ 1 ] . '</option>' . " \n " ;
}
}
$str .= ' </select>' ;
display_item ( lang ( 'Participants' ), $str );
2000-11-23 02:37:50 +01:00
2000-11-26 19:03:20 +01:00
// I Participate
2001-02-18 23:33:10 +01:00
$participate = False ;
if ( $id )
{
2001-03-09 13:23:12 +01:00
for ( $i = 0 ; $i < count ( $phpgw -> calendar -> event -> participants ); $i ++ )
2001-02-18 23:33:10 +01:00
{
2001-03-09 13:23:12 +01:00
if ( $phpgw -> calendar -> event -> participants [ $i ] == $owner )
2001-02-18 23:33:10 +01:00
{
$participate = True ;
}
}
2000-11-26 19:03:20 +01:00
}
2001-02-18 23:33:10 +01:00
$str = '<input type="checkbox" name="cal[participants][]" value="' . $owner . '"' ;
if ((( $id > 0 ) && ( $participate == True )) || ! isset ( $id ))
{
$str .= ' checked' ;
}
$str .= '>' ;
display_item ( $phpgw -> common -> grab_owner_name ( $owner ) . ' ' . lang ( 'Participates' ), $str );
2000-11-26 19:03:20 +01:00
// Repeat Type
2001-02-18 23:33:10 +01:00
$p -> set_var ( 'hr_text' , '<hr>' );
$p -> parse ( 'output' , 'hr' , True );
$p -> set_var ( 'hr_text' , '<center><b>' . lang ( 'Repeating Event Information' ) . '</b></center><br>' );
$p -> parse ( 'output' , 'hr' , True );
$str = '<select name="cal[rpt_type]">' ;
2001-03-09 13:23:12 +01:00
$rpt_type = Array (
RECUR_NONE ,
RECUR_DAILY ,
RECUR_WEEKLY ,
RECUR_MONTHLY_WDAY ,
RECUR_MONTHLY_MDAY ,
RECUR_YEARLY
2001-02-18 23:33:10 +01:00
);
$rpt_type_out = Array (
2001-03-09 13:23:12 +01:00
RECUR_NONE => 'None' ,
RECUR_DAILY => 'Daily' ,
RECUR_WEEKLY => 'Weekly' ,
RECUR_MONTHLY_WDAY => 'Monthly (by day)' ,
RECUR_MONTHLY_MDAY => 'Monthly (by date)' ,
RECUR_YEARLY => 'Yearly'
2001-02-18 23:33:10 +01:00
);
2001-03-09 13:23:12 +01:00
for ( $l = 0 ; $l < count ( $rpt_type ); $l ++ )
2001-02-18 23:33:10 +01:00
{
2001-03-09 13:23:12 +01:00
$str .= '<option value="' . $rpt_type [ $l ] . '"' ;
if ( $phpgw -> calendar -> event -> recur_type == $rpt_type [ $l ])
2001-02-18 23:33:10 +01:00
{
$str .= ' selected' ;
}
2001-03-09 13:23:12 +01:00
$str .= '>' . lang ( $rpt_type_out [ $rpt_type [ $l ]]) . '</option>' ;
2001-02-18 23:33:10 +01:00
}
$str .= '</select>' ;
display_item ( lang ( 'Repeat Type' ), $str );
$p -> set_var ( 'field' , lang ( 'Repeat End Date' ));
$str = '<input type="checkbox" name="cal[rpt_use_end]" value="y"' ;
2001-03-09 13:23:12 +01:00
if ( $phpgw -> calendar -> event -> recur_enddate -> year != 0 && $phpgw -> calendar -> event -> recur_enddate -> month != 0 && $phpgw -> calendar -> event -> recur_enddate -> mday != 0 )
2001-02-18 23:33:10 +01:00
{
$str .= ' checked' ;
}
$str .= '>' . lang ( 'Use End Date' ) . ' ' ;
2001-03-09 13:23:12 +01:00
$recur_end = mktime ( $phpgw -> calendar -> recur_enddate -> hour , $phpgw -> calendar -> recur_enddate -> min , $phpgw -> calendar -> recur_enddate -> sec , $phpgw -> calendar -> recur_enddate -> month , $phpgw -> calendar -> recur_enddate -> mday , $phpgw -> calendar -> recur_enddate -> year );
$recur_end -= (( 60 * 60 ) * intval ( $phpgw_info [ 'user' ][ 'preferences' ][ 'common' ][ 'tz_offset' ]));
$day_html = $sb -> getDays ( 'cal[rpt_day]' , intval ( $phpgw -> common -> show_date ( $recur_end , 'd' )));
$month_html = $sb -> getMonthText ( 'cal[rpt_month]' , intval ( $phpgw -> common -> show_date ( $recur_end , 'n' )));
$year_html = $sb -> getYears ( 'cal[rpt_year]' , intval ( $phpgw -> common -> show_date ( $recur_end , 'Y' )), intval ( $phpgw -> common -> show_date ( $recur_end , 'Y' )));
2001-02-18 23:33:10 +01:00
$str .= $phpgw -> common -> dateformatorder ( $year_html , $month_html , $day_html );
display_item ( lang ( 'Repeat End Date' ), $str );
2001-03-09 13:23:12 +01:00
$str = '<input type="checkbox" name="cal[rpt_sun]" value="' . M_SUNDAY . '"' . (( $phpgw -> calendar -> event -> recur_data & M_SUNDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Sunday' ) . ' ' ;
$str .= '<input type="checkbox" name="cal[rpt_mon]" value="' . M_MONDAY . '"' . (( $phpgw -> calendar -> event -> recur_data & M_MONDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Monday' ) . ' ' ;
$str .= '<input type="checkbox" name="cal[rpt_tue]" value="' . M_TUESDAY . '"' . (( $phpgw -> calendar -> event -> recur_data & M_TUESDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Tuesday' ) . ' ' ;
$str .= '<input type="checkbox" name="cal[rpt_wed]" value="' . M_WEDNESDAY . '"' . (( $phpgw -> calendar -> event -> recur_data & M_WEDNESDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Wednesday' ) . ' ' ;
$str .= '<input type="checkbox" name="cal[rpt_thu]" value="' . M_THURSDAY . '"' . (( $phpgw -> calendar -> event -> recur_data & M_THURSDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Thursday' ) . ' ' ;
$str .= '<input type="checkbox" name="cal[rpt_fri]" value="' . M_FRIDAY . '"' . (( $phpgw -> calendar -> event -> recur_data & M_FRIDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Friday' ) . ' ' ;
$str .= '<input type="checkbox" name="cal[rpt_sat]" value="' . M_SATURDAY . '"' . (( $phpgw -> calendar -> event -> recur_data & M_SATURDAY ) ? ' checked' : '' ) . '> ' . lang ( 'Saturday' ) . ' ' ;
2001-02-18 23:33:10 +01:00
display_item ( lang ( 'Repeat Day' ) . '<br>' . lang ( '(for weekly)' ), $str );
2001-03-09 13:23:12 +01:00
display_item ( lang ( 'Frequency' ), '<input name="cal[rpt_freq]" size="4" maxlength="4" value="' . $phpgw -> calendar -> event -> recur_interval . '">' );
2001-02-18 23:33:10 +01:00
$p -> set_var ( 'submit_button' , lang ( 'Submit' ));
if ( $id > 0 )
{
2001-03-09 13:23:12 +01:00
$p -> set_var ( 'action_url_button' , $phpgw -> link ( '/' . $phpgw_info [ 'flags' ][ 'currentapp' ] . '/delete.php' , 'id=' . $id ));
2001-02-18 23:33:10 +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' );
$p -> pparse ( 'out' , 'edit_entry_end' );
}
else
{
$p -> set_var ( 'delete_button' , '' );
$p -> pparse ( 'out' , 'edit_entry_end' );
}
$phpgw -> common -> phpgw_footer ();
2000-08-18 05:24:22 +02:00
?>