From 6c8b87fbc8a52b53a0adb53f072508ade7e2dca6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 6 Feb 2010 09:30:53 +0000 Subject: [PATCH] Adds a permission for exporting wiki pages. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3371 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/wiki_controller.rb | 28 +++++++++++++++---------- app/views/wiki/show.rhtml | 2 +- app/views/wiki/special_date_index.rhtml | 2 +- app/views/wiki/special_page_index.rhtml | 2 +- config/locales/bg.yml | 1 + config/locales/bs.yml | 1 + config/locales/ca.yml | 1 + config/locales/cs.yml | 1 + config/locales/da.yml | 1 + config/locales/de.yml | 1 + config/locales/el.yml | 1 + config/locales/en.yml | 1 + config/locales/es.yml | 1 + config/locales/eu.yml | 1 + config/locales/fi.yml | 1 + config/locales/fr.yml | 1 + config/locales/gl.yml | 1 + config/locales/he.yml | 1 + config/locales/hr.yml | 1 + config/locales/hu.yml | 1 + config/locales/id.yml | 1 + config/locales/it.yml | 1 + config/locales/ja.yml | 1 + config/locales/ko.yml | 1 + config/locales/lt.yml | 1 + config/locales/nl.yml | 1 + config/locales/no.yml | 1 + config/locales/pl.yml | 1 + config/locales/pt-BR.yml | 1 + config/locales/pt.yml | 1 + config/locales/ro.yml | 1 + config/locales/ru.yml | 1 + config/locales/sk.yml | 1 + config/locales/sl.yml | 1 + config/locales/sr.yml | 1 + config/locales/sv.yml | 1 + config/locales/th.yml | 1 + config/locales/tr.yml | 1 + config/locales/uk.yml | 1 + config/locales/vi.yml | 1 + config/locales/zh-TW.yml | 1 + config/locales/zh.yml | 1 + lib/redmine.rb | 1 + test/fixtures/roles.yml | 1 + 44 files changed, 60 insertions(+), 14 deletions(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 782f939d6..97e1531c0 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 0ae8c10dc..690e9102b 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 53b7124c1..228737a5e 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 0b8eeccce..b3ad10019 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 7c699e1f0..d48c09314 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 28fddcbd5..6d297fefe 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 3f440c92c..dc033a24e 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 a6c18e88a..dd4cea30b 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 99e9a0df5..1da8ac2fc 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 e4c35d143..ddb292c5d 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 c1c1e40b7..3943cb5c3 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 37e9963ab..c8b0ddbee 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 360f488d2..8bc7c8c18 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 ba48eebf3..04bb5c5b7 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 822bb4351..9ed111556 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 1449abb57..99c4361f0 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 707eff4a3..b606ad46d 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 af7aa883a..c2604ee50 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 bf3dc46cf..4244e5b6c 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 603fd19db..f419aa301 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 9e98bbfe2..db92948ae 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 c43d41b53..a3c12ad3f 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 2f3336a6c..4a0fb8941 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 09bedd63e..99fc180b3 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 289db4433..43158bcca 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 7c85fbbd0..024db3238 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 6eabaeb25..726dadb46 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 84cc3ec86..5d4e62e55 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 300d5e773..53f968ad1 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 0acfa0dd5..5d9d8ce46 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 55a61634c..257cf8e19 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 451e70089..2dd495212 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 009ec0294..c1070ab16 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 9a640e010..b12c77d78 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 2d1c7112f..28eaaaa3c 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 64d6b0aba..d0488ad96 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 3c47b7609..c5982851f 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 673762b0e..86b365d85 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 0bf649b47..4ae064d69 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 3ec9d57f9..c66cdd53b 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 b94713379..db5bfa2e8 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 632103a6e..8e7dc4d1c 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 0cf0cc497..9d9de9cf9 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 22f690328..e3dc3645f 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 -- 2.39.5