File "admin-beacons-edit.inc.php"

Full Path: /srv/www/www.cadoro.it/src/controllers/admin-beacons-edit.inc.php
File size: 1.04 KB
MIME-type: text/x-php
Charset: utf-8

<?php
  $beacon = models\Beacon::get_by_id($beacon_id);
  if (!$beacon) {
    not_found();
  }

  $errors = array();

  if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $params = array(
      'name' => _post('name'),
      'identifier' => _post('identifier'),
      'uuid' => _post('uuid'),
      'major' => _post('major'),
      'minor' => _post('minor'),
      'event_enter_region' => _post('event_enter_region'),
      'event_exit_region' => _post('event_exit_region'),
      'event_did_range' => _post('event_did_range'),
    );
    if (!$params['name']) {
      $errors['name'] = 1;
    }
    if (!$params['identifier']) {
      $errors['identifier'] = 1;
    }
    if (!$params['uuid']) {
      $errors['uuid'] = 1;
    }
    if (!$errors) {
      $beacon->update($params);
      header("Location: " . BASE_URL . "/admin/beacons");
      exit;
    }
  }

  $smarty->assign("beacon", $beacon);
  $smarty->assign("errors", $errors);

  $smarty->assign("menu", "content");
  $smarty->assign("submenu", "beacons");

  $smarty->display("admin-beacons-edit.tmpl");
?>