2011031300-1.8_svn-twitter_api-12b832a5a7a3e1bd.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Elgg 1.8-svn upgrade 2011031300
  4. * twitter_api
  5. *
  6. * Updates the database for twitterservice to twitter_api changes.
  7. */
  8. $ia = elgg_set_ignore_access(true);
  9. // make sure we have updated plugins
  10. _elgg_generate_plugin_entities();
  11. $show_hidden = access_get_show_hidden_status();
  12. access_show_hidden_entities(true);
  13. $db_prefix = elgg_get_config('dbprefix');
  14. $site_guid = elgg_get_site_entity()->getGUID();
  15. $old = elgg_get_plugin_from_id('twitterservice');
  16. $new = elgg_get_plugin_from_id('twitter_api');
  17. $has_settings = false;
  18. // if not loaded, don't bother.
  19. if (!$old || !$new) {
  20. return true;
  21. }
  22. $settings = array('consumer_key', 'consumer_secret', 'sign_on', 'new_users');
  23. foreach ($settings as $setting) {
  24. $value = $old->getSetting($setting);
  25. if ($value) {
  26. $has_settings = true;
  27. $new->setSetting($setting, $value);
  28. }
  29. }
  30. // update the user settings
  31. $q = "UPDATE {$db_prefix}private_settings
  32. SET name = replace(name, 'twitterservice', 'twitter_api')
  33. WHERE name like '%twitterservice%'";
  34. update_data($q);
  35. // if there were settings, emit a notice to re-enable twitter_api
  36. if ($has_settings) {
  37. elgg_add_admin_notice('twitter_api:disabled', elgg_echo('update:twitter_api:deactivated'));
  38. }
  39. $old->delete();
  40. access_show_hidden_entities($show_hidden);
  41. elgg_set_ignore_access($ia);