news.php 856 B

12345678910111213141516171819202122232425
  1. <?php
  2. $app->get('/news', function ($request, $response, $args) {
  3. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  4. if ($Organizr->checkRoute($request)) {
  5. if ($Organizr->qualifyRequest(1, true)) {
  6. $Organizr->getNewsIds();
  7. }
  8. }
  9. $response->getBody()->write(jsonE($GLOBALS['api']));
  10. return $response
  11. ->withHeader('Content-Type', 'application/json')
  12. ->withStatus($GLOBALS['responseCode']);
  13. });
  14. $app->post('/news/{id}', function ($request, $response, $args) {
  15. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  16. if ($Organizr->checkRoute($request)) {
  17. if ($Organizr->qualifyRequest(1, true)) {
  18. $Organizr->ignoreNewsId($args['id']);
  19. }
  20. }
  21. $response->getBody()->write(jsonE($GLOBALS['api']));
  22. return $response
  23. ->withHeader('Content-Type', 'application/json')
  24. ->withStatus($GLOBALS['responseCode']);
  25. });