<?php /** * @package Home * @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\Home; use cs\User; if (!isset($_POST['lat'], $_POST['lng'])) { error_code(400); return; } $User = User::instance(); if (!in_array(AUTOMAIDAN_GROUP, $User->get_groups())) { error_code(403); return; } $driver = Drivers::instance()->get($User->id) ?: ['busy' => 0]; if (!Drivers::instance()->set($_POST['lat'], $_POST['lng'], $driver['busy'])) { error_code(500); }
<?php /** * @package Home * @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\Home; use cs\Page, cs\User; $User = User::instance(); if (!in_array(AUTOMAIDAN_COORD_GROUP, $User->get_groups())) { error_code(403); return; } $Page = Page::instance(); $Drivers = Drivers::instance(); $Page->json($Drivers->get_all() ?: []);
/** * Refuse event checking * * @param $id * * @return bool */ function check_refuse($id) { $id = (int) $id; $data = $this->db()->qf(["SELECT `user`, `confirmed`, `assigned_to`\n\t\t\tFROM `{$this->table}`\n\t\t\tWHERE `id` = '%s'", $id]); $User = User::instance(); if ($data['user'] == $User->id || $data['confirmed'] || $data['assigned_to'] != $User->id) { return false; } if ($this->db_prime()->q("UPDATE `{$this->table}`\n\t\t\tSET `assigned_to` = 0\n\t\t\tWHERE `id` = '%s'\n\t\t\tLIMIT 1", $id)) { $Drivers = Drivers::instance(); $driver = $Drivers->get($User->id); $Drivers->set($driver['lat'], $driver['lng'], 0, $driver['id']); unset($this->cache->{$id}); return true; } return false; }