Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 178
- Log:
Hub integration of Beast forum. Completed styling for RISC OS Open site.
Removed reliance on JavaScript. Added Textile hints to various views.
Added bespoke utility code used to port over RForum data for posterity;
note the rather large bug that it ignores the deleted flag on RForum
data.Some amount of testing carried out on Firefox, Opera and Netsurf. Looks
OK so far, but there are definitely some aesthetic kinks to work out
still and doubtless some operational bugs will surface once it goes
live and is subjected to more intensive real world use.
- Author:
- rool
- Date:
- Mon Mar 12 00:19:40 +0000 2007
- Size:
- 3761 Bytes
1 | class UsersController < ApplicationController |
2 | before_filter :find_user, :only => [:edit, :update, :destroy, :admin] |
3 | |
4 | @@hubssolib_permissions = HubSsoLib::Permissions.new({ |
5 | :index => [ :admin, :webmaster ], |
6 | :show => [ :admin, :webmaster, :privileged, :normal ], |
7 | |
8 | # Never use these. |
9 | |
10 | :new => [ :admin ], |
11 | :create => [ :admin ], |
12 | :edit => [ :admin ], |
13 | :update => [ :admin ], |
14 | :activate => [ :admin ], |
15 | :admin => [ :admin ], |
16 | :destroy => [ :admin ], |
17 | }) |
18 | |
19 | def UsersController.hubssolib_permissions |
20 | @@hubssolib_permissions |
21 | end |
22 | |
23 | def index |
24 | respond_to do |format| |
25 | format.html do |
26 | @user_pages, @users = paginate(:users, :per_page => 50, :order => "display_name", :conditions => User.build_search_conditions(params[:q])) |
27 | @user_count = User.count |
28 | @active = User.count(:all, :conditions => "posts_count > 0") |
29 | end |
30 | format.xml do |
31 | @users = User.search(params[:q], :limit => 25) |
32 | render :xml => @users.to_xml |
33 | end |
34 | end |
35 | end |
36 | |
37 | def show |
38 | @user = User.find(params[:id]) |
39 | respond_to do |format| |
40 | format.html |
41 | format.xml { render :xml => @user.to_xml } |
42 | end |
43 | end |
44 | |
45 | def new |
46 | @user = User.new |
47 | end |
48 | |
49 | def create |
50 | respond_to do |format| |
51 | format.html do |
52 | @user = params[:user].blank? ? User.find_by_email(params[:email]) : User.new(params[:user]) |
53 | 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 |
54 | redirect_to login_path and return unless @user |
55 | @user.login = params[:user][:login] unless params[:user].blank? |
56 | @user.reset_login_key! |
57 | UserMailer.deliver_signup(@user, request.host_with_port) |
58 | flash[:notice] = "#{params[:user].blank? ? "An account activation" : "A temporary login"} email has been sent to '#{CGI.escapeHTML @user.email}'." |
59 | redirect_to login_path |
60 | end |
61 | end |
62 | end |
63 | |
64 | def activate |
65 | respond_to do |format| |
66 | format.html do |
67 | self.current_user = User.find_by_login_key(params[:key]) |
68 | if logged_in? && !current_user.activated? |
69 | current_user.toggle! :activated |
70 | flash[:notice] = "Signup complete!" |
71 | end |
72 | redirect_to home_path |
73 | end |
74 | end |
75 | end |
76 | |
77 | def update |
78 | @user.attributes = params[:user] |
79 | # temp fix to let people with dumb usernames change them |
80 | @user.login = params[:user][:login] if not @user.valid? and @user.errors.on(:login) |
81 | @user.save! and flash[:notice]="Your settings have been saved." |
82 | respond_to do |format| |
83 | format.html { redirect_to edit_user_path(@user) } |
84 | format.xml { head 200 } |
85 | end |
86 | end |
87 | |
88 | def admin |
89 | respond_to do |format| |
90 | format.html do |
91 | @user.admin = params[:user][:admin] == '1' |
92 | @user.save |
93 | @user.forums << Forum.find(params[:moderator]) unless params[:moderator].blank? || params[:moderator] == '-' |
94 | redirect_to user_path(@user) |
95 | end |
96 | end |
97 | end |
98 | |
99 | def destroy |
100 | @user.destroy |
101 | respond_to do |format| |
102 | format.html { redirect_to users_path } |
103 | format.xml { head 200 } |
104 | end |
105 | end |
106 | |
107 | protected |
108 | def authorized? |
109 | admin? || (!%w(destroy admin).include?(action_name) && (params[:id].nil? || params[:id] == current_user.id.to_s)) |
110 | end |
111 | |
112 | def find_user |
113 | @user = params[:id] ? User.find_by_id(params[:id]) : current_user |
114 | end |
115 | end |