Class ApplicationController
In: app/controllers/application.rb
Parent: ActionController::Base

************************************************************************/

  • SOLUNAS BOOKING ENGINE */
  • ====================== */
  • */
  • Copyright © 2006 by Marc Isemann */
  • sourceforge.net/projects/solunas */
  • */
  • This program is free software. You can redistribute it and/or modify */
  • it under the terms of the GNU General Public License as published by */
  • the Free Software Foundation; either version 2 of the License. */

************************************************************************/

Methods

Public Instance methods

The authorize method is used as a before_hook in controllers that contain administration actions. If the session does not contain a valid user, the method redirects to the LoginController.login.

[Source]

    # File app/controllers/application.rb, line 32
32:   def authorize                            #:doc:
33:     unless session[:user_id]
34:       flash[:notice] = "Please log in"
35:       redirect_to(:controller => "login", :action => "login")
36:     end
37:     #Set rights and roles -> ToDo
38:     #user = User.find(session[:user_id])
39:     #unless user.roles.detect{|role|
40:     #    role.rights.detect{|right|
41:     #      right.action == action_name && right.controller == self.class.controller_path
42:     #      #right.controller == self.class.controller_path
43:     #    }
44:     #  }
45:     #  flash[:notice] = "You are not authorized to view the page you requested."
46:     #
47:     #  request.env["HTTP_REFERRER"] ? (redirect_to :back) : redirect_to(:controller => "login", :action => "login")
48:     #end
49:   end

[Source]

    # File app/controllers/application.rb, line 51
51:   def authorize_as_admin
52:     unless session[:user_id] && session[:admin] == 1
53:       flash[:notice] = "Please log in"
54:       redirect_to(:controller => "login", :action => "login")
55:     end
56:   end

[Source]

    # File app/controllers/application.rb, line 63
63:   def get_user
64:     @user = User.find(session[:user_id])
65:   end

[Source]

     # File app/controllers/application.rb, line 69
 69:   def month_vars(month, year="2000")
 70: 
 71:     case month
 72:     when 1
 73:       data = {"name" => "January", "end" => "31"}
 74:     when 2
 75:       if (year.to_i % 4 == 0)
 76:         data = {"name" => "February", "end" => "29"}
 77:       else
 78:         data = {"name" => "February", "end" => "28"}
 79:       end
 80:     when 3
 81:       data = {"name" => "March", "end" => "31"}
 82:     when 4
 83:       data = {"name" => "April", "end" => "30"}
 84:     when 5
 85:       data = {"name" => "May", "end" => "31"}
 86:     when 6
 87:       data = {"name" => "June", "end" => "30"}
 88:     when 7
 89:       data = {"name" => "Juny", "end" => "31"}
 90:     when 8
 91:       data = {"name" => "August", "end" => "31"}
 92:     when 9
 93:       data = {"name" => "September", "end" => "30"}
 94:     when 10
 95:       data = {"name" => "October", "end" => "31"}
 96:     when 11
 97:       data = {"name" => "November", "end" => "30"}
 98:     when 12
 99:       data = {"name" => "Dezember", "end" => "31"}
100:     end
101:   end

[Source]

    # File app/controllers/application.rb, line 58
58:   def redirect_to_index(message = nil)
59:     flash[:notice] = message if message
60:     redirect_to(:action => 'index')
61:   end

[Source]

    # File app/controllers/application.rb, line 23
23:   def set_controller_action
24:     @right_controller = self.class.controller_path
25:     @right_action = action_name
26:   end

[Validate]