Exemple #1
0
function handleActions()
{
    global $hasError;
    global $errormsg;
    if (!isset($_POST['series'])) {
        return;
    }
    $seriesname = $_POST['series'];
    $series = new Series($seriesname);
    if (!$series) {
        return;
    }
    if (!$series->authCheck(Player::loginName())) {
        return;
    }
    if ($_POST['action'] == "Update Series") {
        $newactive = $_POST['isactive'];
        $newtime = $_POST['hour'];
        $newday = $_POST['start_day'];
        $prereg = 0;
        if (isset($_POST['preregdefault'])) {
            $prereg = $_POST['preregdefault'];
        }
        $series = new Series($seriesname);
        if ($series->authCheck(Player::loginName())) {
            $series->active = $newactive;
            $series->start_time = $newtime . ":00:00";
            $series->start_day = $newday;
            $series->prereg_default = $prereg;
            $series->save();
        }
    } else {
        if ($_POST['action'] == "Change Logo") {
            if ($_FILES['logo']['size'] > 0) {
                $file = $_FILES['logo'];
                $name = $file['name'];
                $tmp = $file['tmp_name'];
                $size = $file['size'];
                $type = $file['type'];
                $series->setLogo($tmp, $type, $size);
            }
        } else {
            if ($_POST['action'] == "Update Organizers") {
                if (isset($_POST['delstewards'])) {
                    $removals = $_POST['delstewards'];
                    foreach ($removals as $deadsteward) {
                        $series->removeSteward($deadsteward);
                    }
                }
                if (!isset($_POST['addsteward'])) {
                    return;
                }
                $addition = $_POST['addsteward'];
                $addplayer = Player::findByName($addition);
                if ($addplayer == NULL) {
                    $hasError = true;
                    $errormsg .= "Can't add {$addition} to stewards, they don't exist!";
                    return;
                }
                if ($addplayer->verified == 0 && Player::getSessionPlayer()->super == 0) {
                    $hasError = true;
                    $errormsg .= "Can't add {$addplayer->name} to stewards, they aren't a verified user!";
                    return;
                }
                $series->addSteward($addplayer->name);
            } else {
                if ($_POST['action'] == "Update Points Rules") {
                    $new_rules = $_POST['new_rules'];
                    $series->setSeasonRules($_POST['season'], $new_rules);
                }
            }
        }
    }
}