|
|
@ -159,6 +159,7 @@ class User < Principal |
|
|
|
before_create :sanitize_mail_notification_setting |
|
|
|
before_create :sanitize_mail_notification_setting |
|
|
|
before_destroy :delete_associated_private_queries |
|
|
|
before_destroy :delete_associated_private_queries |
|
|
|
before_destroy :reassign_associated |
|
|
|
before_destroy :reassign_associated |
|
|
|
|
|
|
|
before_destroy :remove_from_filter |
|
|
|
|
|
|
|
|
|
|
|
scope :in_group, lambda {|group| |
|
|
|
scope :in_group, lambda {|group| |
|
|
|
group_id = group.is_a?(Group) ? group.id : group.to_i |
|
|
|
group_id = group.is_a?(Group) ? group.id : group.to_i |
|
|
@ -813,6 +814,27 @@ class User < Principal |
|
|
|
(passwords[keep_count..-1] || []).each { |p| p.destroy } |
|
|
|
(passwords[keep_count..-1] || []).each { |p| p.destroy } |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def remove_from_filter |
|
|
|
|
|
|
|
timelines_filter = ["planning_element_responsibles", "planning_element_assignee", "project_responsibles"] |
|
|
|
|
|
|
|
substitute = DeletedUser.first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timelines = Timeline.all(:conditions => ['options LIKE ?', "%#{id}%"]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timelines.each do |timeline| |
|
|
|
|
|
|
|
timelines_filter.each do |field| |
|
|
|
|
|
|
|
changed = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fieldOptions = timeline.options[field] |
|
|
|
|
|
|
|
if fieldOptions && index = fieldOptions.index(id.to_s) then |
|
|
|
|
|
|
|
changed = true |
|
|
|
|
|
|
|
fieldOptions[index] = substitute.id.to_s |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timeline.save! if changed |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def reassign_associated |
|
|
|
def reassign_associated |
|
|
|
substitute = DeletedUser.first |
|
|
|
substitute = DeletedUser.first |
|
|
|
|
|
|
|
|
|
|
|