Skip to content
Extraits de code Groupes Projets
application_controller.rb 1,34 ko
Newer Older
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
Sarah Mei's avatar
Sarah Mei a validé
#  has_mobile_fu
  protect_from_forgery :except => :receive
Sarah Mei's avatar
Sarah Mei a validé
#  before_filter :mobile_except_ipad
maxwell's avatar
maxwell a validé
  before_filter :set_contacts_notifications_and_status, :except => [:create, :update]
  before_filter :count_requests
  before_filter :set_invites
  before_filter :set_locale
danielvincent's avatar
danielvincent a validé

maxwell's avatar
maxwell a validé
  def set_contacts_notifications_and_status
maxwell's avatar
maxwell a validé
    if user_signed_in? 
      @aspect = nil
      @aspects = current_user.aspects.fields(:name)
      @aspects_dropdown_array = @aspects.collect{|x| [x.to_s, x.id]}
      @notifications = Notification.for(current_user).limit(25).all
Raphael's avatar
Raphael a validé
    end
  def mobile_except_ipad
    if is_mobile_device?
      if request.env["HTTP_USER_AGENT"].include? "iPad"
danielvincent's avatar
danielvincent a validé
        session[:mobile_view] = false
danielvincent's avatar
danielvincent a validé

  def count_requests
    @request_count = Request.to(current_user.person).count if current_user
maxwell's avatar
maxwell a validé
    if user_signed_in?
      @invites = current_user.invites
    end
  end
maxwell's avatar
maxwell a validé
    if user_signed_in?
      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