##// END OF EJS Templates
Adds 4h, 8h and 12h as options for session maximum lifetime (#20933)....
Jean-Philippe Lang -
r14265:b0be968d36f5
parent child
Show More
@@ -1,173 +1,192
1 1 # encoding: utf-8
2 2 #
3 3 # Redmine - project management software
4 4 # Copyright (C) 2006-2015 Jean-Philippe Lang
5 5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; either version 2
9 9 # of the License, or (at your option) any later version.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 19
20 20 module SettingsHelper
21 21 def administration_settings_tabs
22 22 tabs = [{:name => 'general', :partial => 'settings/general', :label => :label_general},
23 23 {:name => 'display', :partial => 'settings/display', :label => :label_display},
24 24 {:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication},
25 25 {:name => 'api', :partial => 'settings/api', :label => :label_api},
26 26 {:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
27 27 {:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
28 28 {:name => 'attachments', :partial => 'settings/attachments', :label => :label_attachment_plural},
29 29 {:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification},
30 30 {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails},
31 31 {:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
32 32 ]
33 33 end
34 34
35 35 def setting_select(setting, choices, options={})
36 36 if blank_text = options.delete(:blank)
37 37 choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
38 38 end
39 39 setting_label(setting, options).html_safe +
40 40 select_tag("settings[#{setting}]",
41 41 options_for_select(choices, Setting.send(setting).to_s),
42 42 options).html_safe
43 43 end
44 44
45 45 def setting_multiselect(setting, choices, options={})
46 46 setting_values = Setting.send(setting)
47 47 setting_values = [] unless setting_values.is_a?(Array)
48 48
49 49 content_tag("label", l(options[:label] || "setting_#{setting}")) +
50 50 hidden_field_tag("settings[#{setting}][]", '').html_safe +
51 51 choices.collect do |choice|
52 52 text, value = (choice.is_a?(Array) ? choice : [choice, choice])
53 53 content_tag(
54 54 'label',
55 55 check_box_tag(
56 56 "settings[#{setting}][]",
57 57 value,
58 58 setting_values.include?(value),
59 59 :id => nil
60 60 ) + text.to_s,
61 61 :class => (options[:inline] ? 'inline' : 'block')
62 62 )
63 63 end.join.html_safe
64 64 end
65 65
66 66 def setting_text_field(setting, options={})
67 67 setting_label(setting, options).html_safe +
68 68 text_field_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
69 69 end
70 70
71 71 def setting_text_area(setting, options={})
72 72 setting_label(setting, options).html_safe +
73 73 text_area_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
74 74 end
75 75
76 76 def setting_check_box(setting, options={})
77 77 setting_label(setting, options).html_safe +
78 78 hidden_field_tag("settings[#{setting}]", 0, :id => nil).html_safe +
79 79 check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
80 80 end
81 81
82 82 def setting_label(setting, options={})
83 83 label = options.delete(:label)
84 84 if label == false
85 85 ''
86 86 else
87 87 text = label.is_a?(String) ? label : l(label || "setting_#{setting}")
88 88 label_tag("settings_#{setting}", text, options[:label_options])
89 89 end
90 90 end
91 91
92 92 # Renders a notification field for a Redmine::Notifiable option
93 93 def notification_field(notifiable)
94 94 tag_data = notifiable.parent.present? ?
95 95 {:parent_notifiable => notifiable.parent} :
96 96 {:disables => "input[data-parent-notifiable=#{notifiable.name}]"}
97 97
98 98 tag = check_box_tag('settings[notified_events][]',
99 99 notifiable.name,
100 100 Setting.notified_events.include?(notifiable.name),
101 101 :id => nil,
102 102 :data => tag_data)
103 103
104 104 text = l_or_humanize(notifiable.name, :prefix => 'label_')
105 105
106 106 options = {}
107 107 if notifiable.parent.present?
108 108 options[:class] = "parent"
109 109 end
110 110
111 111 content_tag(:label, tag + text, options)
112 112 end
113 113
114 def session_lifetime_options
115 options = [[l(:label_disabled), 0]]
116 options += [4, 8, 12].map {|hours|
117 [l('datetime.distance_in_words.x_hours', :count => hours), (hours * 60).to_s]
118 }
119 options += [1, 7, 30, 60, 365].map {|days|
120 [l('datetime.distance_in_words.x_days', :count => days), (days * 24 * 60).to_s]
121 }
122 options
123 end
124
125 def session_timeout_options
126 options = [[l(:label_disabled), 0]]
127 options += [1, 2, 4, 8, 12, 24, 48].map {|hours|
128 [l('datetime.distance_in_words.x_hours', :count => hours), (hours * 60).to_s]
129 }
130 options
131 end
132
114 133 def link_copied_issue_options
115 134 options = [
116 135 [:general_text_Yes, 'yes'],
117 136 [:general_text_No, 'no'],
118 137 [:label_ask, 'ask']
119 138 ]
120 139
121 140 options.map {|label, value| [l(label), value.to_s]}
122 141 end
123 142
124 143 def cross_project_subtasks_options
125 144 options = [
126 145 [:label_disabled, ''],
127 146 [:label_cross_project_system, 'system'],
128 147 [:label_cross_project_tree, 'tree'],
129 148 [:label_cross_project_hierarchy, 'hierarchy'],
130 149 [:label_cross_project_descendants, 'descendants']
131 150 ]
132 151
133 152 options.map {|label, value| [l(label), value.to_s]}
134 153 end
135 154
136 155 def parent_issue_dates_options
137 156 options = [
138 157 [:label_parent_task_attributes_derived, 'derived'],
139 158 [:label_parent_task_attributes_independent, 'independent']
140 159 ]
141 160
142 161 options.map {|label, value| [l(label), value.to_s]}
143 162 end
144 163
145 164 def parent_issue_priority_options
146 165 options = [
147 166 [:label_parent_task_attributes_derived, 'derived'],
148 167 [:label_parent_task_attributes_independent, 'independent']
149 168 ]
150 169
151 170 options.map {|label, value| [l(label), value.to_s]}
152 171 end
153 172
154 173 def parent_issue_done_ratio_options
155 174 options = [
156 175 [:label_parent_task_attributes_derived, 'derived'],
157 176 [:label_parent_task_attributes_independent, 'independent']
158 177 ]
159 178
160 179 options.map {|label, value| [l(label), value.to_s]}
161 180 end
162 181
163 182 # Returns the options for the date_format setting
164 183 def date_format_setting_options(locale)
165 184 Setting::DATE_FORMATS.map do |f|
166 185 today = ::I18n.l(Date.today, :locale => locale, :format => f)
167 186 format = f.gsub('%', '').gsub(/[dmY]/) do
168 187 {'d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy'}[$&]
169 188 end
170 189 ["#{today} (#{format})", f]
171 190 end
172 191 end
173 192 end
@@ -1,40 +1,40
1 1 <%= form_tag({:action => 'edit', :tab => 'authentication'}) do %>
2 2
3 3 <div class="box tabular settings">
4 4 <p><%= setting_check_box :login_required %></p>
5 5
6 6 <p><%= setting_select :autologin, [[l(:label_disabled), 0]] + [1, 7, 30, 365].collect{|days| [l('datetime.distance_in_words.x_days', :count => days), days.to_s]} %></p>
7 7
8 8 <p><%= setting_select :self_registration, [[l(:label_disabled), "0"],
9 9 [l(:label_registration_activation_by_email), "1"],
10 10 [l(:label_registration_manual_activation), "2"],
11 11 [l(:label_registration_automatic_activation), "3"]] %></p>
12 12
13 13 <p><%= setting_check_box :unsubscribe %></p>
14 14
15 15 <p><%= setting_text_field :password_min_length, :size => 6 %></p>
16 16
17 17 <p>
18 18 <%= setting_select :password_max_age, [[l(:label_disabled), 0]] + [7, 30, 60, 90, 180, 365].collect{|days| [l('datetime.distance_in_words.x_days', :count => days), days.to_s]} %>
19 19 </p>
20 20
21 21 <p><%= setting_check_box :lost_password, :label => :label_password_lost %></p>
22 22
23 23 <p><%= setting_text_field :max_additional_emails, :size => 6 %></p>
24 24
25 25 <p><%= setting_check_box :openid, :disabled => !Object.const_defined?(:OpenID) %></p>
26 26 </div>
27 27
28 28 <fieldset class="box">
29 29 <legend><%= l(:label_session_expiration) %></legend>
30 30
31 31 <div class="tabular settings">
32 <p><%= setting_select :session_lifetime, [[l(:label_disabled), 0]] + [1, 7, 30, 60, 365].collect{|days| [l('datetime.distance_in_words.x_days', :count => days), (days * 60 * 24).to_s]} %></p>
33 <p><%= setting_select :session_timeout, [[l(:label_disabled), 0]] + [1, 2, 4, 8, 12, 24, 48].collect{|hours| [l('datetime.distance_in_words.x_hours', :count => hours), (hours * 60).to_s]} %></p>
32 <p><%= setting_select :session_lifetime, session_lifetime_options %></p>
33 <p><%= setting_select :session_timeout, session_timeout_options %></p>
34 34 </div>
35 35
36 36 <p><em class="info"><%= l(:text_session_expiration_settings) %></em></p>
37 37 </fieldset>
38 38
39 39 <%= submit_tag l(:button_save) %>
40 40 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now