• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

RM 1.1 Show with SQL imported resources in profile and discussion tab in thread

Scharesoft

Active member
#1
I'm moving with my site from vBulletin and Joomla to XenForo. In Joomla only the download section was used.

To import all downloads to XenForo I wrote a little PHP script and almost everything works as desired, the downloads appear in the resource area and the category count is working.

But there is a problem with the member profile. In the profile the resource tab isn't working, the resource of a member doesn't appear there. Also the discussion tab is missing in the thread, in the associated resource it appears.

I used these querys to import the download files (Maybe they are a little dirty, but they are only for my own use):
PHP:
$xenforoDB->query("INSERT INTO `xf_resource_update` (`resource_id`, `title`, `message`, `message_state`, "
        . "`post_date`, `attach_count`, `likes`, `had_first_visible`) VALUES('"
        . $resource_id . "', '"
        . $xenforoDB->real_escape_string($title) . "', '"
        . $xenforoDB->real_escape_string($message) . "', '"
        . $message_state . "', '"
        . $post_date . "', '"
        . $attach_count . "', '"
        . $likes . "', '"
        . $had_first_visible . "');";)
PHP:
$xenforoDB->query("INSERT INTO `xf_resource_version` (`resource_id`, `resource_update_id`, "
                    . "`version_string`, `release_date`, `download_url`, `download_count`, `version_state`, "
                    . "`had_first_visible`) VALUES('"
                    . $resource_id . "', '"
                    . $resource_update_id . "', '"
                    . $version_string . "', '"
                    . $release_date . "', '"
                    . $xenforoDB->real_escape_string($external_url) . "', '"
                    . $download_count . "', '"
                    . $version_state . "', '"
                    . $had_first_visible . "');";)
PHP:
$xenforoDB->query("INSERT INTO `xf_resource`(`resource_id`, `title`, `tag_line`, `user_id`, `username`, `resource_state`, "
                        . "`resource_date`, `resource_category_id`, `current_version_id`, `description_update_id`, `discussion_thread_id`, "
                        . "`download_count`, `last_update`, `had_first_visible`) VALUES('"
                        . $resource_id . "', '"
                        . $xenforoDB->real_escape_string($title) . "', '"
                        . $tag_line . "', '"
                        . $user_id . "', '"
                        . $xenforoDB->real_escape_string($username) . "', '"
                        . $resource_state . "', '"
                        . $resource_date . "', '"
                        . $resource_category_id . "', '"
                        . $resource_version_id . "', '"
                        . $resource_update_id . "', '"
                        . $discussion_thread_id . "', '"
                        . $download_count . "', '"
                        . $resource_date . "', '"
                        . $had_first_visible . "');";)
I've already rebuilt the resources, resource categories, thread information and the user cache. Each imported download link is an external link, so no file upload was necessary.

Are there any other relevant tables that I've overlooked?
 

Scharesoft

Active member
#2
I found the solution. I forgot to update the resource count in the user table and the discussion_type in the thread table.
PHP:
UPDATE xf_thread AS thread
SET discussion_type = 'resource'
WHERE thread.thread_id = (SELECT discussion_thread_id
    FROM xf_resource AS resource
    WHERE resource.discussion_thread_id = thread.thread_id
    GROUP BY thread.thread_id
)
PHP:
UPDATE xf_user AS user
SET resource_count = (SELECT COUNT(*)
    FROM xf_resource AS resource
    WHERE resource.user_id = user.user_id
    AND resource.resource_state = 'visible'
)