3 * $Id: view_entry.php,v 1.68.2.2 2005/08/10 14:35:15 cknudsen Exp $
6 * Presents page to view an event with links to edit, delete
7 * confirm, copy, add event
10 * id (*) - cal_id of requested event
11 * date - yyyymmdd format of requested event
12 * user - user to display
15 include_once $gfplugins.'webcalendar/www/includes/init.php';
16 include_once $gfplugins.'webcalendar/www/includes/site_extras.php';
18 // make sure this user is allowed to look at this calendar.
22 if ( $is_admin || $is_nonuser_admin || $is_assistant ) {
28 if ( empty ( $id ) || $id <= 0 || ! is_numeric ( $id ) ) {
29 $error = translate ( "Invalid entry id" ) . ".";
32 if ( empty ( $error ) ) {
33 // is this user a participant or the creator of the event?
34 $sql = "SELECT webcal_entry.cal_id FROM webcal_entry, " .
35 "webcal_entry_user WHERE webcal_entry.cal_id = " .
36 "webcal_entry_user.cal_id AND webcal_entry.cal_id = $id " .
37 "AND (webcal_entry.cal_create_by = '$login' " .
38 "OR webcal_entry_user.cal_login = '$login')";
39 $res = dbi_query ( $sql );
41 $row = dbi_fetch_row ( $res );
42 if ( $row && $row[0] > 0 ) {
46 dbi_free_result ( $res );
49 if ( ($login != "__public__") && ($public_access_others == "Y") ) {
55 // if not a participant in the event, must be allowed to look at
56 // other user's calendar.
57 if ( $login == "__public__" ) {
58 if ( $public_access_others == "Y" ) {
62 if ( $allow_view_other == "Y" ) {
66 // If $check_group is true now, it means this user can look at the
67 // event only if they are in the same group as some of the people in
69 // This gets kind of tricky. If there is a participant from a different
70 // group, do we still show it? For now, the answer is no.
71 // This could be configurable somehow, but how many lines of text would
72 // it need in the admin page to describe this scenario? Would confuse
74 // In summary, make sure at least one event participant is in one of
75 // this user's groups.
76 $my_users = get_my_users ();
77 if ( is_array ( $my_users ) ) {
78 $sql = "SELECT webcal_entry.cal_id FROM webcal_entry, " .
79 "webcal_entry_user WHERE webcal_entry.cal_id = " .
80 "webcal_entry_user.cal_id AND webcal_entry.cal_id = $id " .
81 "AND webcal_entry_user.cal_login IN ( ";
82 for ( $i = 0; $i < count ( $my_users ); $i++ ) {
86 $sql .= "'" . $my_users[$i]['cal_login'] . "'";
89 $res = dbi_query ( $sql );
91 $row = dbi_fetch_row ( $res );
92 if ( $row && $row[0] > 0 ) {
95 dbi_free_result ( $res );
98 // If we didn't indicate we need to check groups, then this user
99 // can't view this event.
100 if ( ! $check_group ) {
106 // If they still cannot view, make sure they are not looking at a nonuser
107 // calendar event where the nonuser is the _only_ participant.
108 if ( empty ( $error ) && ! $can_view && ! empty ( $nonuser_enabled ) &&
109 $nonuser_enabled == 'Y' ) {
110 $nonusers = get_nonuser_cals ();
111 $nonuser_lookup = array ();
112 for ( $i = 0; $i < count ( $nonusers ); $i++ ) {
113 $nonuser_lookup[$nonusers[$i]['cal_login']] = 1;
115 $sql = "SELECT cal_login FROM webcal_entry_user " .
116 "WHERE cal_id = $id AND cal_status in ('A','W')";
117 $res = dbi_query ( $sql );
118 $found_nonuser_cal = false;
119 $found_reg_user = false;
121 while ( $row = dbi_fetch_row ( $res ) ) {
122 if ( ! empty ( $nonuser_lookup[$row[0]] ) ) {
123 $found_nonuser_cal = true;
125 $found_reg_user = true;
128 dbi_free_result ( $res );
130 // Does this event contain only nonuser calendars as participants?
131 // If so, then grant access.
132 if ( $found_nonuser_cal && ! $found_reg_user ) {
137 if ( empty ( $error ) && ! $can_view ) {
138 $error = translate ( "You are not authorized" );
141 if ( ! empty ( $year ) ) {
144 if ( ! empty ( $month ) ) {
147 $pri[1] = translate("Low");
148 $pri[2] = translate("Medium");
149 $pri[3] = translate("High");
153 // Make sure this is not a continuation event.
154 // If it is, redirect the user to the original event.
156 if ( empty ( $error ) ) {
157 $res = dbi_query ( "SELECT cal_ext_for_id FROM webcal_entry " .
158 "WHERE cal_id = $id" );
160 if ( $row = dbi_fetch_row ( $res ) ) {
163 dbi_free_result ( $res );
165 // db error... ignore it, I guess.
169 $url = "view_entry.php?id=$ext_id";
171 $url .= "&date=$date";
174 $url .= "&user=$user";
176 if ( $cat_id != "" ) {
177 $url .= "&cat_id=$cat_id";
179 do_redirect ( $url );
184 if ( ! empty ( $error ) ) {
185 echo "<h2>" . translate ( "Error" ) .
188 echo "</body>\n</html>";
191 // Try to determine the event status.
194 if ( ! empty ( $user ) && $login != $user ) {
195 // If viewing another user's calendar, check the status of the
196 // event on their calendar (to see if it's deleted).
197 $sql = "SELECT cal_status FROM webcal_entry_user " .
198 "WHERE cal_login = '$user' AND cal_id = $id";
199 $res = dbi_query ( $sql );
201 if ( $row = dbi_fetch_row ( $res ) ) {
202 $event_status = $row[0];
204 dbi_free_result ( $res );
207 // We are viewing event on user's own calendar, so check the
208 // status on their own calendar.
209 $sql = "SELECT cal_id, cal_status FROM webcal_entry_user " .
210 "WHERE cal_login = '$login' AND cal_id = $id";
211 $res = dbi_query ( $sql );
213 $row = dbi_fetch_row ( $res );
214 $event_status = $row[1];
215 dbi_free_result ( $res );
219 // At this point, if we don't have the event status, then either
220 // this user is not viewing an event from his own calendar and not
221 // viewing an event from someone else's calendar.
222 // They probably got here from the search results page (or possibly
223 // by hand typing in the URL.)
224 // Check to make sure that it hasn't been deleted from everyone's
226 if ( empty ( $event_status ) ) {
227 $sql = "SELECT cal_status FROM webcal_entry_user " .
228 "WHERE cal_status <> 'D' ORDER BY cal_status";
229 $res = dbi_query ( $sql );
231 if ( $row = dbi_fetch_row ( $res ) ) {
232 $event_status = $row[0];
234 dbi_free_result ( $res );
238 // If we have no event status yet, it must have been deleted.
239 if ( ( empty ( $event_status ) && ! $is_admin ) || ! $can_view ) {
241 translate("Error") . "</h2>" .
242 translate("You are not authorized") . ".\n";
244 echo "</body>\n</html>";
249 // Load event info now.
250 $sql = "SELECT cal_create_by, cal_date, cal_time, cal_mod_date, " .
251 "cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, " .
252 "cal_name, cal_description FROM webcal_entry WHERE cal_id = $id";
253 $res = dbi_query ( $sql );
255 echo translate("Invalid entry id") . ": $id";
259 $row = dbi_fetch_row ( $res );
261 $create_by = $row[0];
262 $orig_date = $row[1];
263 $event_time = $row[2];
265 $description = $row[10];
268 translate("Error") . "</h2>" .
269 translate("Invalid entry id") . ".\n";
271 echo "</body>\n</html>";
275 // Timezone Adjustments
276 if ( $event_time >= 0 && ! empty ( $TZ_OFFSET ) && $TZ_OFFSET != 0 ) {
277 // -1 = no time specified
278 $adjusted_time = $event_time + $TZ_OFFSET * 10000;
279 $year = substr($row[1],0,4);
280 $month = substr($row[1],4,2);
281 $day = substr($row[1],-2);
282 if ( $adjusted_time > 240000 ) {
283 $gmt = mktime ( 3, 0, 0, $month, $day, $year );
285 } else if ( $adjusted_time < 0 ) {
286 $gmt = mktime ( 3, 0, 0, $month, $day, $year );
291 $tz_date = ( ! empty ( $gmt ) ) ? date ( "Ymd", $gmt ) : $row[1];
293 // save date so the trailer links are for the same time period
294 $thisyear = (int) ( $tz_date / 10000 );
295 $thismonth = ( $tz_date / 100 ) % 100;
296 $thisday = $tz_date % 100;
297 $thistime = mktime ( 3, 0, 0, $thismonth, $thisday, $thisyear );
298 $thisdow = date ( "w", $thistime );
300 // $subject is used for mailto URLs
301 $subject = translate($application_name) . ": " . $name;
302 // Remove the '"' character since it causes some mailers to barf
303 $subject = str_replace ( "\"", "", $subject );
304 $subject = htmlspecialchars ( $subject );
306 $event_repeats = false;
307 // build info string for repeating events and end date
308 $sql = "SELECT cal_type, cal_end, cal_frequency, cal_days " .
309 "FROM webcal_entry_repeats WHERE cal_id = $id";
311 $res = dbi_query ($sql);
314 if ( $tmprow = dbi_fetch_row ( $res ) ) {
315 $event_repeats = true;
316 $cal_type = $tmprow[0];
317 $cal_end = $tmprow[1];
318 $cal_frequency = $tmprow[2];
319 $cal_days = $tmprow[3];
322 $rep_str .= " - ";
323 $rep_str .= date_to_str ( $cal_end );
325 $rep_str .= " (" . translate("every") . " ";
327 if ( $cal_frequency > 1 ) {
328 switch ( $cal_frequency ) {
329 case 2: $rep_str .= translate("2nd"); break;
330 case 3: $rep_str .= translate("3rd"); break;
331 case 4: $rep_str .= translate("4th"); break;
332 case 5: $rep_str .= translate("5th"); break;
333 case 12: if ( $cal_type == 'monthlyByDay' ||
334 $cal_type == 'monthlyByDayR' ) {
337 default: $rep_str .= $cal_frequency; break;
343 $rep_str .= translate("Day");
345 case "weekly": $rep_str .= translate("Week");
346 for ($i=0; $i<=7; $i++) {
347 if (substr($cal_days, $i, 1) == "y") {
348 $rep_str .= ", " . weekday_short_name($i);
353 case "monthlyByDayR":
354 if ( $cal_frequency == 12 ) {
355 $rep_str .= month_name ( $thismonth - 1 ) . " / ";
357 $rep_str .= translate("Month") . " / ";
359 $days_this_month = $thisyear % 4 == 0 ? $ldays_per_month[$thismonth] :
360 $days_per_month[$thismonth];
361 if ( $cal_type == 'monthlyByDay' ) {
362 $dow1 = date ( "w", mktime ( 3, 0, 0, $thismonth, 1, $thisyear ) );
363 $days_in_first_week = ( 7 - $dow1 );
364 $whichWeek = ceil ( $thisday / 7 );
366 $whichWeek = floor ( ( $days_this_month - $thisday ) / 7 );
370 switch ( $whichWeek ) {
372 if ( $cal_type == 'monthlyByDay' )
373 $rep_str .= translate ( "1st" );
376 $rep_str .= translate ( "2nd" ); break;
378 $rep_str .= translate ( "3rd" ); break;
380 $rep_str .= translate ( "4th" ); break;
382 $rep_str .= translate ( "5th" ); break;
384 if ( $cal_type == 'monthlyByDayR' )
385 $rep_str .= " " . translate ( "last" );
386 $rep_str .= ' ' . weekday_name ( $thisdow );
388 case "monthlyByDate":
389 $rep_str .= translate("Month") . "/" . translate("by date");
392 $rep_str .= translate("Year");
398 dbi_free_result ( $res );
400 /* calculate end time */
401 if ( $event_time >= 0 && $row[5] > 0 )
402 $end_str = "-" . display_time ( add_duration ( $row[2], $row[5] ) );
406 // get the email adress of the creator of the entry
407 user_load_variables ( $create_by, "createby_" );
408 $email_addr = empty ( $createby_email ) ? '' : $createby_email;
410 // If confidential and not this user's event, then
411 // They cannot seem name or description.
412 //if ( $row[8] == "R" && ! $is_my_event && ! $is_admin ) {
413 if ( $row[8] == "R" && ! $is_my_event ) {
415 $name = "[" . translate("Confidential") . "]";
416 $description = "[" . translate("Confidential") . "]";
421 if ( $event_repeats && ! empty ( $date ) )
424 $event_date = $row[1];
426 // TODO: don't let someone view another user's private entry
427 // by hand editing the URL.
430 if ( $categories_enabled == "Y" ) {
431 $cat_owner = ( ( ! empty ( $user ) && strlen ( $user ) ) && ( $is_assistant ||
432 $is_admin ) ) ? $user : $login;
433 $sql = "SELECT cat_name FROM webcal_categories, webcal_entry_user " .
434 "WHERE webcal_entry_user.cal_login = '$cat_owner' AND webcal_entry_user.cal_id = $id " .
435 "AND webcal_entry_user.cal_category = webcal_categories.cat_id";
436 $res2 = dbi_query ( $sql );
438 $row2 = dbi_fetch_row ( $res2 );
439 $category = $row2[0];
440 dbi_free_result ( $res2 );
444 <h2><?php echo htmlspecialchars ( $name ); ?></h2>
445 <table style="border-width:0px;">
446 <tr><td style="vertical-align:top; font-weight:bold;">
447 <?php etranslate("Description")?>:</td><td>
449 if ( ! empty ( $allow_html_description ) &&
450 $allow_html_description == 'Y' ) {
451 $str = str_replace ( '&', '&', $description );
452 $str = str_replace ( '&amp;', '&', $str );
453 // If there is no html found, then go ahead and replace
454 // the line breaks ("\n") with the html break.
455 if ( strstr ( $str, "<" ) && strstr ( $str, ">" ) ) {
456 // found some html...
459 echo nl2br ( activate_urls ( $str ) );
462 echo nl2br ( activate_urls ( htmlspecialchars ( $description ) ) );
466 <?php if ( $event_status != 'A' && ! empty ( $event_status ) ) { ?>
467 <tr><td style="vertical-align:top; font-weight:bold;">
468 <?php etranslate("Status")?>:</td><td>
470 if ( $event_status == 'W' )
471 etranslate("Waiting for approval");
472 if ( $event_status == 'D' )
473 etranslate("Deleted");
474 else if ( $event_status == 'R' )
475 etranslate("Rejected");
480 <tr><td style="vertical-align:top; font-weight:bold;">
481 <?php etranslate("Date")?>:</td><td>
483 if ( $event_repeats ) {
484 echo date_to_str ( $event_date );
486 echo date_to_str ( $row[1], "", true, false, ( $row[5] == ( 24 * 60 ) ? "" : $event_time ) );
490 <?php if ( $event_repeats ) { ?>
491 <tr><td style="vertical-align:top; font-weight:bold;">
492 <?php etranslate("Repeat Type")?>:</td><td>
493 <?php echo date_to_str ( $row[1], "", true, false, $event_time ) . $rep_str; ?>
496 <?php if ( $event_time >= 0 ) { ?>
497 <tr><td style="vertical-align:top; font-weight:bold;">
498 <?php etranslate("Time")?>:</td><td>
500 if ( $row[5] == ( 24 * 60 ) ) {
501 etranslate("All day event");
503 echo display_time ( $row[2] ) . $end_str;
508 <?php if ( $row[5] > 0 && $row[5] != ( 24 * 60 ) ) { ?>
509 <tr><td style="vertical-align:top; font-weight:bold;">
510 <?php etranslate("Duration")?>:</td><td>
511 <?php echo $row[5]; ?> <?php etranslate("minutes")?>
514 <?php if ( $disable_priority_field != "Y" ) { ?>
515 <tr><td style="vertical-align:top; font-weight:bold;">
516 <?php etranslate("Priority")?>:</td><td>
517 <?php echo $pri[$row[6]]; ?>
520 <?php if ( $disable_access_field != "Y" ) { ?>
521 <tr><td style="vertical-align:top; font-weight:bold;">
522 <?php etranslate("Access")?>:</td><td>
523 <?php echo ( $row[8] == "P" ) ? translate("Public") : translate("Confidential"); ?>
526 <?php if ( $categories_enabled == "Y" && ! empty ( $category ) ) { ?>
527 <tr><td style="vertical-align:top; font-weight:bold;">
528 <?php etranslate("Category")?>:</td><td>
529 <?php echo $category; ?>
533 // Display who originally created event
534 // useful if assistant or Admin
535 $proxy_fullname = '';
536 if ( !empty ( $DISPLAY_CREATED_BYPROXY ) && $DISPLAY_CREATED_BYPROXY == "Y" ) {
537 $res = dbi_query ( "SELECT wu.cal_firstname, wu.cal_lastname " .
538 "FROM webcal_user wu INNER JOIN webcal_entry_log wel ON wu.cal_login = wel.cal_login " .
539 "WHERE wel.cal_entry_id = $id " .
540 "AND wel.cal_type = 'C'" );
542 $row3 = dbi_fetch_row ( $res ) ;
543 $proxy_fullname = $row3[0] . " " . $row3[1];
544 $proxy_fullname = ($createby_fullname == $proxy_fullname ? "" :
545 " ( by " . $proxy_fullname . " )");
549 if ( $single_user == "N" ) {
550 echo "<tr><td style=\"vertical-align:top; font-weight:bold;\">\n" .
551 translate("Created by") . ":</td><td>\n";
553 echo "[" . translate("Confidential") . "]\n</td></tr>";
555 if ( strlen ( $email_addr ) ) {
556 echo "<a href=\"mailto:$email_addr?subject=$subject\">" .
557 ( $row[0] == "__public__" ? translate( "Public Access" ): $createby_fullname ) .
558 "</a>$proxy_fullname\n</td></tr>";
560 echo ( $row[0] == "__public__" ? translate( "Public Access" ) : $createby_fullname ) .
561 "$proxy_fullname\n</td></tr>";
566 <tr><td style="vertical-align:top; font-weight:bold;">
567 <?php etranslate("Updated")?>:</td><td>
569 echo date_to_str ( $row[3] );
571 echo display_time ( $row[4] );
575 // load any site-specific fields and display them
576 $extras = get_site_extra_fields ( $id );
577 for ( $i = 0; $i < count ( $site_extras ); $i++ ) {
578 $extra_name = $site_extras[$i][0];
579 $extra_type = $site_extras[$i][2];
580 $extra_arg1 = $site_extras[$i][3];
581 $extra_arg2 = $site_extras[$i][4];
582 if ( ! empty ( $extras[$extra_name]['cal_name'] ) ) {
583 echo "<tr><td style=\"vertical-align:top; font-weight:bold;\">\n" .
584 translate ( $site_extras[$i][1] ) .
586 if ( $extra_type == $EXTRA_URL ) {
587 if ( strlen ( $extras[$extra_name]['cal_data'] ) ) {
588 echo "<a href=\"" . $extras[$extra_name]['cal_data'] . "\">" .
589 $extras[$extra_name]['cal_data'] . "</a>\n";
591 } else if ( $extra_type == $EXTRA_EMAIL ) {
592 if ( strlen ( $extras[$extra_name]['cal_data'] ) ) {
593 echo "<a href=\"mailto:" . $extras[$extra_name]['cal_data'] .
594 "?subject=$subject\">" .
595 $extras[$extra_name]['cal_data'] . "</a>\n";
597 } else if ( $extra_type == $EXTRA_DATE ) {
598 if ( $extras[$extra_name]['cal_date'] > 0 ) {
599 echo date_to_str ( $extras[$extra_name]['cal_date'] );
601 } else if ( $extra_type == $EXTRA_TEXT ||
602 $extra_type == $EXTRA_MULTILINETEXT ) {
603 echo nl2br ( $extras[$extra_name]['cal_data'] );
604 } else if ( $extra_type == $EXTRA_USER ) {
605 echo $extras[$extra_name]['cal_data'];
606 } else if ( $extra_type == $EXTRA_REMINDER ) {
607 if ( $extras[$extra_name]['cal_remind'] <= 0 ) {
610 etranslate ( "Yes" );
611 if ( ( $extra_arg2 & $EXTRA_REMINDER_WITH_DATE ) > 0 ) {
612 echo " - ";
613 echo date_to_str ( $extras[$extra_name]['cal_date'] );
614 } else if ( ( $extra_arg2 & $EXTRA_REMINDER_WITH_OFFSET ) > 0 ) {
615 echo " - ";
616 $minutes = $extras[$extra_name]['cal_data'];
617 $d = (int) ( $minutes / ( 24 * 60 ) );
618 $minutes -= ( $d * 24 * 60 );
619 $h = (int) ( $minutes / 60 );
620 $minutes -= ( $h * 60 );
622 echo $d . " " . translate("days") . " ";
623 } else if ( $d == 1 ) {
624 echo $d . " " . translate("day") . " ";
627 echo $h . " " . translate("hours") . " ";
628 } else if ( $h == 1 ) {
629 echo $h . " " . translate("hour") . " ";
631 if ( $minutes > 1 ) {
632 echo $minutes . " " . translate("minutes");
633 } else if ( $minutes == 1 ) {
634 echo $minutes . " " . translate("minute");
636 echo " " . translate("before event" );
639 } else if ( $extra_type == $EXTRA_SELECTLIST ) {
640 echo $extras[$extra_name]['cal_data'];
642 echo "\n</td></tr>\n";
647 <?php // participants
648 // Only ask for participants if we are multi-user.
649 $allmails = array ();
650 $show_participants = ( $disable_participants_field != "Y" );
652 $show_participants = true;
654 if ( $public_access == "Y" && $login == "__public__" &&
655 ( $public_access_others != "Y" || $public_access_view_part == "N" ) ) {
656 $show_participants = false;
658 if ( $single_user == "N" && $show_participants ) { ?>
659 <tr><td style="vertical-align:top; font-weight:bold;">
660 <?php etranslate("Participants")?>:</td><td>
663 echo "[" . translate("Confidential") . "]";
665 $sql = "SELECT cal_login, cal_status FROM webcal_entry_user " .
666 "WHERE cal_id = $id";
668 $res = dbi_query ( $sql );
670 $num_app = $num_wait = $num_rej = 0;
672 while ( $row = dbi_fetch_row ( $res ) ) {
674 if ( $login == $row[0] && $row[1] == 'W' ) {
677 if ( $row[1] == 'A' ) {
678 $approved[$num_app++] = $pname;
679 } else if ( $row[1] == 'W' ) {
680 $waiting[$num_wait++] = $pname;
681 } else if ( $row[1] == 'R' ) {
682 $rejected[$num_rej++] = $pname;
685 dbi_free_result ( $res );
687 echo translate ("Database error") . ": " . dbi_error() . "<br />\n";
690 for ( $i = 0; $i < $num_app; $i++ ) {
691 user_load_variables ( $approved[$i], "temp" );
692 if ( strlen ( $tempemail ) ) {
693 echo "<a href=\"mailto:" . $tempemail . "?subject=$subject\">" .
694 $tempfullname . "</a><br />\n";
695 $allmails[] = $tempemail;
697 echo $tempfullname . "<br />\n";
700 // show external users here...
701 if ( ! empty ( $allow_external_users ) && $allow_external_users == "Y" ) {
702 $external_users = event_get_external_users ( $id, 1 );
703 $ext_users = explode ( "\n", $external_users );
704 if ( is_array ( $ext_users ) ) {
705 for ( $i = 0; $i < count( $ext_users ); $i++ ) {
706 if ( ! empty ( $ext_users[$i] ) ) {
707 echo $ext_users[$i] . " (" . translate("External User") .
713 for ( $i = 0; $i < $num_wait; $i++ ) {
714 user_load_variables ( $waiting[$i], "temp" );
715 if ( strlen ( $tempemail ) ) {
716 echo "<br /><a href=\"mailto:" . $tempemail . "?subject=$subject\">" .
717 $tempfullname . "</a> (?)\n";
718 $allmails[] = $tempemail;
720 echo "<br />" . $tempfullname . " (?)\n";
723 for ( $i = 0; $i < $num_rej; $i++ ) {
724 user_load_variables ( $rejected[$i], "temp" );
725 if ( strlen ( $tempemail ) ) {
726 echo "<br /><strike><a href=\"mailto:" . $tempemail .
727 "?subject=$subject\">" . $tempfullname .
728 "</a></strike> (" . translate("Rejected") . ")\n";
730 echo "<br /><strike>$tempfullname</strike> (" .
731 translate("Rejected") . ")\n";
737 } // end participants
745 if ( $event_repeats ) {
746 $rdate = "&date=$event_date";
749 // Show a printer-friendly link
750 if ( empty ( $friendly ) ) {
752 translate("Generate printer-friendly version") . "\" class=\"printer\" " .
753 "href=\"view_entry.php?id=$id&friendly=1$rdate\" " .
754 "target=\"cal_printer_friendly\">" .
755 translate("Printer Friendly") . "</a><br />\n";
758 if ( empty ( $event_status ) ) {
759 // this only happens when an admin views a deleted event that he is
760 // not a participant for. Set to $event_status to "D" just to get
761 // rid of all the edit/delete links below.
765 if ( $unapproved && $readonly == 'N' ) {
767 translate("Approve/Confirm entry") .
768 "\" href=\"approve_entry.php?id=$id\" " .
769 "onclick=\"return confirm('" .
770 translate("Approve this entry?") . "');\">" .
771 translate("Approve/Confirm entry") . "</a><br />\n";
773 translate("Reject entry") . "\" href=\"reject_entry.php?id=$id\" " .
774 "onclick=\"return confirm('" .
775 translate("Reject this entry?") . "');\">" .
776 translate("Reject entry") . "</a><br />\n";
779 if ( ! empty ( $user ) && $login != $user ) {
780 $u_url = "&user=$user";
785 $can_edit = ( $is_admin || $is_nonuser_admin && ($user == $create_by) ||
786 ( $is_assistant && ! $is_private && ($user == $create_by) ) ||
787 ( $readonly != "Y" && ( $login == $create_by || $single_user == "Y" ) ) );
788 if ( $public_access == "Y" && $login == "__public__" ) {
791 if ( $readonly == 'Y' ) {
795 // If approved, but event category not set (and user does not have permission
796 // to edit where they could also set the category), then allow them to
797 // set it through set_cat.php.
798 if ( empty ( $user ) && $categories_enabled == "Y" &&
799 $readonly != "Y" && $is_my_event && $login != "__public__" &&
800 $event_status != "D" && ! $can_edit ) {
802 translate("Set category") . "\" class=\"nav\" " .
803 "href=\"set_entry_cat.php?id=$id$rdate\">" .
804 translate("Set category") . "</a><br />\n";
807 if ( $can_edit && $event_status != "D" ) {
808 if ( $event_repeats ) {
810 translate("Edit repeating entry for all dates") .
811 "\" class=\"nav\" href=\"edit_entry.php?id=$id$u_url\">" .
812 translate("Edit repeating entry for all dates") . "</a><br />\n";
813 // Don't allow override of first event
814 if ( ! empty ( $date ) && $date != $orig_date ) {
816 translate("Edit entry for this date") . "\" class=\"nav\" " .
817 "href=\"edit_entry.php?id=$id$u_url$rdate&override=1\">" .
818 translate("Edit entry for this date") . "</a><br />\n";
821 translate("Delete repeating event for all dates") .
822 "\" class=\"nav\" href=\"del_entry.php?id=$id$u_url&override=1\" " .
823 "onclick=\"return confirm('" .
824 translate("Are you sure you want to delete this entry?") . "\\n\\n" .
825 translate("This will delete this entry for all users.") . "');\">" .
826 translate("Delete repeating event for all dates") . "</a><br />\n";
827 // Don't allow deletion of first event
828 if ( ! empty ( $date ) && $date != $orig_date ) {
830 translate("Delete entry only for this date") .
831 "\" class=\"nav\" href=\"del_entry.php?id=$id$u_url$rdate&override=1\" " .
832 "onclick=\"return confirm('" .
833 translate("Are you sure you want to delete this entry?") . "\\n\\n" .
834 translate("This will delete this entry for all users.") . "');\">" .
835 translate("Delete entry only for this date") . "</a><br />\n";
839 translate("Edit entry") . "\" class=\"nav\" " .
840 "href=\"edit_entry.php?id=$id$u_url\">" .
841 translate("Edit entry") . "</a><br />\n";
843 translate("Delete entry") . "\" class=\"nav\" " .
844 "href=\"del_entry.php?id=$id$u_url$rdate\" onclick=\"return confirm('" .
845 translate("Are you sure you want to delete this entry?") . "\\n\\n" .
846 translate("This will delete this entry for all users.") . "');\">" .
847 translate("Delete entry") . "</a><br />\n";
850 translate("Copy entry") . "\" class=\"nav\" " .
851 "href=\"edit_entry.php?id=$id$u_url&copy=1\">" .
852 translate("Copy entry") . "</a><br />\n";
853 } elseif ( $readonly != "Y" && $is_my_event && $login != "__public__" &&
854 $event_status != "D" ) {
856 translate("Delete entry") . "\" class=\"nav\" " .
857 "href=\"del_entry.php?id=$id$u_url$rdate\" onclick=\"return confirm('" .
858 translate("Are you sure you want to delete this entry?") . "\\n\\n" .
859 translate("This will delete the entry from your calendar.") . "');\">" .
860 translate("Delete entry") . "</a><br />\n";
862 translate("Copy entry") . "\" class=\"nav\" " .
863 "href=\"edit_entry.php?id=$id&copy=1\">" .
864 translate("Copy entry") . "</a><br />\n";
866 if ( $readonly != "Y" && ! $is_my_event && ! $is_private &&
867 $event_status != "D" && $login != "__public__" ) {
869 translate("Add to My Calendar") . "\" class=\"nav\" " .
870 "href=\"add_entry.php?id=$id&user=".$_GET['user']."\" onclick=\"return confirm('" .
871 translate("Do you want to add this entry to your calendar?") . "\\n\\n" .
872 translate("This will add the entry to your calendar.") . "');\">" .
873 translate("Add to My Calendar") . "</a><br />\n";
876 if ( count ( $allmails ) > 0 ) {
878 translate("Email all participants") . "\" class=\"nav\" " .
879 "href=\"mailto:" . implode ( ",", $allmails ) .
880 "?subject=" . rawurlencode($subject) . "\">" .
881 translate("Email all participants") . "</a><br />\n";
887 if ( empty ( $log ) ) {
889 translate("Show activity log") . "\" class=\"nav\" " .
890 "href=\"view_entry.php?id=$id&log=1\">" .
891 translate("Show activity log") . "</a><br />\n";
894 translate("Hide activity log") . "\" class=\"nav\" " .
895 "href=\"view_entry.php?id=$id\">" .
896 translate("Hide activity log") . "</a><br />\n";
902 echo "<h3>" . translate("Activity Log") . "</h3>\n";
903 echo "<table class=\"embactlog\">\n";
904 echo "<tr><th class=\"usr\">\n";
905 echo translate("User") . "</th><th class=\"cal\">\n";
906 echo translate("Calendar") . "</th><th class=\"date\">\n";
907 echo translate("Date") . "/" .
908 translate("Time") . "</th><th class=\"action\">\n";
909 echo translate("Action") . "\n</th></tr>\n";
911 $res = dbi_query ( "SELECT cal_login, cal_user_cal, cal_type, " .
912 "cal_date, cal_time " .
913 "FROM webcal_entry_log WHERE cal_entry_id = $id " .
914 "ORDER BY cal_log_id DESC" );
916 while ( $row = dbi_fetch_row ( $res ) ) {
918 echo $row[0] . "</td><td>\n";
919 echo $row[1] . "</td><td>\n" .
920 date_to_str ( $row[3] ) . " " .
921 display_time ( $row[4] ) . "</td><td>\n";
922 if ( $row[2] == $LOG_CREATE ) {
923 etranslate("Event created");
924 } else if ( $row[2] == $LOG_APPROVE ) {
925 etranslate("Event approved");
926 } else if ( $row[2] == $LOG_REJECT ) {
927 etranslate("Event rejected");
928 } else if ( $row[2] == $LOG_UPDATE ) {
929 etranslate("Event updated");
930 } else if ( $row[2] == $LOG_DELETE ) {
931 etranslate("Event deleted");
932 } else if ( $row[2] == $LOG_NOTIFICATION ) {
933 etranslate("Notification sent");
934 } else if ( $row[2] == $LOG_REMINDER ) {
935 etranslate("Reminder sent");
939 dbi_free_result ( $res );
945 echo "<br /><form method=\"post\" name=\"exportform\" " .
946 "action=\"export_handler.php\">\n";
947 echo "<label for=\"exformat\">" .
948 translate("Export this entry to") . ": </label>\n";
949 echo "<select name=\"format\" id=\"exformat\">\n";
950 echo " <option value=\"ical\">iCalendar</option>\n";
951 echo " <option value=\"vcal\">vCalendar</option>\n";
952 echo " <option value=\"pilot-csv\">Pilot-datebook CSV (" .
953 translate("Palm Pilot") . ")</option>\n";
954 echo " <option value=\"pilot-text\">Install-datebook (" .
955 translate("Palm Pilot") . ")</option>\n";
957 echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
958 echo "<input type=\"submit\" value=\"" .
959 translate("Export") . "\" />\n";
965 print_trailer ( empty ($friendly) );