Project

General

Profile

Feature #5095 » add_to_permissions_from_plugins.patch

patch - Lluís Gili, 2010-03-16 13:46

View differences:

lib/redmine/access_control.rb
103 103
        end
104 104
        @actions.flatten!
105 105
      end
106
      
106

  
107
      def add_actions(hash)
108
        hash.each do |controller, actions|
109
          if actions.is_a? Array
110
            @actions << actions.collect {|action| "#{controller}/#{action}"}
111
          else
112
            @actions << "#{controller}/#{actions}"
113
          end
114
        end
115
        @actions.flatten!
116
      end
117

  
107 118
      def public?
108 119
        @public
109 120
      end
lib/redmine/plugin.rb
213 213
        Redmine::AccessControl.map {|map| map.permission(name, actions, options)}
214 214
      end
215 215
    end
216

  
217
    def add_permission(name, actions)
218
      AccessControl.permission(name).add_actions(actions) unless AccessControl.permission(name).nil?
219
    end
216 220
    
217 221
    # Defines a project module, that can be enabled/disabled for each project.
218 222
    # Permissions defined inside +block+ will be bind to the module.
(1-1/2)