user_table.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Page model:
  4. * $users as an array of strings
  5. * $use_metadata true / false
  6. * $meta_map as an array of meta_model objects, index is the user name.
  7. */
  8. ?>
  9. <?php
  10. if (count ( $users ) == 0) {
  11. echo "<p>No users found!</p>";
  12. } else {
  13. ?>
  14. <div class="panel panel-default">
  15. <table class="table">
  16. <thead>
  17. <tr>
  18. <th>Username</th>
  19. <?php
  20. if ($use_metadata) {
  21. ?>
  22. <th>Email</th>
  23. <th>Name</th>
  24. <?php
  25. }
  26. ?>
  27. <th>&nbsp;</th>
  28. </tr>
  29. </thead>
  30. <tbody>
  31. <?php
  32. foreach ( $users as $user ) {
  33. if ($use_metadata) {
  34. $fieldjs = "onclick=\"setUserField('" . htmlspecialchars ( $user ) . "', '" . htmlspecialchars ( $meta_map [$user]->email ) . "', '" . htmlspecialchars ( $meta_map [$user]->name ) . "');\"";
  35. } else {
  36. $fieldjs = "onclick=\"setUserField('" . htmlspecialchars ( $user ) . "','','');\"";
  37. }
  38. echo "<tr class='id-" . htmlspecialchars ( $user ) . "' >";
  39. echo "<td scope='row' " . $fieldjs . ">" . htmlspecialchars ( $user ) . " </td>";
  40. if ($use_metadata && isset ( $meta_map [$user] )) {
  41. echo "<td scope='row'>" . htmlspecialchars ( $meta_map [$user]->email ) . "</td>";
  42. echo "<td scope='row'>" . htmlspecialchars ( $meta_map [$user]->name ) . "</td>";
  43. }
  44. echo "<td scope='row'><a class='btn btn-danger pull-right' " . "onclick=\"deleteUser('" . htmlspecialchars ( $user ) . "');\"" . "href='#' >Delete</a>" . "</li></td>";
  45. }
  46. ?>
  47. </tbody>
  48. </table>
  49. </div>
  50. <p>Click on a user to edit.</p>
  51. <?php
  52. }
  53. ?>