ban.php 648 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * Bans a user.
  4. *
  5. * User entities are banned by setting the 'banned' column
  6. * to 'yes' in the users_entity table.
  7. *
  8. * @package Elgg.Core
  9. * @subpackage Administration.User
  10. */
  11. $guid = get_input('guid');
  12. $user = get_entity($guid);
  13. if ($guid == elgg_get_logged_in_user_guid()) {
  14. register_error(elgg_echo('admin:user:self:ban:no'));
  15. forward(REFERER);
  16. }
  17. if (($user instanceof ElggUser) && ($user->canEdit())) {
  18. if ($user->ban('banned')) {
  19. system_message(elgg_echo('admin:user:ban:yes'));
  20. } else {
  21. register_error(elgg_echo('admin:user:ban:no'));
  22. }
  23. } else {
  24. register_error(elgg_echo('admin:user:ban:no'));
  25. }
  26. forward(REFERER);