2011030700-1.8_svn-blog_status_metadata-4645225d7b440876.php 617 B

123456789101112131415161718192021222324
  1. <?php
  2. /**
  3. * Elgg 1.8-svn upgrade 2011030700
  4. * blog_status_metadata
  5. *
  6. * Add a "status" metadata entry to every blog entity because in 1.8 you can have status = draft or
  7. * status = published
  8. */
  9. $ia = elgg_set_ignore_access(true);
  10. $options = array(
  11. 'type' => 'object',
  12. 'subtype' => 'blog',
  13. 'limit' => 0,
  14. );
  15. $batch = new \ElggBatch('elgg_get_entities', $options);
  16. foreach ($batch as $entity) {
  17. if (!$entity->status) {
  18. // create metadata owned by the original owner
  19. create_metadata($entity->getGUID(), 'status', 'published', '', $entity->owner_guid,
  20. $entity->access_id);
  21. }
  22. }
  23. elgg_set_ignore_access($ia);