0001-Added-edit_own_issues-and-edit_own_new_issues-permis.patch

Leo Hourvitz, 2010-10-08 05:41

Download (5.88 KB)

View differences:

app/controllers/issues_controller.rb
104 104
    @changesets = @issue.changesets.visible.all
105 105
    @changesets.reverse! if User.current.wants_comments_in_reverse_order?
106 106
    @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
107
    @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
107
    @edit_allowed = @issue.editable?
108 108
    @priorities = IssuePriority.all
109 109
    @time_entry = TimeEntry.new
110 110
    respond_to do |format|
......
268 268
  def update_issue_from_params
269 269
    @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
270 270
    @priorities = IssuePriority.all
271
    @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
271
    @edit_allowed = @issue.editable?
272 272
    @time_entry = TimeEntry.new
273 273
    
274 274
    @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
app/models/issue.rb
96 96
    (usr || User.current).allowed_to?(:view_issues, self.project)
97 97
  end
98 98
  
99
  # Returns true if usr or current user is allowed to edit the issue
100
  def editable?(usr=nil)
101
    user = usr || User.current
102
	return user.allowed_to?(:edit_issues, @project) ||
103
		( user.allowed_to?(:edit_own_issues, @project) && @author == user ) ||
104
		( user.allowed_to?(:edit_own_new_issues, @project) && @author == user &&
105
		  ((!@journals) || @journals.reduce(true) { |all_mine,j| all_mine &&= j.user == user }))
106
  end
107
  
99 108
  def after_initialize
100 109
    if new_record?
101 110
      # set default values for new records only
app/models/mail_handler.rb
174 174
    return unless issue
175 175
    # check permission
176 176
    unless @@handler_options[:no_permission_check]
177
      raise UnauthorizedAction unless user.allowed_to?(:add_issue_notes, issue.project) || user.allowed_to?(:edit_issues, issue.project)
178
      raise UnauthorizedAction unless status.nil? || user.allowed_to?(:edit_issues, issue.project)
177
      raise UnauthorizedAction unless user.allowed_to?(:add_issue_notes, issue.project) || issue.editable?(user)
178
      raise UnauthorizedAction unless status.nil? 
179 179
    end
180 180

  
181 181
    # add the note
config/locales/en.yml
362 362
  permission_view_issues: View Issues
363 363
  permission_add_issues: Add issues
364 364
  permission_edit_issues: Edit issues
365
  permission_edit_own_issues: Edit own issues
366
  permission_edit_own_new_issues: Edit own new issues
365 367
  permission_manage_issue_relations: Manage issue relations
366 368
  permission_add_issue_notes: Add notes
367 369
  permission_edit_issue_notes: Edit notes
config/locales/ja.yml
387 387
  permission_view_issues: チケットの閲覧
388 388
  permission_add_issues: チケットの追加
389 389
  permission_edit_issues: チケットの編集
390
  permission_edit_own_issues: 自分のチケットの編集
391
  permission_edit_own_new_issues: 自分の新規チケットの編集
390 392
  permission_manage_issue_relations: チケットの管理
391 393
  permission_add_issue_notes: 注記の追加
392 394
  permission_edit_issue_notes: 注記の編集
lib/redmine.rb
66 66
                                  :reports => [:issue_report, :issue_report_details]}
67 67
    map.permission :add_issues, {:issues => [:new, :create, :update_form]}
68 68
    map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]}
69
    map.permission :edit_own_issues, {:issues => [:edit, :update, :update_form], :journals => [:new]}
70
    map.permission :edit_own_new_issues, {:issues => [:edit, :update, :update_form], :journals => [:new]}
69 71
    map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
70 72
    map.permission :manage_subtasks, {}
71 73
    map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]}
lib/redmine/default_data/loader.rb
79 79
                                    :permissions => [:view_issues,
80 80
                                                    :add_issues,
81 81
                                                    :add_issue_notes,
82
                                                    :edit_own_new_issues,
82 83
                                                    :save_queries,
83 84
                                                    :view_gantt,
84 85
                                                    :view_calendar,
85
-