Feature #9600 » redmine-1.2.1-redmine_link_board_and_news.patch
| redmine-1.2.1/app/helpers/application_helper.rb 2011-07-11 15:47:16.000000000 +0400 → redmine-1.2.1/app/helpers/application_helper.rb 2011-11-18 15:20:37.000000000 +0400 | ||
|---|---|---|
|
# 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|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
|
||
|
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-]+):)?(attachment|document|version|board|news|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\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 message = Message.visible.find_by_id(oid, :include => :parent)
|
||
|
link = link_to_message(message, {:only_path => only_path}, :class => 'message')
|
||
|
end
|
||
|
when 'board'
|
||
|
if board = Board.visible.find_by_id(oid)
|
||
|
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
||
|
:class => 'board'
|
||
|
end
|
||
|
when 'news'
|
||
|
if news = News.visible.find_by_id(oid)
|
||
|
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
||
|
:class => 'news'
|
||
|
end
|
||
|
when 'project'
|
||
|
if p = Project.visible.find_by_id(oid)
|
||
|
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
||
| ... | ... | |
|
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
||
|
:class => 'version'
|
||
|
end
|
||
|
when 'board'
|
||
|
if project && board = project.boards.visible.find_by_name(name)
|
||
|
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
||
|
:class => 'board'
|
||
|
end
|
||
|
when 'news'
|
||
|
if project && news = project.news.visible.find_by_title(name)
|
||
|
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
||
|
:class => 'news'
|
||
|
end
|
||
|
when 'commit'
|
||
|
if project && project.repository && (changeset = Changeset.visible.find(:first, :conditions => ["repository_id = ? AND scmid LIKE ?", project.repository.id, "#{name}%"]))
|
||
|
link = link_to h("#{project_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.identifier},
|
||
| redmine-1.2.1/app/models/board.rb 2011-07-11 15:47:16.000000000 +0400 → redmine-1.2.1/app/models/board.rb 2011-11-18 14:22:57.000000000 +0400 | ||
|---|---|---|
|
validates_length_of :name, :maximum => 30
|
||
|
validates_length_of :description, :maximum => 255
|
||
|
|
||
|
named_scope :visible, lambda {|*args| { :include => :project,
|
||
|
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
|
||
|
|
||
|
def visible?(user=User.current)
|
||
|
!user.nil? && user.allowed_to?(:view_messages, project)
|
||
|
end
|
||