1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-10-17 17:01:01 +00:00
redmine/db/migrate/20150208105930_replace_move_issues_permission.rb
Jean-Philippe Lang 01f673be08 Removed :move_issues permission (#18855).
This permission was wrongly used to allow bulk issue copy. To prevent user from moving an issue to another project, the project field should now be set to read-only in the workflow permissions. A migration does this automatically for roles that have the edit_issues permission without having the move_issues permission.

git-svn-id: http://svn.redmine.org/redmine/trunk@13981 e93f8b46-1217-0410-a6f0-8f06a7374b81
2015-02-08 10:20:53 +00:00

19 lines
663 B
Ruby

class ReplaceMoveIssuesPermission < ActiveRecord::Migration
def self.up
Role.all.each do |role|
if role.has_permission?(:edit_issues) && !role.has_permission?(:move_issues)
# inserts one ligne per trakcer and status
WorkflowPermission.connection.insert_sql(
"INSERT INTO #{WorkflowPermission.table_name} (tracker_id, old_status_id, role_id, type, field_name, rule)" +
" SELECT t.id, s.id, #{role.id}, 'WorkflowPermission', 'project_id', 'readonly'" +
" FROM #{Tracker.table_name} t, #{IssueStatus.table_name} s"
)
end
end
end
def self.down
raise IrreversibleMigration
end
end