//make globals values passed to styles.php are for this user
//makes the demo calendar accurate
$GLOBALS['BGCOLOR'] = $prefarray['BGCOLOR'];
$GLOBALS['H2COLOR'] = $prefarray['H2COLOR'];
$GLOBALS['MENU_THEME'] = $prefarray['MENU_THEME'];
$GLOBALS['TODAYCELLBG'] = $prefarray['TODAYCELLBG'];
$GLOBALS['TABLEBG'] = $prefarray['TABLEBG'];
$GLOBALS['TABLEBG'] = $prefarray['TABLEBG'];
$GLOBALS['THBG'] = $prefarray['THBG'];
$GLOBALS['CELLBG'] = $prefarray['CELLBG'];
$GLOBALS['WEEKENDBG'] = $prefarray['WEEKENDBG'];
$GLOBALS['OTHERMONTHBG'] = $prefarray['OTHERMONTHBG'];
$GLOBALS['FONTS'] = $prefarray['FONTS'];
$GLOBALS['MYEVENTS'] = $prefarray['MYEVENTS'];
//determine if we can set timezones, if not don't display any options
$can_set_timezone = set_env('TZ', $prefarray['TIMEZONE']);
$dateYmd = date('Ymd');
$selected = ' selected="selected" ';
$minutesStr = translate('minutes');
//allow css_cache to display public or NUC values
@session_start();
$_SESSION['webcal_tmp_login'] = $prefuser;
//Prh ... add user to edit_template to get/set correct template
$openStr = "\"window.open( 'edit_template.php?type=%s&user=%s','cal_template','dependent,menubar,scrollbars,height=500,width=500,outerHeight=520,outerWidth=520' );\"";
$currenttab = getPostValue('currenttab', 'settings');
$currenttab = !empty($currenttab) ? $currenttab : 'settings';
$BodyX = 'onload="altrows(); showTab( \'' . $currenttab . '\' );"';
$INC = array('js/visible.php', 'js/pref.php');
print_header($INC, '', $BodyX);
?>
Example #2
0
     $error = $dberror . dbi_error();
     break;
 } else {
     // Check UAC.
     $can_email = 'Y';
     if (access_is_enabled()) {
         $can_email = access_user_calendar('email', $participants[$i], $login);
     }
     // Don't send mail if we are editing a non-user calendar and we are the admin.
     if (!$is_nonuser_admin && $can_email == 'Y') {
         // Only send mail if their email address is filled in.
         $do_send = get_pref_setting($participants[$i], $newevent ? 'EMAIL_EVENT_ADDED' : 'EMAIL_EVENT_UPDATED');
         $htmlmail = get_pref_setting($participants[$i], 'EMAIL_HTML');
         $t_format = get_pref_setting($participants[$i], 'TIME_FORMAT');
         $user_TIMEZONE = get_pref_setting($participants[$i], 'TIMEZONE');
         set_env('TZ', $user_TIMEZONE);
         $user_language = get_pref_setting($participants[$i], 'LANGUAGE');
         user_load_variables($participants[$i], 'temp');
         if (boss_must_be_notified($login, $participants[$i]) && !empty($tempemail) && $do_send == 'Y' && $send_user_mail && $SEND_EMAIL != 'N') {
             // We send to creator if they want it.
             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') {
function print_timezone_select_html($prefix, $tz)
{
    $ret = '';
    // Allows different SETTING names between SERVER and USER.
    if ($prefix == 'admin_') {
        $prefix .= 'SERVER_';
    }
    // We may be using php 4.x on Windows, so we can't use set_env () to
    // adjust the user's TIMEZONE. We'll need to reply on the old fashioned
    // way of using $tz_offset from the server's timezone.
    $can_setTZ = substr($tz, 0, 11) == 'WebCalendar' ? false : true;
    $old_TZ = getenv('TZ');
    set_env('TZ', 'America/New_York');
    $tmp_timezone = date('T');
    set_env('TZ', $old_TZ);
    // Don't change this to date ().
    // if ( date ( 'T' ) == 'Ame' || ! $can_setTZ ) { //We have a problem!!
    if (0) {
        // Ignore this code for now.
        $tz_value = !$can_setTZ ? substr($tz, 12) : 0;
        $ret = '
        <select name="' . $prefix . 'TIMEZONE" id="' . $prefix . 'TIMEZONE">';
        $text_add = translate('Add N hours to');
        $text_sub = translate('Subtract N hours from');
        for ($i = -12; $i <= 13; $i++) {
            $ret .= '
          <option value="WebCalendar/' . $i . '"' . ($tz_value == $i ? ' selected="selected"' : '') . '>' . ($i < 0 ? str_replace('N', -$i, $text_sub) : ($i == 0 ? translate('same as') : str_replace('N', $i, $text_add))) . '</option>';
        }
        $ret .= '
        </select>&nbsp;' . translate('server time');
    } else {
        // This installation supports TZ env.
        // Import Timezone name. This file will not normally be available
        // on windows platforms, so we'll just include it with WebCalendar.
        $tz_file = 'includes/zone.tab';
        if (!($fd = @fopen($tz_file, 'r', false))) {
            return str_replace('XXX', $tz_file, translate('Cannot read timezone file XXX.'));
        } else {
            while (($data = fgets($fd, 1000)) !== false) {
                if (substr(trim($data), 0, 1) == '#' || strlen($data) <= 2) {
                    continue;
                } else {
                    $data = trim($data, strrchr($data, '#'));
                    $data = preg_split('/[\\s,]+/', trim($data));
                    $timezones[] = $data[2];
                }
            }
            fclose($fd);
        }
        sort($timezones);
        $ret = '
        <select name="' . $prefix . 'TIMEZONE" id="' . $prefix . 'TIMEZONE">';
        for ($i = 0, $cnt = count($timezones); $i < $cnt; $i++) {
            $ret .= '
          <option value="' . $timezones[$i] . '"' . ($timezones[$i] == $tz ? ' selected="selected" ' : '') . '>' . unhtmlentities($timezones[$i]) . '</option>';
        }
        // translate ( 'Your current GMT offset is' )
        $ret .= '
        </select>&nbsp;&nbsp;' . str_replace(' XXX ', '&nbsp;' . date('Z') / 3600 . '&nbsp;', translate('Your current GMT offset is XXX hours.'));
    }
    return $ret;
}
Example #4
0
}
$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
  WHERE we.cal_id = weu.cal_id AND we.cal_id = ?
  AND ( we.cal_create_by = ? OR weu.cal_login = ? )', array($id, $sqlparm, $sqlparm));
if ($res) {
    $row = dbi_fetch_row($res);
    if ($row && $row[0] > 0) {
        $can_view = $is_my_event = true;
        $creator = $row[1];
    }
Example #5
0
          WHERE cal_id = ? AND cal_login = ?', array('D', $id, $del_user));
                activity_log($id, $login, $login, $log_reject, '');
            }
        }
    }
}
$ret = getValue('ret');
$return_view = get_last_view();
if (!empty($ret)) {
    if ($ret == 'listall') {
        $url = 'list_unapproved.php';
    } else {
        if ($ret == 'list') {
            $url = 'list_unapproved.php' . (empty($user) ? '' : '?user='******'', empty($user) ? '' : 'user='******'TZ', $TIMEZONE);
if (empty($error) && empty($mailerError)) {
    do_redirect($url);
    exit;
}
// Process errors.
$mail->MailError($mailerError, $error);
function send_reminder($id, $event_date)
{
    global $ALLOW_EXTERNAL_USERS, $debug, $def_tz, $emails, $EXTERNAL_REMINDERS, $attachics, $htmlmail, $is_task, $LANGUAGE, $languages, $names, $only_testing, $SERVER_URL, $site_extras, $t_format, $tz;
    $ext_participants = $participants = array();
    $num_ext_participants = $num_participants = 0;
    $pri[1] = translate('High');
    $pri[2] = translate('Medium');
    $pri[3] = translate('Low');
    // Get participants first...
    $res = dbi_execute('SELECT cal_login, cal_percent FROM webcal_entry_user
    WHERE cal_id = ? AND cal_status IN ( \'A\',\'W\' ) ORDER BY cal_login', array($id));
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $participants[$num_participants++] = $row[0];
            $percentage[$row[0]] = $row[1];
        }
    }
    $partcnt = count($participants);
    // Get external participants.
    if (!empty($ALLOW_EXTERNAL_USERS) && $ALLOW_EXTERNAL_USERS == 'Y' && !empty($EXTERNAL_REMINDERS) && $EXTERNAL_REMINDERS == 'Y') {
        $res = dbi_execute('SELECT cal_fullname, cal_email
      FROM webcal_entry_ext_user WHERE cal_id = ? AND cal_email IS NOT NULL
      ORDER BY cal_fullname', array($id));
        if ($res) {
            while ($row = dbi_fetch_row($res)) {
                $ext_participants[$num_ext_participants] = $row[0];
                $ext_participants_email[$num_ext_participants++] = $row[1];
            }
        }
    }
    $ext_partcnt = count($ext_participants);
    if (!$num_participants && !$num_ext_participants) {
        if ($debug) {
            echo 'No participants found for event id' . ": {$id}<br />\n";
        }
        return;
    }
    // Get event details.
    $res = dbi_execute('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, cal_due_date, cal_due_time FROM webcal_entry
    WHERE cal_id = ?', array($id));
    if (!$res) {
        echo translate('Database error') . ': ' . translate('could not find event id') . " {$id}.\n";
        return;
    }
    if (!($row = dbi_fetch_row($res))) {
        echo translate('Error') . ': ' . str_replace('XXX', $id, translate('could not find event id XXX in database.')) . "\n";
        return;
    }
    // Send mail. We send one user at a time so that we can switch
    // languages between users if needed (as well as HTML vs plain text).
    $mailusers = $recipients = array();
    if (isset($single_user) && $single_user == 'Y') {
        $mailusers[] = $emails[$single_user_login];
        $recipients[] = $single_user_login;
    } else {
        for ($i = 0; $i < $partcnt; $i++) {
            if (strlen($emails[$participants[$i]])) {
                $mailusers[] = $emails[$participants[$i]];
                $recipients[] = $participants[$i];
            } else {
                if ($debug) {
                    echo "No email for user {$participants[$i]}.<br />\n";
                }
            }
        }
        for ($i = 0; $i < $ext_partcnt; $i++) {
            $mailusers[] = $ext_participants_email[$i];
            $recipients[] = $ext_participants[$i];
        }
    }
    $mailusercnt = count($mailusers);
    if ($debug) {
        echo 'Found ' . $mailusercnt . " with email addresses<br />\n";
    }
    for ($j = 0; $j < $mailusercnt; $j++) {
        $recip = $mailusers[$j];
        $user = $recipients[$j];
        $isExt = !in_array($user, $participants);
        $userlang = empty($languages[$user]) ? $LANGUAGE : $languages[$user];
        $userTformat = !empty($t_format[$user]) ? $t_format[$user] : 24;
        // Gotta pick something.
        if ($userlang == 'none') {
            $userlang = 'English-US';
        }
        // Gotta pick something.
        if ($debug) {
            echo "Setting language to \"{$userlang}\".<br />\n";
        }
        reset_language($userlang);
        $adminStr = translate('Administrator');
        // Reset timezone setting for current user.
        if (!empty($tz[$user])) {
            $display_tzid = 2;
            // Display TZ.
            $user_TIMEZONE = $tz[$user];
        } else {
            if (!empty($def_tz)) {
                $display_tzid = 2;
                $user_TIMEZONE = $def_tz;
            } else {
                $display_tzid = 3;
                // Do not use offset & display TZ.
                // I think this is the only real timezone set to UTC...since 1972 at least.
                $user_TIMEZONE = 'Africa/Monrovia';
            }
        }
        // This will allow date functions to use the proper TIMEZONE.
        set_env('TZ', $user_TIMEZONE);
        $useHtml = !empty($htmlmail[$user]) ? 'Y' : 'N';
        $padding = !empty($htmlmail[$user]) ? '&nbsp;&nbsp;&nbsp;' : '   ';
        $body = str_replace('XXX', $is_task ? translate('task') : translate('event'), translate('This is a reminder for the XXX detailed below.')) . "\n\n";
        $create_by = $row[0];
        $event_time = date_to_epoch($row[1] . ($row[2] != -1 ? sprintf("%06d", $row[2]) : ''));
        $name = $row[9];
        $description = $row[10];
        // Add trailing '/' if not found in server_url.
        // Don't include link for External users.
        if (!empty($SERVER_URL) && !$isExt) {
            $eventURL = $SERVER_URL . (substr($SERVER_URL, -1, 1) == '/' ? '' : '/') . 'view_entry.php?id=' . $id . '&em=1';
            if ($useHtml == 'Y') {
                $eventURL = activate_urls($eventURL);
            }
            $body .= $eventURL . "\n\n";
        }
        $body .= strtoupper($name) . "\n\n" . translate('Description') . ":\n" . $padding . $description . "\n" . ($is_task ? translate('Start Date') : translate('Date')) . ': ' . date_to_str($row[2] > 0 ? date('Ymd', $event_date) : gmdate('Ymd', $event_date)) . "\n" . ($row[2] > 0 ? ($is_task ? translate('Start Time') : translate('Time')) . ': ' . display_time('', $display_tzid, $event_time, $userTformat) . "\n" : ($row[2] == 0 && ($row[5] = 1440) ? translate('Time') . ': ' . translate('All day event') . "\n" : '')) . ($row[5] > 0 && !$is_task ? translate('Duration') . ': ' . $row[5] . ' ' . translate('minutes') . "\n" : ($is_task ? translate('Due Date') . ': ' . date_to_str($row[11]) . "\n" . translate('Due Time') . ': ' . display_time($row[12], $display_tzid, '', $userTformat) . "\n" : '')) . ($is_task && isset($percentage[$user]) ? translate('Pecentage Complete') . ': ' . $percentage[$user] . "%\n" : '') . (empty($DISABLE_PRIORITY_FIELD) || $DISABLE_PRIORITY_FIELD != 'Y' ? translate('Priority') . ': ' . $row[6] . '-' . $pri[ceil($row[6] / 3)] . "\n" : '');
        if (empty($DISABLE_ACCESS_FIELD) || $DISABLE_ACCESS_FIELD != 'Y') {
            $body .= translate('Access') . ': ';
            if ($row[8] == 'C') {
                $body .= translate('Confidential') . "\n";
            } elseif ($row[8] == 'P') {
                $body .= translate('Public') . "\n";
            } elseif ($row[8] == 'R') {
                $body .= translate('Private') . "\n";
            }
        }
        $body .= (!empty($single_user_login) && !$single_user_login ? translate('Created by') . ': ' . $row[0] . "\n" : '') . translate('Updated') . ': ' . date_to_str($row[3]) . ' ' . display_time($row[3] . sprintf("%06d", $row[4]), $display_tzid, '', $userTformat) . "\n";
        // Site extra fields.
        $extras = get_site_extra_fields($id);
        $site_extracnt = count($site_extras);
        for ($i = 0; $i < $site_extracnt; $i++) {
            if ($site_extras[$i] == 'FIELDSET') {
                continue;
            }
            $extra_name = $site_extras[$i][0];
            $extra_descr = $site_extras[$i][1];
            $extra_type = $site_extras[$i][2];
            $extra_arg1 = $site_extras[$i][3];
            $extra_arg2 = $site_extras[$i][4];
            if (!empty($site_extras[$i][5])) {
                $extra_view = $site_extras[$i][5] & EXTRA_DISPLAY_REMINDER;
            }
            if (!empty($extras[$extra_name]['cal_name']) && $extras[$extra_name]['cal_name'] != '' && !empty($extra_view)) {
                $val = '';
                $body .= $extra_descr;
                if ($extra_type == EXTRA_DATE) {
                    $body .= ': ' . $extras[$extra_name]['cal_date'] . "\n";
                } elseif ($extra_type == EXTRA_MULTILINETEXT) {
                    $body .= "\n" . $padding . $extras[$extra_name]['cal_data'] . "\n";
                } elseif ($extra_type == EXTRA_RADIO) {
                    $body .= ': ' . $extra_arg1[$extras[$extra_name]['cal_data']] . "\n";
                } else {
                    // Default method for EXTRA_URL, EXTRA_TEXT, etc...
                    $body .= ': ' . $extras[$extra_name]['cal_data'] . "\n";
                }
            }
        }
        if ((empty($single_user) || $single_user != 'Y') && (empty($DISABLE_PARTICIPANTS_FIELD) || $DISABLE_PARTICIPANTS_FIELD != 'N')) {
            $body .= translate('Participants') . ":\n";
            for ($i = 0; $i < $partcnt; $i++) {
                $body .= $padding . $names[$participants[$i]] . "\n";
            }
            for ($i = 0; $i < $ext_partcnt; $i++) {
                $body .= $padding . $ext_participants[$i] . ' ( ' . translate('External User') . ")\n";
            }
        }
        $subject = translate('Reminder') . ': ' . stripslashes($name);
        if ($debug) {
            echo "Sending mail to {$recip} (in {$userlang}).<br />\n";
        }
        if ($only_testing) {
            if ($debug) {
                echo '<hr />
<pre>
To: ' . $recip . '
Subject: ' . $subject . '
From:' . $adminStr . '

' . $body . '

</pre>
';
            }
        } else {
            $mail = new WebCalMailer();
            user_load_variables($user, 'temp');
            $recipName = $isExt ? $user : $GLOBALS['tempfullname'];
            // Send ics attachment to External Users or
            // or users who explicitly chose to receive it.
            $attach = $isExt || isset($attachics[$user]) ? $id : '';
            $mail->WC_Send($adminStr, $recip, $recipName, $subject, $body, $useHtml, $GLOBALS['EMAIL_FALLBACK_FROM'], $attach);
            $cal_text = ($isExt ? translate('External User') : '') . $recipName;
            activity_log($id, 'system', $user, LOG_REMINDER, $cal_text);
        }
    }
}
Example #7
0
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;
}
Example #8
0
    By using this software, you acknowledge having read this license and agree to be bound thereby.

                http://openqrm-enterprise.com

    Copyright 2014, openQRM Enterprise GmbH <*****@*****.**>
*/
$RootDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/';
require_once $RootDir . '/include/openqrm-database-functions.php';
global $USER_INFO_TABLE;
require_once $RootDir . '/class/user.class.php';
require_once $RootDir . '/class/event.class.php';
function set_env()
{
    // auth user
    if (isset($_SERVER['PHP_AUTH_USER'])) {
        $OPENQRM_USER = new user($_SERVER['PHP_AUTH_USER']);
        if ($OPENQRM_USER->check_user_exists()) {
            $OPENQRM_USER->set_user();
            $GLOBALS['OPENQRM_USER'] = $OPENQRM_USER;
            define('OPENQRM_USER_NAME', $OPENQRM_USER->name);
            define('OPENQRM_USER_ROLE_NAME', $OPENQRM_USER->role);
        }
    }
    // admin user for running commands
    $OPENQRM_ADMIN = new user('openqrm');
    $OPENQRM_ADMIN->set_user();
    $GLOBALS['OPENQRM_ADMIN'] = $OPENQRM_ADMIN;
}
set_env();