validate.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Validate a user or users by guid
  4. *
  5. * @package Elgg.Core.Plugin
  6. * @subpackage UserValidationByEmail
  7. */
  8. $user_guids = get_input('user_guids');
  9. $error = FALSE;
  10. if (!$user_guids) {
  11. register_error(elgg_echo('uservalidationbyemail:errors:unknown_users'));
  12. forward(REFERRER);
  13. }
  14. $access = access_get_show_hidden_status();
  15. access_show_hidden_entities(TRUE);
  16. foreach ($user_guids as $guid) {
  17. $user = get_entity($guid);
  18. if (!$user instanceof ElggUser) {
  19. $error = TRUE;
  20. continue;
  21. }
  22. // only validate if not validated
  23. $is_validated = elgg_get_user_validation_status($guid);
  24. $validate_success = elgg_set_user_validation_status($guid, TRUE, 'manual');
  25. if ($is_validated !== FALSE || !($validate_success && $user->enable())) {
  26. $error = TRUE;
  27. continue;
  28. }
  29. }
  30. access_show_hidden_entities($access);
  31. if (count($user_guids) == 1) {
  32. $message_txt = elgg_echo('uservalidationbyemail:messages:validated_user');
  33. $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_validate_user');
  34. } else {
  35. $message_txt = elgg_echo('uservalidationbyemail:messages:validated_users');
  36. $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_validate_users');
  37. }
  38. if ($error) {
  39. register_error($error_txt);
  40. } else {
  41. system_message($message_txt);
  42. }
  43. forward(REFERRER);