Пример #1
0
/**
 * Downloads the thumbnail and saves into data folder
 *
 * @param ElggObject $item
 * @return bool
 */
function videolist_2012022501($item)
{
    require_once elgg_get_plugins_path() . 'upgrade-tools/lib/upgrade_tools.php';
    // get thumbnail image
    $thumbnail = file_get_contents($item->thumbnail);
    if (!$thumbnail) {
        return false;
    }
    $prefix = "videolist/" . $item->guid;
    $filehandler = new ElggFile();
    $filehandler->owner_guid = $item->owner_guid;
    $filehandler->setFilename($prefix . ".jpg");
    $filehandler->open("write");
    $filehandler->write($thumbnail);
    $filehandler->close();
    // update properties
    if ($item->url) {
        $item->video_url = $item->url;
        $item->deleteMetadata('url');
    }
    if ($item->desc) {
        $item->description = $item->desc;
        $item->deleteMetadata('desc');
        $item->save();
    }
    if ($item->embedurl) {
        $item->deleteMetadata('embedurl');
    }
    upgrade_change_subtype($item, 'videolist_item');
    // update river
    $options = array('object_guid' => $item->guid);
    $river_items = elgg_get_river($options);
    foreach ($river_items as $river_item) {
        if ($river_item->action_type == 'create') {
            upgrade_update_river($river_item->id, 'river/object/videolist_item/create', $item->guid, 0);
        }
    }
    return true;
}
Пример #2
0
function tasks_2012100501($task)
{
    require_once elgg_get_plugins_path() . 'upgrade-tools/lib/upgrade_tools.php';
    if ($task->long_description) {
        $task->description = $task->long_description;
        $task->deleteMetadata('long_description');
        $task->save();
    }
    if ($task->parent_guid) {
        $task->list_guid = $task->parent_guid;
        $task->deleteMetadata('parent_guid');
    } else {
        $task->list_guid = 0;
    }
    /* Active was set as default, so it is not indicative of which tasks are
    	really active */
    $task->deleteMetadata('active');
    if ($task->done) {
        $task->status = 'done';
        $task->deleteMetadata('done');
    } else {
        $task->status = 'new';
    }
    // reset priority since old system was a mess
    $task->priority = 2;
    upgrade_change_subtype($task, 'task');
    // update river
    $options = array('object_guid' => $task->guid);
    $items = elgg_get_river($options);
    foreach ($items as $item) {
        if ($item->action_type == 'create') {
            upgrade_update_river($item->id, 'river/object/task/create', $task->guid, 0);
        } elseif (in_array($item->action_type, array('done', 'undone', 'subscribe', 'unsubscribe'))) {
            elgg_delete_river(array('id' => $item->id));
        }
    }
    return true;
}
Пример #3
0
function threads_groupforumpost_2012100501($post)
{
    require_once elgg_get_plugins_path() . 'upgrade-tools/lib/upgrade_tools.php';
    global $MIGRATED;
    $MIGRATED += 1;
    if ($MIGRATED % 100 == 0) {
        error_log("post {$post->guid}");
    }
    // get content from annotations and copy into description
    $annotations = $post->getAnnotations('group_topic_post');
    foreach ($annotations as $annotation) {
        if ($annotation->value) {
            $post->description = $annotation->value;
        }
        $annotation->delete();
    }
    // fix relationships
    $topic = current($post->getEntitiesFromRelationship('group_discussion_top_level_post', true));
    if ($topic) {
        // top level post
        $topic->removeRelationship($post->guid, 'group_discussion_top_level_post');
        $parent = $topic;
    } else {
        // reply
        $topic = current($post->getEntitiesFromRelationship('group_discussion_topic_link', true));
        $parent = current($post->getEntitiesFromRelationship('group_discussion_reply_post', true));
        if ($topic) {
            $topic->removeRelationship($post->guid, 'group_discussion_topic_link');
        }
        if ($parent) {
            $parent->removeRelationship($post->guid, 'group_discussion_reply_post');
        }
    }
    if ($parent) {
        $post->addRelationship($parent->guid, 'parent');
    }
    if ($topic) {
        $post->addRelationship($topic->guid, 'top');
    }
    $post->save();
    upgrade_change_subtype($post, 'topicreply');
    // update river
    $options = array('object_guid' => $post->guid);
    $items = elgg_get_river($options);
    foreach ($items as $item) {
        upgrade_update_river($item->id, 'river/forum/create', $topic->guid, $post->guid);
    }
    return true;
}