# Be sure to restart your web server when you modify this file.

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'

# Specifies gem version of Rails to use when vendor/rails is not present
#RAILS_GEM_VERSION = '1.1.6' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
  # Settings in config/environments/* take precedence over those specified here

  # Skip frameworks you're not going to use (only works if using vendor/rails)
  # config.frameworks -= [ :action_web_service, :action_mailer ]

  # Only load the plugins named here, by default all plugins in vendor/plugins are loaded
  # config.plugins = %W( exception_notification ssl_requirement )

  # Add additional load paths for your own custom dirs
  # config.load_paths += %W( #{RAILS_ROOT}/extras )

  # Force all environments to use the same logger level
  # (by default production uses :info, the others :debug)
  # config.log_level = :debug

  # Use the database for sessions instead of the file system
  # (create the session table with 'rake db:sessions:create')
  # config.action_controller.session_store = :active_record_store

  # Use SQL instead of Active Record's schema dumper when creating the test database.
  # This is necessary if your schema can't be completely dumped by the schema dumper,
  # like if you have constraints or database-specific column types
  # config.active_record.schema_format = :sql

  # Activate observers that should always be running
  # config.active_record.observers = :cacher, :garbage_collector

  # Make Active Record use UTC-base instead of local time
  # config.active_record.default_timezone = :utc

  # See Rails::Configuration for more options

  config.action_controller.session = {
    :session_key => '_login_engine_session',
    :secret      => 'a148d6564bd91d6e6c41e3bf845a816bf1776789860fe524361b23a5bbcd4846ba7f3fd2bc8534961ff9f95ac0ed0c9ef10b81c3444d15605a5c8895fa7a0437'
  }
end

# Include your application configuration below

require 'config'

module LoginEngine
 include AuthenticatedSystem # re-include the helper module

  #--
  # Define the configuration values. config sets the value of the
  # constant ONLY if it has not already been set, i.e. by the user in
  # environment.rb
  #++

  # Source address for user emails
  config :email_from, 'webmaster@your.company'

  # Destination email for system errors
  config :admin_email, 'webmaster@your.company'

  # Sent in emails to users
  config :app_url, 'http://localhost:3000/'

  # Sent in emails to users
  config :app_name, 'TestApp'

  # Email charset
  config :mail_charset, 'utf-8'

  # Security token lifetime in hours
  config :security_token_life_hours, 24

  # Two column form input
  config :two_column_input, true

  # Add all changeable user fields to this array.
  # They will then be able to be edited from the edit action. You
  # should NOT include the email field in this array.
  config :changeable_fields, [ 'firstname', 'lastname' ]

  # Set to true to allow delayed deletes (i.e., delete of record
  # doesn't happen immediately after user selects delete account,
  # but rather after some expiration of time to allow this action
  # to be reverted).
  config :delayed_delete, false

  # Default is one week
  config :delayed_delete_days, 7

  # the table to store user information in
  if ActiveRecord::Base.pluralize_table_names
    config :user_table, "users"
  else
    config :user_table, "user"
  end

  # controls whether or not email is used
  config :use_email_notification, false

  # Controls whether accounts must be confirmed after signing up
  # ONLY if this and use_email_notification are both true
  config :confirm_account, false


  config :salt, "your-salt-here"
end


require 'gettext'
require 'gettext/rails'
require 'amrita2/gettext'
require 'amrita2/macro'

# set text domain for get_text
Amrita2View::Base.text_domain = "login_engine"

# fix trouble with gettext and rails2.0
# http://zargony.com/2007/07/29/using-ruby-gettext-with-edge-rails/
class CGI
  module QueryExtension
    alias index_without_fix :[]
    def [] (key)
      return nil unless @params[key]
      index_without_fix(key)
    end
  end
end