Patch #7770 ยป code_cleanup_ifnot_unless.diff
| app/controllers/application_controller.rb | ||
|---|---|---|
|
end
|
||
|
if lang.nil? && request.env['HTTP_ACCEPT_LANGUAGE']
|
||
|
accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first
|
||
|
if !accept_lang.blank?
|
||
|
unless accept_lang.blank?
|
||
|
accept_lang = accept_lang.downcase
|
||
|
lang = find_language(accept_lang) || find_language(accept_lang.split('-').first)
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
def require_login
|
||
|
if !User.current.logged?
|
||
|
unless User.current.logged?
|
||
|
# Extract only the basic url parameters on non-GET requests
|
||
|
if request.get?
|
||
|
url = url_for(params)
|
||
| ... | ... | |
|
def require_admin
|
||
|
return unless require_login
|
||
|
if !User.current.admin?
|
||
|
unless User.current.admin?
|
||
|
render_403
|
||
|
return false
|
||
|
end
|
||
| ... | ... | |
|
def redirect_back_or_default(default)
|
||
|
back_url = CGI.unescape(params[:back_url].to_s)
|
||
|
if !back_url.blank?
|
||
|
unless back_url.blank?
|
||
|
begin
|
||
|
uri = URI.parse(back_url)
|
||
|
# do not redirect user to another host or to the login or register page
|
||
| app/controllers/messages_controller.rb | ||
|---|---|---|
|
@reply.author = User.current
|
||
|
@reply.board = @board
|
||
|
@topic.children << @reply
|
||
|
if !@reply.new_record?
|
||
|
unless @reply.new_record?
|
||
|
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
|
||
|
attachments = Attachment.attach_files(@reply, params[:attachments])
|
||
|
render_attachment_warning_if_needed(@reply)
|
||
| app/controllers/search_controller.rb | ||
|---|---|---|
|
# tokens must be at least 2 characters long
|
||
|
@tokens = @tokens.uniq.select {|w| w.length > 1 }
|
||
|
|
||
|
if !@tokens.empty?
|
||
|
unless @tokens.empty?
|
||
|
# no more than 5 tokens to search for
|
||
|
@tokens.slice! 5..-1 if @tokens.size > 5
|
||
|
|
||
| app/helpers/application_helper.rb | ||
|---|---|---|
|
s = StringScanner.new(text)
|
||
|
tags = []
|
||
|
parsed = ''
|
||
|
while !s.eos?
|
||
|
until s.eos?
|
||
|
s.scan(/(.*?)(<(\/)?(pre|code)(.*?)>|\z)/im)
|
||
|
text, full_tag, closing, tag = s[1], s[2], s[3], s[4]
|
||
|
if tags.empty?
|
||
| app/helpers/journals_helper.rb | ||
|---|---|---|
|
content = ''
|
||
|
editable = User.current.logged? && (User.current.allowed_to?(:edit_issue_notes, issue.project) || (journal.user == User.current && User.current.allowed_to?(:edit_own_issue_notes, issue.project)))
|
||
|
links = []
|
||
|
if !journal.notes.blank?
|
||
|
unless journal.notes.blank?
|
||
|
links << link_to_remote(image_tag('comment.png'),
|
||
|
{ :url => {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal} },
|
||
|
{ :url => { :controller => 'journals',
|
||
|
:action => 'new',
|
||
|
:id => issue,
|
||
|
:journal_id => journal} },
|
||
|
:title => l(:button_quote)) if options[:reply_links]
|
||
|
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
|
||
|
{ :controller => 'journals', :action => 'edit', :id => journal },
|
||
|
:title => l(:button_edit)) if editable
|
||
|
links << link_to_in_place_notes_editor(image_tag('edit.png'),
|
||
|
"journal-#{journal.id}-notes",
|
||
|
{ :controller => 'journals',
|
||
|
:action => 'edit',
|
||
|
:id => journal },
|
||
|
:title => l(:button_edit)) if editable
|
||
|
end
|
||
|
content << content_tag('div', links.join(' '), :class => 'contextual') unless links.empty?
|
||
|
content << textilizable(journal, :notes)
|
||
| app/helpers/repositories_helper.rb | ||
|---|---|---|
|
case change.action
|
||
|
when 'A'
|
||
|
# Detects moved/copied files
|
||
|
if !change.from_path.blank?
|
||
|
unless change.from_path.blank?
|
||
|
change.action = @changeset.changes.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C'
|
||
|
end
|
||
|
change
|
||
| ... | ... | |
|
def replace_invalid_utf8(str)
|
||
|
if str.respond_to?(:force_encoding)
|
||
|
str.force_encoding('UTF-8')
|
||
|
if ! str.valid_encoding?
|
||
|
str = str.encode("US-ASCII", :invalid => :replace,
|
||
|
:undef => :replace, :replace => '?').encode("UTF-8")
|
||
|
unless str.valid_encoding?
|
||
|
str = str.encode("US-ASCII", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8")
|
||
|
end
|
||
|
end
|
||
|
str
|
||
| app/models/auth_source_ldap.rb | ||
|---|---|---|
|
end
|
||
|
|
||
|
def self.get_attr(entry, attr_name)
|
||
|
if !attr_name.blank?
|
||
|
unless attr_name.blank?
|
||
|
entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name]
|
||
|
end
|
||
|
end
|
||
| app/models/changeset.rb | ||
|---|---|---|
|
end
|
||
|
if str.respond_to?(:force_encoding)
|
||
|
str.force_encoding('UTF-8')
|
||
|
if ! str.valid_encoding?
|
||
|
unless str.valid_encoding?
|
||
|
str = str.encode("US-ASCII", :invalid => :replace,
|
||
|
:undef => :replace, :replace => '?').encode("UTF-8")
|
||
|
end
|
||
| app/models/user.rb | ||
|---|---|---|
|
user = find_by_login(login)
|
||
|
if user
|
||
|
# user is already in local database
|
||
|
return nil if !user.active?
|
||
|
return nil unless user.active?
|
||
|
if user.auth_source
|
||
|
# user has an external authentication method
|
||
|
return nil unless user.auth_source.authenticate(login, password)
|
||
| app/views/context_menus/issues.html.erb | ||
|---|---|---|
|
</li>
|
||
|
<% end %>
|
||
|
<% if !@issue.nil? %>
|
||
|
<% unless @issue.nil? %>
|
||
|
<% if @can[:log_time] -%>
|
||
|
<li><%= context_menu_link l(:button_log_time), {:controller => 'timelog', :action => 'new', :issue_id => @issue},
|
||
|
:class => 'icon-time-add' %></li>
|
||
| app/views/projects/show.rhtml | ||
|---|---|---|
|
<%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
|
||
|
<% end %>
|
||
|
<% @project.visible_custom_field_values.each do |custom_value| %>
|
||
|
<% if !custom_value.value.blank? %>
|
||
|
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
||
|
<% end %>
|
||
|
<% unless custom_value.value.blank? %>
|
||
|
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</ul>
|
||
| app/views/users/show.rhtml | ||
|---|---|---|
|
<li><%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></li>
|
||
|
<% end %>
|
||
|
<% @user.visible_custom_field_values.each do |custom_value| %>
|
||
|
<% if !custom_value.value.blank? %>
|
||
|
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
||
|
<% end %>
|
||
|
<% unless custom_value.value.blank? %>
|
||
|
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
<li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
|
||
|
<% unless @user.last_login_on.nil? %>
|
||
| app/views/versions/_overview.rhtml | ||
|---|---|---|
|
<p><%=h version.description %></p>
|
||
|
<ul>
|
||
|
<% version.custom_values.each do |custom_value| %>
|
||
|
<% if !custom_value.value.blank? %>
|
||
|
<% unless custom_value.value.blank? %>
|
||
|
<li><%=h custom_value.custom_field.name %>: <%=h show_value(custom_value) %></li>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
| lib/redmine/about.rb | ||
|---|---|---|
|
def self.print_plugin_info
|
||
|
plugins = Redmine::Plugin.registered_plugins
|
||
|
if !plugins.empty?
|
||
|
unless plugins.empty?
|
||
|
column_with = plugins.map {|internal_name, plugin| plugin.name.length}.max
|
||
|
puts "\nAbout your Redmine plugins"
|
||
| lib/redmine/scm/adapters/git_adapter.rb | ||
|---|---|---|
|
from_to = ""
|
||
|
from_to << "#{identifier_from}.." if identifier_from
|
||
|
from_to << "#{identifier_to}" if identifier_to
|
||
|
cmd_args << from_to if !from_to.empty?
|
||
|
cmd_args << from_to unless from_to.empty?
|
||
|
cmd_args << "--since=#{options[:since].strftime("%Y-%m-%d %H:%M:%S")}" if options[:since]
|
||
|
cmd_args << "--" << path if path && !path.empty?
|
||
| lib/tasks/migrate_from_trac.rake | ||
|---|---|---|
|
return User.anonymous if username.blank?
|
||
|
u = User.find_by_login(username)
|
||
|
if !u
|
||
|
unless u
|
||
|
# Create a new user if not found
|
||
|
mail = username[0,limit_for(User, 'mail')]
|
||
|
if mail_attr = TracSessionAttribute.find_by_sid_and_name(username, 'email')
|
||