Skip to content
Extraits de code Groupes Projets
application_controller.rb 1,42 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 :mobile_except_ipad
    
      before_filter :set_contacts_and_status, :except => [:create, :update]
    
      before_filter :count_requests
    
      before_filter :set_invites
    
      before_filter :set_locale
    
    danielvincent's avatar
    danielvincent a validé
    
    
      def set_contacts_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
    
          @aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
    
          @contacts = current_user.contacts
    
    Raphael's avatar
    Raphael a validé
        end
    
      def mobile_except_ipad
        if is_mobile_device?
    
          if request.env["HTTP_USER_AGENT"].include? "iPad"
            session[:mobile_view] = false 
          else
            session[:mobile_view] = true
          end
    
      def count_requests
    
        @request_count = current_user.requests_for_me.size if current_user
    
      def set_invites
        if current_user
          @invites = current_user.invites
        end
      end
    
        if current_user
          I18n.locale = current_user.language
        else
          I18n.locale = request.compatible_language_from AVAILABLE_LANGUAGE_CODES
        end
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
    end