account.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. $page_title = "Account";
  3. $user = Core::$user;
  4. Core::addBreadcrumb("/account", $page_title);
  5. $users_pending_verification = 0;
  6. $tests_pending_verification = 0;
  7. $tests_remaining = 0;
  8. $icons = [];
  9. if($user->level >= User::LEVEL_ADMIN) {
  10. $icons[] = new AccountIcon("Customers", "/account/customers", "warehouse");
  11. $icons[] = new AccountIcon("Map Overview", "/account/map-overview", "map-marked");
  12. $icons[] = new AccountIcon(($user->level == User::LEVEL_SUPERADMIN ? "Users" : "Testers"), "/account/users", "users");
  13. $users = User::query(["level" => User::LEVEL_UNVERIFIED]);
  14. $tests = Test::query(["status" => Test::STATUS_PENDING_VERIFICATION]);
  15. $users_pending_verification = count($users);
  16. $tests_pending_verification = count($tests);
  17. $icons[] = new AccountIcon("Projects", "/account/projects", "list");
  18. $icons[] = new AccountIcon("Locations", "/account/locations", "map-marker");
  19. $icons[] = new AccountIcon("Templates", "/account/templates", "file-alt");
  20. }
  21. if($user->level >= User::LEVEL_CUSTOMER) {
  22. $icons[] = new AccountIcon("Reports", "/account/reports", "chart-pie");
  23. }
  24. if($user->isTester() || $user->isAdmin()) {
  25. $tests = $user->getPendingTests();
  26. $tests_remaining = count($tests);
  27. $tests_icon = new AccountIcon("Tests", "/account/tests", "clipboard-check");
  28. $tests_icon->setCounter($tests_remaining);
  29. $icons[] = $tests_icon;
  30. $icons[] = new AccountIcon("Practice", "/account/practice", "chalkboard-teacher");
  31. }
  32. if($user->level == User::LEVEL_TESTER) {
  33. $icons[] = new AccountIcon("Addresses", "/account/addresses", "address-book");
  34. $icons[] = new AccountIcon("Tests (Completed)", "/account/tests/completed", "check");
  35. }
  36. if($user->level == User::LEVEL_REGISTERED) {
  37. $icons[] = new AccountIcon("Submit ID", "/account/submit-id", "id-card");
  38. }
  39. if(!$user->terms_accepted) {
  40. $icons = [];
  41. }
  42. $icons[] = new AccountIcon("Settings", "/account/settings", "cog");
  43. usort($icons, function($a, $b) {
  44. return $a->name <=> $b->name;
  45. });
  46. // Actions
  47. $actions = [];
  48. if($user->level == User::LEVEL_DEACTIVATED) {
  49. $actions[] = new AccountIcon("Reactivate Account", "/account/reactivate", "user-check");
  50. }
  51. else if($user->level == User::LEVEL_TESTER) {
  52. $actions[] = new AccountIcon("Deactivate Account...", "/account/deactivate", "user-times");
  53. }
  54. $actions[] = new AccountIcon("Delete Account...", "/account/delete", "user-slash");
  55. // To-do
  56. $to_do = [];
  57. if($users_pending_verification) {
  58. $icon = new AccountIcon("Verify Users", "/account/users?level=" . User::LEVEL_UNVERIFIED, "user-check");
  59. $icon->setCounter($users_pending_verification);
  60. $to_do[] = $icon;
  61. }
  62. if($tests_pending_verification) {
  63. $icon = new AccountIcon("Verify Tests", "/account/tests?status=" . Test::STATUS_PENDING_VERIFICATION, "clipboard-check");
  64. $icon->setCounter($tests_pending_verification);
  65. $to_do[] = $icon;
  66. }
  67. $referrals = $user->getReferrals();
  68. View::includeOnce("header", compact("page_title"));
  69. View::include("account", compact("icons", "actions", "to_do", "referrals"));
  70. View::includeOnce("footer");
  71. ?>