From 9e46690086b72d5ccda183cec1de68220ec53d2b Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 29 Feb 2016 11:48:43 +0800 Subject: [PATCH] Add Permalink to phpbb3 import script. --- script/import_scripts/phpbb3/importer.rb | 20 +++++++++++++++++++ .../phpbb3/importers/post_importer.rb | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/script/import_scripts/phpbb3/importer.rb b/script/import_scripts/phpbb3/importer.rb index f2c1dc9de16..ffcccae7bd1 100644 --- a/script/import_scripts/phpbb3/importer.rb +++ b/script/import_scripts/phpbb3/importer.rb @@ -108,6 +108,26 @@ module ImportScripts::PhpBB3 end end + # uncomment below lines to create permalink for categories + # def create_category(opts, import_id) + # new_category = super + # Permalink.create(url: "viewforum.php?f=#{import_id}", category_id: new_category.id) + # new_category + # end + + # uncomment below lines to create permalink for topics + # def create_post(opts, import_id) + # post = super + # if post && (topic = post.topic) && (category = topic.category) + # url = "viewtopic.php?f=#{category.custom_fields["import_id"]}&t=#{opts[:import_topic_id]}" + + # if !Permalink.find_by(url: url) + # Permalink.create(url: url, topic_id: topic.id) + # end + # end + # post + # end + def import_private_messages if @settings.fix_private_messages puts '', 'fixing private messages' diff --git a/script/import_scripts/phpbb3/importers/post_importer.rb b/script/import_scripts/phpbb3/importers/post_importer.rb index b6de98622fa..a00335232c3 100644 --- a/script/import_scripts/phpbb3/importers/post_importer.rb +++ b/script/import_scripts/phpbb3/importers/post_importer.rb @@ -28,7 +28,8 @@ module ImportScripts::PhpBB3 id: row[:post_id], user_id: user_id, created_at: Time.zone.at(row[:post_time]), - raw: @text_processor.process_post(row[:post_text], attachments) + raw: @text_processor.process_post(row[:post_text], attachments), + import_topic_id: row[:topic_id] } if is_first_post