Commit 04db8084 authored by jplang's avatar jplang

Fixes ApplicationHelper#link_to_user

* No link to a locked user page (closes #4182)
* Translate Anonymous string

git-svn-id: https://svn.redmine.org/redmine/trunk@3024 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 6662e592
......@@ -44,12 +44,17 @@ module ApplicationHelper
link_to_remote(name, options, html_options) if authorize_for(url[:controller] || params[:controller], url[:action])
end
# Display a link to user's account page
# Displays a link to user's account page if active
def link_to_user(user, options={})
if user.is_a?(User)
!user.anonymous? ? link_to(user.name(options[:format]), :controller => 'users', :action => 'show', :id => user) : 'Anonymous'
name = h(user.name(options[:format]))
if user.active?
link_to name, :controller => 'users', :action => 'show', :id => user
else
name
end
else
user.to_s
h(user.to_s)
end
end
......
......@@ -346,7 +346,7 @@ class AnonymousUser < User
# Overrides a few properties
def logged?; false end
def admin; false end
def name; 'Anonymous' end
def name(*args); I18n.t(:label_user_anonymous) end
def mail; nil end
def time_zone; nil end
def rss_key; nil end
......
......@@ -831,3 +831,4 @@ bg:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -855,3 +855,4 @@ bs:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -834,3 +834,4 @@ ca:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -837,3 +837,4 @@ cs:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -857,3 +857,4 @@ da:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -857,3 +857,4 @@ de:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -837,3 +837,4 @@ el:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -376,6 +376,7 @@ en:
label_user: User
label_user_plural: Users
label_user_new: New user
label_user_anonymous: Anonymous
label_project: Project
label_project_new: New project
label_project_plural: Projects
......
......@@ -878,3 +878,4 @@ es:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -867,3 +867,4 @@ fi:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -398,6 +398,7 @@ fr:
label_user: Utilisateur
label_user_plural: Utilisateurs
label_user_new: Nouvel utilisateur
label_user_anonymous: Anonyme
label_project: Projet
label_project_new: Nouveau projet
label_project_plural: Projets
......
......@@ -857,3 +857,4 @@ gl:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -841,3 +841,4 @@ he:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -862,3 +862,4 @@
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -844,3 +844,4 @@ it:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -866,3 +866,4 @@ ja:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -897,3 +897,4 @@ ko:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -867,3 +867,4 @@ lt:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -819,3 +819,4 @@ nl:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -832,3 +832,4 @@
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -860,3 +860,4 @@ pl:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -863,3 +863,4 @@ pt-BR:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -849,3 +849,4 @@ pt:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -834,3 +834,4 @@ ro:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -945,3 +945,4 @@ ru:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -836,3 +836,4 @@ sk:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -833,3 +833,4 @@ sl:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -852,3 +852,4 @@
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -885,3 +885,4 @@ sv:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -834,3 +834,4 @@ th:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -864,3 +864,4 @@ tr:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -833,3 +833,4 @@ uk:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -896,3 +896,4 @@ vi:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -927,3 +927,4 @@
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -859,3 +859,4 @@ zh:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
label_user_anonymous: Anonymous
......@@ -83,7 +83,7 @@ users_005:
users_006:
id: 6
created_on: 2006-07-19 19:33:19 +02:00
status: 1
status: 0
last_login_on:
language: ''
hashed_password: 1
......
......@@ -483,4 +483,24 @@ EXPECTED
Setting.gravatar_enabled = '0'
assert_nil avatar(User.find_by_mail('jsmith@somenet.foo'))
end
def test_link_to_user
user = User.find(2)
t = link_to_user(user)
assert_equal "<a href=\"/users/2\">#{ user.name }</a>", t
end
def test_link_to_user_should_not_link_to_locked_user
user = User.find(5)
assert user.locked?
t = link_to_user(user)
assert_equal user.name, t
end
def test_link_to_user_should_not_link_to_anonymous
user = User.anonymous
assert user.anonymous?
t = link_to_user(user)
assert_equal ::I18n.t(:label_user_anonymous), t
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment