2014050600-1.9.0_dev-replies_to_entities-094ea0e36bc027d3.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Elgg 1.9.0-dev upgrade 2014050600
  4. * replies_to_entities
  5. *
  6. * Registers discussion reply subtype and adds \ElggUpgrade for ajax upgrade.
  7. *
  8. * We do not migrate discussion replies in this upgrade. See the upgrade action
  9. * in actions/admin/upgrades/upgrade_discussion_replies.php for that.
  10. *
  11. * This upgrade must be run even if the groups plugin is disabled because the
  12. * script will be removed in Elgg 1.10 and we don't want anyone to get stuck
  13. * with old annotation replies just because the groups plugin was not enabled
  14. * when site was upgraded from 1.8.
  15. */
  16. // Register subtype and class for discussion replies
  17. if (get_subtype_id('object', 'discussion_reply')) {
  18. update_subtype('object', 'discussion_reply', 'ElggDiscussionReply');
  19. } else {
  20. add_subtype('object', 'discussion_reply', 'ElggDiscussionReply');
  21. }
  22. $access_status = access_get_show_hidden_status();
  23. access_show_hidden_entities(true);
  24. $ia = elgg_set_ignore_access(true);
  25. $discussion_replies = elgg_get_annotations(array(
  26. 'annotation_names' => 'group_topic_post',
  27. 'count' => true,
  28. ));
  29. // Notify administrator only if there are existing discussion replies
  30. if ($discussion_replies) {
  31. $path = "admin/upgrades/discussion_replies";
  32. $upgrade = new \ElggUpgrade();
  33. // Create the upgrade if one with the same URL doesn't already exist
  34. if (!$upgrade->getUpgradeFromPath($path)) {
  35. $upgrade->setPath($path);
  36. $upgrade->title = 'Group Discussions Upgrade';
  37. $upgrade->description = 'Group discussions have been improved in Elgg 1.9 and require a migration. Run this upgrade to complete the migration.';
  38. $upgrade->save();
  39. }
  40. }
  41. elgg_set_ignore_access($ia);
  42. access_show_hidden_entities($access_status);