2013010400-1.9.0_dev-comments_to_entities-faba94768b055b08.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Elgg 1.9.0-dev upgrade 2013010400
  4. * comments_to_entities
  5. *
  6. * Convert comment annotations to entities.
  7. *
  8. * Register comment subtype and add \ElggUpgrade for ajax upgrade.
  9. *
  10. * We do not migrate comments in this upgrade. See the comment
  11. * upgrade action in actions/admin/upgrades/upgrade_comments.php for that.
  12. */
  13. // Register subtype and class for comments
  14. if (get_subtype_id('object', 'comment')) {
  15. update_subtype('object', 'comment', 'ElggComment');
  16. } else {
  17. add_subtype('object', 'comment', 'ElggComment');
  18. }
  19. $access_status = access_get_show_hidden_status();
  20. access_show_hidden_entities(true);
  21. $ia = elgg_set_ignore_access(true);
  22. // add \ElggUpgrade object if need to migrate comments
  23. $options = array(
  24. 'annotation_names' => 'generic_comment',
  25. 'order_by' => 'n_table.id DESC',
  26. 'count' => true
  27. );
  28. if (elgg_get_annotations($options)) {
  29. $path = "admin/upgrades/comments";
  30. $upgrade = new \ElggUpgrade();
  31. // Create the upgrade if one with the same URL doesn't already exist
  32. if (!$upgrade->getUpgradeFromPath($path)) {
  33. $upgrade->setPath($path);
  34. $upgrade->title = 'Comments Upgrade';
  35. $upgrade->description = 'Comments have been improved in Elgg 1.9 and require a migration. Run this upgrade to complete the migration.';
  36. $upgrade->save();
  37. }
  38. }
  39. elgg_set_ignore_access($ia);
  40. access_show_hidden_entities($access_status);