Patch #23546 » 23546-watched_or_created_or_assigned_issue_visibility_3.4.1.patch
| app/models/issue.rb | ||
|---|---|---|
|
when 'own'
|
||
|
user_ids = [user.id] + user.groups.map(&:id).compact
|
||
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||
|
when 'watched'
|
||
|
user_ids = [user.id] + user.groups.map(&:id).compact
|
||
|
watcher_select = Watcher.where(watchable_type: self.base_class.name, user_id: user.id).select(:watchable_id).to_sql
|
||
|
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}) OR #{table_name}.id IN (#{watcher_select}))"
|
||
|
else
|
||
|
'1=0'
|
||
|
end
|
||
| ... | ... | |
|
!self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
|
||
|
when 'own'
|
||
|
self.author == user || user.is_or_belongs_to?(assigned_to)
|
||
|
when 'watched'
|
||
|
self.author == user || user.is_or_belongs_to?(assigned_to) || self.watched_by?(user)
|
||
|
else
|
||
|
false
|
||
|
end
|
||
| app/models/role.rb | ||
|---|---|---|
|
ISSUES_VISIBILITY_OPTIONS = [
|
||
|
['all', :label_issues_visibility_all],
|
||
|
['default', :label_issues_visibility_public],
|
||
|
['own', :label_issues_visibility_own]
|
||
|
['own', :label_issues_visibility_own],
|
||
|
['watched', :label_issues_visibility_watched]
|
||
|
]
|
||
|
TIME_ENTRIES_VISIBILITY_OPTIONS = [
|
||
| app/views/messages/show.html.erb | ||
|---|---|---|
|
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||
|
<p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p>
|
||
|
<div id="reply" style="display:none;">
|
||
|
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||
|
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'messages-form'} do |f| %>
|
||
|
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
|
||
|
<%= submit_tag l(:button_submit) %>
|
||
|
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
|
||
| config/locales/de.yml | ||
|---|---|---|
|
label_issues_visibility_all: Alle Tickets
|
||
|
label_issues_visibility_own: Tickets die folgender Benutzer erstellt hat oder die ihm zugewiesen sind
|
||
|
label_issues_visibility_public: Alle öffentlichen Tickets
|
||
|
label_issues_visibility_watched: "Aufgaben die folgender Benutzer beobachtet, erstellt hat oder die ihm zugewiesen sind"
|
||
|
label_item_position: "%{position}/%{count}"
|
||
|
label_jump_to_a_project: Zu einem Projekt springen...
|
||
|
label_language_based: Sprachabhängig
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_issues_visibility_all: All issues
|
||
|
label_issues_visibility_public: All non private issues
|
||
|
label_issues_visibility_own: Issues created by or assigned to the user
|
||
|
label_issues_visibility_watched: Issues watched by, created by or assigned to the user
|
||
|
label_git_report_last_commit: Report last commit for files and directories
|
||
|
label_parent_revision: Parent
|
||
|
label_child_revision: Child
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
assert !issue.visible?(User.anonymous)
|
||
|
end
|
||
|
def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_watched
|
||
|
assert Role.anonymous.update_attribute(:issues_visibility, 'watched')
|
||
|
issue = Issue.generate!(:author => User.anonymous, :is_private => true)
|
||
|
assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
|
||
|
assert !issue.visible?(User.anonymous)
|
||
|
end
|
||
|
def test_visible_scope_for_non_member
|
||
|
user = User.find(9)
|
||
|
assert user.projects.empty?
|
||
| ... | ... | |
|
assert_visibility_match user, issues
|
||
|
end
|
||
|
def test_visible_scope_for_non_member_with_watched_issues_visibility
|
||
|
Role.non_member.update_attribute :issues_visibility, 'watched'
|
||
|
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :author => User.anonymous, :subject => 'Issue by non member')
|
||
|
user = User.find(9)
|
||
|
issue.add_watcher(user)
|
||
|
issues = Issue.visible(user).all
|
||
|
assert issues.any?
|
||
|
assert_nil issues.detect {|issue| !issue.watched_by?(user) }
|
||
|
assert_visibility_match user, issues
|
||
|
end
|
||
|
def test_visible_scope_for_non_member_without_view_issues_permissions
|
||
|
# Non member user should not see issues without permission
|
||
|
Role.non_member.remove_permission!(:view_issues)
|
||
- « Previous
- 1
- 2
- Next »