function delete_palm_events($login)
{
    $res = dbi_query("SELECT cal_id FROM webcal_import_data " . "WHERE cal_login = '******'");
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            dbi_query("DELETE FROM webcal_entry_user WHERE cal_id = {$row['0']}");
            dbi_query("DELETE FROM webcal_entry_repeats WHERE cal_id = {$row['0']}");
            dbi_query("DELETE FROM webcal_entry_repeats_not WHERE cal_id = {$row['0']}");
            dbi_query("DELETE FROM webcal_entry_log WHERE cal_entry_id = {$row['0']}");
            dbi_query("DELETE FROM webcal_site_extras WHERE cal_id = {$row['0']}");
            dbi_query("DELETE FROM webcal_reminder_log WHERE cal_id = {$row['0']}");
            dbi_query("DELETE FROM webcal_import_data WHERE cal_id = {$row['0']}");
            dbi_query("DELETE FROM webcal_entry WHERE cal_id = {$row['0']}");
        }
    }
    dbi_free_result($res);
    return 1;
}
示例#2
0
function doDbSanityCheck()
{
    global $db_login, $db_host, $db_database;
    $res = @dbi_query("SELECT COUNT(cal_value) FROM webcal_config", false, false);
    if ($res) {
        if ($row = dbi_fetch_row($res)) {
            // Found database.  All is peachy.
            dbi_free_result($res);
        } else {
            // Error accessing table.
            // User has wrong db name or has not created tables.
            // Note: cannot translate this since we have not included
            // translate.php yet.
            dbi_free_result($res);
            die_miserable_death("Error finding WebCalendar tables in database '{$db_database}' " . "using db login '{$db_login}' on db server '{$db_host}'.<br/><br/>\n" . "Have you created the database tables as specified in the " . "<a href=\"docs/WebCalendar-SysAdmin.html\" target=\"other\">WebCalendar " . "System Administrator's Guide</a>?");
        }
    } else {
        // Error accessing table.
        // User has wrong db name or has not created tables.
        // Note: cannot translate this since we have not included translate.php yet.
        die_miserable_death("Error finding WebCalendar tables in database '{$db_database}' " . "using db login '{$db_login}' on db server '{$db_host}'.<br/><br/>\n" . "Have you created the database tables as specified in the " . "<a href=\"docs/WebCalendar-SysAdmin.html\" target=\"other\">WebCalendar " . "System Administrator's Guide</a>?");
    }
}
        if ($nlastname) {
            $sql .= " cal_lastname = '{$nlastname}', ";
        }
        if ($nfirstname) {
            $sql .= " cal_firstname = '{$nfirstname}', ";
        }
        $sql .= "cal_admin = '{$nadmin}' WHERE cal_login = '******'";
        if (!dbi_query($sql)) {
            $error = translate("Database error") . ": " . dbi_error();
        }
    } else {
        // Adding
        if (preg_match("/^[\\w]+\$/", $nid)) {
            $nid = $NONUSER_PREFIX . $nid;
            $sql = "INSERT INTO webcal_nonuser_cals " . "( cal_login, cal_firstname, cal_lastname, cal_admin ) " . "VALUES ( '{$nid}', '{$nfirstname}', '{$nlastname}', '{$nadmin}' )";
            if (!dbi_query($sql)) {
                $error = translate("Database error") . ": " . dbi_error();
            }
        } else {
            $error = translate("Calendar ID") . " " . translate("word characters only") . ".";
        }
    }
}
if (!empty($error)) {
    print_header('', '', '', true);
    ?>

<h2><?php 
    etranslate("Error");
    ?>
</h2>
function list_unapproved($user)
{
    global $temp_fullname, $key, $login;
    //echo "Listing events for $user <BR>";
    echo "<UL>\n";
    $sql = "SELECT webcal_entry.cal_id, webcal_entry.cal_name, " . "webcal_entry.cal_description, " . "webcal_entry.cal_priority, webcal_entry.cal_date, " . "webcal_entry.cal_time, webcal_entry.cal_duration, " . "webcal_entry_user.cal_status " . "FROM webcal_entry, webcal_entry_user " . "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . "AND ( webcal_entry.cal_ext_for_id IS NULL " . "OR webcal_entry.cal_ext_for_id = 0 ) AND " . "webcal_entry_user.cal_login = '******' AND " . "webcal_entry_user.cal_status = 'W' " . "ORDER BY webcal_entry.cal_date";
    $res = dbi_query($sql);
    $count = 0;
    $eventinfo = "";
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $key++;
            $id = $row[0];
            $name = $row[1];
            $description = $row[2];
            $pri = $row[3];
            $date = $row[4];
            $time = $row[5];
            $duration = $row[6];
            $status = $row[7];
            $divname = "eventinfo-{$id}-{$key}";
            echo "<LI><A CLASS=\"entry\" HREF=\"view_entry.php?id={$id}";
            echo "\" onMouseOver=\"window.status='" . translate("View this entry") . "'; show(event, '{$divname}'); return true;\" onMouseOut=\"hide('{$divname}'); return true;\">";
            $timestr = "";
            if ($time > 0) {
                $timestr = display_time($time);
                if ($duration > 0) {
                    // calc end time
                    $h = (int) ($time / 10000);
                    $m = $time / 100 % 100;
                    $m += $duration;
                    $d = $duration;
                    while ($m >= 60) {
                        $h++;
                        $m -= 60;
                    }
                    $end_time = sprintf("%02d%02d00", $h, $m);
                    $timestr .= " - " . display_time($end_time);
                }
            }
            echo htmlspecialchars($name);
            echo "</A>";
            echo " (" . date_to_str($date) . ")\n";
            echo ": <A HREF=\"approve_entry.php?id={$id}&ret=list";
            if ($user == "__public__") {
                echo "&public=1";
            }
            echo "\" CLASS=\"navlinks\" onClick=\"return confirm('" . translate("Approve this entry?") . "');\">" . translate("Approve/Confirm") . "</A>, ";
            echo "<A HREF=\"reject_entry.php?id={$id}&ret=list";
            if ($user == "__public__") {
                echo "&public=1";
            }
            echo "\" CLASS=\"navlinks\" onClick=\"return confirm('" . translate("Reject this entry?") . "');\">" . translate("Reject") . "</A>";
            $eventinfo .= build_event_popup($divname, $user, $description, $timestr, $time);
            $count++;
        }
        dbi_free_result($res);
    }
    echo "</UL><P>\n";
    if ($count == 0) {
        user_load_variables($user, "temp_");
        echo translate("No unapproved events for") . " " . $temp_fullname . ".";
    } else {
        echo $eventinfo;
    }
}
                    $id++;
                    dbi_free_result($res);
                    $sql = "INSERT INTO webcal_group " . "( cal_group_id, cal_owner, cal_name, cal_last_update ) VALUES ( " . "{$id}, '{$login}', '{$groupname}', {$date} )";
                    if (!dbi_query($sql)) {
                        $error = translate("Database error") . ": " . dbi_error();
                    }
                } else {
                    $error = translate("Database error") . ": " . dbi_error();
                }
            }
        }
        # update user list
        if ($error == "" && !empty($users)) {
            dbi_query("DELETE FROM webcal_group_user WHERE cal_group_id = {$id}");
            for ($i = 0; $i < count($users); $i++) {
                dbi_query("INSERT INTO webcal_group_user ( cal_group_id, cal_login ) " . "VALUES ( {$id}, '{$users[$i]}' )");
            }
        }
    }
}
if (!empty($error)) {
    print_header('', '', '', true);
    ?>
<h2><?php 
    etranslate("Error");
    ?>
</h2>

<blockquote>
<?php 
    echo $error;
        if ($res) {
            $row = dbi_fetch_row($res);
            if ($row[0] > 0) {
                $error = translate("You can only create one layer for each user") . ".";
            }
            dbi_free_result($res);
        }
        if ($error == "") {
            $res = dbi_query("SELECT MAX(cal_layerid) FROM webcal_user_layers");
            if ($res) {
                $row = dbi_fetch_row($res);
                $layerid = $row[0] + 1;
            } else {
                $layerid = 1;
            }
            dbi_query("INSERT INTO webcal_user_layers ( " . "cal_layerid, cal_login, cal_layeruser, cal_color, cal_dups ) " . "VALUES ('{$layerid}', '{$layer_user}', '{$layeruser}', " . "'{$layercolor}', '{$dups}')");
        }
    }
}
if ($error == "") {
    if ($updating_public) {
        do_redirect("layers.php?public=1");
    } else {
        do_redirect("layers.php");
    }
    exit;
}
print_header();
?>

