[ Index ] |
|
Code source de WebCalendar 1.0.5 |
1 <?php 2 /* 3 * $Id: view_entry.php,v 1.68.2.2 2005/08/10 14:35:15 cknudsen Exp $ 4 * 5 * Description: 6 * Presents page to view an event with links to edit, delete 7 * confirm, copy, add event 8 * 9 * Input Parameters: 10 * id (*) - cal_id of requested event 11 * date - yyyymmdd format of requested event 12 * user - user to display 13 * (*) required field 14 */ 15 include_once 'includes/init.php'; 16 include_once 'includes/site_extras.php'; 17 18 // make sure this user is allowed to look at this calendar. 19 $can_view = false; 20 $is_my_event = false; 21 22 if ( $is_admin || $is_nonuser_admin || $is_assistant ) { 23 $can_view = true; 24 } 25 26 $error = ''; 27 28 if ( empty ( $id ) || $id <= 0 || ! is_numeric ( $id ) ) { 29 $error = translate ( "Invalid entry id" ) . "."; 30 } 31 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 ); 40 if ( $res ) { 41 $row = dbi_fetch_row ( $res ); 42 if ( $row && $row[0] > 0 ) { 43 $can_view = true; 44 $is_my_event = true; 45 } 46 dbi_free_result ( $res ); 47 } 48 49 if ( ($login != "__public__") && ($public_access_others == "Y") ) { 50 $can_view = true; 51 } 52 53 if ( ! $can_view ) { 54 $check_group = false; 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" ) { 59 $check_group = true; 60 } 61 } else { 62 if ( $allow_view_other == "Y" ) { 63 $check_group = true; 64 } 65 } 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 68 // the event. 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 73 // 99.9% of users. 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++ ) { 83 if ( $i > 0 ) { 84 $sql .= ", "; 85 } 86 $sql .= "'" . $my_users[$i]['cal_login'] . "'"; 87 } 88 $sql .= " )"; 89 $res = dbi_query ( $sql ); 90 if ( $res ) { 91 $row = dbi_fetch_row ( $res ); 92 if ( $row && $row[0] > 0 ) { 93 $can_view = true; 94 } 95 dbi_free_result ( $res ); 96 } 97 } 98 // If we didn't indicate we need to check groups, then this user 99 // can't view this event. 100 if ( ! $check_group ) { 101 $can_view = false; 102 } 103 } 104 } 105 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; 114 } 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; 120 if ( $res ) { 121 while ( $row = dbi_fetch_row ( $res ) ) { 122 if ( ! empty ( $nonuser_lookup[$row[0]] ) ) { 123 $found_nonuser_cal = true; 124 } else { 125 $found_reg_user = true; 126 } 127 } 128 dbi_free_result ( $res ); 129 } 130 // Does this event contain only nonuser calendars as participants? 131 // If so, then grant access. 132 if ( $found_nonuser_cal && ! $found_reg_user ) { 133 $can_view = true; 134 } 135 } 136 137 if ( empty ( $error ) && ! $can_view ) { 138 $error = translate ( "You are not authorized" ); 139 } 140 141 if ( ! empty ( $year ) ) { 142 $thisyear = $year; 143 } 144 if ( ! empty ( $month ) ) { 145 $thismonth = $month; 146 } 147 $pri[1] = translate("Low"); 148 $pri[2] = translate("Medium"); 149 $pri[3] = translate("High"); 150 151 $unapproved = FALSE; 152 153 // Make sure this is not a continuation event. 154 // If it is, redirect the user to the original event. 155 $ext_id = -1; 156 if ( empty ( $error ) ) { 157 $res = dbi_query ( "SELECT cal_ext_for_id FROM webcal_entry " . 158 "WHERE cal_id = $id" ); 159 if ( $res ) { 160 if ( $row = dbi_fetch_row ( $res ) ) { 161 $ext_id = $row[0]; 162 } 163 dbi_free_result ( $res ); 164 } else { 165 // db error... ignore it, I guess. 166 } 167 } 168 if ( $ext_id > 0 ) { 169 $url = "view_entry.php?id=$ext_id"; 170 if ( $date != "" ) { 171 $url .= "&date=$date"; 172 } 173 if ( $user != "" ) { 174 $url .= "&user=$user"; 175 } 176 if ( $cat_id != "" ) { 177 $url .= "&cat_id=$cat_id"; 178 } 179 do_redirect ( $url ); 180 } 181 182 print_header(); 183 184 if ( ! empty ( $error ) ) { 185 echo "<h2>" . translate ( "Error" ) . 186 "</h2>\n" . $error; 187 print_trailer (); 188 echo "</body>\n</html>"; 189 exit; 190 } 191 // Try to determine the event status. 192 $event_status = ""; 193 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 ); 200 if ( $res ) { 201 if ( $row = dbi_fetch_row ( $res ) ) { 202 $event_status = $row[0]; 203 } 204 dbi_free_result ( $res ); 205 } 206 } else { 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 ); 212 if ( $res ) { 213 $row = dbi_fetch_row ( $res ); 214 $event_status = $row[1]; 215 dbi_free_result ( $res ); 216 } 217 } 218 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 225 // calendar. 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 ); 230 if ( $res ) { 231 if ( $row = dbi_fetch_row ( $res ) ) { 232 $event_status = $row[0]; 233 } 234 dbi_free_result ( $res ); 235 } 236 } 237 238 // If we have no event status yet, it must have been deleted. 239 if ( ( empty ( $event_status ) && ! $is_admin ) || ! $can_view ) { 240 echo "<h2>" . 241 translate("Error") . "</h2>" . 242 translate("You are not authorized") . ".\n"; 243 print_trailer (); 244 echo "</body>\n</html>"; 245 exit; 246 } 247 248 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 ); 254 if ( ! $res ) { 255 echo translate("Invalid entry id") . ": $id"; 256 exit; 257 } 258 259 $row = dbi_fetch_row ( $res ); 260 if ( $row ) { 261 $create_by = $row[0]; 262 $orig_date = $row[1]; 263 $event_time = $row[2]; 264 $name = $row[9]; 265 $description = $row[10]; 266 } else { 267 echo "<h2>" . 268 translate("Error") . "</h2>" . 269 translate("Invalid entry id") . ".\n"; 270 print_trailer (); 271 echo "</body>\n</html>"; 272 exit; 273 } 274 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 ); 284 $gmt += $ONE_DAY; 285 } else if ( $adjusted_time < 0 ) { 286 $gmt = mktime ( 3, 0, 0, $month, $day, $year ); 287 $gmt -= $ONE_DAY; 288 } 289 } 290 // Set alterted date 291 $tz_date = ( ! empty ( $gmt ) ) ? date ( "Ymd", $gmt ) : $row[1]; 292 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 ); 299 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 ); 305 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"; 310 311 $res = dbi_query ($sql); 312 $rep_str = ''; 313 if ( $res ) { 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]; 320 321 if ( $cal_end ) { 322 $rep_str .= " - "; 323 $rep_str .= date_to_str ( $cal_end ); 324 } 325 $rep_str .= " (" . translate("every") . " "; 326 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' ) { 335 break; 336 } 337 default: $rep_str .= $cal_frequency; break; 338 } 339 } 340 $rep_str .= ' '; 341 switch ($cal_type) { 342 case "daily": 343 $rep_str .= translate("Day"); 344 break; 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); 349 } 350 } 351 break; 352 case "monthlyByDay": 353 case "monthlyByDayR": 354 if ( $cal_frequency == 12 ) { 355 $rep_str .= month_name ( $thismonth - 1 ) . " / "; 356 } else { 357 $rep_str .= translate("Month") . " / "; 358 } 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 ); 365 } else { 366 $whichWeek = floor ( ( $days_this_month - $thisday ) / 7 ); 367 $whichWeek++; 368 } 369 $rep_str .= ' '; 370 switch ( $whichWeek ) { 371 case 1: 372 if ( $cal_type == 'monthlyByDay' ) 373 $rep_str .= translate ( "1st" ); 374 break; 375 case 2: 376 $rep_str .= translate ( "2nd" ); break; 377 case 3: 378 $rep_str .= translate ( "3rd" ); break; 379 case 4: 380 $rep_str .= translate ( "4th" ); break; 381 case 5: 382 $rep_str .= translate ( "5th" ); break; 383 } 384 if ( $cal_type == 'monthlyByDayR' ) 385 $rep_str .= " " . translate ( "last" ); 386 $rep_str .= ' ' . weekday_name ( $thisdow ); 387 break; 388 case "monthlyByDate": 389 $rep_str .= translate("Month") . "/" . translate("by date"); 390 break; 391 case "yearly": 392 $rep_str .= translate("Year"); 393 break; 394 } 395 $rep_str .= ")"; 396 } else 397 $rep_str = ""; 398 dbi_free_result ( $res ); 399 } 400 /* calculate end time */ 401 if ( $event_time >= 0 && $row[5] > 0 ) 402 $end_str = "-" . display_time ( add_duration ( $row[2], $row[5] ) ); 403 else 404 $end_str = ""; 405 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; 409 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 ) { 414 $is_private = true; 415 $name = "[" . translate("Confidential") . "]"; 416 $description = "[" . translate("Confidential") . "]"; 417 } else { 418 $is_private = false; 419 } 420 421 if ( $event_repeats && ! empty ( $date ) ) 422 $event_date = $date; 423 else 424 $event_date = $row[1]; 425 426 // TODO: don't let someone view another user's private entry 427 // by hand editing the URL. 428 429 // Get category Info 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 ); 437 if ( $res2 ) { 438 $row2 = dbi_fetch_row ( $res2 ); 439 $category = $row2[0]; 440 dbi_free_result ( $res2 ); 441 } 442 } 443 ?> 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> 448 <?php 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... 457 echo $str; 458 } else { 459 echo nl2br ( activate_urls ( $str ) ); 460 } 461 } else { 462 echo nl2br ( activate_urls ( htmlspecialchars ( $description ) ) ); 463 } 464 ?></td></tr> 465 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> 469 <?php 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"); 476 ?> 477 </td></tr> 478 <?php } ?> 479 480 <tr><td style="vertical-align:top; font-weight:bold;"> 481 <?php etranslate("Date")?>:</td><td> 482 <?php 483 if ( $event_repeats ) { 484 echo date_to_str ( $event_date ); 485 } else { 486 echo date_to_str ( $row[1], "", true, false, ( $row[5] == ( 24 * 60 ) ? "" : $event_time ) ); 487 } 488 ?> 489 </td></tr> 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; ?> 494 </td></tr> 495 <?php } ?> 496 <?php if ( $event_time >= 0 ) { ?> 497 <tr><td style="vertical-align:top; font-weight:bold;"> 498 <?php etranslate("Time")?>:</td><td> 499 <?php 500 if ( $row[5] == ( 24 * 60 ) ) { 501 etranslate("All day event"); 502 } else { 503 echo display_time ( $row[2] ) . $end_str; 504 } 505 ?> 506 </td></tr> 507 <?php } ?> 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")?> 512 </td></tr> 513 <?php } ?> 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]]; ?> 518 </td></tr> 519 <?php } ?> 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"); ?> 524 </td></tr> 525 <?php } ?> 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; ?> 530 </td></tr> 531 <?php } ?> 532 <?php 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'" ); 541 if ( $res ) { 542 $row3 = dbi_fetch_row ( $res ) ; 543 $proxy_fullname = $row3[0] . " " . $row3[1]; 544 $proxy_fullname = ($createby_fullname == $proxy_fullname ? "" : 545 " ( by " . $proxy_fullname . " )"); 546 } 547 } 548 549 if ( $single_user == "N" ) { 550 echo "<tr><td style=\"vertical-align:top; font-weight:bold;\">\n" . 551 translate("Created by") . ":</td><td>\n"; 552 if ( $is_private ) { 553 echo "[" . translate("Confidential") . "]\n</td></tr>"; 554 } else { 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>"; 559 } else { 560 echo ( $row[0] == "__public__" ? translate( "Public Access" ) : $createby_fullname ) . 561 "$proxy_fullname\n</td></tr>"; 562 } 563 } 564 } 565 ?> 566 <tr><td style="vertical-align:top; font-weight:bold;"> 567 <?php etranslate("Updated")?>:</td><td> 568 <?php 569 echo date_to_str ( $row[3] ); 570 echo " "; 571 echo display_time ( $row[4] ); 572 ?> 573 </td></tr> 574 <?php 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] ) . 585 ":</td><td>\n"; 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"; 590 } 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"; 596 } 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'] ); 600 } 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 ) { 608 etranslate ( "No" ); 609 } else { 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 ); 621 if ( $d > 1 ) { 622 echo $d . " " . translate("days") . " "; 623 } else if ( $d == 1 ) { 624 echo $d . " " . translate("day") . " "; 625 } 626 if ( $h > 1 ) { 627 echo $h . " " . translate("hours") . " "; 628 } else if ( $h == 1 ) { 629 echo $h . " " . translate("hour") . " "; 630 } 631 if ( $minutes > 1 ) { 632 echo $minutes . " " . translate("minutes"); 633 } else if ( $minutes == 1 ) { 634 echo $minutes . " " . translate("minute"); 635 } 636 echo " " . translate("before event" ); 637 } 638 } 639 } else if ( $extra_type == $EXTRA_SELECTLIST ) { 640 echo $extras[$extra_name]['cal_data']; 641 } 642 echo "\n</td></tr>\n"; 643 } 644 } 645 ?> 646 647 <?php // participants 648 // Only ask for participants if we are multi-user. 649 $allmails = array (); 650 $show_participants = ( $disable_participants_field != "Y" ); 651 if ( $is_admin ) { 652 $show_participants = true; 653 } 654 if ( $public_access == "Y" && $login == "__public__" && 655 ( $public_access_others != "Y" || $public_access_view_part == "N" ) ) { 656 $show_participants = false; 657 } 658 if ( $single_user == "N" && $show_participants ) { ?> 659 <tr><td style="vertical-align:top; font-weight:bold;"> 660 <?php etranslate("Participants")?>:</td><td> 661 <?php 662 if ( $is_private ) { 663 echo "[" . translate("Confidential") . "]"; 664 } else { 665 $sql = "SELECT cal_login, cal_status FROM webcal_entry_user " . 666 "WHERE cal_id = $id"; 667 //echo "$sql\n"; 668 $res = dbi_query ( $sql ); 669 $first = 1; 670 $num_app = $num_wait = $num_rej = 0; 671 if ( $res ) { 672 while ( $row = dbi_fetch_row ( $res ) ) { 673 $pname = $row[0]; 674 if ( $login == $row[0] && $row[1] == 'W' ) { 675 $unapproved = TRUE; 676 } 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; 683 } 684 } 685 dbi_free_result ( $res ); 686 } else { 687 echo translate ("Database error") . ": " . dbi_error() . "<br />\n"; 688 } 689 } 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; 696 } else { 697 echo $tempfullname . "<br />\n"; 698 } 699 } 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") . 708 ")<br />\n"; 709 } 710 } 711 } 712 } 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; 719 } else { 720 echo "<br />" . $tempfullname . " (?)\n"; 721 } 722 } 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"; 729 } else { 730 echo "<br /><strike>$tempfullname</strike> (" . 731 translate("Rejected") . ")\n"; 732 } 733 } 734 ?> 735 </td></tr> 736 <?php 737 } // end participants 738 ?> 739 740 </table> 741 742 <br /><?php 743 744 $rdate = ""; 745 if ( $event_repeats ) { 746 $rdate = "&date=$event_date"; 747 } 748 749 // Show a printer-friendly link 750 if ( empty ( $friendly ) ) { 751 echo "<a title=\"" . 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"; 756 } 757 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. 762 $event_status = "D"; 763 } 764 765 if ( $unapproved && $readonly == 'N' ) { 766 echo "<a title=\"" . 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"; 772 echo "<a title=\"" . 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"; 777 } 778 779 if ( ! empty ( $user ) && $login != $user ) { 780 $u_url = "&user=$user"; 781 } else { 782 $u_url = ""; 783 } 784 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__" ) { 789 $can_edit = false; 790 } 791 if ( $readonly == 'Y' ) { 792 $can_edit = false; 793 } 794 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 ) { 801 echo "<a title=\"" . 802 translate("Set category") . "\" class=\"nav\" " . 803 "href=\"set_entry_cat.php?id=$id$rdate\">" . 804 translate("Set category") . "</a><br />\n"; 805 } 806 807 if ( $can_edit && $event_status != "D" ) { 808 if ( $event_repeats ) { 809 echo "<a title=\"" . 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 ) { 815 echo "<a title=\"" . 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"; 819 } 820 echo "<a title=\"" . 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 ) { 829 echo "<a title=\"" . 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"; 836 } 837 } else { 838 echo "<a title=\"" . 839 translate("Edit entry") . "\" class=\"nav\" " . 840 "href=\"edit_entry.php?id=$id$u_url\">" . 841 translate("Edit entry") . "</a><br />\n"; 842 echo "<a title=\"" . 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"; 848 } 849 echo "<a title=\"" . 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" ) { 855 echo "<a title=\"" . 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"; 861 echo "<a title=\"" . 862 translate("Copy entry") . "\" class=\"nav\" " . 863 "href=\"edit_entry.php?id=$id&copy=1\">" . 864 translate("Copy entry") . "</a><br />\n"; 865 } 866 if ( $readonly != "Y" && ! $is_my_event && ! $is_private && 867 $event_status != "D" && $login != "__public__" ) { 868 echo "<a title=\"" . 869 translate("Add to My Calendar") . "\" class=\"nav\" " . 870 "href=\"add_entry.php?id=$id\" 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"; 874 } 875 876 if ( count ( $allmails ) > 0 ) { 877 echo "<a title=\"" . 878 translate("Email all participants") . "\" class=\"nav\" " . 879 "href=\"mailto:" . implode ( ",", $allmails ) . 880 "?subject=" . rawurlencode($subject) . "\">" . 881 translate("Email all participants") . "</a><br />\n"; 882 } 883 884 $show_log = false; 885 886 if ( $is_admin ) { 887 if ( empty ( $log ) ) { 888 echo "<a title=\"" . 889 translate("Show activity log") . "\" class=\"nav\" " . 890 "href=\"view_entry.php?id=$id&log=1\">" . 891 translate("Show activity log") . "</a><br />\n"; 892 } else { 893 echo "<a title=\"" . 894 translate("Hide activity log") . "\" class=\"nav\" " . 895 "href=\"view_entry.php?id=$id\">" . 896 translate("Hide activity log") . "</a><br />\n"; 897 $show_log = true; 898 } 899 } 900 901 if ( $show_log ) { 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"; 910 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" ); 915 if ( $res ) { 916 while ( $row = dbi_fetch_row ( $res ) ) { 917 echo "<tr><td>\n"; 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"); 936 } 937 echo "</td></tr>\n"; 938 } 939 dbi_free_result ( $res ); 940 } 941 echo "</table>\n"; 942 } 943 944 if (! $is_private) { 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"; 956 echo "</select>\n"; 957 echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n"; 958 echo "<input type=\"submit\" value=\"" . 959 translate("Export") . "\" />\n"; 960 echo "</form>\n"; 961 } 962 ?> 963 964 <?php 965 print_trailer ( empty ($friendly) ); 966 ?> 967 </body> 968 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Nov 30 19:09:19 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |