Skip to content
Extraits de code Groupes Projets
contacts_controller.rb 1,43 ko
Newer Older
  • Learn to ignore specific revisions
  • danielgrippi's avatar
    danielgrippi a validé
    #   Copyright (c) 2010-2011, Diaspora Inc.  This file is
    
    #   licensed under the Affero General Public License version 3 or later.  See
    #   the COPYRIGHT file.
    
    class ContactsController < ApplicationController
      before_filter :authenticate_user!
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
      def index
    
        respond_to do |format|
    
          # Used for normal requests to contacts#index and subsequent infinite scroll calls
    
          # Used to populate mentions in the publisher
    
          format.json {
    
            aspect_ids = params[:aspect_ids] || current_user.aspects.map(&:id)
    
            @people = Person.all_from_aspects(aspect_ids, current_user).for_json
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
      end
    
    
      def sharing
    
        @contacts = current_user.contacts.sharing.includes(:aspect_memberships)
    
        render :layout => false
    
      def spotlight
        @spotlight = true
        @people = Person.community_spotlight
    
    
      def set_up_contacts
        @contacts = case params[:set]
          when "only_sharing"
            current_user.contacts.only_sharing
          when "all"
            current_user.contacts
          else
            if params[:a_id]
              @aspect = current_user.aspects.find(params[:a_id])
              @aspect.contacts
            else
              current_user.contacts.receiving
            end
        end
        @contacts = @contacts.for_a_stream.paginate(:page => params[:page], :per_page => 25)
      end