/** * Forum-specific export format * * @todo Project file size / export time and possibly break into multiple files * * @param ExportModel $ex * */ protected function forumExport($ex) { $characterSet = $ex->getCharacterSet('posts'); if ($characterSet) { $ex->characterSet = $characterSet; } $ex->beginExport('', 'PunBB 1.*', array('HashMethod' => 'punbb')); $this->cdn = $this->param('cdn', ''); if ($avatarPath = $this->param('avatarpath', false)) { if (!($avatarPath = realpath($avatarPath))) { echo "Unable to access path to avatars: {$avatarPath}\n"; exit(1); } $this->avatarPath = $avatarPath; } unset($avatarPath); // User. $user_Map = array('AvatarID' => array('Column' => 'Photo', 'Filter' => array($this, 'getAvatarByID')), 'id' => 'UserID', 'username' => 'Name', 'email' => 'Email', 'timezone' => 'HourOffset', 'registration_ip' => 'InsertIPAddress', 'PasswordHash' => 'Password'); $ex->exportTable('User', "\n SELECT\n u.*, u.id AS AvatarID,\n concat(u.password, '\$', u.salt) AS PasswordHash,\n from_unixtime(registered) AS DateInserted,\n from_unixtime(last_visit) AS DateLastActive\n FROM :_users u\n WHERE group_id <> 2", $user_Map); // Role. $role_Map = array('g_id' => 'RoleID', 'g_title' => 'Name'); $ex->exportTable('Role', "SELECT * FROM :_groups", $role_Map); // Permission. $permission_Map = array('g_id' => 'RoleID', 'g_modertor' => 'Garden.Moderation.Manage', 'g_mod_edit_users' => 'Garden.Users.Edit', 'g_mod_rename_users' => 'Garden.Users.Delete', 'g_read_board' => 'Vanilla.Discussions.View', 'g_view_users' => 'Garden.Profiles.View', 'g_post_topics' => 'Vanilla.Discussions.Add', 'g_post_replies' => 'Vanilla.Comments.Add', 'g_pun_attachment_allow_download' => 'Plugins.Attachments.Download.Allow', 'g_pun_attachment_allow_upload' => 'Plugins.Attachments.Upload.Allow'); $permission_Map = $ex->fixPermissionColumns($permission_Map); $ex->exportTable('Permission', "\n SELECT\n g.*,\n g_post_replies AS `Garden.SignIn.Allow`,\n g_mod_edit_users AS `Garden.Users.Add`,\n CASE WHEN g_title = 'Administrators' THEN 'All' ELSE NULL END AS _Permissions\n FROM :_groups g", $permission_Map); // UserRole. $userRole_Map = array('id' => 'UserID', 'group_id' => 'RoleID'); $ex->exportTable('UserRole', "SELECT\n CASE u.group_id WHEN 2 THEN 0 ELSE id END AS id,\n u.group_id\n FROM :_users u", $userRole_Map); // Signatures. $ex->exportTable('UserMeta', "\n SELECT\n id,\n 'Plugin.Signatures.Sig' AS Name,\n signature\n FROM :_users u\n WHERE u.signature IS NOT NULL", array('id ' => 'UserID', 'signature' => 'Value')); // Category. $category_Map = array('id' => 'CategoryID', 'forum_name' => 'Name', 'forum_desc' => 'Description', 'disp_position' => 'Sort', 'parent_id' => 'ParentCategoryID'); $ex->exportTable('Category', "\n SELECT\n id,\n forum_name,\n forum_desc,\n disp_position,\n cat_id * 1000 AS parent_id\n FROM :_forums f\n UNION\n\n SELECT\n id * 1000,\n cat_name,\n '',\n disp_position,\n NULL\n FROM :_categories", $category_Map); // Discussion. $discussion_Map = array('id' => 'DiscussionID', 'poster_id' => 'InsertUserID', 'poster_ip' => 'InsertIPAddress', 'closed' => 'Closed', 'sticky' => 'Announce', 'forum_id' => 'CategoryID', 'subject' => 'Name', 'message' => 'Body'); $ex->exportTable('Discussion', "\n SELECT t.*,\n from_unixtime(p.posted) AS DateInserted,\n p.poster_id,\n p.poster_ip,\n p.message,\n from_unixtime(p.edited) AS DateUpdated,\n eu.id AS UpdateUserID,\n 'BBCode' AS Format\n FROM :_topics t\n LEFT JOIN :_posts p\n ON t.first_post_id = p.id\n LEFT JOIN :_users eu\n ON eu.username = p.edited_by", $discussion_Map); // Comment. $comment_Map = array('id' => 'CommentID', 'topic_id' => 'DiscussionID', 'poster_id' => 'InsertUserID', 'poster_ip' => 'InsertIPAddress', 'message' => 'Body'); $ex->exportTable('Comment', "\n SELECT p.*,\n 'BBCode' AS Format,\n from_unixtime(p.posted) AS DateInserted,\n from_unixtime(p.edited) AS DateUpdated,\n eu.id AS UpdateUserID\n FROM :_topics t\n JOIN :_posts p\n ON t.id = p.topic_id\n LEFT JOIN :_users eu\n ON eu.username = p.edited_by\n WHERE p.id <> t.first_post_id;", $comment_Map); if ($ex->exists('tags')) { // Tag. $tag_Map = array('id' => 'TagID', 'tag' => 'Name'); $ex->exportTable('Tag', "SELECT * FROM :_tags", $tag_Map); // TagDisucssion. $tagDiscussionMap = array('topic_id' => 'DiscussionID', 'tag_id' => 'TagID'); $ex->exportTable('TagDiscussion', "SELECT * FROM :_topic_tags", $tagDiscussionMap); } if ($ex->exists('attach_files')) { // Media. $media_Map = array('id' => 'MediaID', 'filename' => 'Name', 'file_mime_type' => 'Type', 'size' => 'Size', 'owner_id' => 'InsertUserID', 'thumb_path' => array('Column' => 'ThumbPath', 'Filter' => array($this, 'filterThumbnailData')), 'thumb_width' => array('Column' => 'ThumbWidth', 'Filter' => array($this, 'filterThumbnailData'))); $ex->exportTable('Media', "\n select f.*,\n concat({$this->cdn}, 'FileUpload/', f.file_path) as Path,\n concat({$this->cdn}, 'FileUpload/', f.file_path) as thumb_path,\n 128 as thumb_width,\n from_unixtime(f.uploaded_at) as DateInserted,\n case when post_id is null then 'Discussion' else 'Comment' end as ForeignTable,\n coalesce(post_id, topic_id) as ForieignID\n from :_attach_files f\n ", $media_Map); } // End $ex->endExport(); }
/** * * @param ExportModel $ex */ public function forumExport($ex) { $characterSet = $ex->getCharacterSet('topics'); if ($characterSet) { $ex->characterSet = $characterSet; } $ex->beginExport('', 'Expression Engine'); $ex->sourcePrefix = 'forum_'; $this->exportConversations(); // Permissions. $permission_Map = array('group_id' => 'RoleID', 'can_access_cp' => 'Garden.Settings.View', 'can_access_edit' => 'Vanilla.Discussions.Edit', 'can_edit_all_comments' => 'Vanilla.Comments.Edit', 'can_access_admin' => 'Garden.Settings.Manage', 'can_admin_members' => 'Garden.Users.Edit', 'can_moderate_comments' => 'Garden.Moderation.Manage', 'can_view_profiles' => 'Garden.Profiles.View', 'can_post_comments' => 'Vanilla.Comments.Add', 'can_view_online_system' => 'Vanilla.Discussions.View', 'can_sign_in' => 'Garden.SignIn.Allow', 'can_view_profiles3' => 'Garden.Activity.View', 'can_post_comments2' => 'Vanilla.Discussions.Add'); $permission_Map = $ex->fixPermissionColumns($permission_Map); foreach ($permission_Map as $column => &$info) { if (is_array($info) && isset($info['Column'])) { $info['Filter'] = array($this, 'YNBool'); } } $ex->exportTable('Permission', "\n SELECT\n g.can_view_profiles AS can_view_profiles2,\n g.can_view_profiles AS can_view_profiles3,\n g.can_post_comments AS can_post_comments2,\n g.can_post_comments AS can_sign_in,\n CASE WHEN can_access_admin = 'y' THEN 'all' WHEN can_view_online_system = 'y' THEN 'view' END AS _Permissions,\n g.*\n FROM forum_member_groups g\n ", $permission_Map); // User. $user_Map = array('member_id' => 'UserID', 'username' => array('Column' => 'Username', 'Type' => 'varchar(50)'), 'screen_name' => array('Column' => 'Name', 'Filter' => array($ex, 'HTMLDecoder')), 'Password2' => 'Password', 'email' => 'Email', 'ipaddress' => 'InsertIPAddress', 'join_date' => array('Column' => 'DateInserted', 'Filter' => array($ex, 'timestampToDate')), 'last_activity' => array('Column' => 'DateLastActive', 'Filter' => array($ex, 'timestampToDate')), 'timezone' => 'HourOffset', 'location' => 'Location'); $ex->exportTable('User', "\n SELECT\n 'django' AS HashMethod,\n concat('sha1\$\$', password) AS Password2,\n CASE WHEN bday_y > 1900 THEN concat(bday_y, '-', bday_m, '-', bday_d) ELSE NULL END AS DateOfBirth,\n from_unixtime(join_date) AS DateFirstVisit,\n ip_address AS LastIPAddress,\n CASE WHEN avatar_filename = '' THEN NULL ELSE concat('imported/', avatar_filename) END AS Photo,\n u.*\n FROM forum_members u", $user_Map); // Role. $role_Map = array('group_id' => 'RoleID', 'group_title' => 'Name', 'group_description' => 'Description'); $ex->exportTable('Role', "\n SELECT *\n FROM forum_member_groups", $role_Map); // User Role. $userRole_Map = array('member_id' => 'UserID', 'group_id' => 'RoleID'); $ex->exportTable('UserRole', "\n SELECT *\n FROM forum_members u", $userRole_Map); // UserMeta $ex->exportTable('UserMeta', "\n SELECT\n member_id AS UserID,\n 'Plugin.Signatures.Sig' AS Name,\n signature AS Value\n FROM forum_members\n WHERE signature <> ''"); // Category. $category_Map = array('forum_id' => 'CategoryID', 'forum_name' => 'Name', 'forum_description' => 'Description', 'forum_parent' => 'ParentCategoryID', 'forum_order' => 'Sort'); $ex->exportTable('Category', "\n SELECT * FROM forum_forums", $category_Map); // Discussion. $discussion_Map = array('topic_id' => 'DiscussionID', 'forum_id' => 'CategoryID', 'author_id' => 'InsertUserID', 'title' => array('Column' => 'Name', 'Filter' => array($ex, 'HTMLDecoder')), 'ip_address' => 'InsertIPAddress', 'body' => array('Column' => 'Body', 'Filter' => array($this, 'cleanBodyBrackets')), 'body2' => array('Column' => 'Format', 'Filter' => array($this, 'guessFormat')), 'topic_date' => array('Column' => 'DateInserted', 'Filter' => array($ex, 'timestampToDate')), 'topic_edit_date' => array('Column' => 'DateUpdated', 'Filter' => array($ex, 'timestampToDate')), 'topic_edit_author' => 'UpdateUserID'); $ex->exportTable('Discussion', "\n SELECT\n CASE WHEN announcement = 'y' THEN 1 WHEN sticky = 'y' THEN 2 ELSE 0 END AS Announce,\n CASE WHEN status = 'c' THEN 1 ELSE 0 END AS Closed,\n t.body AS body2,\n t.*\n FROM forum_forum_topics t", $discussion_Map); // Comment. $comment_Map = array('post_id' => 'CommentID', 'topic_id' => 'DiscussionID', 'author_id' => 'InsertUserID', 'ip_address' => 'InsertIPAddress', 'body' => array('Column' => 'Body', 'Filter' => array($this, 'cleanBodyBrackets')), 'body2' => array('Column' => 'Format', 'Filter' => array($this, 'guessFormat')), 'post_date' => array('Column' => 'DateInserted', 'Filter' => array($ex, 'timestampToDate')), 'post_edit_date' => array('Column' => 'DateUpdated', 'Filter' => array($ex, 'timestampToDate')), 'post_edit_author' => 'UpdateUserID'); $ex->exportTable('Comment', "\n SELECT\n 'Html' AS Format,\n p.body AS body2,\n p.*\n FROM forum_forum_posts p", $comment_Map); // Media. $media_Map = array('filename' => 'Name', 'extension' => array('Column' => 'Type', 'Filter' => 'mimeTypeFromExtension'), 'thumb_path' => array('Column' => 'ThumbPath', 'Filter' => array($this, 'filterThumbnailData')), 'thumb_width' => array('Column' => 'ThumbWidth', 'Filter' => array($this, 'filterThumbnailData')), 'filesize' => 'Size', 'member_id' => 'InsertUserID', 'attachment_date' => array('Column' => 'DateInserted', 'Filter' => array($ex, 'timestampToDate')), 'filehash' => array('Column' => 'FileHash', 'Type' => 'varchar(100)')); $ex->exportTable('Media', "\n SELECT\n concat('imported/', filename) AS Path,\n concat('imported/', filename) as thumb_path,\n 128 as thumb_width,\n CASE WHEN post_id > 0 THEN post_id ELSE topic_id END AS ForeignID,\n CASE WHEN post_id > 0 THEN 'comment' ELSE 'discussion' END AS ForeignTable,\n a.*\n FROM forum_forum_attachments a", $media_Map); $ex->endExport(); }
/** * @param ExportModel $ex */ protected function forumExport($ex) { // $ex->TestMode = FALSE; // $ex->TestLimit = FALSE; // $ex->Destination = 'database'; // $ex->DestDb = 'unknownworlds'; // $ex->CaptureOnly = TRUE; // $ex->ScriptCreateTable = FALSE; // $ex->DestPrefix = 'GDN_'; $ex->sourcePrefix = ':_'; $characterSet = $ex->getCharacterSet('posts'); if ($characterSet) { $ex->characterSet = $characterSet; } // Decode all of the necessary fields. // $ex->HTMLDecoderDb('members', 'members_display_name', 'member_id'); // $ex->HTMLDecoderDb('members', 'name', 'member_id'); // $ex->HTMLDecoderDb('members', 'title', 'member_id'); // $ex->HtmlDecoderDb('groups', 'g_title', 'g_id'); // $ex->HtmlDecoderDb('topics', 'title', 'tid'); // $ex->HtmlDecoderDb('topics', 'description', 'tid'); // Begin $ex->beginExport('', 'IPB 3.*', array('HashMethod' => 'ipb')); // Export avatars if ($this->param('avatars')) { $this->doAvatars(); } if ($ex->exists('members', 'member_id') === true) { $memberID = 'member_id'; } else { $memberID = 'id'; } // Users. $user_Map = array($memberID => 'UserID', 'members_display_name' => array('Column' => 'Name', 'Filter' => 'HtmlDecoder'), 'email' => 'Email', 'joined' => array('Column' => 'DateInserted', 'Filter' => 'timestampToDate'), 'firstvisit' => array('Column' => 'DateFirstVisit', 'SourceColumn' => 'joined', 'Filter' => 'timestampToDate'), 'ip_address' => 'InsertIPAddress', 'title' => 'Title', 'time_offset' => 'HourOffset', 'last_activity' => array('Column' => 'DateLastActive', 'Filter' => 'timestampToDate'), 'member_banned' => 'Banned', 'Photo' => 'Photo', 'title' => 'Title', 'location' => 'Location'); $from = ''; $select = ''; if ($ex->exists('members', 'members_pass_hash') === true) { $select = ",concat(m.members_pass_hash, '\$', m.members_pass_salt) as Password"; } else { $select = ",concat(mc.converge_pass_hash, '\$', mc.converge_pass_salt) as Password"; $from = "left join :_members_converge mc\n on m.{$memberID} = mc.converge_id"; } if ($ex->exists('members', 'hide_email') === true) { $showEmail = '!hide_email'; } else { $showEmail = '0'; } $cdn = $this->cdnPrefix(); if ($ex->exists('member_extra') === true) { $sql = "select\n m.*,\n m.joined as firstvisit,\n 'ipb' as HashMethod,\n {$showEmail} as ShowEmail,\n case when x.avatar_location in ('noavatar', '') then null\n when x.avatar_location like 'upload:%' then concat('{$cdn}ipb/', right(x.avatar_location, length(x.avatar_location) - 7))\n when x.avatar_type = 'upload' then concat('{$cdn}ipb/', x.avatar_location)\n when x.avatar_type = 'url' then x.avatar_location\n when x.avatar_type = 'local' then concat('{$cdn}style_avatars/', x.avatar_location)\n else null\n end as Photo,\n x.location\n {$select}\n from :_members m\n left join :_member_extra x\n on m.{$memberID} = x.id\n {$from}"; } else { $sql = "select\n m.*,\n joined as firstvisit,\n 'ipb' as HashMethod,\n {$showEmail} as ShowEmail,\n case when length(p.pp_main_photo) <= 3 or p.pp_main_photo is null then null\n when p.pp_main_photo like '%//%' then p.pp_main_photo\n else concat('{$cdn}ipb/', p.pp_main_photo)\n end as Photo\n {$select}\n from :_members m\n left join :_profile_portal p\n on m.{$memberID} = p.pp_member_id\n {$from}"; } $this->clearFilters('members', $user_Map, $sql, 'm'); $ex->exportTable('User', $sql, $user_Map); // ":_" will be replaced by database prefix // Roles. $role_Map = array('g_id' => 'RoleID', 'g_title' => 'Name'); $ex->exportTable('Role', "select * from :_groups", $role_Map); // Permissions. $permission_Map = array('g_id' => 'RoleID', 'g_view_board' => 'Garden.SignIn.Allow', 'g_view_board2' => 'Garden.Profiles.View', 'g_view_board3' => 'Garden.Activity.View', 'g_view_board4' => 'Vanilla.Discussions.View', 'g_edit_profile' => 'Garden.Profiles.Edit', 'g_post_new_topics' => 'Vanilla.Discussions.Add', 'g_reply_other_topics' => 'Vanilla.Comments.Add', 'g_open_close_posts' => 'Vanilla.Discussions.Close', 'g_is_supmod' => 'Garden.Moderation.Manage', 'g_access_cp' => 'Garden.Settings.View'); $permission_Map = $ex->fixPermissionColumns($permission_Map); $ex->exportTable('Permission', "\n select r.*,\n r.g_view_board as g_view_board2,\n r.g_view_board as g_view_board3,\n r.g_view_board as g_view_board4\n from :_groups r", $permission_Map); // User Role. if ($ex->exists('members', 'member_group_id') === true) { $groupID = 'member_group_id'; } else { $groupID = 'mgroup'; } $userRole_Map = array($memberID => 'UserID', $groupID => 'RoleID'); $sql = "\n select\n m.{$memberID}, m.{$groupID}\n from :_members m"; if ($ex->exists('members', 'mgroup_others')) { $sql .= "\n union all\n\n select m.{$memberID}, g.g_id\n from :_members m\n join :_groups g\n on find_in_set(g.g_id, m.mgroup_others)"; } $ex->exportTable('UserRole', $sql, $userRole_Map); // UserMeta. $userMeta_Map = array('UserID' => 'UserID', 'Name' => 'Name', 'Value' => 'Value'); if ($ex->exists('profile_portal', 'signature') === true) { $sql = "\n select\n pp_member_id as UserID,\n 'Plugin.Signatures.Sig' as Name,\n signature as Value\n from :_profile_portal\n where length(signature) > 1\n\n union all\n\n select\n pp_member_id as UserID,\n 'Plugin.Signatures.Format' as Name,\n 'IPB' as Value\n from :_profile_portal\n where length(signature) > 1\n "; } elseif ($ex->exists('member_extra', array('id', 'signature')) === true) { $sql = "\n select\n id as UserID,\n 'Plugin.Signatures.Sig' as Name,\n signature as Value\n from :_member_extra\n where length(signature) > 1\n\n union all\n\n select\n id as UserID,\n 'Plugin.Signatures.Format' as Name,\n 'IPB' as Value\n from :_member_extra\n where length(signature) > 1"; } else { $sql = false; } if ($sql) { $ex->exportTable('UserMeta', $sql, $userMeta_Map); } // Category. $category_Map = array('id' => 'CategoryID', 'name' => array('Column' => 'Name', 'Filter' => 'HtmlDecoder'), 'name_seo' => 'UrlCode', 'description' => 'Description', 'parent_id' => 'ParentCategoryID', 'position' => 'Sort'); $ex->exportTable('Category', "select * from :_forums", $category_Map); // Discussion. $descriptionSQL = 'p.post'; $hasTopicDescription = $ex->exists('topics', array('description')) === true; if ($hasTopicDescription || $ex->exists('posts', array('description')) === true) { $description = $hasTopicDescription ? 't.description' : 'p.description'; $descriptionSQL = "case\n when {$description} <> '' and p.post is not null then concat('<div class=\"IPBDescription\">', {$description}, '</div>', p.post)\n when {$description} <> '' then {$description}\n else p.post\n end"; } $discussion_Map = array('tid' => 'DiscussionID', 'title' => 'Name', 'description' => array('Column' => 'SubName', 'Type' => 'varchar(255)'), 'forum_id' => 'CategoryID', 'starter_id' => 'InsertUserID', 'start_date' => array('Column' => 'DateInserted', 'Filter' => 'timestampToDate'), 'ip_address' => 'InsertIPAddress', 'edit_time' => array('Column' => 'DateUpdated', 'Filter' => 'timestampToDate'), 'posts' => 'CountComments', 'views' => 'CountViews', 'pinned' => 'Announce', 'post' => 'Body', 'closed' => 'Closed'); $sql = "\n select\n t.*,\n {$descriptionSQL} as post,\n case when t.state = 'closed' then 1 else 0 end as closed,\n 'BBCode' as Format,\n p.ip_address,\n p.edit_time\n from :_topics t\n left join :_posts p\n on t.topic_firstpost = p.pid\n where t.tid between {from} and {to}"; $this->clearFilters('topics', $discussion_Map, $sql, 't'); $ex->exportTable('Discussion', $sql, $discussion_Map); // Tags $ex->query("DROP TABLE IF EXISTS `z_tag` "); $ex->query("CREATE TABLE `z_tag` (\n `TagID` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `FullName` varchar(50) DEFAULT NULL,\n PRIMARY KEY (`TagID`),\n UNIQUE KEY `FullName` (`FullName`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $ex->query("insert into z_tag (FullName) (select distinct t.tag_text as FullName from :_core_tags t)"); $tagDiscussion_Map = array('tag_added' => array('Column' => 'DateInserted', 'Filter' => 'timestampToDate')); $sql = "select TagID, '0' as CategoryID, tag_meta_id as DiscussionID, t.tag_added\n from :_core_tags t\n left join z_tag zt on t.tag_text = zt.FullName"; $ex->exportTable('TagDiscussion', $sql, $tagDiscussion_Map); $tag_Map = array('FullName' => 'FullName', 'FullNameToName' => array('Column' => 'Name', 'Filter' => 'formatUrl')); $sql = "select TagID, FullName, FullName as FullNameToName\n from z_tag zt"; $ex->exportTable('Tag', $sql, $tag_Map); // Comments. $comment_Map = array('pid' => 'CommentID', 'topic_id' => 'DiscussionID', 'author_id' => 'InsertUserID', 'ip_address' => 'InsertIPAddress', 'post_date' => array('Column' => 'DateInserted', 'Filter' => 'timestampToDate'), 'edit_time' => array('Column' => 'DateUpdated', 'Filter' => 'timestampToDate'), 'post' => 'Body'); $sql = "\n select\n p.*,\n 'BBCode' as Format\n from :_posts p\n join :_topics t\n on p.topic_id = t.tid\n where p.pid between {from} and {to}\n and p.pid <> t.topic_firstpost"; $this->clearFilters('Comment', $comment_Map, $sql, 'p'); $ex->exportTable('Comment', $sql, $comment_Map); // Media. $media_Map = array('attach_id' => 'MediaID', 'atype_mimetype' => 'Type', 'attach_file' => 'Name', 'attach_path' => 'Path', 'attach_date' => array('Column' => 'DateInserted', 'Filter' => 'timestampToDate'), 'thumb_path' => array('Column' => 'ThumbPath', 'Filter' => array($this, 'filterThumbnailData')), 'thumb_width' => array('Column' => 'ThumbWidth', 'Filter' => array($this, 'filterThumbnailData')), 'attach_member_id' => 'InsertUserID', 'attach_filesize' => 'Size', 'ForeignID' => 'ForeignID', 'ForeignTable' => 'ForeignTable', 'img_width' => 'ImageWidth', 'img_height' => 'ImageHeight'); $sql = "select\n a.*,\n concat('~cf/ipb/', a.attach_location) as attach_path,\n concat('~cf/ipb/', a.attach_location) as thumb_path,\n 128 as thumb_width,\n ty.atype_mimetype,\n case when p.pid = t.topic_firstpost then 'discussion' else 'comment' end as ForeignTable,\n case when p.pid = t.topic_firstpost then t.tid else p.pid end as ForeignID,\n case a.attach_img_width when 0 then a.attach_thumb_width else a.attach_img_width end as img_width,\n case a.attach_img_height when 0 then a.attach_thumb_height else a.attach_img_height end as img_height\nfrom :_attachments a\njoin :_posts p\n on a.attach_rel_id = p.pid and a.attach_rel_module = 'post'\njoin :_topics t\n on t.tid = p.topic_id\nleft join :_attachments_type ty\n on a.attach_ext = ty.atype_extension"; $this->clearFilters('Media', $media_Map, $sql); $ex->exportTable('Media', $sql, $media_Map); if ($ex->exists('message_topic_user_map')) { $this->_exportConversationsV3(); } else { $this->_exportConversationsV2(); } $ex->endExport(); }