<h2><?php 
function user_has_boss($assistant)
{
    $ret = false;
    $res = dbi_query("SELECT * FROM webcal_asst as b " . "WHERE b.cal_assistant = '{$assistant}'");
    if ($res) {
        if (dbi_fetch_row($res)) {
            $ret = true;
        }
        dbi_free_result($res);
    }
    return $ret;
}
示例#8
0
?>
</a><br /><br />

<table style="border-width:0px;">
<tr><td style="vertical-align:top;">
	<label for="users"><?php 
etranslate("Assistants");
?>
:</label></td><td>
	<select name="users[]" id="users" size="10" multiple="multiple">
<?php 
// get list of all users
$users = get_my_users();
// get list of users for this view
$sql = "SELECT cal_boss, cal_assistant FROM webcal_asst WHERE cal_boss = '{$user}'";
$res = dbi_query($sql);
if ($res) {
    while ($row = dbi_fetch_row($res)) {
        $assistantuser[$row[1]] = 1;
    }
    dbi_free_result($res);
}
for ($i = 0; $i < count($users); $i++) {
    $u = $users[$i]['cal_login'];
    if ($u == $login) {
        continue;
    }
    if ($u == '__public__') {
        continue;
    }
    echo "<option value=\"{$u}\"";
function import_data($data, $overwrite, $type)
{
    global $login, $count_con, $count_suc, $error_num, $ImportType, $LOG_CREATE;
    global $single_user, $single_user_login, $allow_conflicts;
    global $numDeleted, $errormsg;
    global $calUser, $H2COLOR, $sqlLog;
    $oldUIDs = array();
    $oldIds = array();
    $firstEventId = 0;
    $importId = 1;
    // Generate a unique import id
    $res = dbi_query("SELECT MAX(cal_import_id) FROM webcal_import");
    if ($res) {
        if ($row = dbi_fetch_row($res)) {
            $importId = $row[0] + 1;
        }
        dbi_free_result($res);
    }
    $sql = "INSERT INTO webcal_import ( cal_import_id, cal_name, " . "cal_date, cal_type, cal_login ) VALUES ( {$importId}, NULL, " . date("Ymd") . ", '{$type}', '{$login}' )";
    if (!dbi_query($sql)) {
        $errormsg = translate("Database error") . ": " . dbi_error();
        return;
    }
    foreach ($data as $Entry) {
        $priority = 2;
        $participants[0] = $calUser;
        // Some additional date/time info
        $START = $Entry['StartTime'] > 0 ? localtime($Entry['StartTime']) : 0;
        $END = $Entry['EndTime'] > 0 ? localtime($Entry['EndTime']) : 0;
        $Entry['StartMinute'] = sprintf("%02d", $START[1]);
        $Entry['StartHour'] = sprintf("%02d", $START[2]);
        $Entry['StartDay'] = sprintf("%02d", $START[3]);
        $Entry['StartMonth'] = sprintf("%02d", $START[4] + 1);
        $Entry['StartYear'] = sprintf("%04d", $START[5] + 1900);
        $Entry['EndMinute'] = sprintf("%02d", $END[1]);
        $Entry['EndHour'] = sprintf("%02d", $END[2]);
        $Entry['EndDay'] = sprintf("%02d", $END[3]);
        $Entry['EndMonth'] = sprintf("%02d", $END[4] + 1);
        $Entry['EndYear'] = sprintf("%04d", $END[5] + 1900);
        if ($overwrite && !empty($Entry['UID'])) {
            $oldUIDs[$Entry['UID']]++;
        }
        // Check for untimed
        if ($Entry['Untimed'] == 1) {
            $Entry['StartMinute'] = '';
            $Entry['StartHour'] = '';
            $Entry['EndMinute'] = '';
            $Entry['EndHour'] = '';
        }
        // first check for any schedule conflicts
        if (empty($allow_conflicts) && $Entry['Duration'] != 0) {
            $date = mktime(0, 0, 0, $Entry['StartMonth'], $Entry['StartDay'], $Entry['StartYear']);
            $endt = !empty($Entry['Repeat']['EndTime']) ? $Entry['Repeat']['EndTime'] : 'NULL';
            $dayst = !empty($Entry['Repeat']['RepeatDays']) ? $Entry['Repeat']['RepeatDays'] : "nnnnnnn";
            $ex_days = array();
            if (!empty($Entry['Repeat']['Exceptions'])) {
                foreach ($Entry['Repeat']['Exceptions'] as $ex_date) {
                    $ex_days[] = date("Ymd", $ex_date);
                }
            }
            $dates = get_all_dates($date, RepeatType($Entry['Repeat']['Interval']), $endt, $dayst, $ex_days, $Entry['Repeat']['Frequency']);
            $overlap = overlap($dates, $Entry['Duration'], $Entry['StartHour'], $Entry['StartMinute'], $participants, $login, 0);
        }
        if (empty($error) && !empty($overlap)) {
            $error = translate("The following conflicts with the suggested time") . ":<ul>{$overlap}</ul>\n";
        }
        if (empty($error)) {
            $updateMode = false;
            // See if event already is there from prior import.
            // The same UID is used for all events imported at once with iCal.
            // So, we still don't have enough info to find the exact
            // event we want to replace.  We could just delete all
            // existing events that correspond to the UID.
            /************************************************************************
              Not sure what to do with this code since I don't know how Palm and vCal
              use the UID stuff yet...
              
                  if ( ! empty ( $Entry['UID'] ) ) {
                    $res = dbi_query ( "SELECT webcal_import_data.cal_id " .
                      "FROM webcal_import_data, webcal_entry_user " .
                      "WHERE cal_import_type = 'ical' AND " .
                      "webcal_import_data.cal_id = webcal_entry_user.cal_id AND " .
                      "webcal_entry_user.cal_login = '******' AND " .
                      "cal_external_id = '$Entry[UID]'" );
                    if ( $res ) {
                      if ( $row = dbi_fetch_row ( $res ) ) {
                        if ( ! empty ( $row[0] ) ) {
                          $id = $row[0];
                          $updateMode = true;
                          // update rather than add a new event
                        }
                      }
                    }
                  }
            ************************************************************************/
            // Add the Event
            $res = dbi_query("SELECT MAX(cal_id) FROM webcal_entry");
            if ($res) {
                $row = dbi_fetch_row($res);
                $id = $row[0] + 1;
                dbi_free_result($res);
            } else {
                $id = 1;
                //$error = "Unable to select MAX cal_id: " . dbi_error () . "<br /><br />\n<b>SQL:</b> $sql";
                //break;
            }
            if ($firstEventId == 0) {
                $firstEventId = $id;
            }
            $names = array();
            $values = array();
            $names[] = 'cal_id';
            $values[] = "{$id}";
            if (!$updateMode) {
                $names[] = 'cal_create_by';
                $values[] = "'{$login}'";
            }
            $names[] = 'cal_date';
            $values[] = sprintf("%04d%02d%02d", $Entry['StartYear'], $Entry['StartMonth'], $Entry['StartDay']);
            $names[] = 'cal_time';
            $values[] = $Entry['Untimed'] == 1 ? "-1" : sprintf("%02d%02d00", $Entry['StartHour'], $Entry['StartMinute']);
            $names[] = 'cal_mod_date';
            $values[] = date("Ymd");
            $names[] = 'cal_mod_time';
            $values[] = date("Gis");
            $names[] = 'cal_duration';
            $values[] = sprintf("%d", $Entry['Duration']);
            $names[] = 'cal_priority';
            $values[] = $priority;
            $names[] = 'cal_access';
            $values[] = $Entry['Private'] == 1 ? "'R'" : "'P'";
            $names[] = 'cal_type';
            $values[] = $Entry['Repeat'] ? "'M'" : "'E'";
            if (strlen($Entry['Summary']) == 0) {
                $Entry['Summary'] = translate("Unnamed Event");
            }
            if (strlen($Entry['Description']) == 0) {
                $Entry['Description'] = $Entry['Summary'];
            }
            $Entry['Summary'] = str_replace("\\n", "\n", $Entry['Summary']);
            $Entry['Summary'] = str_replace("\\'", "'", $Entry['Summary']);
            $Entry['Summary'] = str_replace("\\\"", "\"", $Entry['Summary']);
            $Entry['Summary'] = str_replace("'", "\\'", $Entry['Summary']);
            $names[] = 'cal_name';
            $values[] = "'" . $Entry['Summary'] . "'";
            $Entry['Description'] = str_replace("\\n", "\n", $Entry['Description']);
            $Entry['Description'] = str_replace("\\'", "'", $Entry['Description']);
            $Entry['Description'] = str_replace("\\\"", "\"", $Entry['Description']);
            $Entry['Description'] = str_replace("'", "\\'", $Entry['Description']);
            // limit length to 1024 chars since we setup tables that way
            if (strlen($Entry['Description']) >= 1024) {
                $Entry['Description'] = substr($Entry['Description'], 0, 1019) . "...";
            }
            $names[] = 'cal_description';
            $values[] = "'" . $Entry['Description'] . "'";
            //echo "Summary:<p>" . nl2br ( htmlspecialchars ( $Entry['Summary'] ) ) . "</p>";
            //echo "Description:<p>" . nl2br ( htmlspecialchars ( $Entry['Description'] ) ) . "</p>"; exit;
            if ($updateMode) {
                $sql = "UPDATE webcal_entry SET ";
                for ($f = 0; $f < count($names); $f++) {
                    if ($f > 0) {
                        $sql .= ", ";
                    }
                    $sql .= $names[$f] . " = " . $values[$f];
                }
                $sql .= " WHERE cal_id = {$id}";
            } else {
                $sql = "INSERT INTO webcal_entry ( " . implode(", ", $names) . " ) VALUES ( " . implode(", ", $values) . " )";
            }
            if (empty($error)) {
                $sqlLog .= $sql . "<br />\n";
                //echo "SQL: $sql <br />\n";
                if (!dbi_query($sql)) {
                    $error .= "<p>" . translate("Database error") . ": " . dbi_error() . "</p>\n";
                    break;
                }
            }
            // log add/update
            activity_log($id, $login, $login, $updateMode ? $LOG_UPDATE : $LOG_CREATE, "Import from {$ImportType}");
            if ($single_user == "Y") {
                $participants[0] = $single_user_login;
            }
            // Now add to webcal_import_data
            if (!$updateMode) {
                if ($ImportType == "PALMDESKTOP") {
                    $sql = "INSERT INTO webcal_import_data ( cal_import_id, cal_id, " . "cal_login, cal_import_type, cal_external_id ) VALUES ( " . "{$importId}, {$id}, '{$calUser}', 'palm', '{$Entry['RecordID']}' )";
                    $sqlLog .= $sql . "<br />\n";
                    if (!dbi_query($sql)) {
                        $error = translate("Database error") . ": " . dbi_error();
                        break;
                    }
                } else {
                    if ($ImportType == "VCAL") {
                        $uid = empty($Entry['UID']) ? "null" : "'{$Entry['UID']}'";
                        if (strlen($uid) > 200) {
                            $uid = "NULL";
                        }
                        $sql = "INSERT INTO webcal_import_data ( cal_import_id, cal_id, " . "cal_login, cal_import_type, cal_external_id ) VALUES ( " . "{$importId}, {$id}, '{$calUser}', 'vcal', {$uid} )";
                        $sqlLog .= $sql . "<br />\n";
                        if (!dbi_query($sql)) {
                            $error = translate("Database error") . ": " . dbi_error();
                            break;
                        }
                    } else {
                        if ($ImportType == "ICAL") {
                            $uid = empty($Entry['UID']) ? "null" : "'{$Entry['UID']}'";
                            if (strlen($uid) > 200) {
                                $uid = "NULL";
                            }
                            $sql = "INSERT INTO webcal_import_data ( cal_import_id, cal_id, " . "cal_login, cal_import_type, cal_external_id ) VALUES ( " . "{$importId}, {$id}, '{$calUser}', 'ical', {$uid} )";
                            $sqlLog .= $sql . "<br />\n";
                            if (!dbi_query($sql)) {
                                $error = translate("Database error") . ": " . dbi_error();
                                break;
                            }
                        }
                    }
                }
            }
            // Now add participants
            if (!$updateMode) {
                $status = $login == "__public__" ? 'W' : 'A';
                if (empty($cat_id)) {
                    $cat_id = 'NULL';
                }
                $sql = "INSERT INTO webcal_entry_user " . "( cal_id, cal_login, cal_status, cal_category ) VALUES ( {$id}, '" . $participants[0] . "', '{$status}', {$cat_id} )";
                $sqlLog .= $sql . "<br />\n";
                if (!dbi_query($sql)) {
                    $error = translate("Database error") . ": " . dbi_error();
                    break;
                }
            }
            // Add repeating info
            if ($updateMode) {
                // remove old repeating info
                dbi_query("DELETE FROM webcal_entry_repeats WHERE cal_id = {$id}");
                dbi_query("DELETE FROM webcal_entry_repeats_not WHERE cal_id = {$id}");
            }
            if (!empty($Entry['Repeat']['Interval'])) {
                //while ( list($k,$v) = each ( $Entry['Repeat'] ) ) {
                //  echo "$k: $v <br />\n";
                //}
                $rpt_type = RepeatType($Entry['Repeat']['Interval']);
                $freq = $Entry['Repeat']['Frequency'] ? $Entry['Repeat']['Frequency'] : 1;
                if (strlen($Entry['Repeat']['EndTime'])) {
                    $REND = localtime($Entry['Repeat']['EndTime']);
                    $end = sprintf("%04d%02d%02d", $REND[5] + 1900, $REND[4] + 1, $REND[3]);
                } else {
                    $end = 'NULL';
                }
                $days = !empty($Entry['Repeat']['RepeatDays']) ? "'" . $Entry['Repeat']['RepeatDays'] . "'" : 'NULL';
                $sql = "INSERT INTO webcal_entry_repeats ( cal_id, " . "cal_type, cal_end, cal_days, cal_frequency ) VALUES " . "( {$id}, '{$rpt_type}', {$end}, {$days}, {$freq} )";
                $sqlLog .= $sql . "<br />\n";
                if (!dbi_query($sql)) {
                    $error = "Unable to add to webcal_entry_repeats: " . dbi_error() . "<br /><br />\n<b>SQL:</b> {$sql}";
                    break;
                }
                // Repeating Exceptions...
                if (!empty($Entry['Repeat']['Exceptions'])) {
                    foreach ($Entry['Repeat']['Exceptions'] as $ex_date) {
                        $ex_date = date("Ymd", $ex_date);
                        $sql = "INSERT INTO webcal_entry_repeats_not ( cal_id, cal_date ) VALUES ( {$id}, {$ex_date} )";
                        $sqlLog .= $sql . "<br />\n";
                        if (!dbi_query($sql)) {
                            $error = "Unable to add to webcal_entry_repeats_not: " . dbi_error() . "<br /><br />\n<b>SQL:</b> {$sql}";
                            break;
                        }
                    }
                }
            }
            // End Repeat
            // Add Alarm info -> site_extras
            if ($updateMode) {
                dbi_query("DELETE FROM webcal_site_extras WHERE cal_id = {$id}");
            }
            if ($Entry['AlarmSet'] == 1) {
                $RM = $Entry['AlarmAdvanceAmount'];
                if ($Entry['AlarmAdvanceType'] == 1) {
                    $RM = $RM * 60;
                }
                if ($Entry['AlarmAdvanceType'] == 2) {
                    $RM = $RM * 60 * 24;
                }
                $sql = "INSERT INTO webcal_site_extras ( cal_id, " . "cal_name, cal_type, cal_remind, cal_data ) VALUES " . "( {$id}, 'Reminder', 7, 1, {$RM} )";
                $sqlLog .= $sql . "<br />\n";
                if (!dbi_query($sql)) {
                    $error = translate("Database error") . ": " . dbi_error();
                }
            }
        }
        if (!empty($error) && empty($overlap)) {
            $error_num++;
            echo "<h2>" . translate("Error") . "</h2>\n<blockquote>\n";
            echo $error . "</blockquote>\n<br />\n";
        }
        // Conflicting
        if (!empty($overlap)) {
            echo "<b><h2>" . translate("Scheduling Conflict") . ": ";
            $count_con++;
            echo "</h2></b>";
            if ($Entry['Duration'] > 0) {
                $time = display_time($Entry['StartHour'] . $Entry['StartMinute'] . "00") . " - " . display_time($Entry['EndHour'] . $Entry['EndMinute'] . "00");
            }
            $dd = $Entry['StartMonth'] . "-" . $Entry['StartDay'] . "-" . $Entry['StartYear'];
            echo "<a class=\"entry\" href=\"view_entry.php?id={$id}";
            echo "\" onmouseover=\"window.status='" . translate("View this entry") . "'; return true;\" onmouseout=\"window.status=''; return true;\">";
            $Entry['Summary'] = str_replace("''", "'", $Entry['Summary']);
            $Entry['Summary'] = str_replace("'", "\\'", $Entry['Summary']);
            echo htmlspecialchars($Entry['Summary']);
            echo "</a> (" . $dd;
            $time = trim($time);
            if (!empty($time)) {
                echo "&nbsp; " . $time;
            }
            echo ")<br />\n";
            etranslate("conflicts with the following existing calendar entries");
            echo ":<ul>\n" . $overlap . "</ul>\n";
        } else {
            // No Conflict
            echo "<b><h2>" . translate("Event Imported") . ":</h2></b>\n";
            $count_suc++;
            if ($Entry['Duration'] > 0) {
                $time = display_time($Entry['StartHour'] . $Entry['StartMinute'] . "00") . " - " . display_time($Entry['EndHour'] . $Entry['EndMinute'] . "00");
            }
            $dateYmd = sprintf("%04d%02d%02d", $Entry['StartYear'], $Entry['StartMonth'], $Entry['StartDay']);
            $dd = date_to_str($dateYmd);
            echo "<a class=\"entry\" href=\"view_entry.php?id={$id}";
            echo "\" onmouseover=\"window.status='" . translate("View this entry") . "'; return true;\" onmouseout=\"window.status=''; return true;\">";
            $Entry['Summary'] = str_replace("''", "'", $Entry['Summary']);
            $Entry['Summary'] = str_replace("\\", "", $Entry['Summary']);
            echo htmlspecialchars($Entry['Summary']);
            echo "</a> (" . $dd;
            if (!empty($time)) {
                echo "&nbsp; " . $time;
            }
            echo ")<br />\n";
        }
        // Reset Variables
        $overlap = $error = $dd = $time = '';
    }
    // Mark old events from prior import as deleted.
    if ($overwrite && count($oldUIDs) > 0) {
        // We could do this with a single SQL using sub-select, but
        // I'm pretty sure MySQL does not support it.
        $old = array_keys($oldUIDs);
        for ($i = 0; $i < count($old); $i++) {
            $sql = "SELECT cal_id FROM webcal_import_data WHERE " . "cal_import_type = '{$type}' AND " . "cal_external_id = '{$old[$i]}' AND " . "cal_login = '******' AND " . "cal_id < {$firstEventId}";
            $res = dbi_query($sql);
            if ($res) {
                while ($row = dbi_fetch_row($res)) {
                    $oldIds[] = $row[0];
                }
                dbi_free_result($res);
            } else {
                echo translate("Database error") . ": " . dbi_error() . "<br />\n";
            }
        }
        for ($i = 0; $i < count($oldIds); $i++) {
            $sql = "UPDATE webcal_entry_user SET cal_status = 'D' " . "WHERE cal_id = {$oldIds[$i]}";
            $sqlLog .= $sql . "<br />\n";
            dbi_query($sql);
            $numDeleted++;
        }
    }
    //echo "<b>SQL:</b><br />\n$sqlLog\n";
}
示例#10
0
<br /><br /><br />
<span style="font-size:13px;">
<?php 
etranslate("cookies-note");
?>
</span>
<br />
<hr /><br /><br />
<a href="<?php 
echo $PROGRAM_URL;
?>
" class="aboutinfo"><?php 
echo $PROGRAM_NAME;
?>
</a>

<?php 
// Print custom trailer (since we do not call print_trailer function)
if (!empty($CUSTOM_TRAILER) && $CUSTOM_TRAILER == 'Y') {
    $res = dbi_query("SELECT cal_template_text FROM webcal_report_template " . "WHERE cal_template_type = 'T' and cal_report_id = 0");
    if ($res) {
        if ($row = dbi_fetch_row($res)) {
            echo $row[0];
        }
        dbi_free_result($res);
    }
}
?>
</body>
</html>
示例#11
0
文件: pref.php 项目: rohcehlam/rflow
$updating_public = false;
$prefarray = array();
$prefarray['EMAIL_ASSISTANT_EVENTS'] = $prefarray['APPROVE_ASSISTANT_EVENT'] = '';
// no undefined vars message
$res = dbi_query("SELECT cal_setting, cal_value FROM webcal_config ");
if ($res) {
    while ($row = dbi_fetch_row($res)) {
        $prefarray[$row[0]] = $row[1];
    }
    dbi_free_result($res);
}
if ($is_admin && !empty($public) && $public_access == "Y") {
    $updating_public = true;
    $res = dbi_query("SELECT cal_setting, cal_value FROM webcal_user_pref " . "WHERE cal_login = '******'");
} else {
    $res = dbi_query("SELECT cal_setting, cal_value FROM webcal_user_pref " . "WHERE cal_login = '******'");
}
if ($res) {
    while ($row = dbi_fetch_row($res)) {
        $prefarray[$row[0]] = $row[1];
    }
    dbi_free_result($res);
}
$INC = array('js/pref.php');
print_header($INC);
?>

<h2><?php 
if ($updating_public) {
    echo translate($PUBLIC_ACCESS_FULLNAME) . "&nbsp;";
}
示例#12
0
function list_unapproved($user)
{
    global $temp_fullname, $key, $login;
    //echo "Listing events for $user <br>";
    $sql = "SELECT webcal_entry.cal_id, webcal_entry.cal_name, " . "webcal_entry.cal_description, " . "webcal_entry.cal_priority, webcal_entry.cal_date, " . "webcal_entry.cal_time, webcal_entry.cal_duration, " . "webcal_entry_user.cal_status " . "FROM webcal_entry, webcal_entry_user " . "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . "AND ( webcal_entry.cal_ext_for_id IS NULL " . "OR webcal_entry.cal_ext_for_id = 0 ) AND " . "webcal_entry_user.cal_login = '******' AND " . "webcal_entry_user.cal_status = 'W' " . "ORDER BY webcal_entry.cal_date";
    $res = dbi_query($sql);
    $count = 0;
    $eventinfo = "";
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            if ($count == 0) {
                echo "<ul>\n";
            }
            $key++;
            $id = $row[0];
            $name = $row[1];
            $description = $row[2];
            $pri = $row[3];
            $date = $row[4];
            $time = $row[5];
            $duration = $row[6];
            $status = $row[7];
            $divname = "eventinfo-{$id}-{$key}";
            echo "<li><a title=\"" . translate("View this entry") . "\" class=\"entry\" href=\"view_entry.php?id={$id}&amp;user={$user}";
            echo "\" onmouseover=\"window.status='" . translate("View this entry") . "'; show(event, '{$divname}'); return true;\" onmouseout=\"hide('{$divname}'); return true;\">";
            $timestr = "";
            if ($time > 0) {
                $timestr = display_time($time);
                if ($duration > 0) {
                    // calc end time
                    $h = (int) ($time / 10000);
                    $m = $time / 100 % 100;
                    $m += $duration;
                    $d = $duration;
                    while ($m >= 60) {
                        $h++;
                        $m -= 60;
                    }
                    $end_time = sprintf("%02d%02d00", $h, $m);
                    $timestr .= " - " . display_time($end_time);
                }
            }
            echo htmlspecialchars($name);
            echo "</a>";
            echo " (" . date_to_str($date) . ")\n";
            //approve
            echo ": <a title=\"" . translate("Approve/Confirm") . "\"  href=\"approve_entry.php?id={$id}&amp;ret=list&amp;user={$user}";
            if ($user == "__public__") {
                echo "&amp;public=1";
            }
            echo "\" class=\"nav\" onclick=\"return confirm('" . translate("Approve this entry?") . "');\">" . translate("Approve/Confirm") . "</a>, ";
            //reject
            echo "<a title=\"" . translate("Reject") . "\" href=\"reject_entry.php?id={$id}&amp;ret=list&amp;user={$user}";
            if ($user == "__public__") {
                echo "&amp;public=1";
            }
            echo "\" class=\"nav\" onclick=\"return confirm('" . translate("Reject this entry?") . "');\">" . translate("Reject") . "</a>";
            //delete
            echo ", <a title=\"" . translate("Delete") . "\" href=\"del_entry.php?id={$id}&amp;ret=list";
            if ($user != $login) {
                echo "&amp;user={$user}";
            }
            echo "\" class=\"nav\" onclick=\"return confirm('" . translate("Are you sure you want to delete this entry?") . "');\">" . translate("Delete") . "</a>";
            echo "\n</li>\n";
            $eventinfo .= build_event_popup($divname, $user, $description, $timestr, site_extras_for_popup($id));
            $count++;
        }
        dbi_free_result($res);
        if ($count > 0) {
            echo "</ul>\n";
        }
    }
    if ($count == 0) {
        user_load_variables($user, "temp_");
        echo "<span class=\"nounapproved\">" . translate("No unapproved events for") . "&nbsp;" . $temp_fullname . ".</span>\n";
    } else {
        if (!empty($eventinfo)) {
            echo $eventinfo;
        }
    }
}
示例#13
0
if ($is_admin) {
    if (empty($log)) {
        echo "<a title=\"" . translate("Show activity log") . "\" class=\"nav\" href=\"view_entry.php?id={$id}&amp;log=1\">" . translate("Show activity log") . "</a><br />\n";
    } else {
        echo "<a title=\"" . translate("Hide activity log") . "\" class=\"nav\" href=\"view_entry.php?id={$id}\">" . translate("Hide activity log") . "</a><br />\n";
        $show_log = true;
    }
}
if ($show_log) {
    echo "<h3>" . translate("Activity Log") . "</h3>\n";
    echo "<table class=\"embactlog\">\n";
    echo "<tr><th class=\"usr\">\n" . translate("User") . "</th><th class=\"cal\">\n";
    echo translate("Calendar") . "</th><th class=\"date\">\n";
    echo translate("Date") . "/" . translate("Time") . "</th><th class=\"action\">\n";
    echo translate("Action") . "\n</th></tr>\n";
    $res = dbi_query("SELECT cal_login, cal_user_cal, cal_type, " . "cal_date, cal_time " . "FROM webcal_entry_log WHERE cal_entry_id = {$id} " . "ORDER BY cal_log_id DESC");
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            echo "<tr><td>\n";
            echo $row[0] . "</td><td>\n";
            echo $row[1] . "</td><td>\n" . date_to_str($row[3]) . "&nbsp;" . display_time($row[4]) . "</td><td>\n";
            if ($row[2] == $LOG_CREATE) {
                etranslate("Event created");
            } else {
                if ($row[2] == $LOG_APPROVE) {
                    etranslate("Event approved");
                } else {
                    if ($row[2] == $LOG_REJECT) {
                        etranslate("Event rejected");
                    } else {
                        if ($row[2] == $LOG_UPDATE) {
示例#14
0
        if ($row[0] == $id) {
            $is_my_event = true;
            echo "Event # " . $id . " is already on your calendar.";
            exit;
        }
        dbi_free_result($res);
    }
    // Now lets make sure the user is allowed to add the event (not private)
    $sql = "SELECT cal_access FROM webcal_entry WHERE cal_id = " . $id;
    $res = dbi_query($sql);
    if (!$res) {
        echo translate("Invalid entry id") . ": {$id}";
        exit;
    }
    $row = dbi_fetch_row($res);
    if ($row[0] == "R" && !$is_my_event) {
        $is_private = true;
        etranslate("This is a private event and may not be added to your calendar.");
        exit;
    } else {
        $is_private = false;
    }
    // add the event
    if ($readonly == "N" && !$is_my_event && !$is_private) {
        if (!dbi_query("INSERT INTO webcal_entry_user ( cal_id, cal_login, cal_status ) VALUES ( {$id}, '{$login}', 'A' )")) {
            $error = translate("Error adding event") . ": " . dbi_error();
        }
    }
}
send_to_preferred_view();
exit;
示例#15
0
<?php

include_once 'includes/init.php';
$error = "";
if ($user != $login) {
    $user = ($is_admin || $is_nonuser_admin) && $user ? $user : $login;
}
# update user list
dbi_query("DELETE FROM webcal_asst WHERE cal_boss = '{$user}'");
if (!empty($users)) {
    for ($i = 0; $i < count($users); $i++) {
        dbi_query("INSERT INTO webcal_asst ( cal_boss, cal_assistant ) " . "VALUES ( '{$user}', '{$users[$i]}' )");
    }
}
$url = "assistant_edit.php";
if (($is_admin || $is_nonuser_admin) && $login != $user) {
    $url = $url . (strpos($url, "?") === false ? "?" : "&amp;") . "user={$user}";
}
do_redirect($url);
print_header();
?>
<h2><?php 
etranslate("Error");
?>
</h2>

<blockquote>
<?php 
echo $error;
//if ( $sql != "" )
//  echo "<br /><br /><span style=\"font-weight:bold;\">SQL:</span> $sql";
示例#16
0
    } else {
        if ($wday == 0 || $wday == 6) {
            echo "<td class=\"weekend\">";
        } else {
            echo "<td class=\"reg\">";
        }
    }
    //  echo "<td style=\"width:90%; background-color:$color;\">";
    if (empty($add_link_in_views) || $add_link_in_views != "N") {
        echo html_for_add_icon(date("Ymd", $date), "", "", $user);
    }
    // Parametres par defaut
    if ($prefarray["WORK_DAY_START_HOUR"] == NULL || $prefarray["WORK_DAY_END_HOUR"] == NULL) {
        $val = dbi_fetch_row(dbi_query("SELECT cal_value FROM webcal_config where cal_setting=\"WORK_DAY_START_HOUR\""));
        $prefarray["WORK_DAY_START_HOUR"] = $val[0];
        $val = dbi_fetch_row(dbi_query("SELECT cal_value FROM webcal_config where cal_setting=\"WORK_DAY_END_HOUR\""));
        $prefarray["WORK_DAY_END_HOUR"] = $val[0];
    }
    print_header_timebar($prefarray["WORK_DAY_START_HOUR"], $prefarray["WORK_DAY_END_HOUR"]);
    print_date_entries_timebar(date("Ymd", $date), $GLOBALS["login"], true);
    echo "</td>";
    echo "</tr>\n";
}
echo "</table>\n<br />\n";
$user = "";
// reset
echo $eventinfo;
echo "<a title=\"" . translate("Generate printer-friendly version") . "\" class=\"printer\" href=\"view_t.php?timeb={$timeb}&amp;id={$id}&amp;date={$thisdate}&amp;friendly=1\" target=\"cal_printer_friendly\" onmouseover=\"window.status='" . translate("Generate printer-friendly version") . "'\">[" . translate("Printer Friendly") . "]</a>\n";
print_trailer();
?>
</body>
示例#17
0
<?php

include_once 'includes/init.php';
$updating_public = false;
if ($is_admin && !empty($public) && $public_access == "Y") {
    $updating_public = true;
    $layer_user = "******";
} else {
    $layer_user = $login;
}
load_user_layers($layer_user, 1);
if (strlen($layers[$id]['cal_layeruser']) > 0 && ($is_admin || $readonly == "N")) {
    $layeruser = $layers[$id]['cal_layeruser'];
    dbi_query("DELETE FROM webcal_user_layers " . "WHERE cal_login = '******' AND cal_layeruser = '******'");
}
if ($updating_public) {
    do_redirect("layers.php?public=1");
} else {
    do_redirect("layers.php");
}
示例#18
0
         if (!$is_admin && $login != $report_login) {
             // If not admin, only creator can edit/delete the event
             $error = translate("You are not authorized");
         }
         // If we are editing a public user report we need to set $updating_public
         if ($is_admin && $report_login == "__public__") {
             $updating_public = true;
         }
     } else {
         $error = translate("Invalid report id") . ": {$report_id}";
     }
     dbi_free_result($res);
 } else {
     $error = translate("Database error") . ": " . dbi_error();
 }
 $res = dbi_query("SELECT cal_template_type, cal_template_text " . "FROM webcal_report_template " . "WHERE cal_report_id = {$report_id}");
 if ($res) {
     while ($row = dbi_fetch_row($res)) {
         if ($row[0] == 'P') {
             $page_template = $row[1];
         } else {
             if ($row[0] == 'D') {
                 $day_template = $row[1];
             } else {
                 if ($row[0] == 'E') {
                     $event_template = $row[1];
                 }
             }
         }
     }
     dbi_free_result($res);
示例#19
0
                                dbi_query("UPDATE webcal_entry_user SET cal_status = 'D' " . "WHERE cal_id = {$ex_events[$i]} " . "AND cal_login = '******'");
                            }
                        }
                    }
                }
            }
            // Now, mark event as deleted for all users.
            dbi_query("UPDATE webcal_entry_user SET cal_status = 'D' " . "WHERE cal_id = {$id}");
        }
    } else {
        // Not the owner of the event and are not the admin.
        // Just delete the event from this user's calendar.
        // We could just set the status to 'D' instead of deleting.
        // (but we would need to make some changes to edit_entry_handler.php
        // to accomodate this).
        dbi_query("DELETE FROM webcal_entry_user " . "WHERE cal_id = {$id} AND cal_login = '******'");
        activity_log($id, $login, $login, $LOG_REJECT, "");
    }
}
if (strlen(get_last_view())) {
    $url = get_last_view();
} else {
    $redir = "";
    if ($thisdate != "") {
        $redir = "?date={$thisdate}";
    }
    if ($user != "") {
        if ($redir != "") {
            $redir .= "&";
        }
        $redir .= "user={$user}";
示例#20
0
<?php

include_once $gfplugins . 'webcalendar/www/includes/init.php';
// load user and global cats
load_user_categories();
$error = "";
if ($categories_enabled == "N") {
    send_to_preferred_view();
    exit;
}
// If editing, make sure they are editing their own
// (or they are an admin user).
if (!empty($id)) {
    $res = dbi_query("SELECT cat_id, cat_owner FROM webcal_categories WHERE " . "cat_id = {$id}");
    if ($res) {
        if ($row = dbi_fetch_row($res)) {
            if ($row[0] != $id) {
                $error = translate("Invalid entry id") . ": " . $id;
            } else {
                if ($row[1] != $login && !$is_admin) {
                    $error = translate("You are not authorized") . ".";
                }
            }
        }
        dbi_free_result($res);
    } else {
        $error = translate("Database error") . ": " . dbi_error();
    }
}
print_header();
?>
示例#21
0
<?php

include_once $gfplugins . 'webcalendar/www/includes/init.php';
function print_color_sample($color)
{
    echo "<table style=\"border-width:0px;\"><tr><td style=\"background-color:{$color};\">&nbsp;&nbsp;</td></tr></table>";
}
// I know we've already loaded the global settings above, but read them
// in again and store them in a different place because they may have
// been superceded by local user preferences.
// We will store value in the array $s[].
$res = dbi_query("SELECT cal_setting, cal_value FROM webcal_config");
$s = array();
if ($res) {
    while ($row = dbi_fetch_row($res)) {
        $setting = $row[0];
        $value = $row[1];
        $s[$setting] = $value;
        //echo "Setting '$setting' to '$value' <br />\n";
    }
    dbi_free_result($res);
}
$BodyX = 'onload="public_handler(); eu_handler(); email_handler();"';
$INC = array('js/admin.php', 'js/visible.php');
print_header($INC, '', $BodyX);
?>

<h2><?php 
etranslate("System Settings");
?>
&nbsp;<img src="help.gif" alt="<?php 
    }
    dbi_free_result($res);
} else {
    echo translate("Database error") . ": " . dbi_error();
}
?>
</table><br />
<div class="navigation">
<?php 
//go BACK in time
if (!empty($nextpage)) {
    echo "<a title=\"" . translate("Previous") . "&nbsp;{$PAGE_SIZE}&nbsp;" . translate("Events") . "\" class=\"prev\" href=\"activity_log.php?startid={$nextpage}\">" . translate("Previous") . "&nbsp;{$PAGE_SIZE}&nbsp;" . translate("Events") . "</a>\n";
}
if (!empty($startid)) {
    $previd = $startid + $PAGE_SIZE;
    $res = dbi_query("SELECT MAX(cal_log_id) FROM " . "webcal_entry_log");
    if ($res) {
        if ($row = dbi_fetch_row($res)) {
            if ($row[0] <= $previd) {
                $prevarg = '';
            } else {
                $prevarg = "?startid={$previd}";
            }
            //go FORWARD in time
            echo "<a title=\"" . translate("Next") . "&nbsp;{$PAGE_SIZE}&nbsp;" . translate("Events") . "\" class=\"next\" href=\"activity_log.php{$prevarg}\">" . translate("Next") . "&nbsp;{$PAGE_SIZE}&nbsp;" . translate("Events") . "</a><br />\n";
        }
        dbi_free_result($res);
    }
}
?>
</div>
function get_cal_ent_extras($id, $from, $where = false)
{
    $res = dbi_query("SELECT * FROM {$from} WHERE cal_id='{$id}'" . ($where ? "AND ( {$where} );" : ';'));
    if ($res) {
        return dbi_fetch_row($res);
    } else {
        return false;
    }
}
示例#24
0
      echo " | ";
    echo $views_link[$i];
  }
}*/
?>

