Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Check :export_work_packages permission on the work package

Klaus Zanders622b9d9813f7
diff --git a/app/controllers/work_packages_controller.rb b/app/controllers/work_packages_controller.rb
index 1f9ccf85399..0635b21b775 100644
--- a/app/controllers/work_packages_controller.rb
+++ b/app/controllers/work_packages_controller.rb
@@ -135,11 +135,7 @@ class WorkPackagesController < ApplicationController
end
def user_allowed_to_export?
- if @project
- User.current.allowed_in_project?(:export_work_packages, @project)
- else
- User.current.allowed_in_any_project?(:export_work_packages)
- end
+ User.current.allowed_in_any_work_package?(:export_work_packages, in_project: @project)
end
def supported_list_formats
diff --git a/lib/api/v3/work_packages/work_package_collection_representer.rb b/lib/api/v3/work_packages/work_package_collection_representer.rb
index e52146616cd..e33c01989fe 100644
--- a/lib/api/v3/work_packages/work_package_collection_representer.rb
+++ b/lib/api/v3/work_packages/work_package_collection_representer.rb
@@ -135,8 +135,7 @@ module API
end
links :representations do
- if (project && current_user.allowed_in_project?(:export_work_packages, project)) ||
- (!project && current_user.allowed_in_any_project?(:export_work_packages))
+ if current_user.allowed_in_any_work_package?(:export_work_packages, in_project: project)
representation_formats
end
end
diff --git a/modules/reporting/app/views/cost_reports/index.html.erb b/modules/reporting/app/views/cost_reports/index.html.erb
index 22ea7be6ab9..6a9e4f34291 100644
--- a/modules/reporting/app/views/cost_reports/index.html.erb
+++ b/modules/reporting/app/views/cost_reports/index.html.erb
@@ -43,7 +43,7 @@ See COPYRIGHT and LICENSE files for more details.
</h2>
</div>
<ul class="toolbar-items">
- <% if (@project && User.current.allowed_in_project?(:export_work_packages, @project)) || (@project.nil? && User.current.allowed_in_any_project?(:export_work_packages)) %>
+ <% if User.current.allowed_in_any_work_package?(:export_work_packages, in_project: @project) %>
<li class="toolbar-item">
<%= link_to(t(:export_to_excel),
{ controller: "cost_reports" ,