end
if params[:friends]
- user = @user
- if user
- friend_ids = []
- user.friends.each do |friend|
- friend_user = User.find(friend.friend_user_id)
- if friend_user.data_public?
- friend_ids << friend.friend_user_id
- end
- end
- if friend_ids.length > 0
- conditions = cond_merge conditions, ['user_id in (?)', friend_ids]
- else
- conditions = cond_merge conditions, ['false']
- end
+ if @user
+ changesets = changesets.where(:user_id => @user.friend_users.public)
elsif request.format == :html
@title = t 'user.no_such_user.title'
render :template => 'user/no_such_user', :status => :not_found
has_many :new_messages, :class_name => "Message", :foreign_key => :to_user_id, :conditions => { :to_user_visible => true, :message_read => false }, :order => 'sent_on DESC'
has_many :sent_messages, :class_name => "Message", :foreign_key => :from_user_id, :conditions => { :from_user_visible => true }, :order => 'sent_on DESC'
has_many :friends, :include => :befriendee, :conditions => "users.status IN ('active', 'confirmed')"
+ has_many :friend_users, :through => :friends, :source => :befriendee
has_many :tokens, :class_name => "UserToken"
has_many :preferences, :class_name => "UserPreference"
has_many :changesets, :order => 'created_at DESC'
scope :visible, where(:status => ["pending", "active", "confirmed"])
scope :active, where(:status => ["active", "confirmed"])
+ scope :public, where(:data_public => true)
validates_presence_of :email, :display_name
validates_confirmation_of :email#, :message => ' addresses must match'