-
Notifications
You must be signed in to change notification settings - Fork 0
/
editcache.php
38 lines (31 loc) · 1.15 KB
/
editcache.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once 'libs/models/geocache.php';
require_once 'libs/utils.php';
//if (!loggedIn()) {
// showView('login.php', array('error' => "You must login to view this page."));
//}
$id = (int) $_GET['id'];
$geocache = Geocache::getGeocacheById($id);
if (!$geocache->userIsOwner()) {
$_SESSION['error'] = "You are not the owner of this geocache.";
header("Location: geocacheview.php?id=$id");
exit();
}
if (empty($_POST)) {
showView('cacheform.php', array('action' => "editcache.php?id=$id", 'geocache' => $geocache));
}
$geocache->setType($_POST['type']);
$geocache->setName($_POST['name']);
$geocache->setDescription($_POST['description']);
$geocache->setHint($_POST['hint']);
$geocache->setDifficulty($_POST['difficulty']);
$geocache->setTerrain($_POST['terrain']);
$geocache->setLatitude($_POST['latitude']);
$geocache->setLongitude($_POST['longitude']);
if ($geocache->isValid()) {
$geocache->updateInDb();
header("Location: geocacheview.php?id=$id");
} else {
$errors = $geocache->errors;
showView('cacheform.php', array('action' => "editcache.php?id=$id", 'geocache' => $geocache, 'errors' => $errors));
}