Exemplo n.º 1
0
function save_layer($layer_user, $layeruser, $layercolor, $dups, $id)
{
    global $error, $layers;
    if ($layer_user == $layeruser) {
        $error = translate('You cannot create a layer for yourself.');
    }
    load_user_layers($layer_user, 1);
    if (!empty($layeruser) && $error == '') {
        // Existing layer entry.
        if (!empty($layers[$id]['cal_layeruser'])) {
            // Update existing layer entry for this user.
            $layerid = $layers[$id]['cal_layerid'];
            dbi_execute('UPDATE webcal_user_layers SET cal_layeruser = ?,
        cal_color = ?, cal_dups = ? WHERE cal_layerid = ?', array($layeruser, $layercolor, $dups, $layerid));
        } else {
            // New layer entry.
            // Check for existing layer for user. Can only have one layer per user.
            $res = dbi_execute('SELECT COUNT( cal_layerid ) FROM webcal_user_layers
        WHERE cal_login = ? AND cal_layeruser = ?', array($layer_user, $layeruser));
            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_execute('SELECT MAX( cal_layerid ) FROM webcal_user_layers');
                if ($res) {
                    $row = dbi_fetch_row($res);
                    $layerid = $row[0] + 1;
                } else {
                    $layerid = 1;
                }
                dbi_execute('INSERT INTO webcal_user_layers ( cal_layerid, cal_login,
          cal_layeruser, cal_color, cal_dups ) VALUES ( ?, ?, ?, ?, ? )', array($layerid, $layer_user, $layeruser, $layercolor, $dups));
            }
        }
    }
}
<?php

include_once $gfplugins . 'webcalendar/www/includes/init.php';
load_user_layers();
if (!$is_admin) {
    echo "<h2>" . translate("Error") . "</h2>" . translate("You are not authorized") . ".\n";
    echo "</body>\n</html>";
    exit;
}
$error = "";
if ($action == "Delete" || $action == translate("Delete")) {
    // delete this nonuser calendar
    $user = $nid;
    // Get event ids for all events this user is a participant
    $events = array();
    $res = dbi_query("SELECT webcal_entry.cal_id " . "FROM webcal_entry, webcal_entry_user " . "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . "AND webcal_entry_user.cal_login = '******'");
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $events[] = $row[0];
        }
    }
    // Now count number of participants in each event...
    // If just 1, then save id to be deleted
    $delete_em = array();
    for ($i = 0; $i < count($events); $i++) {
        $res = dbi_query("SELECT COUNT(*) FROM webcal_entry_user " . "WHERE cal_id = " . $events[$i]);
        if ($res) {
            if ($row = dbi_fetch_row($res)) {
                if ($row[0] == 1) {
                    $delete_em[] = $events[$i];
                }
Exemplo n.º 3
0
    $error = translate("You are not authorized");
}
if (empty($dups)) {
    $dups = 'N';
}
$updating_public = false;
if ($is_admin && !empty($public) && $public_access == "Y") {
    $updating_public = true;
    $layer_user = "******";
} else {
    $layer_user = $login;
}
if ($layer_user == $layeruser) {
    $error = translate("You cannot create a layer for yourself") . ".";
}
load_user_layers($layer_user, 1);
if (!empty($layeruser) && $error == "") {
    // existing layer entry
    if (!empty($layers[$id]['cal_layeruser'])) {
        // update existing layer entry for this user
        $layerid = $layers[$id]['cal_layerid'];
        dbi_query("UPDATE webcal_user_layers SET cal_layeruser = '******', cal_color = '{$layercolor}', cal_dups = '{$dups}' WHERE cal_layerid = '{$layerid}'");
    } else {
        // new layer entry
        // check for existing layer for user.  can only have one layer per user
        $res = dbi_query("SELECT COUNT(cal_layerid) FROM webcal_user_layers " . "WHERE cal_login = '******' AND cal_layeruser = '******'");
        if ($res) {
            $row = dbi_fetch_row($res);
            if ($row[0] > 0) {
                $error = translate("You can only create one layer for each user") . ".";
            }
Exemplo n.º 4
0
    $u = getValue("user", "[A-Za-z0-9_\\.=@,\\-]+", true);
    if (!empty($u)) {
        $username = $u;
        $login = $u;
        // We also set $login since some functions assume that it is set.
    }
}
$cat_id = '';
if ($categories_enabled == 'Y') {
    $x = getIntValue("cat_id", true);
    if (!empty($x)) {
        $cat_id = $x;
    }
}
if ($load_layers) {
    load_user_layers($username);
}
//load_user_categories ();
// Calculate date range
$date = getIntValue("date", true);
if (empty($date) || strlen($date) != 8) {
    // If no date specified, start with today
    $date = date("Ymd");
}
$thisyear = substr($date, 0, 4);
$thismonth = substr($date, 4, 2);
$thisday = substr($date, 6, 2);
$startTime = mktime(3, 0, 0, $thismonth, $thisday, $thisyear);
$x = getIntValue("days", true);
if (!empty($x)) {
    $numDays = $x;
Exemplo n.º 5
0
<?php

/* $Id: week.php,v 1.133.2.5 2008/09/27 14:50:18 cknudsen Exp $ */
include_once 'includes/init.php';
//check UAC
if (!access_can_access_function(ACCESS_WEEK) || !empty($user) && !access_user_calendar('view', $user)) {
    send_to_preferred_view();
}
load_user_layers($user != $login && $is_nonuser_admin ? $user : '');
load_user_categories();
$nextYmd = date('Ymd', mktime(0, 0, 0, $thismonth, $thisday + 7, $thisyear));
$prevYmd = date('Ymd', mktime(0, 0, 0, $thismonth, $thisday - 7, $thisyear));
$boldDays = !empty($BOLD_DAYS_IN_YEAR) && $BOLD_DAYS_IN_YEAR == 'Y';
$wkstart = get_weekday_before($thisyear, $thismonth, $thisday + 1);
$wkend = $wkstart + 86400 * ($DISPLAY_WEEKENDS == 'N' ? 5 : 7);
$startdate = date('Ymd', $wkstart);
$enddate = date('Ymd', $wkend);
$start_ind = 0;
if ($DISPLAY_WEEKENDS == 'N') {
    $end_ind = 4;
    $WEEK_START = 1;
    //Set to Monday.
} else {
    $end_ind = 6;
}
if (empty($TIME_SLOTS)) {
    $TIME_SLOTS = 24;
}
$interval = 1440 / $TIME_SLOTS;
$first_slot = intval($WORK_DAY_START_HOUR * 60 / $interval);
$last_slot = intval($WORK_DAY_END_HOUR * 60 / $interval);