Exemplo n.º 1
0
     // no annotations left
     break;
 }
 $db_prefix = elgg_get_config('dbprefix');
 // Create a new object for each annotation
 foreach ($annotations as $annotation) {
     $object = new ElggComment();
     $object->owner_guid = $annotation->owner_guid;
     $object->container_guid = $annotation->entity_guid;
     $object->description = $annotation->value;
     $object->access_id = $annotation->access_id;
     // make sure disabled comments stay disabled
     $object->enabled = $annotation->enabled;
     $object->time_created = $annotation->time_created;
     $object->save(false);
     $guid = $object->getGUID();
     if ($guid) {
         /**
          * Update the entry in river table for this comment
          *
          * - Update the view path
          * - Remove annotation id
          * - Save comment guid to the object_guid column
          */
         $query = "\n\t\t\t\tUPDATE {$db_prefix}river\n\t\t\t\tSET view = 'river/object/comment/create',\n\t\t\t\t\ttype = 'object',\n\t\t\t\t\tsubtype = 'comment',\n\t\t\t\t\tannotation_id = 0,\n\t\t\t\t\tobject_guid = {$guid},\n\t\t\t\t\ttarget_guid = {$object->container_guid}\n\t\t\t\tWHERE action_type = 'comment'\n\t\t\t\t  AND annotation_id = {$annotation->id}\n\t\t\t";
         if (!update_data($query)) {
             register_error(elgg_echo('upgrade:comments:river_update_failed', array($annotation->id)));
             $error_count++;
             continue;
         }
         // set the time_updated and last_action for this comment