diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 782f939d..97e1531c 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -47,15 +47,17 @@ class WikiController < ApplicationController return end @content = @page.content_for_version(params[:version]) - if params[:format] == 'html' - export = render_to_string :action => 'export', :layout => false - send_data(export, :type => 'text/html', :filename => "#{@page.title}.html") - return - elsif params[:format] == 'txt' - send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt") - return + if User.current.allowed_to?(:export_wiki_pages, @project) + if params[:format] == 'html' + export = render_to_string :action => 'export', :layout => false + send_data(export, :type => 'text/html', :filename => "#{@page.title}.html") + return + elsif params[:format] == 'txt' + send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt") + return + end end - @editable = editable? + @editable = editable? render :action => 'show' end @@ -177,9 +179,13 @@ class WikiController < ApplicationController @pages_by_parent_id = @pages.group_by(&:parent_id) # export wiki to a single html file when 'export' - @pages = @wiki.pages.find :all, :order => 'title' - export = render_to_string :action => 'export_multiple', :layout => false - send_data(export, :type => 'text/html', :filename => "wiki.html") + if User.current.allowed_to?(:export_wiki_pages, @project) + @pages = @wiki.pages.find :all, :order => 'title' + export = render_to_string :action => 'export_multiple', :layout => false + send_data(export, :type => 'text/html', :filename => "wiki.html") + else + redirect_to :action => 'index', :id => @project, :page => nil + end return else # requested special page doesn't exist, redirect to default page diff --git a/app/views/wiki/show.rhtml b/app/views/wiki/show.rhtml index 0ae8c10d..690e9102 100644 --- a/app/views/wiki/show.rhtml +++ b/app/views/wiki/show.rhtml @@ -48,7 +48,7 @@ <% other_formats_links do |f| %> <%= f.link_to 'HTML', :url => {:page => @page.title, :version => @content.version} %> <%= f.link_to 'TXT', :url => {:page => @page.title, :version => @content.version} %> -<% end %> +<% end if User.current.allowed_to?(:export_wiki_pages, @project) %> <% content_for :header_tags do %> <%= stylesheet_link_tag 'scm' %> diff --git a/app/views/wiki/special_date_index.rhtml b/app/views/wiki/special_date_index.rhtml index 53b7124c..228737a5 100644 --- a/app/views/wiki/special_date_index.rhtml +++ b/app/views/wiki/special_date_index.rhtml @@ -24,7 +24,7 @@ <% unless @pages.empty? %> <% other_formats_links do |f| %> <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %> - <%= f.link_to 'HTML', :url => {:action => 'special', :page => 'export'} %> + <%= f.link_to('HTML', :url => {:action => 'special', :page => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %> <% end %> <% end %> diff --git a/app/views/wiki/special_page_index.rhtml b/app/views/wiki/special_page_index.rhtml index 0b8eeccc..b3ad1001 100644 --- a/app/views/wiki/special_page_index.rhtml +++ b/app/views/wiki/special_page_index.rhtml @@ -17,7 +17,7 @@ <% unless @pages.empty? %> <% other_formats_links do |f| %> <%= f.link_to 'Atom', :url => {:controller => 'projects', :action => 'activity', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %> - <%= f.link_to 'HTML', :url => {:action => 'special', :page => 'export'} %> + <%= f.link_to('HTML', :url => {:action => 'special', :page => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %> <% end %> <% end %> diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 7c699e1f..d48c0931 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -878,3 +878,4 @@ bg: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/bs.yml b/config/locales/bs.yml index 28fddcbd..6d297fef 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -902,3 +902,4 @@ bs: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 3f440c92..dc033a24 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -881,3 +881,4 @@ ca: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/cs.yml b/config/locales/cs.yml index a6c18e88..dd4cea30 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -884,3 +884,4 @@ cs: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/da.yml b/config/locales/da.yml index 99e9a0df..1da8ac2f 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -904,3 +904,4 @@ da: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/de.yml b/config/locales/de.yml index e4c35d14..ddb292c5 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -904,3 +904,4 @@ de: label_close_versions: Vollständige Versionen schließen label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/el.yml b/config/locales/el.yml index c1c1e40b..3943cb5c 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -884,3 +884,4 @@ el: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/en.yml b/config/locales/en.yml index 37e9963a..c8b0ddbe 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -382,6 +382,7 @@ en: permission_edit_own_messages: Edit own messages permission_delete_messages: Delete messages permission_delete_own_messages: Delete own messages + permission_export_wiki_pages: Export wiki pages project_module_issue_tracking: Issue tracking project_module_time_tracking: Time tracking diff --git a/config/locales/es.yml b/config/locales/es.yml index 360f488d..8bc7c8c1 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -928,3 +928,4 @@ es: label_close_versions: Cerrar versiones completadas label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/eu.yml b/config/locales/eu.yml index ba48eebf..04bb5c5b 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -888,3 +888,4 @@ eu: enumeration_system_activity: Sistemako Jarduera label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 822bb435..9ed11155 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -914,3 +914,4 @@ fi: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 1449abb5..99c4361f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -405,6 +405,7 @@ fr: permission_edit_own_messages: Modifier ses propres messages permission_delete_messages: Supprimer les messages permission_delete_own_messages: Supprimer ses propres messages + permission_export_wiki_pages: Exporter les pages project_module_issue_tracking: Suivi des demandes project_module_time_tracking: Suivi du temps passé diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 707eff4a..b606ad46 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -904,3 +904,4 @@ gl: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/he.yml b/config/locales/he.yml index af7aa883..c2604ee5 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -888,3 +888,4 @@ he: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/hr.yml b/config/locales/hr.yml index bf3dc46c..4244e5b6 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -891,3 +891,4 @@ hr: Are you sure you want to continue? label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 603fd19d..f419aa30 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -909,3 +909,4 @@ label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/id.yml b/config/locales/id.yml index 9e98bbfe..db92948a 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -896,3 +896,4 @@ id: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/it.yml b/config/locales/it.yml index c43d41b5..a3c12ad3 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -891,3 +891,4 @@ it: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 2f3336a6..4a0fb894 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -913,3 +913,4 @@ ja: enumeration_doc_categories: 文書カテゴリ enumeration_activities: 作業分類 (時間トラッキング) enumeration_system_activity: システム作業分類 + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 09bedd63..99fc180b 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -944,3 +944,4 @@ ko: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/lt.yml b/config/locales/lt.yml index 289db443..43158bcc 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -952,3 +952,4 @@ lt: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 7c85fbbd..024db323 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -866,3 +866,4 @@ nl: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/no.yml b/config/locales/no.yml index 6eabaeb2..726dadb4 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -879,3 +879,4 @@ label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 84cc3ec8..5d4e62e5 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -909,3 +909,4 @@ pl: label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 300d5e77..53f968ad 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -912,3 +912,4 @@ pt-BR: label_board_sticky: Marcado label_board_locked: Travado label_change_log: Registro de alterações + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 0acfa0dd..5d9d8ce4 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -896,3 +896,4 @@ pt: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/ro.yml b/config/locales/ro.yml index 55a61634..257cf8e1 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -881,3 +881,4 @@ ro: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 451e7008..2dd49521 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -992,3 +992,4 @@ ru: label_close_versions: Закрыть завершенные версии label_board_sticky: Прикреплена label_board_locked: Заблокирована + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 009ec029..c1070ab1 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -883,3 +883,4 @@ sk: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 9a640e01..b12c77d7 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -880,3 +880,4 @@ sl: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 2d1c7112..28eaaaa3 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -899,3 +899,4 @@ label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 64d6b0ab..d0488ad9 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -933,3 +933,4 @@ sv: enumeration_doc_categories: Dokumentkategorier enumeration_activities: Aktiviteter (tidsuppföljning) enumeration_system_activity: Systemaktivitet + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/th.yml b/config/locales/th.yml index 3c47b760..c5982851 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -881,3 +881,4 @@ th: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 673762b0..86b365d8 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -911,3 +911,4 @@ tr: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 0bf649b4..4ae064d6 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -880,3 +880,4 @@ uk: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 3ec9d57f..c66cdd53 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -943,3 +943,4 @@ vi: label_close_versions: Close completed versions label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index b9471337..db5bfa2e 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -975,3 +975,4 @@ enumeration_doc_categories: 文件分類 enumeration_activities: 活動 (時間追蹤) enumeration_system_activity: 系統活動 + permission_export_wiki_pages: Export wiki pages diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 632103a6..8e7dc4d1 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -906,3 +906,4 @@ zh: enumeration_system_activity: 系统活动 label_board_sticky: Sticky label_board_locked: Locked + permission_export_wiki_pages: Export wiki pages diff --git a/lib/redmine.rb b/lib/redmine.rb index 0cf0cc49..9d9de9cf 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -92,6 +92,7 @@ Redmine::AccessControl.map do |map| map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member map.permission :view_wiki_pages, :wiki => [:index, :special] + map.permission :export_wiki_pages, {} map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment] map.permission :delete_wiki_pages_attachments, {} diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml index 22f69032..e3dc3645 100644 --- a/test/fixtures/roles.yml +++ b/test/fixtures/roles.yml @@ -33,6 +33,7 @@ roles_001: - :view_documents - :manage_documents - :view_wiki_pages + - :export_wiki_pages - :view_wiki_edits - :edit_wiki_pages - :delete_wiki_pages_attachments