2013-04-11 16:04:20 -04:00
|
|
|
# Responsible for logging the actions of admins and moderators.
|
2013-07-23 17:58:26 -04:00
|
|
|
class StaffActionLogger
|
2014-11-24 13:48:54 -05:00
|
|
|
|
2015-02-05 14:34:57 -05:00
|
|
|
def self.base_attrs
|
|
|
|
[:topic_id, :post_id, :context, :subject, :ip_address, :previous_value, :new_value]
|
|
|
|
end
|
|
|
|
|
2013-04-11 16:04:20 -04:00
|
|
|
def initialize(admin)
|
|
|
|
@admin = admin
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:admin) unless @admin && @admin.is_a?(User)
|
2013-04-11 16:04:20 -04:00
|
|
|
end
|
|
|
|
|
2013-07-25 18:04:51 -04:00
|
|
|
def log_user_deletion(deleted_user, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:deleted_user) unless deleted_user && deleted_user.is_a?(User)
|
2013-09-10 21:21:16 -04:00
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:delete_user],
|
2013-10-22 18:55:30 -04:00
|
|
|
ip_address: deleted_user.ip_address.to_s,
|
2014-10-01 11:40:13 -04:00
|
|
|
details: [:id, :username, :name, :created_at, :trust_level, :last_seen_at, :last_emailed_at].map { |x| "#{x}: #{deleted_user.send(x)}" }.join("\n")
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2015-02-05 14:34:57 -05:00
|
|
|
def log_custom(custom_type, details=nil)
|
|
|
|
raise Discourse::InvalidParameters.new(:custom_type) unless custom_type
|
|
|
|
|
|
|
|
details ||= {}
|
|
|
|
|
|
|
|
attrs = {}
|
|
|
|
StaffActionLogger.base_attrs.each do |attr|
|
|
|
|
attrs[attr] = details.delete(attr) if details.has_key?(attr)
|
|
|
|
end
|
|
|
|
attrs[:details] = details.map {|r| "#{r[0]}: #{r[1]}"}.join("\n")
|
|
|
|
attrs[:acting_user_id] = @admin.id
|
|
|
|
attrs[:action] = UserHistory.actions[:custom_staff]
|
|
|
|
attrs[:custom_type] = custom_type
|
|
|
|
|
|
|
|
UserHistory.create(attrs)
|
|
|
|
end
|
|
|
|
|
2014-10-01 11:40:13 -04:00
|
|
|
def log_post_deletion(deleted_post, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:deleted_post) unless deleted_post && deleted_post.is_a?(Post)
|
2014-10-01 11:40:13 -04:00
|
|
|
|
2016-04-10 23:50:08 -04:00
|
|
|
topic = deleted_post.topic || Topic.with_deleted.find_by(id: deleted_post.topic_id)
|
2014-10-01 11:40:13 -04:00
|
|
|
|
2015-08-13 23:57:02 -04:00
|
|
|
username = deleted_post.user.try(:username) || "unknown"
|
|
|
|
name = deleted_post.user.try(:name) || "unknown"
|
2016-04-10 23:50:08 -04:00
|
|
|
topic_title = topic.try(:title) || "not found"
|
2015-08-13 23:57:02 -04:00
|
|
|
|
2014-10-01 11:40:13 -04:00
|
|
|
details = [
|
|
|
|
"id: #{deleted_post.id}",
|
|
|
|
"created_at: #{deleted_post.created_at}",
|
2015-08-13 23:57:02 -04:00
|
|
|
"user: #{username} (#{name})",
|
2016-04-10 23:50:08 -04:00
|
|
|
"topic: #{topic_title}",
|
2014-10-01 11:40:13 -04:00
|
|
|
"post_number: #{deleted_post.post_number}",
|
|
|
|
"raw: #{deleted_post.raw}"
|
|
|
|
]
|
|
|
|
|
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:delete_post],
|
|
|
|
post_id: deleted_post.id,
|
|
|
|
details: details.join("\n")
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_topic_deletion(deleted_topic, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:deleted_topic) unless deleted_topic && deleted_topic.is_a?(Topic)
|
2014-10-01 11:40:13 -04:00
|
|
|
|
2016-06-15 08:45:18 -04:00
|
|
|
user = deleted_topic.user ? "#{deleted_topic.user.username} (#{deleted_topic.user.name})" : "(deleted user)"
|
2016-06-15 08:41:08 -04:00
|
|
|
|
2014-10-01 11:40:13 -04:00
|
|
|
details = [
|
|
|
|
"id: #{deleted_topic.id}",
|
|
|
|
"created_at: #{deleted_topic.created_at}",
|
2016-06-15 08:41:08 -04:00
|
|
|
"user: #{user}",
|
2014-10-01 11:40:13 -04:00
|
|
|
"title: #{deleted_topic.title}"
|
|
|
|
]
|
|
|
|
|
|
|
|
if first_post = deleted_topic.ordered_posts.first
|
|
|
|
details << "raw: #{first_post.raw}"
|
|
|
|
end
|
|
|
|
|
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:delete_topic],
|
|
|
|
topic_id: deleted_topic.id,
|
|
|
|
details: details.join("\n")
|
2013-08-19 16:58:38 -04:00
|
|
|
}))
|
2013-04-11 16:04:20 -04:00
|
|
|
end
|
2013-07-08 05:53:22 -04:00
|
|
|
|
2013-08-13 12:04:28 -04:00
|
|
|
def log_trust_level_change(user, old_trust_level, new_trust_level, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user && user.is_a?(User)
|
|
|
|
raise Discourse::InvalidParameters.new(:old_trust_level) unless TrustLevel.valid? old_trust_level
|
|
|
|
raise Discourse::InvalidParameters.new(:new_trust_level) unless TrustLevel.valid? new_trust_level
|
2013-09-10 21:21:16 -04:00
|
|
|
UserHistory.create!( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:change_trust_level],
|
2013-08-07 17:01:59 -04:00
|
|
|
target_user_id: user.id,
|
2014-10-01 11:40:13 -04:00
|
|
|
details: "old trust level: #{old_trust_level}\nnew trust level: #{new_trust_level}"
|
2013-08-19 16:58:38 -04:00
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2017-01-10 16:45:36 -05:00
|
|
|
def log_lock_trust_level(user, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user && user.is_a?(User)
|
|
|
|
UserHistory.create!( params(opts).merge({
|
|
|
|
action: UserHistory.actions[user.trust_level_locked ? :lock_trust_level : :unlock_trust_level],
|
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2013-08-19 16:58:38 -04:00
|
|
|
def log_site_setting_change(setting_name, previous_value, new_value, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:setting_name) unless setting_name.present? && SiteSetting.respond_to?(setting_name)
|
2013-09-10 21:21:16 -04:00
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:change_site_setting],
|
2013-08-19 16:58:38 -04:00
|
|
|
subject: setting_name,
|
|
|
|
previous_value: previous_value,
|
|
|
|
new_value: new_value
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2017-04-12 10:52:52 -04:00
|
|
|
def theme_json(theme)
|
|
|
|
ThemeSerializer.new(theme, root:false).to_json
|
|
|
|
end
|
|
|
|
|
|
|
|
def strip_duplicates(old,cur)
|
|
|
|
return [old,cur] unless old && cur
|
|
|
|
|
|
|
|
old = JSON.parse(old)
|
|
|
|
cur = JSON.parse(cur)
|
|
|
|
|
|
|
|
old.each do |k, v|
|
|
|
|
next if k == "name"
|
|
|
|
next if k == "id"
|
|
|
|
if (v == cur[k])
|
|
|
|
cur.delete(k)
|
|
|
|
old.delete(k)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
[old.to_json, cur.to_json]
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_theme_change(old_json, new_theme, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:new_theme) unless new_theme
|
|
|
|
|
|
|
|
new_json = theme_json(new_theme)
|
|
|
|
|
|
|
|
old_json,new_json = strip_duplicates(old_json,new_json)
|
|
|
|
|
2013-09-10 21:21:16 -04:00
|
|
|
UserHistory.create( params(opts).merge({
|
2017-04-12 10:52:52 -04:00
|
|
|
action: UserHistory.actions[:change_theme],
|
|
|
|
subject: new_theme.name,
|
|
|
|
previous_value: old_json,
|
|
|
|
new_value: new_json
|
2013-08-21 12:03:21 -04:00
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2017-04-12 10:52:52 -04:00
|
|
|
def log_theme_destroy(theme, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:theme) unless theme
|
2013-09-10 21:21:16 -04:00
|
|
|
UserHistory.create( params(opts).merge({
|
2017-04-12 10:52:52 -04:00
|
|
|
action: UserHistory.actions[:delete_theme],
|
|
|
|
subject: theme.name,
|
|
|
|
previous_value: theme_json(theme)
|
2013-08-21 10:49:35 -04:00
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2016-01-18 10:26:14 -05:00
|
|
|
def log_site_text_change(subject, new_text=nil, old_text=nil, opts={})
|
2015-12-18 08:31:04 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:subject) unless subject.present?
|
2017-03-01 03:12:17 -05:00
|
|
|
UserHistory.create!( params(opts).merge({
|
2015-12-18 08:31:04 -05:00
|
|
|
action: UserHistory.actions[:change_site_text],
|
|
|
|
subject: subject,
|
|
|
|
previous_value: old_text,
|
|
|
|
new_value: new_text
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2015-01-16 17:30:46 -05:00
|
|
|
def log_username_change(user, old_username, new_username, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
2015-01-16 17:30:46 -05:00
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:change_username],
|
|
|
|
target_user_id: user.id,
|
|
|
|
previous_value: old_username,
|
|
|
|
new_value: new_username
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2017-02-23 00:48:57 -05:00
|
|
|
def log_name_change(user_id, old_name, new_name, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user_id
|
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:change_name],
|
|
|
|
target_user_id: user_id,
|
|
|
|
previous_value: old_name,
|
|
|
|
new_value: new_name
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2013-11-07 13:53:32 -05:00
|
|
|
def log_user_suspend(user, reason, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
2013-11-01 10:47:03 -04:00
|
|
|
UserHistory.create( params(opts).merge({
|
2013-11-07 13:53:32 -05:00
|
|
|
action: UserHistory.actions[:suspend_user],
|
2013-11-01 10:47:03 -04:00
|
|
|
target_user_id: user.id,
|
|
|
|
details: reason
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2013-11-07 13:53:32 -05:00
|
|
|
def log_user_unsuspend(user, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
2013-11-01 10:47:03 -04:00
|
|
|
UserHistory.create( params(opts).merge({
|
2013-11-07 13:53:32 -05:00
|
|
|
action: UserHistory.actions[:unsuspend_user],
|
2013-11-01 10:47:03 -04:00
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2014-03-19 15:30:12 -04:00
|
|
|
def log_badge_grant(user_badge, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:user_badge) unless user_badge
|
2014-03-19 15:30:12 -04:00
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:grant_badge],
|
|
|
|
target_user_id: user_badge.user_id,
|
|
|
|
details: user_badge.badge.name
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_badge_revoke(user_badge, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:user_badge) unless user_badge
|
2014-03-19 15:30:12 -04:00
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:revoke_badge],
|
|
|
|
target_user_id: user_badge.user_id,
|
|
|
|
details: user_badge.badge.name
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2014-09-29 16:31:05 -04:00
|
|
|
def log_check_email(user, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
2014-09-29 16:31:05 -04:00
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:check_email],
|
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2014-12-29 05:50:36 -05:00
|
|
|
def log_show_emails(users, opts={})
|
2014-12-15 14:14:12 -05:00
|
|
|
return if users.blank?
|
2014-12-29 05:50:36 -05:00
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:check_email],
|
|
|
|
details: users.map { |u| "[#{u.id}] #{u.username}"}.join("\n")
|
|
|
|
}))
|
2014-11-03 06:46:08 -05:00
|
|
|
end
|
|
|
|
|
2014-11-06 04:58:47 -05:00
|
|
|
def log_impersonate(user, opts={})
|
2015-02-05 14:34:57 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
2014-11-06 04:58:47 -05:00
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:impersonate],
|
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2014-11-26 19:12:23 -05:00
|
|
|
def log_roll_up(subnets, opts={})
|
2014-11-24 13:48:54 -05:00
|
|
|
UserHistory.create(params(opts).merge({
|
2014-11-26 19:12:23 -05:00
|
|
|
action: UserHistory.actions[:roll_up],
|
2014-11-24 13:48:54 -05:00
|
|
|
details: subnets.join(", ")
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2015-09-17 03:51:32 -04:00
|
|
|
def log_category_settings_change(category, category_params, old_permissions=nil)
|
|
|
|
validate_category(category)
|
|
|
|
|
|
|
|
changed_attributes = category.previous_changes.slice(*category_params.keys)
|
|
|
|
|
2015-12-06 02:29:13 -05:00
|
|
|
if !old_permissions.empty? && (old_permissions != category_params[:permissions])
|
2015-09-17 03:51:32 -04:00
|
|
|
changed_attributes.merge!({ permissions: [old_permissions.to_json, category_params[:permissions].to_json] })
|
|
|
|
end
|
|
|
|
|
|
|
|
changed_attributes.each do |key, value|
|
|
|
|
UserHistory.create(params.merge({
|
|
|
|
action: UserHistory.actions[:change_category_settings],
|
|
|
|
category_id: category.id,
|
|
|
|
context: category.url,
|
|
|
|
subject: key,
|
|
|
|
previous_value: value[0],
|
|
|
|
new_value: value[1]
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_category_deletion(category)
|
|
|
|
validate_category(category)
|
|
|
|
|
|
|
|
details = [
|
|
|
|
"created_at: #{category.created_at}",
|
|
|
|
"name: #{category.name}",
|
|
|
|
"permissions: #{category.permissions_params}"
|
|
|
|
]
|
|
|
|
|
|
|
|
if parent_category = category.parent_category
|
|
|
|
details << "parent_category: #{parent_category.name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
UserHistory.create(params.merge({
|
|
|
|
action: UserHistory.actions[:delete_category],
|
|
|
|
category_id: category.id,
|
|
|
|
details: details.join("\n"),
|
|
|
|
context: category.url
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_category_creation(category)
|
|
|
|
validate_category(category)
|
|
|
|
|
|
|
|
details = [
|
|
|
|
"created_at: #{category.created_at}",
|
|
|
|
"name: #{category.name}"
|
|
|
|
]
|
|
|
|
|
|
|
|
UserHistory.create(params.merge({
|
|
|
|
action: UserHistory.actions[:create_category],
|
|
|
|
details: details.join("\n"),
|
|
|
|
category_id: category.id,
|
|
|
|
context: category.url
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2016-01-14 15:05:11 -05:00
|
|
|
def log_block_user(user, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:block_user],
|
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_unblock_user(user, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:unblock_user],
|
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2016-01-27 04:38:16 -05:00
|
|
|
def log_grant_admin(user, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:grant_admin],
|
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_revoke_admin(user, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:revoke_admin],
|
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_grant_moderation(user, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:grant_moderation],
|
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_revoke_moderation(user, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
|
|
|
UserHistory.create( params(opts).merge({
|
|
|
|
action: UserHistory.actions[:revoke_moderation],
|
|
|
|
target_user_id: user.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2017-01-16 13:53:31 -05:00
|
|
|
def log_backup_create(opts={})
|
2016-02-27 12:38:24 -05:00
|
|
|
UserHistory.create(params(opts).merge({
|
2017-01-16 13:53:31 -05:00
|
|
|
action: UserHistory.actions[:backup_create],
|
2016-02-27 22:14:27 -05:00
|
|
|
ip_address: @admin.ip_address.to_s
|
2016-02-27 12:38:24 -05:00
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2017-01-16 13:53:31 -05:00
|
|
|
def log_backup_download(backup, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:backup) unless backup
|
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:backup_download],
|
|
|
|
ip_address: @admin.ip_address.to_s,
|
|
|
|
details: backup.filename
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_backup_destroy(backup, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:backup) unless backup
|
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:backup_destroy],
|
|
|
|
ip_address: @admin.ip_address.to_s,
|
|
|
|
details: backup.filename
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2016-07-25 12:57:06 -04:00
|
|
|
def log_revoke_email(user, reason, opts={})
|
2016-05-02 17:15:32 -04:00
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:revoke_email],
|
|
|
|
target_user_id: user.id,
|
2016-07-25 12:57:06 -04:00
|
|
|
details: reason
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_user_deactivate(user, reason, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:deactivate_user],
|
|
|
|
target_user_id: user.id,
|
|
|
|
details: reason
|
2016-05-02 17:15:32 -04:00
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2017-01-10 16:45:36 -05:00
|
|
|
def log_user_activate(user, reason, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:user) unless user
|
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:activate_user],
|
|
|
|
target_user_id: user.id,
|
|
|
|
details: reason
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2016-09-14 16:36:08 -04:00
|
|
|
def log_wizard_step(step, opts={})
|
|
|
|
raise Discourse::InvalidParameters.new(:step) unless step
|
|
|
|
UserHistory.create(params(opts).merge({
|
|
|
|
action: UserHistory.actions[:wizard_step],
|
|
|
|
context: step.id
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2017-01-11 01:46:48 -05:00
|
|
|
def log_change_readonly_mode(state)
|
|
|
|
UserHistory.create(params.merge({
|
|
|
|
action: UserHistory.actions[:change_readonly_mode],
|
|
|
|
previous_value: !state,
|
|
|
|
new_value: state
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
|
2013-08-19 16:58:38 -04:00
|
|
|
private
|
|
|
|
|
2015-02-05 14:34:57 -05:00
|
|
|
def params(opts=nil)
|
|
|
|
opts ||= {}
|
2014-11-24 13:48:54 -05:00
|
|
|
{ acting_user_id: @admin.id, context: opts[:context] }
|
|
|
|
end
|
2013-08-21 12:03:21 -04:00
|
|
|
|
2015-09-17 03:51:32 -04:00
|
|
|
def validate_category(category)
|
|
|
|
raise Discourse::InvalidParameters.new(:category) unless category && category.is_a?(Category)
|
|
|
|
end
|
|
|
|
|
2013-07-08 05:53:22 -04:00
|
|
|
end
|