<!-- REPORTS -->
<?php 
$reports_link = array();
if (!empty($reports_enabled) && $reports_enabled == 'Y') {
    if (!empty($user) && $user != $login) {
        $u_url = "&amp;user={$user}";
    } else {
        $u_url = "";
    }
    $res = dbi_query("SELECT cal_report_name, cal_report_id " . "FROM webcal_report " . "WHERE cal_login = '******' OR " . "( cal_is_global = 'Y' AND cal_show_in_trailer = 'Y' ) " . "ORDER BY cal_report_id");
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $reports_link[] = "<a title=\"" . htmlspecialchars($row[0]) . "\" href=\"report.php?report_id={$row['1']}{$u_url}\">" . htmlspecialchars($row[0]) . "</a>";
        }
        dbi_free_result($res);
    }
    /*
      if ( count ( $reports_link ) > 0 ) {
        ?><br/><span class="prefix"><?php etranslate("Reports");?>:</span>&nbsp;<?php
        for ( $i = 0; $i < count ( $reports_link ); $i++ ) {
          if ( $i > 0 )
            echo " | ";
          echo $reports_link[$i];
        }
      } */
示例#25
0
function export_alarm_ical($id, $description)
{
    $sql = "SELECT cal_data FROM webcal_site_extras " . "WHERE cal_id = {$id} AND cal_type = 7 AND cal_remind = 1";
    $res = dbi_query($sql);
    $row = dbi_fetch_row($res);
    dbi_free_result($res);
    if ($row) {
        echo "BEGIN:VALARM\r\n";
        echo "TRIGGER:-PT" . $row[0] . "M\r\n";
        echo "ACTION:DISPLAY\r\n";
        $array = export_fold_lines($description, "utf8");
        while (list($key, $value) = each($array)) {
            echo "{$value}\r\n";
        }
        echo "END:VALARM\r\n";
    }
}
示例#26
0
function user_get_users()
{
    global $public_access, $PUBLIC_ACCESS_FULLNAME;
    $count = 0;
    $ret = array();
    if ($public_access == "Y") {
        $ret[$count++] = array("cal_login" => "__public__", "cal_lastname" => "", "cal_firstname" => "", "cal_is_admin" => "N", "cal_email" => "", "cal_password" => "", "cal_fullname" => $PUBLIC_ACCESS_FULLNAME);
    }
    $res = dbi_query("SELECT cal_login, cal_lastname, cal_firstname, " . "cal_is_admin, cal_email, cal_passwd FROM webcal_user " . "ORDER BY cal_lastname, cal_firstname, cal_login");
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            if (strlen($row[1]) && strlen($row[2])) {
                $fullname = "{$row['2']} {$row['1']}";
            } else {
                $fullname = $row[0];
            }
            $ret[$count++] = array("cal_login" => $row[0], "cal_lastname" => $row[1], "cal_firstname" => $row[2], "cal_is_admin" => $row[3], "cal_email" => empty($row[4]) ? "" : $row[4], "cal_password" => $row[5], "cal_fullname" => $fullname);
        }
        dbi_free_result($res);
    }
    return $ret;
}
示例#27
0
</span><br />
<span class="viewname"><?php 
echo $view_name;
?>
</span>
</div></div><br />

