2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-07-05 17:17:03 -04:00
|
|
|
require_relative 'database_3_0'
|
2015-12-14 17:18:11 -05:00
|
|
|
require_relative '../support/constants'
|
2015-07-05 17:17:03 -04:00
|
|
|
|
|
|
|
module ImportScripts::PhpBB3
|
|
|
|
class Database_3_1 < Database_3_0
|
2022-02-16 07:04:31 -05:00
|
|
|
def fetch_users(last_user_id, profile_fields)
|
2016-05-07 17:35:48 -04:00
|
|
|
query(<<-SQL, :user_id)
|
2015-12-14 17:18:11 -05:00
|
|
|
SELECT u.user_id, u.user_email, u.username,
|
|
|
|
CASE WHEN u.user_password LIKE '$2y$%'
|
|
|
|
THEN CONCAT('$2a$', SUBSTRING(u.user_password, 5))
|
|
|
|
ELSE u.user_password
|
|
|
|
END AS user_password, u.user_regdate, u.user_lastvisit, u.user_ip,
|
2015-07-05 17:17:03 -04:00
|
|
|
u.user_type, u.user_inactive_reason, g.group_name, b.ban_start, b.ban_end, b.ban_reason,
|
|
|
|
u.user_posts, f.pf_phpbb_website AS user_website, f.pf_phpbb_location AS user_from,
|
|
|
|
u.user_birthday, u.user_avatar_type, u.user_avatar
|
2022-02-16 07:04:31 -05:00
|
|
|
#{profile_fields_query(profile_fields)}
|
2016-07-11 17:59:15 -04:00
|
|
|
FROM #{@table_prefix}users u
|
|
|
|
LEFT OUTER JOIN #{@table_prefix}profile_fields_data f ON (u.user_id = f.user_id)
|
|
|
|
JOIN #{@table_prefix}groups g ON (g.group_id = u.group_id)
|
|
|
|
LEFT OUTER JOIN #{@table_prefix}banlist b ON (
|
2015-07-05 17:17:03 -04:00
|
|
|
u.user_id = b.ban_userid AND b.ban_exclude = 0 AND
|
|
|
|
(b.ban_end = 0 OR b.ban_end >= UNIX_TIMESTAMP())
|
|
|
|
)
|
2016-01-14 16:43:19 -05:00
|
|
|
WHERE u.user_id > #{last_user_id} AND u.user_type != #{Constants::USER_TYPE_IGNORE}
|
2016-05-07 17:35:48 -04:00
|
|
|
ORDER BY u.user_id
|
2015-07-05 17:17:03 -04:00
|
|
|
LIMIT #{@batch_size}
|
|
|
|
SQL
|
|
|
|
end
|
2022-02-16 07:04:31 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def profile_fields_query(profile_fields)
|
|
|
|
@profile_fields_query ||= begin
|
|
|
|
if profile_fields.present?
|
|
|
|
columns = profile_fields.map { |field| "pf_#{field[:phpbb_field_name]}" }
|
|
|
|
", #{columns.join(', ')}"
|
|
|
|
else
|
|
|
|
""
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-07-05 17:17:03 -04:00
|
|
|
end
|
|
|
|
end
|