Ability to assign issues to groups (#2964).
Option is disabled by default. It can be turned on in application settings. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6306 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+14
-4
@@ -45,7 +45,6 @@ class User < Principal
|
||||
|
||||
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
|
||||
:after_remove => Proc.new {|user, group| group.user_removed(user)}
|
||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||
has_many :changesets, :dependent => :nullify
|
||||
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
|
||||
has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'"
|
||||
@@ -388,6 +387,17 @@ class User < Principal
|
||||
@projects_by_role
|
||||
end
|
||||
|
||||
# Returns true if user is arg or belongs to arg
|
||||
def is_or_belongs_to?(arg)
|
||||
if arg.is_a?(User)
|
||||
self == arg
|
||||
elsif arg.is_a?(Group)
|
||||
arg.users.include?(self)
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
# Return true if the user is allowed to do the specified action on a specific context
|
||||
# Action can be:
|
||||
# * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit')
|
||||
@@ -469,7 +479,7 @@ class User < Principal
|
||||
true
|
||||
when 'selected'
|
||||
# user receives notifications for created/assigned issues on unselected projects
|
||||
if object.is_a?(Issue) && (object.author == self || object.assigned_to == self)
|
||||
if object.is_a?(Issue) && (object.author == self || is_or_belongs_to?(object.assigned_to))
|
||||
true
|
||||
else
|
||||
false
|
||||
@@ -477,13 +487,13 @@ class User < Principal
|
||||
when 'none'
|
||||
false
|
||||
when 'only_my_events'
|
||||
if object.is_a?(Issue) && (object.author == self || object.assigned_to == self)
|
||||
if object.is_a?(Issue) && (object.author == self || is_or_belongs_to?(object.assigned_to))
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when 'only_assigned'
|
||||
if object.is_a?(Issue) && object.assigned_to == self
|
||||
if object.is_a?(Issue) && is_or_belongs_to?(object.assigned_to)
|
||||
true
|
||||
else
|
||||
false
|
||||
|
||||
Reference in New Issue
Block a user