@@ -1,159 +1,160 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 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. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class MyController < ApplicationController |
|
18 | class MyController < ApplicationController | |
19 | helper :issues |
|
19 | helper :issues | |
20 |
|
20 | |||
21 | layout 'base' |
|
21 | layout 'base' | |
22 | before_filter :require_login |
|
22 | before_filter :require_login | |
23 |
|
23 | |||
24 | BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues, |
|
24 | BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues, | |
25 | 'issuesreportedbyme' => :label_reported_issues, |
|
25 | 'issuesreportedbyme' => :label_reported_issues, | |
26 | 'issueswatched' => :label_watched_issues, |
|
26 | 'issueswatched' => :label_watched_issues, | |
27 | 'news' => :label_news_latest, |
|
27 | 'news' => :label_news_latest, | |
28 | 'calendar' => :label_calendar, |
|
28 | 'calendar' => :label_calendar, | |
29 | 'documents' => :label_document_plural |
|
29 | 'documents' => :label_document_plural | |
30 | }.freeze |
|
30 | }.freeze | |
31 |
|
31 | |||
32 | DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'], |
|
32 | DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'], | |
33 | 'right' => ['issuesreportedbyme'] |
|
33 | 'right' => ['issuesreportedbyme'] | |
34 | }.freeze |
|
34 | }.freeze | |
35 |
|
35 | |||
36 | verify :xhr => true, |
|
36 | verify :xhr => true, | |
37 | :session => :page_layout, |
|
37 | :session => :page_layout, | |
38 | :only => [:add_block, :remove_block, :order_blocks] |
|
38 | :only => [:add_block, :remove_block, :order_blocks] | |
39 |
|
39 | |||
40 | def index |
|
40 | def index | |
41 | page |
|
41 | page | |
42 | render :action => 'page' |
|
42 | render :action => 'page' | |
43 | end |
|
43 | end | |
44 |
|
44 | |||
45 | # Show user's page |
|
45 | # Show user's page | |
46 | def page |
|
46 | def page | |
47 | @user = self.logged_in_user |
|
47 | @user = self.logged_in_user | |
48 | @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT |
|
48 | @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | # Edit user's account |
|
51 | # Edit user's account | |
52 | def account |
|
52 | def account | |
53 | @user = User.current |
|
53 | @user = User.current | |
54 | @pref = @user.pref |
|
54 | @pref = @user.pref | |
55 | if request.post? |
|
55 | if request.post? | |
56 | @user.attributes = params[:user] |
|
56 | @user.attributes = params[:user] | |
57 | @user.mail_notification = (params[:notification_option] == 'all') |
|
57 | @user.mail_notification = (params[:notification_option] == 'all') | |
58 | @user.pref.attributes = params[:pref] |
|
58 | @user.pref.attributes = params[:pref] | |
|
59 | @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') | |||
59 | if @user.save |
|
60 | if @user.save | |
60 | @user.pref.save |
|
61 | @user.pref.save | |
61 | @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) |
|
62 | @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) | |
62 | set_language_if_valid @user.language |
|
63 | set_language_if_valid @user.language | |
63 | flash[:notice] = l(:notice_account_updated) |
|
64 | flash[:notice] = l(:notice_account_updated) | |
64 | redirect_to :action => 'account' |
|
65 | redirect_to :action => 'account' | |
65 | return |
|
66 | return | |
66 | end |
|
67 | end | |
67 | end |
|
68 | end | |
68 | @notification_options = [[l(:label_user_mail_option_all), 'all'], |
|
69 | @notification_options = [[l(:label_user_mail_option_all), 'all'], | |
69 | [l(:label_user_mail_option_none), 'none']] |
|
70 | [l(:label_user_mail_option_none), 'none']] | |
70 | # Only users that belong to more than 1 project can select projects for which they are notified |
|
71 | # Only users that belong to more than 1 project can select projects for which they are notified | |
71 | # Note that @user.membership.size would fail since AR ignores :include association option when doing a count |
|
72 | # Note that @user.membership.size would fail since AR ignores :include association option when doing a count | |
72 | @notification_options.insert 1, [l(:label_user_mail_option_selected), 'selected'] if @user.memberships.length > 1 |
|
73 | @notification_options.insert 1, [l(:label_user_mail_option_selected), 'selected'] if @user.memberships.length > 1 | |
73 | @notification_option = @user.mail_notification? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected') |
|
74 | @notification_option = @user.mail_notification? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected') | |
74 | end |
|
75 | end | |
75 |
|
76 | |||
76 | # Manage user's password |
|
77 | # Manage user's password | |
77 | def password |
|
78 | def password | |
78 | @user = self.logged_in_user |
|
79 | @user = self.logged_in_user | |
79 | flash[:error] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id |
|
80 | flash[:error] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id | |
80 | if request.post? |
|
81 | if request.post? | |
81 | if @user.check_password?(params[:password]) |
|
82 | if @user.check_password?(params[:password]) | |
82 | @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] |
|
83 | @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] | |
83 | if @user.save |
|
84 | if @user.save | |
84 | flash[:notice] = l(:notice_account_password_updated) |
|
85 | flash[:notice] = l(:notice_account_password_updated) | |
85 | redirect_to :action => 'account' |
|
86 | redirect_to :action => 'account' | |
86 | end |
|
87 | end | |
87 | else |
|
88 | else | |
88 | flash[:error] = l(:notice_account_wrong_password) |
|
89 | flash[:error] = l(:notice_account_wrong_password) | |
89 | end |
|
90 | end | |
90 | end |
|
91 | end | |
91 | end |
|
92 | end | |
92 |
|
93 | |||
93 | # Create a new feeds key |
|
94 | # Create a new feeds key | |
94 | def reset_rss_key |
|
95 | def reset_rss_key | |
95 | if request.post? && User.current.rss_token |
|
96 | if request.post? && User.current.rss_token | |
96 | User.current.rss_token.destroy |
|
97 | User.current.rss_token.destroy | |
97 | flash[:notice] = l(:notice_feeds_access_key_reseted) |
|
98 | flash[:notice] = l(:notice_feeds_access_key_reseted) | |
98 | end |
|
99 | end | |
99 | redirect_to :action => 'account' |
|
100 | redirect_to :action => 'account' | |
100 | end |
|
101 | end | |
101 |
|
102 | |||
102 | # User's page layout configuration |
|
103 | # User's page layout configuration | |
103 | def page_layout |
|
104 | def page_layout | |
104 | @user = self.logged_in_user |
|
105 | @user = self.logged_in_user | |
105 | @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup |
|
106 | @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup | |
106 | session[:page_layout] = @blocks |
|
107 | session[:page_layout] = @blocks | |
107 | %w(top left right).each {|f| session[:page_layout][f] ||= [] } |
|
108 | %w(top left right).each {|f| session[:page_layout][f] ||= [] } | |
108 | @block_options = [] |
|
109 | @block_options = [] | |
109 | BLOCKS.each {|k, v| @block_options << [l(v), k]} |
|
110 | BLOCKS.each {|k, v| @block_options << [l(v), k]} | |
110 | end |
|
111 | end | |
111 |
|
112 | |||
112 | # Add a block to user's page |
|
113 | # Add a block to user's page | |
113 | # The block is added on top of the page |
|
114 | # The block is added on top of the page | |
114 | # params[:block] : id of the block to add |
|
115 | # params[:block] : id of the block to add | |
115 | def add_block |
|
116 | def add_block | |
116 | block = params[:block] |
|
117 | block = params[:block] | |
117 | render(:nothing => true) and return unless block && (BLOCKS.keys.include? block) |
|
118 | render(:nothing => true) and return unless block && (BLOCKS.keys.include? block) | |
118 | @user = self.logged_in_user |
|
119 | @user = self.logged_in_user | |
119 | # remove if already present in a group |
|
120 | # remove if already present in a group | |
120 | %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } |
|
121 | %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } | |
121 | # add it on top |
|
122 | # add it on top | |
122 | session[:page_layout]['top'].unshift block |
|
123 | session[:page_layout]['top'].unshift block | |
123 | render :partial => "block", :locals => {:user => @user, :block_name => block} |
|
124 | render :partial => "block", :locals => {:user => @user, :block_name => block} | |
124 | end |
|
125 | end | |
125 |
|
126 | |||
126 | # Remove a block to user's page |
|
127 | # Remove a block to user's page | |
127 | # params[:block] : id of the block to remove |
|
128 | # params[:block] : id of the block to remove | |
128 | def remove_block |
|
129 | def remove_block | |
129 | block = params[:block] |
|
130 | block = params[:block] | |
130 | # remove block in all groups |
|
131 | # remove block in all groups | |
131 | %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } |
|
132 | %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block } | |
132 | render :nothing => true |
|
133 | render :nothing => true | |
133 | end |
|
134 | end | |
134 |
|
135 | |||
135 | # Change blocks order on user's page |
|
136 | # Change blocks order on user's page | |
136 | # params[:group] : group to order (top, left or right) |
|
137 | # params[:group] : group to order (top, left or right) | |
137 | # params[:list-(top|left|right)] : array of block ids of the group |
|
138 | # params[:list-(top|left|right)] : array of block ids of the group | |
138 | def order_blocks |
|
139 | def order_blocks | |
139 | group = params[:group] |
|
140 | group = params[:group] | |
140 | group_items = params["list-#{group}"] |
|
141 | group_items = params["list-#{group}"] | |
141 | if group_items and group_items.is_a? Array |
|
142 | if group_items and group_items.is_a? Array | |
142 | # remove group blocks if they are presents in other groups |
|
143 | # remove group blocks if they are presents in other groups | |
143 | %w(top left right).each {|f| |
|
144 | %w(top left right).each {|f| | |
144 | session[:page_layout][f] = (session[:page_layout][f] || []) - group_items |
|
145 | session[:page_layout][f] = (session[:page_layout][f] || []) - group_items | |
145 | } |
|
146 | } | |
146 | session[:page_layout][group] = group_items |
|
147 | session[:page_layout][group] = group_items | |
147 | end |
|
148 | end | |
148 | render :nothing => true |
|
149 | render :nothing => true | |
149 | end |
|
150 | end | |
150 |
|
151 | |||
151 | # Save user's page layout |
|
152 | # Save user's page layout | |
152 | def page_layout_save |
|
153 | def page_layout_save | |
153 | @user = self.logged_in_user |
|
154 | @user = self.logged_in_user | |
154 | @user.pref[:my_page_layout] = session[:page_layout] if session[:page_layout] |
|
155 | @user.pref[:my_page_layout] = session[:page_layout] if session[:page_layout] | |
155 | @user.pref.save |
|
156 | @user.pref.save | |
156 | session[:page_layout] = nil |
|
157 | session[:page_layout] = nil | |
157 | redirect_to :action => 'page' |
|
158 | redirect_to :action => 'page' | |
158 | end |
|
159 | end | |
159 | end |
|
160 | end |
@@ -1,130 +1,138 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 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. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class Mailer < ActionMailer::Base |
|
18 | class Mailer < ActionMailer::Base | |
19 | helper ApplicationHelper |
|
19 | helper ApplicationHelper | |
20 | helper IssuesHelper |
|
20 | helper IssuesHelper | |
21 | helper CustomFieldsHelper |
|
21 | helper CustomFieldsHelper | |
22 |
|
22 | |||
23 | include ActionController::UrlWriter |
|
23 | include ActionController::UrlWriter | |
24 |
|
24 | |||
25 | def issue_add(issue) |
|
25 | def issue_add(issue) | |
26 | recipients issue.recipients |
|
26 | recipients issue.recipients | |
27 | subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" |
|
27 | subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" | |
28 | body :issue => issue, |
|
28 | body :issue => issue, | |
29 | :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue) |
|
29 | :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue) | |
30 | end |
|
30 | end | |
31 |
|
31 | |||
32 | def issue_edit(journal) |
|
32 | def issue_edit(journal) | |
33 | issue = journal.journalized |
|
33 | issue = journal.journalized | |
34 | recipients issue.recipients |
|
34 | recipients issue.recipients | |
35 | # Watchers in cc |
|
35 | # Watchers in cc | |
36 | cc(issue.watcher_recipients - @recipients) |
|
36 | cc(issue.watcher_recipients - @recipients) | |
37 | subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" |
|
37 | subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" | |
38 | body :issue => issue, |
|
38 | body :issue => issue, | |
39 | :journal => journal, |
|
39 | :journal => journal, | |
40 | :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue) |
|
40 | :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue) | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
43 | def document_added(document) |
|
43 | def document_added(document) | |
44 | recipients document.project.recipients |
|
44 | recipients document.project.recipients | |
45 | subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}" |
|
45 | subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}" | |
46 | body :document => document, |
|
46 | body :document => document, | |
47 | :document_url => url_for(:controller => 'documents', :action => 'show', :id => document) |
|
47 | :document_url => url_for(:controller => 'documents', :action => 'show', :id => document) | |
48 | end |
|
48 | end | |
49 |
|
49 | |||
50 | def attachments_added(attachments) |
|
50 | def attachments_added(attachments) | |
51 | container = attachments.first.container |
|
51 | container = attachments.first.container | |
52 | added_to = '' |
|
52 | added_to = '' | |
53 | added_to_url = '' |
|
53 | added_to_url = '' | |
54 | case container.class.name |
|
54 | case container.class.name | |
55 | when 'Version' |
|
55 | when 'Version' | |
56 | added_to_url = url_for(:controller => 'projects', :action => 'list_files', :id => container.project_id) |
|
56 | added_to_url = url_for(:controller => 'projects', :action => 'list_files', :id => container.project_id) | |
57 | added_to = "#{l(:label_version)}: #{container.name}" |
|
57 | added_to = "#{l(:label_version)}: #{container.name}" | |
58 | when 'Document' |
|
58 | when 'Document' | |
59 | added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id) |
|
59 | added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id) | |
60 | added_to = "#{l(:label_document)}: #{container.title}" |
|
60 | added_to = "#{l(:label_document)}: #{container.title}" | |
61 | end |
|
61 | end | |
62 | recipients container.project.recipients |
|
62 | recipients container.project.recipients | |
63 | subject "[#{container.project.name}] #{l(:label_attachment_new)}" |
|
63 | subject "[#{container.project.name}] #{l(:label_attachment_new)}" | |
64 | body :attachments => attachments, |
|
64 | body :attachments => attachments, | |
65 | :added_to => added_to, |
|
65 | :added_to => added_to, | |
66 | :added_to_url => added_to_url |
|
66 | :added_to_url => added_to_url | |
67 | end |
|
67 | end | |
68 |
|
68 | |||
69 | def news_added(news) |
|
69 | def news_added(news) | |
70 | recipients news.project.recipients |
|
70 | recipients news.project.recipients | |
71 | subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}" |
|
71 | subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}" | |
72 | body :news => news, |
|
72 | body :news => news, | |
73 | :news_url => url_for(:controller => 'news', :action => 'show', :id => news) |
|
73 | :news_url => url_for(:controller => 'news', :action => 'show', :id => news) | |
74 | end |
|
74 | end | |
75 |
|
75 | |||
76 | def message_posted(message, recipients) |
|
76 | def message_posted(message, recipients) | |
77 | recipients(recipients) |
|
77 | recipients(recipients) | |
78 | subject "[#{message.board.project.name} - #{message.board.name}] #{message.subject}" |
|
78 | subject "[#{message.board.project.name} - #{message.board.name}] #{message.subject}" | |
79 | body :message => message, |
|
79 | body :message => message, | |
80 | :message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root) |
|
80 | :message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root) | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | def account_information(user, password) |
|
83 | def account_information(user, password) | |
84 | set_language_if_valid user.language |
|
84 | set_language_if_valid user.language | |
85 | recipients user.mail |
|
85 | recipients user.mail | |
86 | subject l(:mail_subject_register) |
|
86 | subject l(:mail_subject_register) | |
87 | body :user => user, |
|
87 | body :user => user, | |
88 | :password => password, |
|
88 | :password => password, | |
89 | :login_url => url_for(:controller => 'account', :action => 'login') |
|
89 | :login_url => url_for(:controller => 'account', :action => 'login') | |
90 | end |
|
90 | end | |
91 |
|
91 | |||
92 | def lost_password(token) |
|
92 | def lost_password(token) | |
93 | set_language_if_valid(token.user.language) |
|
93 | set_language_if_valid(token.user.language) | |
94 | recipients token.user.mail |
|
94 | recipients token.user.mail | |
95 | subject l(:mail_subject_lost_password) |
|
95 | subject l(:mail_subject_lost_password) | |
96 | body :token => token, |
|
96 | body :token => token, | |
97 | :url => url_for(:controller => 'account', :action => 'lost_password', :token => token.value) |
|
97 | :url => url_for(:controller => 'account', :action => 'lost_password', :token => token.value) | |
98 | end |
|
98 | end | |
99 |
|
99 | |||
100 | def register(token) |
|
100 | def register(token) | |
101 | set_language_if_valid(token.user.language) |
|
101 | set_language_if_valid(token.user.language) | |
102 | recipients token.user.mail |
|
102 | recipients token.user.mail | |
103 | subject l(:mail_subject_register) |
|
103 | subject l(:mail_subject_register) | |
104 | body :token => token, |
|
104 | body :token => token, | |
105 | :url => url_for(:controller => 'account', :action => 'register', :token => token.value) |
|
105 | :url => url_for(:controller => 'account', :action => 'register', :token => token.value) | |
106 | end |
|
106 | end | |
107 |
|
107 | |||
108 | def test(user) |
|
108 | def test(user) | |
109 | set_language_if_valid(user.language) |
|
109 | set_language_if_valid(user.language) | |
110 | recipients user.mail |
|
110 | recipients user.mail | |
111 | subject 'Redmine test' |
|
111 | subject 'Redmine test' | |
112 | body :url => url_for(:controller => 'welcome') |
|
112 | body :url => url_for(:controller => 'welcome') | |
113 | end |
|
113 | end | |
114 |
|
114 | |||
115 | private |
|
115 | private | |
116 | def initialize_defaults(method_name) |
|
116 | def initialize_defaults(method_name) | |
117 | super |
|
117 | super | |
118 | set_language_if_valid Setting.default_language |
|
118 | set_language_if_valid Setting.default_language | |
119 | from Setting.mail_from |
|
119 | from Setting.mail_from | |
120 | default_url_options[:host] = Setting.host_name |
|
120 | default_url_options[:host] = Setting.host_name | |
121 | default_url_options[:protocol] = Setting.protocol |
|
121 | default_url_options[:protocol] = Setting.protocol | |
122 | end |
|
122 | end | |
123 |
|
123 | |||
|
124 | # Overrides the create_mail method to remove the current user from the recipients and cc | |||
|
125 | # if he doesn't want to receive notifications about what he does | |||
|
126 | def create_mail | |||
|
127 | recipients.delete(User.current.mail) if recipients && User.current.pref[:no_self_notified] | |||
|
128 | cc.delete(User.current.mail) if cc && User.current.pref[:no_self_notified] | |||
|
129 | super | |||
|
130 | end | |||
|
131 | ||||
124 | # Renders a message with the corresponding layout |
|
132 | # Renders a message with the corresponding layout | |
125 | def render_message(method_name, body) |
|
133 | def render_message(method_name, body) | |
126 | layout = method_name.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml' |
|
134 | layout = method_name.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml' | |
127 | body[:content_for_layout] = render(:file => method_name, :body => body) |
|
135 | body[:content_for_layout] = render(:file => method_name, :body => body) | |
128 | ActionView::Base.new(File.join(template_root, 'mailer'), body, self).render(:file => layout) |
|
136 | ActionView::Base.new(File.join(template_root, 'mailer'), body, self).render(:file => layout) | |
129 | end |
|
137 | end | |
130 | end |
|
138 | end |
@@ -1,41 +1,42 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to(l(:button_change_password), :action => 'password') unless @user.auth_source_id %> |
|
2 | <%= link_to(l(:button_change_password), :action => 'password') unless @user.auth_source_id %> | |
3 | </div> |
|
3 | </div> | |
4 | <h2><%=l(:label_my_account)%></h2> |
|
4 | <h2><%=l(:label_my_account)%></h2> | |
5 | <%= error_messages_for 'user' %> |
|
5 | <%= error_messages_for 'user' %> | |
6 |
|
6 | |||
7 | <% form_for :user, @user, :url => { :action => "account" }, :builder => TabularFormBuilder, :lang => current_language do |f| %> |
|
7 | <% form_for :user, @user, :url => { :action => "account" }, :builder => TabularFormBuilder, :lang => current_language do |f| %> | |
8 | <div class="splitcontentleft"> |
|
8 | <div class="splitcontentleft"> | |
9 | <h3><%=l(:label_information_plural)%></h3> |
|
9 | <h3><%=l(:label_information_plural)%></h3> | |
10 | <div class="box tabular"> |
|
10 | <div class="box tabular"> | |
11 | <p><%= f.text_field :firstname, :required => true %></p> |
|
11 | <p><%= f.text_field :firstname, :required => true %></p> | |
12 | <p><%= f.text_field :lastname, :required => true %></p> |
|
12 | <p><%= f.text_field :lastname, :required => true %></p> | |
13 | <p><%= f.text_field :mail, :required => true %></p> |
|
13 | <p><%= f.text_field :mail, :required => true %></p> | |
14 | <p><%= f.select :language, lang_options_for_select %></p> |
|
14 | <p><%= f.select :language, lang_options_for_select %></p> | |
15 |
|
15 | |||
16 | <% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %> |
|
16 | <% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %> | |
17 | <p><%= pref_fields.check_box :hide_mail %></p> |
|
17 | <p><%= pref_fields.check_box :hide_mail %></p> | |
18 | <% end %> |
|
18 | <% end %> | |
19 | </div> |
|
19 | </div> | |
20 |
|
20 | |||
21 | <%= submit_tag l(:button_save) %> |
|
21 | <%= submit_tag l(:button_save) %> | |
22 | </div> |
|
22 | </div> | |
23 |
|
23 | |||
24 | <div class="splitcontentright"> |
|
24 | <div class="splitcontentright"> | |
25 | <h3><%=l(:field_mail_notification)%></h3> |
|
25 | <h3><%=l(:field_mail_notification)%></h3> | |
26 | <div class="box"> |
|
26 | <div class="box"> | |
27 | <%= select_tag 'notification_option', options_for_select(@notification_options, @notification_option), |
|
27 | <%= select_tag 'notification_option', options_for_select(@notification_options, @notification_option), | |
28 | :onchange => 'if ($("notification_option").value == "selected") {Element.show("notified-projects")} else {Element.hide("notified-projects")}' %> |
|
28 | :onchange => 'if ($("notification_option").value == "selected") {Element.show("notified-projects")} else {Element.hide("notified-projects")}' %> | |
29 | <% content_tag 'div', :id => 'notified-projects', :style => (@notification_option == 'selected' ? '' : 'display:none;') do %> |
|
29 | <% content_tag 'div', :id => 'notified-projects', :style => (@notification_option == 'selected' ? '' : 'display:none;') do %> | |
30 | <p><% User.current.projects.each do |project| %> |
|
30 | <p><% User.current.projects.each do |project| %> | |
31 | <label><%= check_box_tag 'notified_project_ids[]', project.id, @user.notified_projects_ids.include?(project.id) %> <%= project.name %></label><br /> |
|
31 | <label><%= check_box_tag 'notified_project_ids[]', project.id, @user.notified_projects_ids.include?(project.id) %> <%= project.name %></label><br /> | |
32 | <% end %></p> |
|
32 | <% end %></p> | |
33 | <p><em><%= l(:text_user_mail_option) %></em></p> |
|
33 | <p><em><%= l(:text_user_mail_option) %></em></p> | |
34 | <% end %> |
|
34 | <% end %> | |
|
35 | <p><label><%= check_box_tag 'no_self_notified', 1, @user.pref[:no_self_notified] %> I don't want to be notified of changes that I make myself.</label></p> | |||
35 | </div> |
|
36 | </div> | |
36 | </div> |
|
37 | </div> | |
37 | <% end %> |
|
38 | <% end %> | |
38 |
|
39 | |||
39 | <% content_for :sidebar do %> |
|
40 | <% content_for :sidebar do %> | |
40 | <%= render :partial => 'sidebar' %> |
|
41 | <%= render :partial => 'sidebar' %> | |
41 | <% end %> |
|
42 | <% end %> |
General Comments 0
You need to be logged in to leave comments.
Login now