view_own_issues.patch

Correct patch file.. - Gilles Pietri, 2009-05-20 14:32

Download (4.91 KB)

View differences:

app/models/query.rb (copie de travail)
334 334
    elsif project
335 335
      project_clauses << "#{Project.table_name}.id = %d" % project.id
336 336
    end
337
    project_clauses <<  Project.allowed_to_condition(User.current, :view_issues)
338 337
    project_clauses.join(' AND ')
339 338
  end
340 339

  
......
375 374
      
376 375
    end if filters and valid?
377 376
    
377
    permissions = '('
378
    permissions << Project.allowed_to_condition(User.current, :view_issues)
379
    permissions << ' OR ('
380
    permissions << Project.allowed_to_condition(User.current, :view_own_issues)
381
    permissions << ' AND '
382
    permissions << "#{Issue.table_name}.author_id = #{User.current.id.to_s}"
383
    permissions << '))'
384

  
385
    filters_clauses << permissions
386

  
378 387
    (filters_clauses << project_statement).join(' AND ')
379 388
  end
380 389
  
app/controllers/issues_controller.rb (copie de travail)
106 106
  end
107 107
  
108 108
  def show
109
    @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
110
    @journals.each_with_index {|j,i| j.indice = i+1}
111
    @journals.reverse! if User.current.wants_comments_in_reverse_order?
112
    @changesets = @issue.changesets
113
    @changesets.reverse! if User.current.wants_comments_in_reverse_order?
114
    @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
115
    @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
116
    @priorities = Enumeration.priorities
117
    @time_entry = TimeEntry.new
118
    respond_to do |format|
119
      format.html { render :template => 'issues/show.rhtml' }
120
      format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
121
      format.pdf  { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
109
    if User.current.allowed_to?(:view_issues, @project) or (User.current.allowed_to?(:view_own_issues, @project) and User.current == @issue.author)
110
      @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
111
      @journals.each_with_index {|j,i| j.indice = i+1}
112
      @journals.reverse! if User.current.wants_comments_in_reverse_order?
113
      @changesets = @issue.changesets
114
      @changesets.reverse! if User.current.wants_comments_in_reverse_order?
115
      @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
116
      @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
117
      @priorities = Enumeration.priorities
118
      @time_entry = TimeEntry.new
119
      respond_to do |format|
120
        format.html { render :template => 'issues/show.rhtml' }
121
        format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
122
        format.pdf  { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
123
      end
124
    else
125
      render_403
122 126
    end
123 127
  end
124 128

  
app/views/issues/_sidebar.rhtml (copie de travail)
1 1
<h3><%= l(:label_issue_plural) %></h3>
2
<% if User.current.allowed_to?(:view_issues, @project) or User.current.allowed_to?(:view_own_issues, @project) %>
2 3
<%= link_to l(:label_issue_view_all), { :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 } %><br />
3
<% if @project %>
4
<% end %>
5
<% if @project and User.current.allowed_to?(:view_issues, @project) %>
4 6
<%= link_to l(:field_summary), :controller => 'reports', :action => 'issue_report', :id => @project %><br />
5 7
<%= link_to l(:label_change_log), :controller => 'projects', :action => 'changelog', :id => @project %><br />
6 8
<% end %>
lib/redmine.rb (copie de travail)
34 34
                                  :issues => [:index, :changes, :show, :context_menu],
35 35
                                  :versions => [:show, :status_by],
36 36
                                  :queries => :index,
37
                                  :reports => :issue_report}, :public => true                    
37
                                  :reports => :issue_report}                    
38
    map.permission :view_own_issues, {:issues => [:index, :changes, :show], :queries => :index}
38 39
    map.permission :add_issues, {:issues => :new}
39 40
    map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit]}
40 41
    map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}