makeadmin.php 622 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Grants admin privileges to a user.
  4. *
  5. * In >=1.7.1, admin is flagged by setting the admin
  6. * column in the users_entity table.
  7. *
  8. * In <1.7.1, admin is a piece of metadata on the user object.
  9. *
  10. * @package Elgg.Core
  11. * @subpackage Administration.User
  12. */
  13. $guid = get_input('guid');
  14. $user = get_entity($guid);
  15. if (($user instanceof ElggUser) && ($user->canEdit())) {
  16. if ($user->makeAdmin()) {
  17. system_message(elgg_echo('admin:user:makeadmin:yes'));
  18. } else {
  19. register_error(elgg_echo('admin:user:makeadmin:no'));
  20. }
  21. } else {
  22. register_error(elgg_echo('admin:user:makeadmin:no'));
  23. }
  24. forward(REFERER);