Skip to content
Extraits de code Groupes Projets
application_controller.rb 1,07 ko
Newer Older
  • Learn to ignore specific revisions
  • Raphael's avatar
    Raphael a validé
    #   Copyright (c) 2010, Diaspora Inc.  This file is
    
    Raphael's avatar
    Raphael a validé
    #   licensed under the Affero General Public License version 3 or later.  See
    
    Raphael's avatar
    Raphael a validé
    #   the COPYRIGHT file.
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
    class ApplicationController < ActionController::Base
    
      protect_from_forgery :except => :receive
    
      before_filter :set_friends_and_status, :except => [:create, :update]
    
      before_filter :count_requests
    
    danielvincent's avatar
    danielvincent a validé
      before_filter :fb_user_info
    
    danielvincent's avatar
    danielvincent a validé
    
      layout :layout_by_resource
    
      def layout_by_resource
        if devise_controller?
          "session_wall"
        else
          "application"
        end
      end
    
      def set_friends_and_status
    
    Raphael's avatar
    Raphael a validé
        if current_user
    
    danielvincent's avatar
    danielvincent a validé
          if params[:aspect] == nil || params[:aspect] == 'all'
    
            @aspect = :all
          else
            @aspect = current_user.aspect_by_id( params[:aspect])
          end
    
    Raphael's avatar
    Raphael a validé
          @aspects = current_user.aspects
    
    Raphael's avatar
    Raphael a validé
          @friends = current_user.friends
        end
    
      end
    
      def count_requests
    
        @request_count = Request.for_user(current_user).size if current_user
    
    danielvincent's avatar
    danielvincent a validé
      def fb_user_info
    
          @access_token = warden.session[:access_token]
    
          @logged_in = @access_token.present?
        end
    
    danielvincent's avatar
    danielvincent a validé
      end
    
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
    end