Mercurial > hg > soundsoftware-site
comparison app/controllers/my_controller.rb @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | 3e4c3460b6ca |
children | 4f746d8966dd |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
57 if @user.save | 57 if @user.save |
58 @user.pref.save | 58 @user.pref.save |
59 @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) | 59 @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) |
60 set_language_if_valid @user.language | 60 set_language_if_valid @user.language |
61 flash[:notice] = l(:notice_account_updated) | 61 flash[:notice] = l(:notice_account_updated) |
62 redirect_to :action => 'account' | 62 redirect_to my_account_path |
63 return | 63 return |
64 end | 64 end |
65 end | 65 end |
66 end | 66 end |
67 | 67 |
68 # Destroys user's account | 68 # Destroys user's account |
69 def destroy | 69 def destroy |
70 @user = User.current | 70 @user = User.current |
71 unless @user.own_account_deletable? | 71 unless @user.own_account_deletable? |
72 redirect_to :action => 'account' | 72 redirect_to my_account_path |
73 return | 73 return |
74 end | 74 end |
75 | 75 |
76 if request.post? && params[:confirm] | 76 if request.post? && params[:confirm] |
77 @user.destroy | 77 @user.destroy |
86 # Manage user's password | 86 # Manage user's password |
87 def password | 87 def password |
88 @user = User.current | 88 @user = User.current |
89 unless @user.change_password_allowed? | 89 unless @user.change_password_allowed? |
90 flash[:error] = l(:notice_can_t_change_password) | 90 flash[:error] = l(:notice_can_t_change_password) |
91 redirect_to :action => 'account' | 91 redirect_to my_account_path |
92 return | 92 return |
93 end | 93 end |
94 if request.post? | 94 if request.post? |
95 if @user.check_password?(params[:password]) | 95 if @user.check_password?(params[:password]) |
96 @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] | 96 @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] |
97 if @user.save | 97 if @user.save |
98 flash[:notice] = l(:notice_account_password_updated) | 98 flash[:notice] = l(:notice_account_password_updated) |
99 redirect_to :action => 'account' | 99 redirect_to my_account_path |
100 end | 100 end |
101 else | 101 else |
102 flash[:error] = l(:notice_account_wrong_password) | 102 flash[:error] = l(:notice_account_wrong_password) |
103 end | 103 end |
104 end | 104 end |
112 User.current.reload | 112 User.current.reload |
113 end | 113 end |
114 User.current.rss_key | 114 User.current.rss_key |
115 flash[:notice] = l(:notice_feeds_access_key_reseted) | 115 flash[:notice] = l(:notice_feeds_access_key_reseted) |
116 end | 116 end |
117 redirect_to :action => 'account' | 117 redirect_to my_account_path |
118 end | 118 end |
119 | 119 |
120 # Create a new API key | 120 # Create a new API key |
121 def reset_api_key | 121 def reset_api_key |
122 if request.post? | 122 if request.post? |
125 User.current.reload | 125 User.current.reload |
126 end | 126 end |
127 User.current.api_key | 127 User.current.api_key |
128 flash[:notice] = l(:notice_api_access_key_reseted) | 128 flash[:notice] = l(:notice_api_access_key_reseted) |
129 end | 129 end |
130 redirect_to :action => 'account' | 130 redirect_to my_account_path |
131 end | 131 end |
132 | 132 |
133 # User's page layout configuration | 133 # User's page layout configuration |
134 def page_layout | 134 def page_layout |
135 @user = User.current | 135 @user = User.current |
155 # add it on top | 155 # add it on top |
156 layout['top'].unshift block | 156 layout['top'].unshift block |
157 @user.pref[:my_page_layout] = layout | 157 @user.pref[:my_page_layout] = layout |
158 @user.pref.save | 158 @user.pref.save |
159 end | 159 end |
160 redirect_to :action => 'page_layout' | 160 redirect_to my_page_layout_path |
161 end | 161 end |
162 | 162 |
163 # Remove a block to user's page | 163 # Remove a block to user's page |
164 # params[:block] : id of the block to remove | 164 # params[:block] : id of the block to remove |
165 def remove_block | 165 def remove_block |
168 # remove block in all groups | 168 # remove block in all groups |
169 layout = @user.pref[:my_page_layout] || {} | 169 layout = @user.pref[:my_page_layout] || {} |
170 %w(top left right).each {|f| (layout[f] ||= []).delete block } | 170 %w(top left right).each {|f| (layout[f] ||= []).delete block } |
171 @user.pref[:my_page_layout] = layout | 171 @user.pref[:my_page_layout] = layout |
172 @user.pref.save | 172 @user.pref.save |
173 redirect_to :action => 'page_layout' | 173 redirect_to my_page_layout_path |
174 end | 174 end |
175 | 175 |
176 # Change blocks order on user's page | 176 # Change blocks order on user's page |
177 # params[:group] : group to order (top, left or right) | 177 # params[:group] : group to order (top, left or right) |
178 # params[:list-(top|left|right)] : array of block ids of the group | 178 # params[:list-(top|left|right)] : array of block ids of the group |