private_issues.v.0.3.patch

for trunk version (3629) - Oleg Volkov, 2010-04-09 14:02

Download (11.5 KB)

View differences:

redmine/app/controllers/projects_controller.rb 2010-04-09 10:01:51.640590759 +0400
152 152
    @open_issues_by_tracker = Issue.visible.count(:group => :tracker,
153 153
                                            :include => [:project, :status, :tracker],
154 154
                                            :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false])
155
    @private_issues_by_tracker = Issue.count(:group => :tracker,
156
                                             :include => [:project, :status, :tracker],
157
                                             :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=? AND #{Issue.table_name}.is_private=?", false, true])
155 158
    @total_issues_by_tracker = Issue.visible.count(:group => :tracker,
156 159
                                            :include => [:project, :status, :tracker],
157 160
                                            :conditions => cond)
......
331 334
    @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
332 335

  
333 336
    events = @activity.events(@date_from, @date_to)
337

  
338
    # The private issues should be removed from events
339
    events.each do |event|
340
      events.delete(event) if event.kind_of?(Issue) && !event.visible?(User.current, Project.find(event.project))
341
    end
334 342
    
335 343
    if events.empty? || stale?(:etag => [events.first, User.current])
336 344
      respond_to do |format|
redmine/app/models/issue.rb 2010-04-09 15:25:11.948089072 +0400
74 74
  after_destroy :update_parent_attributes
75 75
  
76 76
  # Returns true if usr or current user is allowed to view the issue
77
  def visible?(usr=nil)
78
    (usr || User.current).allowed_to?(:view_issues, self.project)
77
  def visible?(usr=User.current, project=self.project)
78
    is_private==false && usr.allowed_to?(:view_issues, project) ||
79
    is_private==true && (usr.allowed_to?(:view_private_issues, project) || author == usr || assigned_to == usr || watched_by?(usr))
79 80
  end
80 81
  
81 82
  def after_initialize
......
204 205
    category_id
205 206
    assigned_to_id
206 207
    priority_id
208
    is_private
207 209
    fixed_version_id
208 210
    subject
209 211
    description
......
716 718
    if assigned_to.nil? && category && category.assigned_to
717 719
      self.assigned_to = category.assigned_to
718 720
    end
721
    if User.current.allowed_to?(:add_private_issues, self.project)
722
      self.is_private=1 unless User.current.allowed_to?(:add_issues, self.project)
723
    else
724
      self.is_private=0
725
    end
719 726
  end
720 727

  
721 728
  # Updates start/due dates of following issues
redmine/app/views/issues/_form.rhtml 2010-04-09 14:11:07.304447444 +0400
25 25
<div id="attributes" class="attributes">
26 26
	<%= render :partial => 'attributes' %>
27 27
</div>
28
<% if User.current.allowed_to?(:add_issues, @project) && User.current.allowed_to?(:add_private_issues, @project) %>
29
<p><%=f.check_box :is_private %></p>
30
<% end%>
28 31

  
29 32
<% if @issue.new_record? %>
30 33
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
redmine/app/views/issues/_list.rhtml 2010-04-09 15:30:25.912189407 +0400
24 24
		</tr>
25 25
		<% previous_group = group %>
26 26
  <% end %>
27
  <% if issue.visible? %>
27 28
	<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
28 29
	    <td class="checkbox"><%= check_box_tag("ids[]", issue.id, false, :id => nil) %></td>
29 30
		<td class="id"><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %></td>
30 31
        <% query.columns.each do |column| %><%= content_tag 'td', column_content(column, issue), :class => column.name %><% end %>
31 32
	</tr>
33
  <% end %>
32 34
	<% end -%>
33 35
	</tbody>
34 36
</table>
redmine/app/views/issues/_list_simple.rhtml 2010-04-09 15:31:32.377528332 +0400
9 9
		</tr></thead>
10 10
		<tbody>	
11 11
		<% for issue in issues %>
12
  <% if issue.visible? %>
12 13
		<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %>">
13 14
			<td class="id">
14 15
			  <%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;') %>
......
20 21
        <%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue %> (<%=h issue.status %>)
21 22
      </td>
22 23
		</tr>
24
  <% end %>
23 25
		<% end %>
24 26
		</tbody>
25 27
	</table>
redmine/app/views/issues/show.rhtml 2010-04-09 15:15:32.905963122 +0400
1
<% if @issue.visible? %>
2

  
1 3
<%= render :partial => 'action_menu' %>
2 4

  
3 5
<h2><%= @issue.tracker.name %> #<%= @issue.id %></h2>
......
40 42
    <% if @issue.estimated_hours %>
41 43
    <th class="estimated-hours"><%=l(:field_estimated_hours)%>:</th><td class="estimated-hours"><%= l_hours(@issue.estimated_hours) %></td>
42 44
    <% end %>
45
    <% if @issue.is_private %>
46
    <th class="private-issue"><%=l(:field_is_private)%>:</th><td class="private-issue"><%=l(:general_text_Yes)%></td>
47
    <% end %>
43 48
</tr>
44 49
<%= render_custom_fields_rows(@issue) %>
45 50
<%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
......
130 135
    <%= stylesheet_link_tag 'context_menu' %>
131 136
<% end %>
132 137
<div id="context-menu" style="display: none;"></div>
133
<%= javascript_tag "new ContextMenu('#{url_for(:controller => 'issues', :action => 'context_menu')}')" %>
138
<%= javascript_tag "new ContextMenu('#{url_for(:controller => 'issues', :action => 'context_menu')}')" %>
139
<% else %>
140
  <p class="nodata"><%=l(:label_access_denied)%> </p>
141
<% end %>
redmine/app/views/projects/show.rhtml 2010-04-09 15:33:58.651978555 +0400
33 33
                                                "tracker_id" => tracker.id %>:
34 34
					<%= l(:label_x_open_issues_abbr_on_total, :count => @open_issues_by_tracker[tracker].to_i,
35 35
																										:total => @total_issues_by_tracker[tracker].to_i) %>
36
        (<%= @private_issues_by_tracker[tracker] || 0 %> <%= l(:label_private_issues, @private_issues_by_tracker[tracker] || 0)%>)
36 37
			</li>
37 38
    <% end %>
38 39
    </ul>
redmine/config/locales/en.yml 2010-04-08 12:57:27.000000000 +0400
275 275
  field_default_value: Default value
276 276
  field_comments_sorting: Display comments
277 277
  field_parent_title: Parent page
278
  field_is_private: Private issue
278 279
  field_editable: Editable
279 280
  field_watcher: Watcher
280 281
  field_identity_url: OpenID URL
......
347 348
  permission_manage_categories: Manage issue categories
348 349
  permission_view_issues: View Issues
349 350
  permission_add_issues: Add issues
351
  permission_add_private_issues: Add private issues
352
  permission_view_private_issues: View private issues
350 353
  permission_edit_issues: Edit issues
351 354
  permission_manage_issue_relations: Manage issue relations
352 355
  permission_add_issue_notes: Add notes
......
402 405
  project_module_repository: Repository
403 406
  project_module_boards: Boards
404 407
  
408
  label_access_denied: Access denied
405 409
  label_user: User
406 410
  label_user_plural: Users
407 411
  label_user_new: New user
......
519 523
  label_public_projects: Public projects
520 524
  label_open_issues: open
521 525
  label_open_issues_plural: open
526
  label_private_issues: private
527
  label_private_issues_plural: private
522 528
  label_closed_issues: closed
523 529
  label_closed_issues_plural: closed
524 530
  label_x_open_issues_abbr_on_total:
redmine/config/locales/ru.yml 2010-04-08 13:06:36.000000000 +0400
354 354
  field_port: Порт
355 355
  field_possible_values: Возможные значения
356 356
  field_priority: Приоритет
357
  field_is_private: Конфиденциальная задача
357 358
  field_project: Проект
358 359
  field_redirect_existing_links: Перенаправить существующие ссылки
359 360
  field_regexp: Регулярное выражение
......
394 395
  gui_validation_error_plural5: "{{count}} ошибок"
395 396

  
396 397
  label_activity: Активность
398
  label_access_denied: Доступ запрещен
397 399
  label_add_another_file: Добавить ещё один файл
398 400
  label_added_time_by: "Добавил(а) {{author}} {{age}} назад"
399 401
  label_added: добавлено
......
593 595
  label_not_contains: не содержит
594 596
  label_not_equals: не соответствует
595 597
  label_open_issues: открыт
598
  label_private_issues_plural2: конфиденциальных
599
  label_private_issues_plural5: конфиденциальных
600
  label_private_issues_plural: конфиденциальных
601
  label_private_issues: конфиденциальная
596 602
  label_open_issues_plural: открыто
597 603
  label_open_issues_plural2: открыто
598 604
  label_open_issues_plural5: открыто
......
783 789

  
784 790
  permission_add_issues: Добавление задач
785 791
  permission_add_issue_notes: Добавление примечаний
792
  permission_add_private_issues: Добавление конфиденциальных задач
793
  permission_view_private_issues: Просмотр конфиденциальных задач
786 794
  permission_add_issue_watchers: Добавление наблюдателей
787 795
  permission_add_messages: Отправка сообщений
788 796
  permission_browse_repository: Просмотр хранилища
redmine/lib/redmine.rb 2010-04-08 13:10:43.000000000 +0400
52 52
                                  :queries => :index,
53 53
                                  :reports => [:issue_report, :issue_report_details]}
54 54
    map.permission :add_issues, {:issues => [:new, :update_form]}
55
    map.permission :add_private_issues, {:issues => :new}
56
    map.permission :view_private_issues, {:projects => [:changelog, :roadmap],
57
                                  :issues => [:index, :changes, :show, :context_menu],
58
                                  :versions => [:show, :status_by],
59
                                  :queries => :index,
60
                                  :reports => :issue_report}
55 61
    map.permission :edit_issues, {:issues => [:edit, :update, :reply, :bulk_edit, :update_form]}
56 62
    map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
57 63
    map.permission :manage_subtasks, {}