account.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_url = $user->isAdmin() ? "/account/tests?custom=overdue_test" : "/account/tests";
  28. $tests_icon = new AccountIcon(_("Tests"), $tests_url, "clipboard-check");
  29. $tests_icon->setCounter($tests_remaining);
  30. $icons[] = $tests_icon;
  31. $icons[] = new AccountIcon(_("Practice"), "/account/practice", "chalkboard-teacher");
  32. }
  33. if($user->level == User::LEVEL_TESTER) {
  34. $icons[] = new AccountIcon(_("Addresses"), "/account/addresses", "address-book");
  35. $icons[] = new AccountIcon(_("Tests (Completed)"), "/account/tests/completed", "check");
  36. }
  37. if($user->level == User::LEVEL_REGISTERED) {
  38. $icons[] = new AccountIcon(_("Submit ID"), "/account/submit-id", "id-card");
  39. }
  40. if(!$user->terms_accepted) {
  41. $icons = [];
  42. }
  43. $icons[] = new AccountIcon(_("Settings"), "/account/settings", "cog");
  44. usort($icons, function($a, $b) {
  45. return $a->name <=> $b->name;
  46. });
  47. // Actions
  48. $actions = [];
  49. if($user->level == User::LEVEL_DEACTIVATED) {
  50. $actions[] = new AccountIcon(_("Reactivate Account"), "/account/reactivate", "user-check");
  51. }
  52. else if($user->level == User::LEVEL_TESTER) {
  53. $actions[] = new AccountIcon(_("Deactivate Account..."), "/account/deactivate", "user-times");
  54. }
  55. $actions[] = new AccountIcon(_("Delete Account..."), "/account/delete", "user-slash");
  56. // To-do
  57. $to_do = [];
  58. if($users_pending_verification) {
  59. $icon = new AccountIcon(_("Verify Users"), "/account/users?level=" . User::LEVEL_UNVERIFIED, "user-check");
  60. $icon->setCounter($users_pending_verification);
  61. $to_do[] = $icon;
  62. }
  63. if($tests_pending_verification) {
  64. $icon = new AccountIcon(_("Verify Tests"), "/account/tests?status=" . Test::STATUS_PENDING_VERIFICATION, "clipboard-check");
  65. $icon->setCounter($tests_pending_verification);
  66. $to_do[] = $icon;
  67. }
  68. $referrals = $user->getReferrals();
  69. View::includeOnce("header", compact("page_title"));
  70. View::include("account", compact("icons", "actions", "to_do", "referrals"));
  71. View::includeOnce("footer");
  72. ?>