Merge pull request #3003 from evazion/feat-noter-any-metatag

Add noter:<any|none>, commenter:<any|none> metatags
This commit is contained in:
Albert Yi
2017-05-01 14:52:30 -07:00
committed by GitHub
4 changed files with 65 additions and 12 deletions

View File

@@ -14,8 +14,8 @@ class Comment < ActiveRecord::Base
after_update(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do |rec|
ModAction.log("comment ##{rec.id} updated by #{CurrentUser.name}")
end
after_update :update_last_commented_at_on_destroy, :if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed?}
after_update(:if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed? && CurrentUser.id != rec.creator_id}) do |rec|
after_save :update_last_commented_at_on_destroy, :if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed?}
after_save(:if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed? && CurrentUser.id != rec.creator_id}) do |rec|
ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.name}")
end
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :moderator, :admin]
@@ -171,13 +171,13 @@ class Comment < ActiveRecord::Base
include VoteMethods
def initialize_creator
self.creator_id = CurrentUser.user.id
self.ip_addr = CurrentUser.ip_addr
self.creator_id ||= CurrentUser.user.id
self.ip_addr ||= CurrentUser.ip_addr
end
def initialize_updater
self.updater_id = CurrentUser.user.id
self.updater_ip_addr = CurrentUser.ip_addr
self.updater_id ||= CurrentUser.user.id
self.updater_ip_addr ||= CurrentUser.ip_addr
end
def creator_name

View File

@@ -452,13 +452,27 @@ class Tag < ActiveRecord::Base
when "commenter", "comm"
q[:commenter_ids] ||= []
user_id = User.name_to_id($2)
q[:commenter_ids] << user_id unless user_id.blank?
if $2 == "none"
q[:commenter_ids] << "none"
elsif $2 == "any"
q[:commenter_ids] << "any"
else
user_id = User.name_to_id($2)
q[:commenter_ids] << user_id unless user_id.blank?
end
when "noter"
q[:noter_ids] ||= []
user_id = User.name_to_id($2)
q[:noter_ids] << user_id unless user_id.blank?
if $2 == "none"
q[:noter_ids] << "none"
elsif $2 == "any"
q[:noter_ids] << "any"
else
user_id = User.name_to_id($2)
q[:noter_ids] << user_id unless user_id.blank?
end
when "noteupdater"
q[:note_updater_ids] ||= []