0 ) { $id = 0; } $external_users = ""; $participants = array (); if ( ! empty ( $id ) && $id > 0 ) { // first see who has access to edit this entry if ( $is_admin || $is_assistant || $is_nonuser_admin) { $can_edit = true; } else { $can_edit = false; if ( $readonly == "N" || $is_admin ) { $sql = "SELECT webcal_entry.cal_id FROM webcal_entry, " . "webcal_entry_user WHERE webcal_entry.cal_id = " . "webcal_entry_user.cal_id AND webcal_entry.cal_id = $id " . "AND (webcal_entry.cal_create_by = '$login' " . "OR webcal_entry_user.cal_login = '$login')"; $res = dbi_query ( $sql ); if ( $res ) { $row = dbi_fetch_row ( $res ); if ( $row && $row[0] > 0 ) $can_edit = true; dbi_free_result ( $res ); } } } $sql = "SELECT cal_create_by, cal_date, cal_time, cal_mod_date, " . "cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, " . "cal_name, cal_description FROM webcal_entry WHERE cal_id = " . $id; $res = dbi_query ( $sql ); if ( $res ) { $row = dbi_fetch_row ( $res ); if ( ! empty ( $override ) ) { // Leave $cal_date to what was set in URL with date=YYYYMMDD } else { $cal_date = $row[1]; } $create_by = $row[0]; $year = (int) ( $cal_date / 10000 ); $month = ( $cal_date / 100 ) % 100; $day = $cal_date % 100; $time = $row[2]; if ( $time >= 0 ) { /* -1 = no time specified */ $time += $TZ_OFFSET * 10000; if ( $time > 240000 ) { $time -= 240000; $gmt = mktime ( 3, 0, 0, $month, $day, $year ); $gmt += $ONE_DAY; $month = date ( "m", $gmt ); $day = date ( "d", $gmt ); $year = date ( "Y", $gmt ); } else if ( $time < 0 ) { $time += 240000; $gmt = mktime ( 3, 0, 0, $month, $day, $year ); $gmt -= $ONE_DAY; $month = date ( "m", $gmt ); $day = date ( "d", $gmt ); $year = date ( "Y", $gmt ); } // Set alterted date $cal_date = sprintf("%04d%02d%02d",$year,$month,$day); } if ( $time >= 0 ) { $hour = floor($time / 10000); $minute = ( $time / 100 ) % 100; $duration = $row[5]; } else { $duration = ""; } $priority = $row[6]; $type = $row[7]; $access = $row[8]; $name = $row[9]; $description = $row[10]; // check for repeating event info... // but not if we are overriding a single entry of an already repeating // event... confusing, eh? if ( ! empty ( $override ) ) { $rpt_type = "none"; $rpt_end = 0; $rpt_end_date = $cal_date; $rpt_freq = 1; $rpt_days = "nnnnnnn"; $rpt_sun = $rpt_mon = $rpt_tue = $rpt_wed = $rpt_thu = $rpt_fri = $rpt_sat = false; } else { $res = dbi_query ( "SELECT cal_id, cal_type, cal_end, " . "cal_frequency, cal_days FROM webcal_entry_repeats " . "WHERE cal_id = $id" ); if ( $res ) { if ( $row = dbi_fetch_row ( $res ) ) { $rpt_type = $row[1]; if ( $row[2] > 0 ) $rpt_end = date_to_epoch ( $row[2] ); else $rpt_end = 0; $rpt_end_date = $row[2]; $rpt_freq = $row[3]; $rpt_days = $row[4]; $rpt_sun = ( substr ( $rpt_days, 0, 1 ) == 'y' ); $rpt_mon = ( substr ( $rpt_days, 1, 1 ) == 'y' ); $rpt_tue = ( substr ( $rpt_days, 2, 1 ) == 'y' ); $rpt_wed = ( substr ( $rpt_days, 3, 1 ) == 'y' ); $rpt_thu = ( substr ( $rpt_days, 4, 1 ) == 'y' ); $rpt_fri = ( substr ( $rpt_days, 5, 1 ) == 'y' ); $rpt_sat = ( substr ( $rpt_days, 6, 1 ) == 'y' ); } } } } $sql = "SELECT cal_login, cal_category FROM webcal_entry_user WHERE cal_id = $id"; $res = dbi_query ( $sql ); if ( $res ) { while ( $row = dbi_fetch_row ( $res ) ) { if ( ! $is_secretary || $login != $row[0] ) $participants[$row[0]] = 1; if ($login == $row[0]) $cat_id = $row[1]; } } if ( ! empty ( $allow_external_users ) && $allow_external_users == "Y" ) { $external_users = event_get_external_users ( $id ); } } else { $id = 0; // to avoid warnings below about use of undefined var if ( empty ( $hour ) ) $time = -1; else $time = $hour * 100; if ( $readonly == "N" || $is_admin ) $can_edit = true; if ( ! empty ( $defusers ) ) { $tmp_ar = explode ( ",", $defusers ); for ( $i = 0; $i < count ( $tmp_ar ); $i++ ) { $participants[$tmp_ar[$i]] = 1; } } } if ( ! empty ( $year ) && $year ) $thisyear = $year; if ( ! empty ( $month ) && $month ) $thismonth = $month; if ( ! empty ( $day ) && $day ) $thisday = $day; if ( empty ( $rpt_type ) || ! $rpt_type ) $rpt_type = "none"; // avoid error for using undefined vars if ( empty ( $hour ) ) $hour = -1; if ( empty ( $duration ) ) $duration = 0; if ( $duration == ( 24 * 60 ) ) { $hour = $minute = $duration = ""; $allday = "Y"; } else $allday = "N"; if ( empty ( $name ) ) $name = ""; if ( empty ( $description ) ) $description = ""; if ( empty ( $priority ) ) $priority = 0; if ( empty ( $access ) ) $access = ""; if ( empty ( $rpt_freq ) ) $rpt_freq = 0; if ( empty ( $rpt_end_date ) ) $rpt_end_date = 0; if ( ( empty ( $year ) || ! $year ) && ( empty ( $month ) || ! $month ) && ( ! empty ( $date ) && strlen ( $date ) ) ) { $thisyear = $year = substr ( $date, 0, 4 ); $thismonth = $month = substr ( $date, 4, 2 ); $thisday = $day = substr ( $date, 6, 2 ); $cal_date = $date; } else { if ( empty ( $cal_date ) ) $cal_date = date ( "Ymd" ); } $thisdate = sprintf ( "%04d%02d%02d", $thisyear, $thismonth, $thisday ); if ( empty ( $cal_date ) || ! $cal_date ) $cal_date = $thisdate; $BodyX = 'xonload="timetype_handler()"'; $INC = array('js/popups.php','js/edit_entry.php'); print_header($INC,'',$BodyX); ?>
0 && ( $login == $create_by || $single_user == "Y" || $is_admin ) ) { ?> ');">