Added an option to turn user Gravatars on or off

* Option can be found in Administration > General, called
  "Use Gravatar user icons"
* Defaulting Gravatars to off
* Added a helper gravatar_for_mail to check the setting before rendering
  the Gravatar.

  #1776


git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1972 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis 2008-10-31 00:41:28 +00:00
parent 048fa5bd77
commit ba20a67873
9 changed files with 21 additions and 10 deletions

View File

@ -561,6 +561,12 @@ module ApplicationHelper
(@has_content && @has_content[name]) || false (@has_content && @has_content[name]) || false
end end
def gravatar_for_mail(mail, options = { })
if Setting.gravatar_enabled?
return gravatar(mail, options) rescue nil
end
end
private private
def wiki_helper def wiki_helper

View File

@ -2,7 +2,7 @@
<%= link_to(l(:button_edit), {:controller => 'users', :action => 'edit', :id => @user}, :class => 'icon icon-edit') if User.current.admin? %> <%= link_to(l(:button_edit), {:controller => 'users', :action => 'edit', :id => @user}, :class => 'icon icon-edit') if User.current.admin? %>
</div> </div>
<h2><%= gravatar @user.mail unless @user.mail.empty? %> <%=h @user.name %></h2> <h2><%= gravatar_for_mail @user.mail unless @user.mail.empty? %> <%=h @user.name %></h2>
<p> <p>
<%= mail_to(h(@user.mail)) unless @user.pref.hide_mail %> <%= mail_to(h(@user.mail)) unless @user.pref.hide_mail %>

View File

@ -4,7 +4,7 @@
<h4><div style="float:right;"><%= link_to "##{journal.indice}", :anchor => "note-#{journal.indice}" %></div> <h4><div style="float:right;"><%= link_to "##{journal.indice}", :anchor => "note-#{journal.indice}" %></div>
<%= content_tag('a', '', :name => "note-#{journal.indice}")%> <%= content_tag('a', '', :name => "note-#{journal.indice}")%>
<%= format_time(journal.created_on) %> - <%= journal.user.name %></h4> <%= format_time(journal.created_on) %> - <%= journal.user.name %></h4>
<%= gravatar(journal.user.mail.blank? ? "" : journal.user.mail, :size => "32") %> <%= gravatar_for_mail(journal.user.mail.blank? ? "" : journal.user.mail, :size => "32") %>
<ul> <ul>
<% for detail in journal.details %> <% for detail in journal.details %>
<li><%= show_detail(detail) %></li> <li><%= show_detail(detail) %></li>

View File

@ -10,7 +10,7 @@
<h2><%= @issue.tracker.name %> #<%= @issue.id %></h2> <h2><%= @issue.tracker.name %> #<%= @issue.id %></h2>
<div class="issue <%= "status-#{@issue.status.position} priority-#{@issue.priority.position}" %>"> <div class="issue <%= "status-#{@issue.status.position} priority-#{@issue.priority.position}" %>">
<%= gravatar(@issue.author.mail, :size => "64") rescue nil %> <%= gravatar_for_mail(@issue.author.mail, :size => "64") %>
<h3><%=h @issue.subject %></h3> <h3><%=h @issue.subject %></h3>
<p class="author"> <p class="author">
<%= authoring @issue.created_on, @issue.author %>. <%= authoring @issue.created_on, @issue.author %>.
@ -27,7 +27,7 @@
<td class="due-date"><b><%=l(:field_due_date)%>:</b></td><td class="due-date"><%= format_date(@issue.due_date) %></td> <td class="due-date"><b><%=l(:field_due_date)%>:</b></td><td class="due-date"><%= format_date(@issue.due_date) %></td>
</tr> </tr>
<tr> <tr>
<td class="assigned-to"><b><%=l(:field_assigned_to)%>:</b></td><td><%= gravatar(@issue.assigned_to.mail, :size => "14") unless @issue.assigned_to.blank?%><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td> <td class="assigned-to"><b><%=l(:field_assigned_to)%>:</b></td><td><%= gravatar_for_mail(@issue.assigned_to.mail, :size => "14") unless @issue.assigned_to.blank?%><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td>
<td class="progress"><b><%=l(:field_done_ratio)%>:</b></td><td class="progress"><%= progress_bar @issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%" %></td> <td class="progress"><b><%=l(:field_done_ratio)%>:</b></td><td class="progress"><%= progress_bar @issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%" %></td>
</tr> </tr>
<tr> <tr>

View File

@ -7,9 +7,9 @@
<dl> <dl>
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> <% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
<dt class="<%= e.event_type %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>"> <dt class="<%= e.event_type %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
<%= gravatar(e.user.mail, :size => "24") if e.respond_to?(:user) rescue nil%> <%= gravatar_for_mail(e.user.mail, :size => "24") if e.respond_to?(:user) %>
<%= gravatar(e.author.mail, :size => "24") if e.respond_to?(:author) rescue nil%> <%= gravatar_for_mail(e.author.mail, :size => "24") if e.respond_to?(:author) %>
<%= gravatar(e.committer.match('\\<.+?\\>')[0].gsub(/[<>]/, ''), :size => "24") if e.respond_to?(:committer) rescue nil%> <%= gravatar_for_mail(e.committer.match('\\<.+?\\>')[0].gsub(/[<>]/, ''), :size => "24") if e.respond_to?(:committer) rescue nil %>
<span class="time"><%= format_time(e.event_datetime, false) %></span> <span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %> <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %>
<%= link_to format_activity_title(e.event_title), e.event_url %></dt> <%= link_to format_activity_title(e.event_title), e.event_url %></dt>

View File

@ -46,6 +46,9 @@
<p><label><%= l(:setting_feeds_limit) %></label> <p><label><%= l(:setting_feeds_limit) %></label>
<%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p> <%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></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>
</div> </div>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>

View File

@ -29,7 +29,7 @@
<tbody> <tbody>
<% for user in @users -%> <% for user in @users -%>
<tr class="user <%= cycle("odd", "even") %> <%= %w(anon active registered locked)[user.status] %>"> <tr class="user <%= cycle("odd", "even") %> <%= %w(anon active registered locked)[user.status] %>">
<td class="username"><%= gravatar(user.mail.blank? ? "" : user.mail, :size => "24") %><%= link_to h(user.login), :action => 'edit', :id => user %></td> <td class="username"><%= gravatar_for_mail(user.mail.blank? ? "" : user.mail, :size => "24") %><%= link_to h(user.login), :action => 'edit', :id => user %></td>
<td class="firstname"><%= h(user.firstname) %></td> <td class="firstname"><%= h(user.firstname) %></td>
<td class="lastname"><%= h(user.lastname) %></td> <td class="lastname"><%= h(user.lastname) %></td>
<td class="email"><%= mail_to(h(user.mail)) %></td> <td class="email"><%= mail_to(h(user.mail)) %></td>

View File

@ -135,4 +135,5 @@ emails_footer:
default: |- default: |-
You have received this notification because you have either subscribed to it, or are involved in it. You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://hostname/my/account To change your notification preferences, please click here: http://hostname/my/account
gravatar_enabled:
default: 0

View File

@ -222,6 +222,7 @@ setting_enabled_scm: Enabled SCM
setting_mail_handler_api_enabled: Enable WS for incoming emails setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key setting_mail_handler_api_key: API key
setting_sequential_project_identifiers: Generate sequential project identifiers setting_sequential_project_identifiers: Generate sequential project identifiers
setting_gravatar_enabled: Use Gravatar user icons
permission_edit_project: Edit project permission_edit_project: Edit project
permission_select_project_modules: Select project modules permission_select_project_modules: Select project modules