2010040201.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Pull admin metadata setting into users_entity table column
  4. */
  5. $siteadmin = elgg_get_metastring_id('siteadmin');
  6. $admin = elgg_get_metastring_id('admin');
  7. $yes = elgg_get_metastring_id('yes');
  8. $one = elgg_get_metastring_id('1');
  9. $qs = array();
  10. $qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity DISABLE KEYS";
  11. $qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity
  12. ADD admin ENUM('yes', 'no') NOT NULL DEFAULT 'no' AFTER `banned`";
  13. $qs[] = "UPDATE {$CONFIG->dbprefix}users_entity SET admin = 'yes' where guid IN (select x.guid FROM(
  14. SELECT * FROM {$CONFIG->dbprefix}users_entity as e,
  15. {$CONFIG->dbprefix}metadata as md
  16. WHERE (
  17. md.name_id IN ('$admin', '$siteadmin')
  18. AND md.value_id IN ('$yes', '$one')
  19. AND e.guid = md.entity_guid
  20. AND e.banned = 'no'
  21. )) as x)";
  22. $qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity ADD KEY admin (admin)";
  23. $qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity ENABLE KEYS";
  24. $qs[] = "DELETE FROM {$CONFIG->dbprefix}metadata
  25. WHERE (
  26. name_id IN ('$admin', '$siteadmin')
  27. AND value_id IN ('$yes', '$one')
  28. )";
  29. foreach ($qs as $q) {
  30. update_data($q);
  31. }