get_sections.php 846 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. require "app.php";
  3. if (!hasPermission("edit.Page")) {
  4. die("Not enough permissions.");
  5. }
  6. if (isset($_GET['listall'])) {
  7. $query = $conn->query("SELECT UID, name FROM Section");
  8. $sectionlist = array();
  9. while ($row = $query->fetchArray()) {
  10. $sectionlist[$row['UID']] = $row['name'];
  11. }
  12. echo json_encode($sectionlist);
  13. } else if (isset($_GET['getids'])) {
  14. $sectionnames = json_decode($_GET['getids']);
  15. $sectionids = array();
  16. foreach ($sectionnames as $sectionname)
  17. array_push($sectionids, $conn->query("SELECT UID FROM Section WHERE name='$sectionname'")->fetchArray()['UID']);
  18. echo json_encode($sectionids);
  19. } else {
  20. $sections = json_decode($_GET['sections']);
  21. $app = new App(true);
  22. foreach ($sections as $section) {
  23. $app->addSection($section);
  24. }
  25. }
  26. ?>