summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb (renamed from app/controllers/application.rb)7
-rw-r--r--app/controllers/repositories_controller.rb2
-rw-r--r--app/models/mailer.rb48
-rw-r--r--app/views/layouts/mailer.text.html.erb (renamed from app/views/mailer/layout.text.html.rhtml)0
-rw-r--r--app/views/layouts/mailer.text.plain.erb (renamed from app/views/mailer/layout.text.plain.rhtml)0
-rw-r--r--app/views/settings/_authentication.rhtml12
-rw-r--r--app/views/settings/_display.rhtml4
-rw-r--r--app/views/settings/_issues.rhtml8
-rw-r--r--app/views/settings/_mail_handler.rhtml3
-rw-r--r--app/views/settings/_notifications.rhtml6
-rw-r--r--app/views/settings/_projects.rhtml8
-rw-r--r--app/views/settings/_repositories.rhtml8
12 files changed, 66 insertions, 40 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application_controller.rb
index 6d6338ffa..59d117e4f 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application_controller.rb
@@ -20,12 +20,7 @@ require 'cgi'
class ApplicationController < ActionController::Base
include Redmine::I18n
-
- # In case the cookie store secret changes
- rescue_from CGI::Session::CookieStore::TamperedWithCookie do |exception|
- render :text => 'Your session was invalid and has been reset. Please, reload this page.', :status => 500
- end
-
+
layout 'base'
before_filter :user_setup, :check_if_login_required, :set_localization
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 938ace9ba..42405468f 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -259,7 +259,7 @@ private
def graph_commits_per_author(repository)
commits_by_author = repository.changesets.count(:all, :group => :committer)
- commits_by_author.sort! {|x, y| x.last <=> y.last}
+ commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}
changes_by_author = repository.changes.count(:all, :group => :committer)
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index fbe76ac3a..1a2e35e7d 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class Mailer < ActionMailer::Base
+ layout 'mailer'
helper :application
helper :issues
helper :custom_fields
@@ -45,6 +46,7 @@ class Mailer < ActionMailer::Base
subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
body :issue => issue,
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
+ render_multipart('issue_add', body)
end
# Builds a tmail object used to email recipients of the edited issue.
@@ -71,6 +73,8 @@ class Mailer < ActionMailer::Base
body :issue => issue,
:journal => journal,
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
+
+ render_multipart('issue_edit', body)
end
def reminder(user, issues, days)
@@ -80,6 +84,7 @@ class Mailer < ActionMailer::Base
body :issues => issues,
:days => days,
:issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.id, :sort_key => 'due_date', :sort_order => 'asc')
+ render_multipart('reminder', body)
end
# Builds a tmail object used to email users belonging to the added document's project.
@@ -93,6 +98,7 @@ class Mailer < ActionMailer::Base
subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
body :document => document,
:document_url => url_for(:controller => 'documents', :action => 'show', :id => document)
+ render_multipart('document_added', body)
end
# Builds a tmail object used to email recipients of a project when an attachements are added.
@@ -121,6 +127,7 @@ class Mailer < ActionMailer::Base
body :attachments => attachments,
:added_to => added_to,
:added_to_url => added_to_url
+ render_multipart('attachments_added', body)
end
# Builds a tmail object used to email recipients of a news' project when a news item is added.
@@ -135,6 +142,7 @@ class Mailer < ActionMailer::Base
subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
body :news => news,
:news_url => url_for(:controller => 'news', :action => 'show', :id => news)
+ render_multipart('news_added', body)
end
# Builds a tmail object used to email the specified recipients of the specified message that was posted.
@@ -151,6 +159,7 @@ class Mailer < ActionMailer::Base
subject "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
body :message => message,
:message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root)
+ render_multipart('message_posted', body)
end
# Builds a tmail object used to email the recipients of a project of the specified wiki content was added.
@@ -167,6 +176,7 @@ class Mailer < ActionMailer::Base
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :page => wiki_content.page.pretty_title)}"
body :wiki_content => wiki_content,
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title)
+ render_multipart('wiki_content_added', body)
end
# Builds a tmail object used to email the recipients of a project of the specified wiki content was updated.
@@ -184,6 +194,7 @@ class Mailer < ActionMailer::Base
body :wiki_content => wiki_content,
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title),
:wiki_diff_url => url_for(:controller => 'wiki', :action => 'diff', :id => wiki_content.project, :page => wiki_content.page.title, :version => wiki_content.version)
+ render_multipart('wiki_content_updated', body)
end
# Builds a tmail object used to email the specified user their account information.
@@ -198,6 +209,7 @@ class Mailer < ActionMailer::Base
body :user => user,
:password => password,
:login_url => url_for(:controller => 'account', :action => 'login')
+ render_multipart('account_information', body)
end
# Builds a tmail object used to email all active administrators of an account activation request.
@@ -211,6 +223,7 @@ class Mailer < ActionMailer::Base
subject l(:mail_subject_account_activation_request, Setting.app_title)
body :user => user,
:url => url_for(:controller => 'users', :action => 'index', :status => User::STATUS_REGISTERED, :sort_key => 'created_on', :sort_order => 'desc')
+ render_multipart('account_activation_request', body)
end
# Builds a tmail object used to email the specified user that their account was activated by an administrator.
@@ -224,6 +237,7 @@ class Mailer < ActionMailer::Base
subject l(:mail_subject_register, Setting.app_title)
body :user => user,
:login_url => url_for(:controller => 'account', :action => 'login')
+ render_multipart('account_activated', body)
end
def lost_password(token)
@@ -232,6 +246,7 @@ class Mailer < ActionMailer::Base
subject l(:mail_subject_lost_password, Setting.app_title)
body :token => token,
:url => url_for(:controller => 'account', :action => 'lost_password', :token => token.value)
+ render_multipart('lost_password', body)
end
def register(token)
@@ -240,6 +255,7 @@ class Mailer < ActionMailer::Base
subject l(:mail_subject_register, Setting.app_title)
body :token => token,
:url => url_for(:controller => 'account', :action => 'activate', :token => token.value)
+ render_multipart('register', body)
end
def test(user)
@@ -247,6 +263,7 @@ class Mailer < ActionMailer::Base
recipients user.mail
subject 'Redmine test'
body :url => url_for(:controller => 'welcome')
+ render_multipart('test', body)
end
# Overrides default deliver! method to prevent from sending an email
@@ -327,26 +344,17 @@ class Mailer < ActionMailer::Base
super
end
- # Renders a message with the corresponding layout
- def render_message(method_name, body)
- layout = method_name.to_s.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml'
- body[:content_for_layout] = render(:file => method_name, :body => body)
- ActionView::Base.new(template_root, body, self).render(:file => "mailer/#{layout}", :use_full_path => true)
- end
-
- # for the case of plain text only
- def body(*params)
- value = super(*params)
- if Setting.plain_text_mail?
- templates = Dir.glob("#{template_path}/#{@template}.text.plain.{rhtml,erb}")
- unless String === @body or templates.empty?
- template = File.basename(templates.first)
- @body[:content_for_layout] = render(:file => template, :body => @body)
- @body = ActionView::Base.new(template_root, @body, self).render(:file => "mailer/layout.text.plain.rhtml", :use_full_path => true)
- return @body
- end
- end
- return value
+ # Rails 2.3 has problems rendering implicit multipart messages with
+ # layouts so this method will wrap an multipart messages with
+ # explicit parts.
+ #
+ # https://rails.lighthouseapp.com/projects/8994/tickets/2338-actionmailer-mailer-views-and-content-type
+ # https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts
+
+ def render_multipart(method_name, body)
+ content_type "multipart/alternative"
+ part :content_type => "text/plain", :body => render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb')
+ part :content_type => "text/html", :body => render_message("#{method_name}.text.html.rhtml", body) unless Setting.plain_text_mail?
end
# Makes partial rendering work with Rails 1.2 (retro-compatibility)
diff --git a/app/views/mailer/layout.text.html.rhtml b/app/views/layouts/mailer.text.html.erb
index 83d967864..83d967864 100644
--- a/app/views/mailer/layout.text.html.rhtml
+++ b/app/views/layouts/mailer.text.html.erb
diff --git a/app/views/mailer/layout.text.plain.rhtml b/app/views/layouts/mailer.text.plain.erb
index 1cbcbc236..1cbcbc236 100644
--- a/app/views/mailer/layout.text.plain.rhtml
+++ b/app/views/layouts/mailer.text.plain.erb
diff --git a/app/views/settings/_authentication.rhtml b/app/views/settings/_authentication.rhtml
index 25d344da6..f4b8dbf52 100644
--- a/app/views/settings/_authentication.rhtml
+++ b/app/views/settings/_authentication.rhtml
@@ -2,7 +2,9 @@
<div class="box tabular settings">
<p><label><%= l(:setting_login_required) %></label>
-<%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p>
+<%= hidden_field_tag 'settings[login_required]', 0 %>
+<%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %>
+</p>
<p><label><%= l(:setting_autologin) %></label>
<%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [l('datetime.distance_in_words.x_days', :count => days), days.to_s]}, Setting.autologin) %></p>
@@ -19,10 +21,14 @@
<%= text_field_tag 'settings[password_min_length]', Setting.password_min_length, :size => 6 %></p>
<p><label><%= l(:label_password_lost) %></label>
-<%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p>
+<%= hidden_field_tag 'settings[lost_password]', 0 %>
+<%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %>
+</p>
<p><label><%= l(:setting_openid) %></label>
-<%= check_box_tag 'settings[openid]', 1, Setting.openid?, :disabled => !Object.const_defined?(:OpenID) %><%= hidden_field_tag 'settings[openid]', 0 %></p>
+<%= hidden_field_tag 'settings[openid]', 0 %>
+<%= check_box_tag 'settings[openid]', 1, Setting.openid?, :disabled => !Object.const_defined?(:OpenID) %>
+</p>
</div>
<div style="float:right;">
diff --git a/app/views/settings/_display.rhtml b/app/views/settings/_display.rhtml
index a14ff47ce..984f762e4 100644
--- a/app/views/settings/_display.rhtml
+++ b/app/views/settings/_display.rhtml
@@ -17,7 +17,9 @@
<%= select_tag 'settings[user_format]', options_for_select( @options[:user_format], Setting.user_format.to_s ) %></p>
<p><label><%= l(:setting_gravatar_enabled) %></label>
-<%= check_box_tag 'settings[gravatar_enabled]', 1, Setting.gravatar_enabled? %><%= hidden_field_tag 'settings[gravatar_enabled]', 0 %></p>
+<%= hidden_field_tag 'settings[gravatar_enabled]', 0 %>
+<%= check_box_tag 'settings[gravatar_enabled]', 1, Setting.gravatar_enabled? %>
+</p>
</div>
<%= submit_tag l(:button_save) %>
diff --git a/app/views/settings/_issues.rhtml b/app/views/settings/_issues.rhtml
index 0703661e0..b0277fab3 100644
--- a/app/views/settings/_issues.rhtml
+++ b/app/views/settings/_issues.rhtml
@@ -2,10 +2,14 @@
<div class="box tabular settings">
<p><label><%= l(:setting_cross_project_issue_relations) %></label>
-<%= check_box_tag 'settings[cross_project_issue_relations]', 1, Setting.cross_project_issue_relations? %><%= hidden_field_tag 'settings[cross_project_issue_relations]', 0 %></p>
+<%= hidden_field_tag 'settings[cross_project_issue_relations]', 0 %>
+<%= check_box_tag 'settings[cross_project_issue_relations]', 1, Setting.cross_project_issue_relations? %>
+</p>
<p><label><%= l(:setting_display_subprojects_issues) %></label>
-<%= check_box_tag 'settings[display_subprojects_issues]', 1, Setting.display_subprojects_issues? %><%= hidden_field_tag 'settings[display_subprojects_issues]', 0 %></p>
+<%= hidden_field_tag 'settings[display_subprojects_issues]', 0 %>
+<%= check_box_tag 'settings[display_subprojects_issues]', 1, Setting.display_subprojects_issues? %>
+</p>
<p><label><%= l(:setting_issues_export_limit) %></label>
<%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p>
diff --git a/app/views/settings/_mail_handler.rhtml b/app/views/settings/_mail_handler.rhtml
index 830b1ba4a..8d83358b7 100644
--- a/app/views/settings/_mail_handler.rhtml
+++ b/app/views/settings/_mail_handler.rhtml
@@ -2,9 +2,10 @@
<div class="box tabular settings">
<p><label><%= l(:setting_mail_handler_api_enabled) %></label>
+<%= hidden_field_tag 'settings[mail_handler_api_enabled]', 0 %>
<%= check_box_tag 'settings[mail_handler_api_enabled]', 1, Setting.mail_handler_api_enabled?,
:onclick => "if (this.checked) { Form.Element.enable('settings_mail_handler_api_key'); } else { Form.Element.disable('settings_mail_handler_api_key'); }" %>
-<%= hidden_field_tag 'settings[mail_handler_api_enabled]', 0 %></p>
+</p>
<p><label><%= l(:setting_mail_handler_api_key) %></label>
<%= text_field_tag 'settings[mail_handler_api_key]', Setting.mail_handler_api_key,
diff --git a/app/views/settings/_notifications.rhtml b/app/views/settings/_notifications.rhtml
index bc0141187..1b1b294b2 100644
--- a/app/views/settings/_notifications.rhtml
+++ b/app/views/settings/_notifications.rhtml
@@ -6,12 +6,14 @@
<%= text_field_tag 'settings[mail_from]', Setting.mail_from, :size => 60 %></p>
<p><label><%= l(:setting_bcc_recipients) %></label>
+<%= hidden_field_tag 'settings[bcc_recipients]', 0 %>
<%= check_box_tag 'settings[bcc_recipients]', 1, Setting.bcc_recipients? %>
-<%= hidden_field_tag 'settings[bcc_recipients]', 0 %></p>
+</p>
<p><label><%= l(:setting_plain_text_mail) %></label>
+<%= hidden_field_tag 'settings[plain_text_mail]', 0 %>
<%= check_box_tag 'settings[plain_text_mail]', 1, Setting.plain_text_mail? %>
-<%= hidden_field_tag 'settings[plain_text_mail]', 0 %></p>
+</p>
</div>
<fieldset class="box" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend>
diff --git a/app/views/settings/_projects.rhtml b/app/views/settings/_projects.rhtml
index 2f831c8fd..704905af2 100644
--- a/app/views/settings/_projects.rhtml
+++ b/app/views/settings/_projects.rhtml
@@ -2,10 +2,14 @@
<div class="box tabular settings">
<p><label><%= l(:setting_default_projects_public) %></label>
-<%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %><%= hidden_field_tag 'settings[default_projects_public]', 0 %></p>
+<%= hidden_field_tag 'settings[default_projects_public]', 0 %>
+<%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %>
+</p>
<p><label><%= l(:setting_sequential_project_identifiers) %></label>
-<%= check_box_tag 'settings[sequential_project_identifiers]', 1, Setting.sequential_project_identifiers? %><%= hidden_field_tag 'settings[sequential_project_identifiers]', 0 %></p>
+<%= hidden_field_tag 'settings[sequential_project_identifiers]', 0 %>
+<%= check_box_tag 'settings[sequential_project_identifiers]', 1, Setting.sequential_project_identifiers? %>
+</p>
<p><label><%= l(:setting_new_project_user_role_id) %></label>
<%= select_tag('settings[new_project_user_role_id]', options_for_select([["--- #{l(:actionview_instancetag_blank_option)} ---", '']] + Role.find_all_givable.collect {|r| [r.name, r.id]}, Setting.new_project_user_role_id.to_i)) %></p>
diff --git a/app/views/settings/_repositories.rhtml b/app/views/settings/_repositories.rhtml
index a20fc5131..4f07f053a 100644
--- a/app/views/settings/_repositories.rhtml
+++ b/app/views/settings/_repositories.rhtml
@@ -2,10 +2,14 @@
<div class="box tabular settings">
<p><label><%= l(:setting_autofetch_changesets) %></label>
-<%= check_box_tag 'settings[autofetch_changesets]', 1, Setting.autofetch_changesets? %><%= hidden_field_tag 'settings[autofetch_changesets]', 0 %></p>
+<%= hidden_field_tag 'settings[autofetch_changesets]', 0 %>
+<%= check_box_tag 'settings[autofetch_changesets]', 1, Setting.autofetch_changesets? %>
+</p>
<p><label><%= l(:setting_sys_api_enabled) %></label>
-<%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p>
+<%= hidden_field_tag 'settings[sys_api_enabled]', 0 %>
+<%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %>
+</p>
<p><label><%= l(:setting_enabled_scm) %></label>
<% REDMINE_SUPPORTED_SCM.each do |scm| -%>