Project

General

Profile

Patch #6690 » redmine-userlink.diff

Ahmad Azhar, 2010-10-18 06:49

View differences:

app/helpers/application_helper.rb (working copy)
# Forum messages:
# message#1218 -> Link to message with id 1218
def parse_redmine_links(text, project, obj, attr, only_path, options)
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(attachment|document|version|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(attachment|document|version|commit|source|export|message|project|user)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
leading, esc, prefix, sep, identifier = $1, $2, $3, $5 || $7, $6 || $8
link = nil
if esc.nil?
......
if p = Project.visible.find_by_id(oid)
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
end
when 'user'
if u = User.find_by_id(oid)
link = link_to_user(u)
end
end
elsif sep == ':'
# removes the double quotes if any
......
if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
end
when 'user'
if u = User.find_by_login(name)
link = link_to_user(u)
end
end
end
end
(1-1/3)