<?php
require_once __DIR__ . '/../config.php';

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
  if (!file_exists(TASKBAR_FILE)) {
    file_put_contents(TASKBAR_FILE, json_encode(['items'=>[]], JSON_PRETTY_PRINT));
  }
  json_out(['ok'=>true,'taskbar'=>json_decode(file_get_contents(TASKBAR_FILE),true)]);
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  require_admin();
  file_put_contents(TASKBAR_FILE, json_encode(read_json_body(), JSON_PRETTY_PRINT));
  json_out(['ok'=>true]);
}
?>
