summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-26 15:46:12 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-26 15:46:12 +0000
commitc36c924714cbbbf88f825b1513a0d22a3b513332 (patch)
treeaf350edc4ace2b94269222c468ab846d9469f35d /app
parenta4c64ff84befbd87653f0b5c0c5a6c69a78401a6 (diff)
downloadredmine-c36c924714cbbbf88f825b1513a0d22a3b513332.tar.gz
redmine-c36c924714cbbbf88f825b1513a0d22a3b513332.zip
Ask for confirmation when a non-admin users tries to remove himself from a project (#4402).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3249 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/member.rb8
-rw-r--r--app/views/projects/settings/_members.rhtml3
2 files changed, 10 insertions, 1 deletions
diff --git a/app/models/member.rb b/app/models/member.rb
index 44a421745..3ef1afdef 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -57,6 +57,14 @@ class Member < ActiveRecord::Base
member_roles.detect {|mr| mr.inherited_from}.nil?
end
+ def include?(user)
+ if principal.is_a?(Group)
+ !user.nil? && user.groups.include?(principal)
+ else
+ self.user == user
+ end
+ end
+
def before_destroy
if user
# remove category based auto assignments for this member
diff --git a/app/views/projects/settings/_members.rhtml b/app/views/projects/settings/_members.rhtml
index bfea86753..c0d48b9c2 100644
--- a/app/views/projects/settings/_members.rhtml
+++ b/app/views/projects/settings/_members.rhtml
@@ -35,7 +35,8 @@
<td class="buttons">
<%= link_to_function l(:button_edit), "$('member-#{member.id}-roles').hide(); $('member-#{member.id}-roles-form').show(); return false;", :class => 'icon icon-edit' %>
<%= link_to_remote(l(:button_delete), { :url => {:controller => 'members', :action => 'destroy', :id => member},
- :method => :post
+ :method => :post,
+ :confirm => (!User.current.admin? && member.include?(User.current) ? l(:text_own_membership_delete_confirmation) : nil)
}, :title => l(:button_delete),
:class => 'icon icon-del') if member.deletable? %>
</td>