Пример #1
0
<?php

$page = "adm/adm_game_seasons";
include "adm_header.php";
include 'include/providers/class_gameprovider.php';
include 'include/providers/class_game.php';
$provider_id = $provider->provider_info['provider_id'];
$game_model = new se_game();
if (isset($_POST['action'])) {
    $action = $_POST['action'];
    if ($action == 'add_season') {
        $number = isset($_POST['number']) ? (int) $_POST['number'] : null;
        $name = isset($_POST['name']) && trim($_POST['name']) ? trim($_POST['name']) : null;
        $description = isset($_POST['description']) && trim($_POST['description']) ? trim($_POST['description']) : null;
        if ($number && $name && $description) {
            $game_model->add_season($provider_id, $number, $name, $description);
        }
    } else {
        if ($action == 'update_season') {
            $season_id = isset($_POST['season_id']) ? (int) $_POST['season_id'] : null;
            $number = isset($_POST['number']) ? (int) $_POST['number'] : null;
            $name = isset($_POST['name']) && trim($_POST['name']) ? trim($_POST['name']) : null;
            $description = isset($_POST['description']) && trim($_POST['description']) ? trim($_POST['description']) : null;
            if ($season_id && $number && $name && $description && $game_model->is_provider_season($provider_id, $season_id)) {
                $game_model->update_season(null, $number, $name, $description, null, null, $season_id);
            }
        } else {
            if ($action == 'delete_season') {
                $season_id = isset($_POST['season_id']) ? (int) $_POST['season_id'] : null;
                // Необходимо сделать проверку, нашего ли поставщика этот сезон
                if ($season_id && $game_model->is_provider_season($provider_id, $season_id)) {