} dbi_free_result($res); } //get user settings $res = dbi_execute('SELECT cal_setting, cal_value FROM webcal_user_pref WHERE cal_login = ?', array($prefuser)); if ($res) { while ($row = dbi_fetch_row($res)) { $prefarray[$row[0]] = $row[1]; } dbi_free_result($res); } //this will force $LANGUAGE to to the current value and eliminate having //to double click the 'SAVE' buton $translation_loaded = false; reset_language(get_pref_setting($login, 'LANGUAGE')); //move this include here to allow proper translation include 'includes/date_formats.php'; //get list of menu themes $menuthemes = array(); $dir = 'includes/menu/themes/'; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file == '.' || $file == '..' || $file == 'CVS' || $file == 'default') { continue; } if (is_dir($dir . $file)) { $menuthemes[] = $file; } }
dbi_free_result($res); } // Get event name $sql = "SELECT cal_name FROM webcal_entry WHERE cal_id = {$id}"; $res = dbi_query($sql); if ($res) { $row = dbi_fetch_row($res); $name = $row[0]; dbi_free_result($res); } // TODO: switch transation language based on user so each user // gets message in their selected language. for ($i = 0; $i < count($partlogin); $i++) { // Log the deletion activity_log($id, $login, $partlogin[$i], $LOG_DELETE, ""); $do_send = get_pref_setting($partlogin[$i], "EMAIL_EVENT_DELETED"); user_load_variables($partlogin[$i], "temp"); if ($partlogin[$i] != $login && $do_send == "Y" && strlen($tempemail) && $send_email != "N") { $msg = translate("Hello") . ", " . $tempfullname . ".\n\n" . translate("An appointment has been canceled for you by") . " " . $login_fullname . ". " . translate("The subject was") . " \"" . $name . "\"\n\n"; if (strlen($login_email)) { $extra_hdrs = "From: {$login_email}\nX-Mailer: " . translate($application_name); } else { $extra_hdrs = "From: {$email_fallback_from}\nX-Mailer: " . translate($application_name); } mail($tempemail, translate($application_name) . " " . translate("Notification") . ": " . $name, html_to_8bits($msg), $extra_hdrs); } } // Instead of deleting from the database... mark it as deleted // by setting the status for each participant to "D" (instead // of "A"/Accepted, "W"/Waiting-on-approval or "R"/Rejected) if ($override_repeat) {
$res = dbi_query($sql); if ($res) { $row = dbi_fetch_row($res); $name = $row[0]; $description = $row[1]; $fmtdate = $row[2]; $time = $row[3]; dbi_free_result($res); } if ($time != '-1') { $hour = substr($time, 0, 2); $minute = substr($time, 2, 2); } for ($i = 0; $i < count($partlogin); $i++) { // does this user want email for this? $send_user_mail = get_pref_setting($partlogin[$i], "EMAIL_EVENT_REJECTED"); user_load_variables($partlogin[$i], "temp"); if ($send_user_mail == "Y" && strlen($tempemail) && $send_email != "N") { $msg = translate("Hello") . ", " . $tempfullname . ".\n\n" . translate("An appointment has been rejected by") . " " . $login_fullname . ". " . translate("The subject was") . " \"" . $name . " \"\n" . translate("The description is") . " \"" . $description . "\"\n" . translate("Date") . ": " . date_to_str($fmtdate) . "\n" . (empty($hour) && empty($minute) ? "" : translate("Time") . ": " . display_time($hour * 10000 + $minute * 100)) . "\n\n\n"; if (!empty($server_url)) { $url = $server_url . "view_entry.php?id=" . $id; $msg .= "\n\n" . $url; } $from = $email_fallback_from; if (strlen($login_email)) { $from = $login_email; } $extra_hdrs = "From: {$from}\r\nX-Mailer: " . translate("Title"); mail($tempemail, translate($application_name) . " " . translate("Notification") . ": " . $name, html_to_8bits($msg), $extra_hdrs); activity_log($id, $login, $partlogin[$i], $LOG_NOTIFICATION, "Event rejected by {$app_user}"); }
$row = dbi_fetch_row($res); $name = $row[0]; $description = $row[1]; $fmtdate = $row[2]; $time = $row[3]; dbi_free_result($res); } if ($time != '-1') { $hour = substr($time, 0, 2); $minute = substr($time, 2, 2); } for ($i = 0; $i < count($partlogin); $i++) { // does this user want email for this? $send_user_mail = get_pref_setting($partlogin[$i], "EMAIL_EVENT_REJECTED"); user_load_variables($partlogin[$i], "temp"); $user_language = get_pref_setting($partlogin[$i], "LANGUAGE"); if ($send_user_mail == "Y" && strlen($tempemail) && $send_email != "N") { if ($GLOBALS['LANGUAGE'] != $user_language && !empty($user_language) && $user_language != 'none') { reset_language($user_language); } $msg = translate("Hello") . ", " . $tempfullname . ".\n\n" . translate("An appointment has been rejected by") . " " . $login_fullname . ". " . translate("The subject was") . " \"" . $name . " \"\n" . translate("The description is") . " \"" . $description . "\"\n" . translate("Date") . ": " . date_to_str($fmtdate) . "\n" . (empty($hour) && empty($minute) ? "" : translate("Time") . ": " . display_time($hour * 10000 + $minute * 100)) . "\n\n\n"; if (!empty($server_url)) { $url = $server_url . "view_entry.php?id=" . $id; $msg .= "\n\n" . $url; } $from = $email_fallback_from; if (strlen($login_email)) { $from = $login_email; } $extra_hdrs = "From: {$from}\r\nX-Mailer: " . translate("Title"); mail($tempemail, translate($application_name) . " " . translate("Notification") . ": " . $name, html_to_8bits($msg), $extra_hdrs);
function boss_must_approve_event($assistant, $boss) { if (user_is_assistant($assistant, $boss)) { return get_pref_setting($boss, "APPROVE_ASSISTANT_EVENT") == "Y" ? true : false; } return true; }
$sql = "INSERT INTO webcal_entry_user " . "( cal_id, cal_login, cal_status, cal_category ) VALUES ( {$id}, '" . $participants[$i] . "', '{$status}', {$my_cat_id} )"; if (!dbi_query($sql)) { $error = translate("Database error") . ": " . dbi_error(); break; } else { // Don't send mail if we are editing a non-user calendar // and we are the admin if (!$is_nonuser_admin) { $from = $user_email; if (empty($from) && !empty($email_fallback_from)) { $from = $email_fallback_from; } // only send mail if their email address is filled in $do_send = get_pref_setting($participants[$i], $newevent ? "EMAIL_EVENT_ADDED" : "EMAIL_EVENT_UPDATED"); $user_TZ = get_pref_setting($participants[$i], "TZ_OFFSET"); $user_language = get_pref_setting($participants[$i], "LANGUAGE"); user_load_variables($participants[$i], "temp"); if ($participants[$i] != $login && boss_must_be_notified($login, $participants[$i]) && strlen($tempemail) && $do_send == "Y" && $send_user_mail && $send_email != "N") { // Want date/time in user's timezone $user_hour = $hour + $user_TZ; if ($user_hour < 0) { $user_hour += 24; // adjust date $user_date = mktime(3, 0, 0, $month, $day, $year); $user_date -= $ONE_DAY; $user_month = date("m", $date); $user_day = date("d", $date); $user_year = date("Y", $date); } elseif ($user_hour >= 24) { $user_hour -= 24; // adjust date
if ($send_own != 'Y' && $participants[$i] == $login) { continue; } reset_language(empty($user_language) || $user_language == 'none' ? $LANGUAGE : $user_language); $fmtdate = $timetype == 'T' ? date('Ymd', $eventstart) : gmdate('Ymd', $eventstart); $msg = str_replace('XXX', $tempfullname, $helloStr) . "\n\n" . str_replace('XXX', $login_fullname, $newevent || empty($old_status[$participants[$i]]) ? $newAppStr : $updAppStr) . "\n" . str_replace('XXX', $name, $subjStr) . "\n\n" . str_replace('XXX', $description, $descStr) . "\n" . str_replace('XXX', date_to_str($fmtdate), $dateStr) . "\n" . ($timetype != 'T' ? '' : str_replace('XXX', display_time('', 2, $eventstart, $t_format), $timeStr) . "\n") . $extra_email_data . str_replace('XXX', generate_application_name(), $REQUIRE_APPROVALS == 'Y' ? translate('Please look on XXX to accept or reject this appointment.') : translate('Please look on XXX to view this appointment.')); // Add URL to event, if we can figure it out. if (!empty($SERVER_URL)) { // DON'T change & to & here. Email will handle it. $url = $SERVER_URL . 'view_entry.php?id=' . $id . '&em=1'; if ($htmlmail == 'Y') { $url = activate_urls($url); } $msg .= "\n\n" . $url; } $wantsAttach = get_pref_setting($participants[$i], 'EMAIL_ATTACH_ICS', 'N'); $attachId = $wantsAttach == 'Y' ? $id : ''; // Use WebCalMailer class. $mail->WC_Send($login_fullname, $tempemail, $tempfullname, $name, $msg, $htmlmail, $from, $attachId); activity_log($id, $login, $participants[$i], LOG_NOTIFICATION, ''); } } } } //end for loop participants // Add external participants. $ext_emails = $ext_names = $matches = array(); $ext_count = 0; $externalparticipants = getPostValue('externalparticipants'); if ($single_user == 'N' && !empty($ALLOW_EXTERNAL_USERS) && $ALLOW_EXTERNAL_USERS == 'Y' && !empty($externalparticipants)) { $lines = explode("\n", $externalparticipants);
function boss_must_be_notified($assistant, $boss) { if (user_is_assistant($assistant, $boss)) { return get_pref_setting($boss, 'EMAIL_ASSISTANT_EVENTS') == 'Y' ? true : false; } return true; }
$eventstart = date_to_epoch($fmtdate . $time); $TIME_FORMAT = 24; for ($i = 0, $cnt = count($partlogin); $i < $cnt; $i++) { // Log the deletion. activity_log($id, $login, $partlogin[$i], $log_delete, ''); // Check UAC. $can_email = access_is_enabled() ? access_user_calendar('email', $partlogin[$i], $login) : false; // Don't email the logged in user. if ($can_email && $partlogin[$i] != $login) { set_env('TZ', get_pref_setting($partlogin[$i], 'TIMEZONE')); $user_language = get_pref_setting($partlogin[$i], 'LANGUAGE'); user_load_variables($partlogin[$i], 'temp'); if (!$is_nonuser_admin && $partlogin[$i] != $login && get_pref_setting($partlogin[$i], 'EMAIL_EVENT_DELETED') == 'Y' && boss_must_be_notified($login, $partlogin[$i]) && !empty($tempemail) && $SEND_EMAIL != 'N') { reset_language(empty($user_language) || $user_language == 'none' ? $LANGUAGE : $user_language); // Use WebCalMailer class. $mail->WC_Send($login_fullname, $tempemail, $tempfullname, $name, str_replace('XXX', $tempfullname, translate('Hello, XXX.')) . ".\n\n" . str_replace('XXX', $login_fullname, translate('XXX has canceled an appointment.')) . "\n" . str_replace('XXX', $name, translate('Subject XXX')) . "\"\n" . str_replace('XXX', date_to_str($thisdate), translate('Date XXX')) . "\n" . (!empty($eventtime) && $eventtime != '-1' ? str_replace('XXX', display_time('', 2, $eventstart, get_pref_setting($partlogin[$i], 'TIME_FORMAT')), translate('Time XXX')) : '') . "\n\n", get_pref_setting($partlogin[$i], 'EMAIL_HTML'), $login_email); } } } // Instead of deleting from the database... // mark it as deleted by setting the status for each participant to "D" // (instead of "A"/Accepted, "W"/Waiting-on-approval or "R"/Rejected). if ($override_repeat) { dbi_execute('INSERT INTO webcal_entry_repeats_not ( cal_id, cal_date, cal_exdate ) VALUES ( ?, ?, ? )', array($id, $date, 1)); // Should we log this to the activity log??? } else { // If it's a repeating event, delete any event exceptions that were entered. if ($event_repeats) { $res = dbi_execute('SELECT cal_id FROM webcal_entry WHERE cal_group_id = ?', array($id)); if ($res) {
$show_log = !empty($log); $can_email = 'Y'; $areYouSureStr = str_replace('XXX', translate('entry'), translate('Are you sure you want to delete this XXX?')); $pri[1] = translate('High'); $pri[2] = translate('Medium'); $pri[3] = translate('Low'); if (empty($id) || $id <= 0 || !is_numeric($id)) { $error = translate('Invalid entry id.'); } $hide_details = $login == '__public__' && !empty($OVERRIDE_PUBLIC) && $OVERRIDE_PUBLIC == 'Y'; // Check if we can display basic info for RSS FEED $rssuser = getGetValue('rssuser'); if (!empty($rssuser)) { $user_rss_enabled = get_pref_setting($rssuser, 'USER_RSS_ENABLED'); $user_remote_access = get_pref_setting($rssuser, 'USER_REMOTE_ACCESS'); $user_rss_timezone = get_pref_setting($rssuser, 'TIMEZONE'); $rss_view = $RSS_ENABLED == 'Y' && $user_rss_enabled == 'Y' && $friendly == 1 && !empty($rssuser) && isset($user_remote_access); if ($rss_view == true) { if ($login == '__public__') { $user = $rssuser; } $hide_details = false; // Make sure the displayed time is accurate. set_env('TZ', $user_rss_timezone); } } // Is this user a participant or the creator of the event? // If assistant is doing this, then we need to switch login to user in the sql. $sqlparm = $is_assistant ? $user : $login; $res = dbi_execute('SELECT we.cal_id, we.cal_create_by FROM webcal_entry we, webcal_entry_user weu
$my_cat_id = 'NULL'; } $sql = "INSERT INTO webcal_entry_user " . "( cal_id, cal_login, cal_status, cal_category ) VALUES ( {$id}, '" . $participants[$i] . "', '{$status}', {$my_cat_id} )"; if (!dbi_query($sql)) { $error = translate("Database error") . ": " . dbi_error(); break; } else { // Don't send mail if we are editing a non-user calendar // and we are the admin if (!$is_nonuser_admin) { $from = $user_email; if (empty($from) && !empty($email_fallback_from)) { $from = $email_fallback_from; } // only send mail if their email address is filled in $do_send = get_pref_setting($participants[$i], $newevent ? "EMAIL_EVENT_ADDED" : "EMAIL_EVENT_UPDATED"); user_load_variables($participants[$i], "temp"); if ($participants[$i] != $login && boss_must_be_notified($login, $participants[$i]) && strlen($tempemail) && $do_send == "Y" && $send_user_mail && $send_email != "N") { $fmtdate = sprintf("%04d%02d%02d", $year, $month, $day); $msg = translate("Hello") . ", " . $tempfullname . ".\n\n"; if ($newevent || $old_status[$participants[$i]] == '') { $msg .= translate("A new appointment has been made for you by"); } else { $msg .= translate("An appointment has been updated by"); } $msg .= " " . $login_fullname . ". " . translate("The subject is") . " \"" . $name . "\"\n\n" . translate("The description is") . " \"" . $description . "\"\n" . translate("Date") . ": " . date_to_str($fmtdate) . "\n" . (empty($hour) && empty($minute) ? "" : translate("Time") . ": " . display_time($hour * 10000 + $minute * 100) . "\n") . translate("Please look on") . " " . translate($application_name) . " " . ($require_approvals == "Y" ? translate("to accept or reject this appointment") : translate("to view this appointment")) . "."; // add URL to event, if we can figure it out if (!empty($server_url)) { $url = $server_url . "view_entry.php?id=" . $id; $msg .= "\n\n" . $url; }
// Set for use elsewhere as a global $login = $username; // Load user preferences for DISPLAY_UNAPPROVED load_user_preferences(); if ($public_must_be_enabled && $PUBLIC_ACCESS != 'Y') { $error = print_not_auth(21); } if ($error == '') { if ($allow_user_override) { $u = getValue('user', "[A-Za-z0-9_\\.=@,\\-]+", true); if (!empty($u)) { $username = $u; $login = $u; $TIMEZONE = get_pref_setting($username, 'TIMEZONE'); $DISPLAY_UNAPPROVED = get_pref_setting($username, 'DISPLAY_UNAPPROVED'); $DISPLAY_TASKS_IN_GRID = get_pref_setting($username, 'DISPLAY_TASKS_IN_GRID'); // We also set $login since some functions assume that it is set. } } $get_unapproved = !empty($DISPLAY_UNAPPROVED) && $DISPLAY_UNAPPROVED == 'Y'; if ($CATEGORIES_ENABLED == 'Y') { $x = getValue('cat_id', '-?[0-9]+', true); if (!empty($x)) { $cat_id = $x; } } $x = getGetValue('upcoming_title', true); if (!empty($x)) { $upcoming_title = $x; } $x = getGetValue('showMore', true);
$creator = $row[4]; dbi_free_result($res); } $eventstart = date_to_epoch($fmtdate . $time); // TODO figure out if creator wants approved comment email. // Check UAC. $send_user_mail = access_is_enabled() ? access_user_calendar('email', $creator, $login) : 'Y'; $htmlmail = get_pref_setting($creator, 'EMAIL_HTML'); user_load_variables($creator, 'temp'); $user_TIMEZONE = get_pref_setting($creator, 'TIMEZONE'); set_env('TZ', $user_TIMEZONE); $user_language = get_pref_setting($creator, 'LANGUAGE'); if ($send_user_mail == 'Y' && strlen($tempemail) && $SEND_EMAIL != 'N') { reset_language(empty($user_language) || $user_language == 'none' ? $LANGUAGE : $user_language); // translate ( 'Hello' ) $msg = str_replace('XXX', $tempfullname, translate('Hello, XXX.')) . "\n\n" . str_replace('XXX', $login_fullname, translate('XXX has approved an appointment and added comments.')) . "\n\n" . str_replace('XXX', $name, translate('Subject XXX')) . "\n" . str_replace('XXX', $description, translate('Description XXX')) . "\n" . str_replace('XXX', date_to_str($fmtdate), translate('Date XXX')) . ' ' . (empty($hour) && empty($minute) ? '' : str_replace('XXX', display_time('', 2, $eventstart, get_pref_setting($creator, 'TIME_FORMAT')), translate('Time XXX'))) . "\n"; if (!empty($SERVER_URL)) { // DON'T change & to & here. email will handle it $url = $SERVER_URL . 'view_entry.php?id=' . $id . '&em=1'; if ($htmlmail == 'Y') { $url = activate_urls($url); } $msg .= "\n" . $url; } if (!empty($comments)) { // translate ( 'Comments' ) $msg .= "\n\n" . str_replace('XXX', $comments, translate('Comments XXX')); } $from = strlen($login_email) ? $login_email : $EMAIL_FALLBACK_FROM; // Send mail. $mail->WC_Send($login_fullname, $tempemail, $tempfullname, $name, $msg, $htmlmail, $from);
$thisdate = $dateYmd; } else { $thisdate = sprintf("%04d%02d%02d", $thisyear, empty($thismonth) ? date('m') : $thismonth, empty($thisday) ? date('d') : $thisday); } if (empty($cal_date) || !$cal_date) { $cal_date = $thisdate; } if (empty($due_date) || !$due_date) { $due_date = $thisdate; } // Setup to display user's timezone difference if Admin or Assistant. // Even though event is stored in GMT, // an Assistant may need to know that the boss is in a different Timezone. if ($is_assistant || $is_admin && !empty($user)) { $tz_offset = date('Z', date_to_epoch($cal_date . $cal_time)); $user_TIMEZONE = get_pref_setting($user, 'TIMEZONE'); set_env('TZ', $user_TIMEZONE); $user_tz_offset = date('Z', date_to_epoch($cal_date . $cal_time)); if ($tz_offset != $user_tz_offset) { // Different TZ_Offset. user_load_variables($user, 'temp'); $tz_diff = ($user_tz_offset - $tz_offset) / 3600; $abs_diff = abs($tz_diff); // translate ( 'is in a different timezone than you are. Currently' ) // translate ( 'hour ahead of you' ) translate ( 'hour behind you' ) // translate ( 'hours ahead of you' ) translate ( 'hours behind you' ) // translate ( 'XXX is in a different timezone (ahead)' ) // translate ( 'XXX is in a different timezone (behind)' ) // Line breaks in translates below are to bypass update_translation.pl. $TZ_notice = str_replace('XXX', array($tempfullname, $abs_diff . ' ' . translate('hour' . ($abs_diff == 1 ? '' : 's')), translate('Time entered here is based on your Timezone.')), translate('XXX is in a different timezone (' . ($tz_diff > 0 ? 'ahead)' : 'behind)'))); }
function icaldate_to_timestamp($vdate, $tzid = '', $plus_d = '0', $plus_m = '0', $plus_y = '0') { global $SERVER_TIMEZONE, $calUser; $this_TIMEZONE = $Z = ''; // Just in case, trim off leading/trailing whitespace. $vdate = trim($vdate); $user_TIMEZONE = get_pref_setting($calUser, 'TIMEZONE'); $H = $M = $S = 0; $y = substr($vdate, 0, 4) + $plus_y; $m = substr($vdate, 4, 2) + $plus_m; $d = substr($vdate, 6, 2) + $plus_d; if (strlen($vdate) > 8) { $H = substr($vdate, 9, 2); $M = substr($vdate, 11, 2); $S = substr($vdate, 13, 2); $Z = substr($vdate, 15, 1); } // if we get a Mozilla TZID we try to parse it $tzid = parse_tzid($tzid); // Sunbird does not do Timezone right so... // We'll just hardcode their GMT timezone def here switch ($tzid) { case '/Mozilla.org/BasicTimezones/GMT': case 'GMT': // I think this is the only real timezone set to UTC...since 1972 at least $this_TIMEZONE = 'Africa/Monrovia'; $Z = 'Z'; break; case 'US-Eastern': case 'US/Eastern': $this_TIMEZONE = 'America/New_York'; break; case 'US-Central': case 'US/Central': $this_TIMEZONE = 'America/America/Chicago'; break; case 'US-Pacific': case 'US/Pacific': $this_TIMEZONE = 'America/Los_Angeles'; break; case '': break; default: $this_TIMEZONE = $tzid; break; } //end switch // Convert time from user's timezone to GMT if datetime value if (empty($this_TIMEZONE)) { $this_TIMEZONE = !empty($user_TIMEZONE) ? $user_TIMEZONE : $SERVER_TIMEZONE; } if (empty($Z)) { putenv("TZ={$this_TIMEZONE}"); $TS = mktime($H, $M, $S, $m, $d, $y); } else { $TS = gmmktime($H, $M, $S, $m, $d, $y); } set_env('TZ', $user_TIMEZONE); return $TS; }