<?php 
// The table has names across the top and dates for rows.  Since we need
// to spit out an entire row before we can move to the next date, we'll
// save up all the HTML for each cell and then print it out when we're
// done..
// Additionally, we only want to put at most 6 users in one table since
// any more than that doesn't really fit in the page.
// get users in this view
$res = dbi_query("SELECT cal_login FROM webcal_view_user WHERE cal_view_id = {$id}");
$viewusers = array();
$all_users = false;
if ($res) {
    while ($row = dbi_fetch_row($res)) {
        $viewusers[] = $row[0];
        if ($row[0] == "__all__") {
            $all_users = true;
        }
    }
    dbi_free_result($res);
} else {
    $error = translate("Database error") . ": " . dbi_error();
}
if ($all_users) {
    $viewusers = array();
示例#28
0
function process_event($id, $name, $event_date, $event_time)
{
    global $site_extras, $debug, $only_testing;
    global $EXTRA_REMINDER_WITH_OFFSET, $EXTRA_REMINDER_WITH_DATE;
    if ($debug) {
        printf("Event %d: \"%s\" at %s on %s <br />\n", $id, $name, $event_time, $event_date);
    }
    // Check to see if this event has any reminders
    $extras = get_site_extra_fields($id);
    for ($j = 0; $j < count($site_extras); $j++) {
        $extra_name = $site_extras[$j][0];
        $extra_type = $site_extras[$j][2];
        $extra_arg1 = $site_extras[$j][3];
        $extra_arg2 = $site_extras[$j][4];
        //if ( $debug )
        //  printf ( "  name: %s\n  type: %d\n  arg1: %s\n  arg2: %s\n",
        //  $extra_name, $extra_type, $extra_arg1, $extra_arg2 );
        if (!empty($extras[$extra_name]['cal_remind'])) {
            if ($debug) {
                echo "  Reminder set for event. <br />\n";
            }
            // how many minutes before event should we send the reminder?
            $ev_h = (int) ($event_time / 10000);
            $ev_m = $event_time / 100 % 100;
            $ev_year = substr($event_date, 0, 4);
            $ev_month = substr($event_date, 4, 2);
            $ev_day = substr($event_date, 6, 2);
            $event_time = mktime($ev_h, $ev_m, 0, $ev_month, $ev_day, $ev_year);
            if (($extra_arg2 & $EXTRA_REMINDER_WITH_OFFSET) > 0) {
                $minsbefore = $extras[$extra_name]['cal_data'];
                $remind_time = $event_time - $minsbefore * 60;
            } else {
                if (($extra_arg2 & $EXTRA_REMINDER_WITH_DATE) > 0) {
                    $rd = $extras[$extra_name]['cal_date'];
                    $r_year = substr($rd, 0, 4);
                    $r_month = substr($rd, 4, 2);
                    $r_day = substr($rd, 6, 2);
                    $remind_time = mktime(0, 0, 0, $r_month, $r_day, $r_year);
                } else {
                    $minsbefore = $extra_arg1;
                    $remind_time = $event_time - $minsbefore * 60;
                }
            }
            if ($debug) {
                echo "  Mins Before: {$minsbefore} <br />\n";
            }
            if ($debug) {
                echo "  Event time is: " . date("m/d/Y H:i", $event_time) . "<br />\n";
                echo "  Remind time is: " . date("m/d/Y H:i", $remind_time) . "<br />\n";
            }
            if (time() >= $remind_time) {
                // It's remind time or later. See if one has already been sent
                $last_sent = 0;
                $res = dbi_query("SELECT MAX(cal_last_sent) FROM " . "webcal_reminder_log WHERE cal_id = " . $id . " AND cal_event_date = {$event_date}" . " AND cal_name = '" . $extra_name . "'");
                if ($res) {
                    if ($row = dbi_fetch_row($res)) {
                        $last_sent = $row[0];
                    }
                    dbi_free_result($res);
                }
                if ($debug) {
                    echo "  Last sent on: " . date("m/d/Y H:i", $last_sent) . "<br />\n";
                }
                if ($last_sent < $remind_time) {
                    // Send a reminder
                    if ($debug) {
                        echo "  SENDING REMINDER! <br />\n";
                    }
                    send_reminder($id, $event_date);
                    // now update the db...
                    log_reminder($id, $extra_name, $event_date);
                }
            }
        }
    }
}
示例#29
0
/**
 * Prints the common trailer.
 *
 * @param bool $include_nav_links Should the standard navigation links be
 *                               included in the trailer?
 * @param bool $closeDb           Close the database connection when finished?
 * @param bool $disableCustom     Disable the custom trailer the administrator
 *                                has setup?  (This is useful for small popup
 *                                windows and pages being used in an iframe.)
 */
function print_trailer($include_nav_links = true, $closeDb = true, $disableCustom = false)
{
    global $CUSTOM_TRAILER, $c, $STARTVIEW;
    global $login, $user, $cat_id, $categories_enabled, $thisyear, $thismonth, $thisday, $DATE_FORMAT_MY, $WEEK_START, $DATE_FORMAT_MD, $readonly, $is_admin, $public_access, $public_access_can_add, $single_user, $use_http_auth, $login_return_path, $require_approvals, $is_nonuser_admin, $public_access_others, $allow_view_other, $views, $reports_enabled, $LAYER_STATUS, $nonuser_enabled, $groups_enabled, $fullname, $has_boss;
    if ($include_nav_links) {
        include_once "includes/trailer.php";
    }
    // Add custom trailer if enabled
    if ($CUSTOM_TRAILER == 'Y' && !$disableCustom && isset($c)) {
        $res = dbi_query("SELECT cal_template_text FROM webcal_report_template " . "WHERE cal_template_type = 'T' and cal_report_id = 0");
        if ($res) {
            if ($row = dbi_fetch_row($res)) {
                echo $row[0];
            }
            dbi_free_result($res);
        }
    }
    if ($closeDb) {
        if (isset($c)) {
            dbi_close($c);
        }
        unset($c);
    }
}
示例#30
0
<BODY BGCOLOR="<?php 
echo $BGCOLOR;
?>
" CLASS="defaulttext">

<H2><FONT COLOR="<?php 
echo $H2COLOR;
?>
"><?php 
etranslate("Groups");
?>
</FONT></H2>

<UL>
<?php 
$res = dbi_query("SELECT cal_group_id, cal_name FROM webcal_group " . "ORDER BY cal_name");
if ($res) {
    while ($row = dbi_fetch_row($res)) {
        echo "<LI><A HREF=\"group_edit.php?id=" . $row[0] . "\">" . $row[1] . "</A> ";
    }
    dbi_free_result($res);
}
?>
</UL>
<P>
<?php 
echo "<A HREF=\"group_edit.php\">" . translate("Add New Group") . "</A><BR>\n";
?>

<?php 
include "includes/trailer.php";