##// END OF EJS Templates
Host setting should contain the path prefix (Redmine base URL) to properly generate links in emails that are sent offline (#2122)....
Jean-Philippe Lang -
r1987:006337fb0e8c
parent child
Show More
@@ -5,19 +5,19
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class SettingsController < ApplicationController
19 19 before_filter :require_admin
20
20
21 21 def index
22 22 edit
23 23 render :action => 'edit'
@@ -39,8 +39,11 class SettingsController < ApplicationController
39 39 @options = {}
40 40 @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
41 41 @deliveries = ActionMailer::Base.perform_deliveries
42
43 @guessed_host_and_path = request.host_with_port
44 @guessed_host_and_path << ('/'+ request.relative_url_root.gsub(%r{^\/}, '')) unless request.relative_url_root.blank?
42 45 end
43
46
44 47 def plugin
45 48 plugin_id = params[:id].to_sym
46 49 @plugin = Redmine::Plugin.registered_plugins[plugin_id]
@@ -5,12 +5,12
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -19,15 +19,15 class Mailer < ActionMailer::Base
19 19 helper :application
20 20 helper :issues
21 21 helper :custom_fields
22
22
23 23 include ActionController::UrlWriter
24
25 def issue_add(issue)
24
25 def issue_add(issue)
26 26 redmine_headers 'Project' => issue.project.identifier,
27 27 'Issue-Id' => issue.id,
28 28 'Issue-Author' => issue.author.login
29 29 redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
30 recipients issue.recipients
30 recipients issue.recipients
31 31 subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
32 32 body :issue => issue,
33 33 :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
@@ -50,7 +50,7 class Mailer < ActionMailer::Base
50 50 :journal => journal,
51 51 :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
52 52 end
53
53
54 54 def reminder(user, issues, days)
55 55 set_language_if_valid user.language
56 56 recipients user.mail
@@ -59,7 +59,7 class Mailer < ActionMailer::Base
59 59 :days => days,
60 60 :issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.id, :sort_key => 'issues.due_date', :sort_order => 'asc')
61 61 end
62
62
63 63 def document_added(document)
64 64 redmine_headers 'Project' => document.project.identifier
65 65 recipients document.project.recipients
@@ -67,7 +67,7 class Mailer < ActionMailer::Base
67 67 body :document => document,
68 68 :document_url => url_for(:controller => 'documents', :action => 'show', :id => document)
69 69 end
70
70
71 71 def attachments_added(attachments)
72 72 container = attachments.first.container
73 73 added_to = ''
@@ -104,7 +104,7 class Mailer < ActionMailer::Base
104 104 body :message => message,
105 105 :message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root)
106 106 end
107
107
108 108 def account_information(user, password)
109 109 set_language_if_valid user.language
110 110 recipients user.mail
@@ -113,7 +113,7 class Mailer < ActionMailer::Base
113 113 :password => password,
114 114 :login_url => url_for(:controller => 'account', :action => 'login')
115 115 end
116
116
117 117 def account_activation_request(user)
118 118 # Send the email to all active administrators
119 119 recipients User.find_active(:all, :conditions => {:admin => true}).collect { |u| u.mail }.compact
@@ -128,7 +128,7 class Mailer < ActionMailer::Base
128 128 subject l(:mail_subject_lost_password, Setting.app_title)
129 129 body :token => token,
130 130 :url => url_for(:controller => 'account', :action => 'lost_password', :token => token.value)
131 end
131 end
132 132
133 133 def register(token)
134 134 set_language_if_valid(token.user.language)
@@ -137,7 +137,7 class Mailer < ActionMailer::Base
137 137 body :token => token,
138 138 :url => url_for(:controller => 'account', :action => 'activate', :token => token.value)
139 139 end
140
140
141 141 def test(user)
142 142 set_language_if_valid(user.language)
143 143 recipients user.mail
@@ -148,12 +148,12 class Mailer < ActionMailer::Base
148 148 # Overrides default deliver! method to prevent from sending an email
149 149 # with no recipient, cc or bcc
150 150 def deliver!(mail = @mail)
151 return false if (recipients.nil? || recipients.empty?) &&
151 return false if (recipients.nil? || recipients.empty?) &&
152 152 (cc.nil? || cc.empty?) &&
153 153 (bcc.nil? || bcc.empty?)
154 154 super
155 155 end
156
156
157 157 # Sends reminders to issue assignees
158 158 # Available options:
159 159 # * :days => how many days in the future to remind about (defaults to 7)
@@ -163,13 +163,13 class Mailer < ActionMailer::Base
163 163 days = options[:days] || 7
164 164 project = options[:project] ? Project.find(options[:project]) : nil
165 165 tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
166
166
167 167 s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ?", false, days.day.from_now.to_date]
168 168 s << "#{Issue.table_name}.assigned_to_id IS NOT NULL"
169 169 s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}"
170 170 s << "#{Issue.table_name}.project_id = #{project.id}" if project
171 171 s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker
172
172
173 173 issues_by_assignee = Issue.find(:all, :include => [:status, :assigned_to, :project, :tracker],
174 174 :conditions => s.conditions
175 175 ).group_by(&:assigned_to)
@@ -185,17 +185,18 class Mailer < ActionMailer::Base
185 185 from Setting.mail_from
186 186 default_url_options[:host] = Setting.host_name
187 187 default_url_options[:protocol] = Setting.protocol
188 default_url_options[:skip_relative_url_root] = true
188 189 # Common headers
189 190 headers 'X-Mailer' => 'Redmine',
190 191 'X-Redmine-Host' => Setting.host_name,
191 192 'X-Redmine-Site' => Setting.app_title
192 193 end
193
194
194 195 # Appends a Redmine header field (name is prepended with 'X-Redmine-')
195 196 def redmine_headers(h)
196 197 h.each { |k,v| headers["X-Redmine-#{k}"] = v }
197 198 end
198
199
199 200 # Overrides the create_mail method
200 201 def create_mail
201 202 # Removes the current user from the recipients and cc
@@ -209,10 +210,10 class Mailer < ActionMailer::Base
209 210 bcc([recipients, cc].flatten.compact.uniq)
210 211 recipients []
211 212 cc []
212 end
213 end
213 214 super
214 215 end
215
216
216 217 # Renders a message with the corresponding layout
217 218 def render_message(method_name, body)
218 219 layout = method_name.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml'
@@ -234,7 +235,7 class Mailer < ActionMailer::Base
234 235 end
235 236 return value
236 237 end
237
238
238 239 # Makes partial rendering work with Rails 1.2 (retro-compatibility)
239 240 def self.controller_path
240 241 ''
@@ -33,7 +33,8
33 33 <%= text_field_tag 'settings[activity_days_default]', Setting.activity_days_default, :size => 6 %> <%= l(:label_day_plural) %></p>
34 34
35 35 <p><label><%= l(:setting_host_name) %></label>
36 <%= text_field_tag 'settings[host_name]', Setting.host_name, :size => 60 %></p>
36 <%= text_field_tag 'settings[host_name]', Setting.host_name, :size => 60 %><br />
37 <em><%= l(:label_example) %>: <%= @guessed_host_and_path %></em></p>
37 38
38 39 <p><label><%= l(:setting_protocol) %></label>
39 40 <%= select_tag 'settings[protocol]', options_for_select(['http', 'https'], Setting.protocol) %></p>
@@ -196,7 +196,7 setting_issues_export_limit: Issues export limit
196 196 setting_mail_from: Emission email address
197 197 setting_bcc_recipients: Blind carbon copy recipients (bcc)
198 198 setting_plain_text_mail: plain text mail (no HTML)
199 setting_host_name: Host name
199 setting_host_name: Host name and path
200 200 setting_text_formatting: Text formatting
201 201 setting_wiki_compression: Wiki history compression
202 202 setting_feeds_limit: Feed content limit
@@ -576,6 +576,7 label_planning: Planning
576 576 label_incoming_emails: Incoming emails
577 577 label_generate_key: Generate a key
578 578 label_issue_watchers: Watchers
579 label_example: Example
579 580
580 581 button_login: Login
581 582 button_submit: Submit
@@ -197,7 +197,7 setting_issues_export_limit: Limite export demandes
197 197 setting_mail_from: Adresse d'émission
198 198 setting_bcc_recipients: Destinataires en copie cachée (cci)
199 199 setting_plain_text_mail: Mail texte brut (non HTML)
200 setting_host_name: Nom d'hôte
200 setting_host_name: Nom d'hôte et chemin
201 201 setting_text_formatting: Formatage du texte
202 202 setting_wiki_compression: Compression historique wiki
203 203 setting_feeds_limit: Limite du contenu des flux RSS
@@ -576,6 +576,7 label_planning: Planning
576 576 label_incoming_emails: Emails entrants
577 577 label_generate_key: Générer une clé
578 578 label_issue_watchers: Utilisateurs surveillant cette demande
579 label_example: Exemple
579 580
580 581 button_login: Connexion
581 582 button_submit: Soumettre
General Comments 0
You need to be logged in to leave comments. Login now