2010102801.php 932 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * Convert river entries for tags to be tagger-tagee-annotation from
  4. * image-tagee
  5. */
  6. $album_subtype_id = get_subtype_id('object', 'album');
  7. global $DB_QUERY_CACHE, $DB_PROFILE, $ENTITY_CACHE, $CONFIG;
  8. $query = "SELECT * FROM {$CONFIG->dbprefix}river WHERE view = 'river/object/image/tag'";
  9. $river_items = mysql_query($query);
  10. while ($item = mysql_fetch_object($river_items)) {
  11. $DB_QUERY_CACHE = $DB_PROFILE = array();
  12. // find the annotation for this river item
  13. elgg_get_annotations(array('guid' => $item->subject_guid, 'annotation_name' => 'phototag', 'limit' => 999));
  14. foreach ($annotations as $annotation) {
  15. $tag = unserialize($annotation->value);
  16. if ($tag->type === 'user') {
  17. if ($tag->value == $item->object_guid) {
  18. $update = "UPDATE {$CONFIG->dbprefix}river SET subject_guid = $annotation->owner_guid, annotation_id = $annotation->id where id = $item->id";
  19. mysql_query($update);
  20. }
  21. }
  22. }
  23. }