Changeset 221

Show
Ignore:
Timestamp:
01/12/06 03:12:36 (3 years ago)
Author:
lazyatom
Message:

Merged changes from revisions 155-220 (rel_0.9.0) into main plugin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/user_engine/README

    r155 r221  
    808010. The UserEngine provides a default stylesheet and a small javascript helper file (used in the Role#edit action), so you'll probably want to include the former and almost certainly the latter in your application's layout. Add the following lines: 
    8181 
    82       <%= engine_stylesheet "user" %> 
    83       <%= engine_javascript "user" %> 
     82      <%= engine_stylesheet "user_engine" %> 
     83      <%= engine_javascript "user_engine" %> 
    8484 
    858511. Remove any existing sessions (since they might interfere with the login process), and start the server and log using your administrator login and password (if you didn't set one explicitly in your configuration, the defaults are 'admin'/'testing' - make sure you change them!) and go to http://localhost:3000/user/list to see a list of all the users. From there you can create new users, view roles & permissions, and play around... 
     
    182182 
    183183 
     184= Notes 
     185 
     186=== Database Schemas & Testing 
     187 
     188Currently, since not all databases appear to support structure cloning, the tests will load the entire schema into your test database, potentially blowing away any other test structures you might have. If this presents an issue for your application, comment out the line in test/test_helper.rb 
     189 
     190 
    184191= LICENSE 
    185192 
  • plugins/user_engine/app/controllers/user_controller.rb

    r153 r221  
    3636    @content_columns = user_content_columns_to_display     
    3737    @user_pages, @all_users = paginate :user, :per_page => 10         
    38   end 
    39  
    40   # We need to wrap around the old edit 
    41   alias :old_edit :edit 
    42   def edit 
    43     @all_roles = Role.find_all.select { |r| r.name != UserEngine.config(:guest_role_name) } 
    44     old_edit 
    4538  end 
    4639 
  • plugins/user_engine/app/models/role.rb

    r153 r221  
    3838  # there can only be one omnipotent role. 
    3939  def validate_on_create 
    40     if self.omnipotent? && Role.find_by_omnipotent(1
     40    if self.omnipotent? && Role.find_by_omnipotent(true
    4141      errors.add_to_base("There can only be one omnipotent role.") 
    4242    end 
  • plugins/user_engine/lib/user_engine.rb

    r153 r221  
    152152    # actually generating the link. 
    153153    auth_options = options.dup 
    154     auth_options[:controller].gsub!(/^\//, '') if auth_options[:controller] 
     154    if auth_options[:controller] 
     155      auth_options[:controller] = auth_options[:controller].gsub(/^\//, '') 
     156    end 
    155157     
    156158    (block.nil? || (yield block)) && authorized?(auth_options) { 
  • plugins/user_engine/tasks/user_engine.rake

    r153 r221  
    2424    u.change_password UserEngine.config(:admin_password) 
    2525    u.verified = 1 
    26     u.save 
     26    raise "Couldn't save administrator!" if !u.save 
    2727  end 
    2828 
     
    3131    u.roles << Role.find_by_name(UserEngine.config(:admin_role_name)) 
    3232  end 
     33 
     34  raise "Couldn't save administrator after assigning roles!" if !u.save 
    3335end 
    3436 
     
    4345    guest.description = "Implicit role for all accessors of the site" 
    4446    guest.system_role = true 
     47    guest.omnipotent = false 
     48    raise "Couldn't save guest role!" if !guest.save 
    4549 
    4650    guest.permissions << Permission.find_by_controller_and_action('user', 'login') 
     
    4852    guest.permissions << Permission.find_by_controller_and_action('user', 'signup') 
    4953 
    50     guest.save 
     54    raise "Couldn't save guest role after setting permissions!" if !guest.save 
    5155  end 
    5256 
     
    6165    admin.omnipotent = true 
    6266    admin.system_role = true 
     67    raise "Couldn't save admin role!" if !admin.save 
    6368 
    6469    @all_action_permissions.each { |permission| 
     
    6873    } 
    6974 
    70     admin.save 
     75    raise "Couldn't save admin role after assigning permissions!" if !admin.save 
    7176  end 
    7277 
     
    7883    user.description = "The default role for all logged-in users" 
    7984    user.system_role = true 
     85    user.omnipotent = false 
     86    raise "Couldn't save default user role!" if !user.save 
    8087 
    8188    # all users automatically get the Guest permissions implicitly 
     
    8592    user.permissions << Permission.find_by_controller_and_action('user', 'edit') 
    8693 
    87     user.save 
     94    raise "Couldn't save default user role after assigning permissions!" if !user.save 
    8895  end 
    8996end