def self.generate_salt
Redmine::Utils.random_hex(16)
end
+
# Send a security notification to all admins if the user has gained/lost admin privileges
def deliver_security_notification
options = {
title: :label_user_plural,
url: {controller: 'users', action: 'index'}
}
+
deliver = false
if (admin? && id_changed? && active?) || # newly created admin
(admin? && admin_changed? && active?) || # regular user became admin
options[:message] = :mail_body_security_notification_remove
end
- User.where(admin: true, status: Principal::STATUS_ACTIVE).each{|u| Mailer.security_notification(u, options).deliver} if deliver
+ if deliver
+ users = User.active.where(admin: true).to_a
+ Mailer.security_notification(users, options).deliver
+ end
end
-
-
-
end
class AnonymousUser < User
::I18n.l(date.to_date, options)
end
- def format_time(time, include_date=true, user=User.current)
+ def format_time(time, include_date=true, user=nil)
return nil unless time
+ user ||= User.current
options = {}
options[:format] = (Setting.time_format.blank? ? :time : Setting.time_format)
time = time.to_time if time.is_a?(String)