Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 173
- Log:
Updated to latest release of Beast according to the "getting started with
Beast" guide at:http://beast.caboo.se/forums/1/topics/381
This check-in includes frozen Edge Rails and has the beginnings of
configuration for the ROOL site included.
- Author:
- rool
- Date:
- Fri Mar 02 15:59:12 +0000 2007
- Size:
- 3083 Bytes
1 | class UsersController < ApplicationController |
2 | before_filter :login_required, :only => [:edit, :update, :destroy, :admin] |
3 | before_filter :find_user, :only => [:edit, :update, :destroy, :admin] |
4 | |
5 | def index |
6 | respond_to do |format| |
7 | format.html do |
8 | @user_pages, @users = paginate(:users, :per_page => 50, :order => "display_name", :conditions => User.build_search_conditions(params[:q])) |
9 | @user_count = User.count |
10 | @active = User.count(:all, :conditions => "posts_count > 0") |
11 | end |
12 | format.xml do |
13 | @users = User.search(params[:q], :limit => 25) |
14 | render :xml => @users.to_xml |
15 | end |
16 | end |
17 | end |
18 | |
19 | def show |
20 | @user = User.find(params[:id]) |
21 | respond_to do |format| |
22 | format.html |
23 | format.xml { render :xml => @user.to_xml } |
24 | end |
25 | end |
26 | |
27 | def new |
28 | @user = User.new |
29 | end |
30 | |
31 | def create |
32 | respond_to do |format| |
33 | format.html do |
34 | @user = params[:user].blank? ? User.find_by_email(params[:email]) : User.new(params[:user]) |
35 | flash[:error] = "I could not find an account with the email address '#{CGI.escapeHTML params[:email]}'. Did you type it correctly?" if params[:email] and not @user |
36 | redirect_to login_path and return unless @user |
37 | @user.login = params[:user][:login] unless params[:user].blank? |
38 | @user.reset_login_key! |
39 | UserMailer.deliver_signup(@user, request.host_with_port) |
40 | flash[:notice] = "#{params[:user].blank? ? "An account activation" : "A temporary login"} email has been sent to '#{CGI.escapeHTML @user.email}'." |
41 | redirect_to login_path |
42 | end |
43 | end |
44 | end |
45 | |
46 | def activate |
47 | respond_to do |format| |
48 | format.html do |
49 | self.current_user = User.find_by_login_key(params[:key]) |
50 | if logged_in? && !current_user.activated? |
51 | current_user.toggle! :activated |
52 | flash[:notice] = "Signup complete!" |
53 | end |
54 | redirect_to home_path |
55 | end |
56 | end |
57 | end |
58 | |
59 | def update |
60 | @user.attributes = params[:user] |
61 | # temp fix to let people with dumb usernames change them |
62 | @user.login = params[:user][:login] if not @user.valid? and @user.errors.on(:login) |
63 | @user.save! and flash[:notice]="Your settings have been saved." |
64 | respond_to do |format| |
65 | format.html { redirect_to edit_user_path(@user) } |
66 | format.xml { head 200 } |
67 | end |
68 | end |
69 | |
70 | def admin |
71 | respond_to do |format| |
72 | format.html do |
73 | @user.admin = params[:user][:admin] == '1' |
74 | @user.save |
75 | @user.forums << Forum.find(params[:moderator]) unless params[:moderator].blank? || params[:moderator] == '-' |
76 | redirect_to user_path(@user) |
77 | end |
78 | end |
79 | end |
80 | |
81 | def destroy |
82 | @user.destroy |
83 | respond_to do |format| |
84 | format.html { redirect_to users_path } |
85 | format.xml { head 200 } |
86 | end |
87 | end |
88 | |
89 | protected |
90 | def authorized? |
91 | admin? || (!%w(destroy admin).include?(action_name) && (params[:id].nil? || params[:id] == current_user.id.to_s)) |
92 | end |
93 | |
94 | def find_user |
95 | @user = params[:id] ? User.find_by_id(params[:id]) : current_user |
96 | end |
97 | end |