- def trace_public_default
- return self.preferences.find(:first, :conditions => {:k => "gps.trace.public", :v => "default"})
+ ##
+ # returns true if the user has the moderator role, false otherwise
+ def moderator?
+ has_role? 'moderator'
+ end
+
+ ##
+ # returns true if the user has the moderator role, false otherwise
+ def administrator?
+ has_role? 'administrator'
+ end
+
+ ##
+ # returns true if the user has the requested role
+ def has_role?(role)
+ roles.inject(false) { |x, r| x or r.role == role }
+ end
+
+ ##
+ # returns the first active block which would require users to view
+ # a message, or nil if there are none.
+ def blocked_on_view
+ active_blocks.inject(nil) { |s,x| s || (x.needs_view? ? x : nil) }