user.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. elgg_gatekeeper();
  3. $username = get_input("username");
  4. $type = get_input("type");
  5. if (!empty($username)) {
  6. $user = get_user_by_username($username);
  7. } else {
  8. $user = elgg_get_logged_in_user_entity();
  9. }
  10. if (empty($user)) {
  11. register_error(elgg_echo("account_removal:user:error:no_user"));
  12. forward(REFERER);
  13. }
  14. if ($user->isAdmin() && ($user->getGUID() == elgg_get_logged_in_user_guid())) {
  15. register_error(elgg_echo("account_removal:user:error:admin"));
  16. forward(REFERER);
  17. } elseif (!$user->isAdmin() && ($user->getGUID() != elgg_get_logged_in_user_guid()) && !elgg_is_admin_logged_in()) {
  18. register_error(elgg_echo("account_removal:user:error:user"));
  19. forward(REFERER);
  20. }
  21. // set context and page owner
  22. elgg_push_context("settings");
  23. elgg_set_page_owner_guid($user->getGUID());
  24. // push breadcrumb
  25. elgg_push_breadcrumb(elgg_echo("settings"), "settings/user/" . $user->username);
  26. elgg_push_breadcrumb(elgg_echo("account_removal:menu:title"));
  27. // build page elements
  28. $title_text = elgg_echo("account_removal:user:title");
  29. $body = elgg_view("account_removal/forms/user", array("entity" => $user, "type" => $type));
  30. // need to forward or display a page
  31. echo elgg_view_page($title_text, elgg_view_layout("one_sidebar", array(
  32. "title" => $title_text,
  33. "content" => $body
  34. )));
  35. elgg_pop_context();