Fix: public tracks config option has no effect

This commit is contained in:
Bartek Fabiszewski 2017-04-14 17:22:52 +02:00
parent 77d1a5a012
commit a64213940a
3 changed files with 6 additions and 5 deletions

View File

@ -57,7 +57,7 @@ $type = isset($_REQUEST["type"]) ? $_REQUEST["type"] : "kml";
$userId = (isset($_REQUEST["userid"]) && is_numeric($_REQUEST["userid"])) ? (int) $_REQUEST["userid"] : NULL; $userId = (isset($_REQUEST["userid"]) && is_numeric($_REQUEST["userid"])) ? (int) $_REQUEST["userid"] : NULL;
$trackId = (isset($_REQUEST["trackid"]) && is_numeric($_REQUEST["trackid"])) ? (int) $_REQUEST["trackid"] : NULL; $trackId = (isset($_REQUEST["trackid"]) && is_numeric($_REQUEST["trackid"])) ? (int) $_REQUEST["trackid"] : NULL;
if ($config::$require_authentication && !$user->isAdmin && $user->id !== $userId) { if (!$config::$public_tracks && !$user->isAdmin && $user->id !== $userId) {
// unauthorized // unauthorized
$mysqli->close(); $mysqli->close();
exit(); exit();

View File

@ -26,15 +26,16 @@ $trackId = (isset($_REQUEST["trackid"]) && is_numeric($_REQUEST["trackid"])) ? (
if ($userId) { if ($userId) {
$positionsArr = []; $positionsArr = [];
if (!$config::$require_authentication || $user->isAdmin || $user->id === $userId) { if ($config::$public_tracks || $user->isAdmin || $user->id === $userId) {
$position = new uPosition(); $position = new uPosition();
if ($trackId) { if ($trackId) {
// get all track data // get all track data
$positionsArr = $position->getAll($userId, $trackId); $positionsArr = $position->getAll($userId, $trackId);
} else { } else {
// get data only for latest point // get data only for latest point
$position->getLast($userId); if ($position->getLast($userId)->isValid) {
$positionsArr[] = $position; $positionsArr[] = $position;
}
} }
} }

View File

@ -25,7 +25,7 @@ $userId = (isset($_REQUEST["userid"]) && is_numeric($_REQUEST["userid"])) ? (int
if ($userId) { if ($userId) {
$tracksArr = []; $tracksArr = [];
if (!$config::$require_authentication || $user->isAdmin || $user->id === $userId) { if ($config::$public_tracks || $user->isAdmin || $user->id === $userId) {
$track = new uTrack(); $track = new uTrack();
$tracksArr = $track->getAll($userId); $tracksArr = $track->getAll($userId);
} }