Exemplo n.º 1
0
require_once 'core/init.php';
$pageTitle = 'Locations';
$user = new User();
if (!$user->isLoggedIn()) {
    Redirect::to('login.php');
}
// Defaults
$style = '';
$displayErrors = "none";
$errorDisplay = "";
$leagueOptions = new League();
if (isset($_GET['delete']) && $_GET['delete'] == true && isset($_GET['locationid']) && is_numeric($_GET['locationid'])) {
    try {
        $locationId = escape($_GET['locationid']);
        $leagueOptions->deleteLocation($locationId);
        Session::flash('deleted', 'Location Deleted Successfully');
        Redirect::to('locations.php');
    } catch (Exception $e) {
        die($e->getMessage());
    }
} else {
    $locationResults = $leagueOptions->getLocations();
}
if (Input::exists()) {
    if (Token::check(Input::get('token'))) {
        $validate = new Validation();
        $validation = $validate->check($_POST, array('GroundName' => array('name' => 'Ground Name', 'min' => 5, 'max' => 50, 'required' => true), 'Town' => array('name' => 'Town', 'min' => 3, 'max' => 50), 'PostCode' => array('name' => 'Postcode', 'min' => 3, 'max' => 10)));
        if ($validation->passed()) {
            try {
                $leagueOptions->createLocation(array('GroundName' => Input::get('GroundName'), 'Town' => Input::get('Town'), 'PostCode' => Input::get('PostCode')));