Mercurial > hg > soundsoftware-site
comparison app/controllers/my_controller.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 0a574315af3e 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
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. |
92 if @user.save | 92 if @user.save |
93 @user.pref.save | 93 @user.pref.save |
94 @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) | 94 @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) |
95 set_language_if_valid @user.language | 95 set_language_if_valid @user.language |
96 flash[:notice] = l(:notice_account_updated) | 96 flash[:notice] = l(:notice_account_updated) |
97 redirect_to :action => 'account' | 97 redirect_to my_account_path |
98 return | 98 return |
99 end | 99 end |
100 end | 100 end |
101 end | 101 end |
102 | 102 |
103 # Destroys user's account | 103 # Destroys user's account |
104 def destroy | 104 def destroy |
105 @user = User.current | 105 @user = User.current |
106 unless @user.own_account_deletable? | 106 unless @user.own_account_deletable? |
107 redirect_to :action => 'account' | 107 redirect_to my_account_path |
108 return | 108 return |
109 end | 109 end |
110 | 110 |
111 if request.post? && params[:confirm] | 111 if request.post? && params[:confirm] |
112 @user.destroy | 112 @user.destroy |
121 # Manage user's password | 121 # Manage user's password |
122 def password | 122 def password |
123 @user = User.current | 123 @user = User.current |
124 unless @user.change_password_allowed? | 124 unless @user.change_password_allowed? |
125 flash[:error] = l(:notice_can_t_change_password) | 125 flash[:error] = l(:notice_can_t_change_password) |
126 redirect_to :action => 'account' | 126 redirect_to my_account_path |
127 return | 127 return |
128 end | 128 end |
129 if request.post? | 129 if request.post? |
130 if @user.check_password?(params[:password]) | 130 if @user.check_password?(params[:password]) |
131 @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] | 131 @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] |
132 if @user.save | 132 if @user.save |
133 flash[:notice] = l(:notice_account_password_updated) | 133 flash[:notice] = l(:notice_account_password_updated) |
134 redirect_to :action => 'account' | 134 redirect_to my_account_path |
135 end | 135 end |
136 else | 136 else |
137 flash[:error] = l(:notice_account_wrong_password) | 137 flash[:error] = l(:notice_account_wrong_password) |
138 end | 138 end |
139 end | 139 end |
147 User.current.reload | 147 User.current.reload |
148 end | 148 end |
149 User.current.rss_key | 149 User.current.rss_key |
150 flash[:notice] = l(:notice_feeds_access_key_reseted) | 150 flash[:notice] = l(:notice_feeds_access_key_reseted) |
151 end | 151 end |
152 redirect_to :action => 'account' | 152 redirect_to my_account_path |
153 end | 153 end |
154 | 154 |
155 # Create a new API key | 155 # Create a new API key |
156 def reset_api_key | 156 def reset_api_key |
157 if request.post? | 157 if request.post? |
160 User.current.reload | 160 User.current.reload |
161 end | 161 end |
162 User.current.api_key | 162 User.current.api_key |
163 flash[:notice] = l(:notice_api_access_key_reseted) | 163 flash[:notice] = l(:notice_api_access_key_reseted) |
164 end | 164 end |
165 redirect_to :action => 'account' | 165 redirect_to my_account_path |
166 end | 166 end |
167 | 167 |
168 # User's page layout configuration | 168 # User's page layout configuration |
169 def page_layout | 169 def page_layout |
170 @user = User.current | 170 @user = User.current |
190 # add it on top | 190 # add it on top |
191 layout['top'].unshift block | 191 layout['top'].unshift block |
192 @user.pref[:my_page_layout] = layout | 192 @user.pref[:my_page_layout] = layout |
193 @user.pref.save | 193 @user.pref.save |
194 end | 194 end |
195 redirect_to :action => 'page_layout' | 195 redirect_to my_page_layout_path |
196 end | 196 end |
197 | 197 |
198 # Remove a block to user's page | 198 # Remove a block to user's page |
199 # params[:block] : id of the block to remove | 199 # params[:block] : id of the block to remove |
200 def remove_block | 200 def remove_block |
203 # remove block in all groups | 203 # remove block in all groups |
204 layout = @user.pref[:my_page_layout] || {} | 204 layout = @user.pref[:my_page_layout] || {} |
205 %w(top left right).each {|f| (layout[f] ||= []).delete block } | 205 %w(top left right).each {|f| (layout[f] ||= []).delete block } |
206 @user.pref[:my_page_layout] = layout | 206 @user.pref[:my_page_layout] = layout |
207 @user.pref.save | 207 @user.pref.save |
208 redirect_to :action => 'page_layout' | 208 redirect_to my_page_layout_path |
209 end | 209 end |
210 | 210 |
211 # Change blocks order on user's page | 211 # Change blocks order on user's page |
212 # params[:group] : group to order (top, left or right) | 212 # params[:group] : group to order (top, left or right) |
213 # params[:list-(top|left|right)] : array of block ids of the group | 213 # params[:list-(top|left|right)] : array of block ids of the group |