2010111501.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Set validation metadata on unvalidated users to false rather than
  4. * not existing. This is needed because of the change in how validation is
  5. * being handled.
  6. */
  7. // turn off system log because of all the metadata this can create
  8. elgg_unregister_event_handler('all', 'all', 'system_log_listener');
  9. elgg_unregister_event_handler('log', 'systemlog', 'system_log_default_logger');
  10. $ia = elgg_set_ignore_access(TRUE);
  11. $hidden_entities = access_get_show_hidden_status();
  12. access_show_hidden_entities(TRUE);
  13. $validated_id = elgg_get_metastring_id('validated');
  14. $one_id = elgg_get_metastring_id(1);
  15. $query = "SELECT guid FROM {$CONFIG->dbprefix}entities e
  16. WHERE e.type = 'user' AND e.enabled = 'no' AND
  17. NOT EXISTS (
  18. SELECT 1 FROM {$CONFIG->dbprefix}metadata md
  19. WHERE md.entity_guid = e.guid
  20. AND md.name_id = $validated_id
  21. AND md.value_id = $one_id)";
  22. $user_guids = mysql_query($query);
  23. while ($user_guid = mysql_fetch_object($user_guids)) {
  24. create_metadata($user_guid->guid, 'validated', false, '', 0, ACCESS_PUBLIC, false);
  25. }
  26. access_show_hidden_entities($hidden_entities);
  27. elgg_set_ignore_access($ia);