Пример #1
0
 }
 $db_prefix = elgg_get_config('dbprefix');
 $container_guids = array();
 // Create a new object for each annotation
 foreach ($annotations as $annotation) {
     $object = new ElggDiscussionReply();
     $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 replies stay disabled
     $object->enabled = $annotation->enabled;
     $object->time_created = $annotation->time_created;
     $object->save(false);
     $container_guids[] = $object->container_guid;
     $guid = $object->getGUID();
     if ($guid) {
         /**
          * Update the entry in river table for this reply
          *
          * - Update the view path
          * - Remove annotation id
          * - Save reply guid to the object_guid column
          */
         $query = "\n\t\t\t\tUPDATE {$db_prefix}river\n\t\t\t\tSET view = 'river/object/discussion_reply/create',\n\t\t\t\t\ttype = 'object',\n\t\t\t\t\tsubtype = 'discussion_reply',\n\t\t\t\t\taction_type = 'reply',\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 = 'reply'\n\t\t\t\t  AND annotation_id = {$annotation->id}\n\t\t\t";
         if (!update_data($query)) {
             register_error(elgg_echo('upgrade:river_update_failed', array($annotation->id)));
             $error_count++;
         }
         // set the time_updated and last_action for this reply
         // to the original time_created
Пример #2
0
     $reply->access_id = $topic->access_id;
     $reply->description = $answer->description;
     if ($reply->save()) {
         questions_backdate_entity($reply->getGUID(), $answer->time_created);
     }
     // copy all comments on the answer to topic replies
     $comment_options['container_guid'] = $answer->getGUID();
     $comments = new ElggBatch('elgg_get_entities', $comment_options);
     foreach ($comments as $comment) {
         $reply = new ElggDiscussionReply();
         $reply->owner_guid = $comment->getOwnerGUID();
         $reply->container_guid = $topic->getGUID();
         $reply->access_id = $topic->access_id;
         $reply->description = $comment->description;
         if ($reply->save()) {
             questions_backdate_entity($reply->getGUID(), $comment->time_created);
         }
         $comment->delete();
     }
     $answer->delete();
 }
 // last changes to the topic
 // backdate the discussion
 $topic->time_created = $entity->time_created;
 // set correct owner of the topic
 $topic->owner_guid = $entity->getOwnerGUID();
 $topic->save();
 // cleaup the old question
 $entity->delete();
 // restore access
 elgg_set_ignore_access($ia);