2 include_once $gfplugins.'webcalendar/www/includes/init.php';
6 if ( $readonly == 'Y' ) {
7 $error = translate("You are not authorized");
10 // Allow administrators to approve public events
11 if ( $public_access == "Y" && ! empty ( $public ) && $is_admin )
12 $app_user = "__public__";
14 $app_user = ( $is_assistant || $is_nonuser_admin ? $user : $login );
16 if ( empty ( $error ) && $id > 0 ) {
17 if ( ! dbi_query ( "UPDATE webcal_entry_user SET cal_status = 'R' " .
18 "WHERE cal_login = '$app_user' AND cal_id = $id" ) ) {
19 $error = translate("Error approving event") . ": " . dbi_error ();
21 activity_log ( $id, $login, $app_user, $LOG_REJECT, "" );
24 // Update any extension events related to this one.
25 $res = dbi_query ( "SELECT cal_id FROM webcal_entry " .
26 "WHERE cal_ext_for_id = $id" );
28 if ( $row = dbi_fetch_row ( $res ) ) {
30 if ( ! dbi_query ( "UPDATE webcal_entry_user SET cal_status = 'R' " .
31 "WHERE cal_login = '$app_user' AND cal_id = $ext_id" ) ) {
32 $error = translate("Error approving event") . ": " . dbi_error ();
35 dbi_free_result ( $res );
38 // Email participants to notify that it was rejected.
39 // Get list of participants
40 $sql = "SELECT cal_login FROM webcal_entry_user WHERE cal_id = $id and cal_status = 'A'";
42 $res = dbi_query ( $sql );
44 while ( $row = dbi_fetch_row ( $res ) )
45 $partlogin[] = $row[0];
46 dbi_free_result($res);
49 // Get the name of the event
50 $sql = "SELECT cal_name, cal_description, cal_date, cal_time FROM webcal_entry WHERE cal_id = $id";
51 $res = dbi_query ( $sql );
53 $row = dbi_fetch_row ( $res );
55 $description = $row[1];
58 dbi_free_result ( $res );
62 $hour = substr($time,0,2);
63 $minute = substr($time,2,2);
66 for ( $i = 0; $i < count ( $partlogin ); $i++ ) {
67 // does this user want email for this?
68 $send_user_mail = get_pref_setting ( $partlogin[$i],
69 "EMAIL_EVENT_REJECTED" );
70 user_load_variables ( $partlogin[$i], "temp" );
71 $user_language = get_pref_setting ( $partlogin[$i], "LANGUAGE" );
72 if ( $send_user_mail == "Y" && strlen ( $tempemail ) &&
73 $send_email != "N" ) {
74 if (($GLOBALS['LANGUAGE'] != $user_language) && ! empty ( $user_language ) && ( $user_language != 'none' )){
75 reset_language ( $user_language );
77 $msg = translate("Hello") . ", " . $tempfullname . ".\n\n" .
78 translate("An appointment has been rejected by") .
79 " " . $login_fullname . ". " .
80 translate("The subject was") . " \"" . $name . " \"\n" .
81 translate("The description is") . " \"" . $description . "\"\n" .
82 translate("Date") . ": " . date_to_str ( $fmtdate ) . "\n" .
83 ( ( empty ( $hour ) && empty ( $minute ) ) ? "" :
84 translate("Time") . ": " .
85 display_time ( ( $hour * 10000 ) + ( $minute * 100 ) ) ) .
87 if ( ! empty ( $server_url ) ) {
88 $url = $server_url . "view_entry.php?id=" . $id;
89 $msg .= "\n\n" . $url;
92 $from = $email_fallback_from;
93 if ( strlen ( $login_email ) )
96 $extra_hdrs = "From: $from\r\nX-Mailer: " . translate("Title");
99 translate($application_name) . " " . translate("Notification") . ": " . $name,
100 html_to_8bits ($msg), $extra_hdrs );
101 activity_log ( $id, $login, $partlogin[$i], $LOG_NOTIFICATION,
102 "Event rejected by $app_user" );
107 if ( empty ( $error ) ) {
108 if ( $ret == "list" )
109 do_redirect ( "list_unapproved.php?user=$app_user" );
111 do_redirect ( "view_entry.php?id=$id&user=$app_user" );
115 echo "<h2>" . translate("Error") . "</h2>\n";
116 echo "<p>" . $error . "</p>\n";