getList.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. require 'app.php';
  3. $type = "";
  4. if (isset($_GET['type']))
  5. $type = $_GET['type'];
  6. else
  7. die("No type specified.");
  8. if (!hasPermission("list.$type")) {
  9. die("Not enough permissions.");
  10. }
  11. ?>
  12. <?php
  13. $result = $conn->query("SELECT * FROM $type ORDER BY listId");
  14. if ($result === FALSE) {
  15. $result = $conn->query("SELECT * FROM $type ORDER BY UID");
  16. }
  17. while($row = $result->fetchArray()) {
  18. if (isset($row['name'])) {
  19. $name = $row['name'];
  20. } else {
  21. $name = $row['User'];
  22. }
  23. ?>
  24. <tr id="<?php echo "Item_" . $row['UID'] ?>">
  25. <td><?php echo $name ?></td>
  26. <td>
  27. <!--Delete button-->
  28. <form>
  29. <input type="hidden" class="uid" name="uid" value="<?php echo $row['UID'] ?>"/>
  30. <button class="btn delete btn-danger" data-target="#delete-modal-<?php echo $row['UID'] ?>" data-toggle="modal" type="button"><i class="fa fa-trash-o"></i> Delete</button>
  31. <!-- Modal -->
  32. <div id="delete-modal-<?php echo $row['UID'] ?>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="delete-modal-<?php echo $row['UID'] ?>">
  33. <div class="modal-dialog" role="document">
  34. <div class="modal-content">
  35. <div class="modal-header">
  36. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  37. <h4 class="modal-title" id="delete-modal-<?php echo $row['UID'] ?>">Confirm deletion</h4>
  38. </div>
  39. <div class="modal-body">
  40. Clicking 'Delete' will permanently delete the <?php echo strtolower($type) . " '$name'" ?>. Are you sure you want to do this?
  41. </div>
  42. <div class="modal-footer">
  43. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  44. <button data="<?php echo $row['UID'] ?>" data-dismiss="modal" type="button" class="delete-confirm btn btn-danger">Delete</button>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </form>
  50. <!--Edit button-->
  51. <form action="" method="get">
  52. <input type="hidden" name="p" value="edit"/>
  53. <input type="hidden" name="type" value="<?php echo $type; ?>"/>
  54. <input type="hidden" name="uid" value="<?php echo $row['UID'] ?>"/>
  55. <button class="btn btn-primary" type="submit"><i class="fa fa-pencil"></i> Edit</button>
  56. </form>
  57. </td>
  58. </tr>
  59. <?php
  60. }
  61. ?>