Patch #6690 » userlink.patch
| app/helpers/application_helper.rb 2012-01-24 09:46:33.000000000 +0100 | ||
|---|---|---|
|
# identifier:version:1.0.0
|
||
|
# identifier:source:some/file
|
||
|
def parse_redmine_links(text, project, obj, attr, only_path, options)
|
||
|
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
|
||
|
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export|user)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
|
||
|
leading, esc, project_prefix, project_identifier, prefix, sep, identifier = $1, $2, $3, $4, $5, $7 || $9, $8 || $10
|
||
|
link = nil
|
||
|
if project_identifier
|
||
| ... | ... | |
|
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
|
||