Adds a setting to choose which role is given to a non-admin user who creates a project (#1007).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2754 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -78,7 +78,8 @@ class ProjectsController < ApplicationController
|
||||
@project.set_parent!(params[:project]['parent_id']) if User.current.admin? && params[:project].has_key?('parent_id')
|
||||
# Add current user as a project member if he is not admin
|
||||
unless User.current.admin?
|
||||
m = Member.new(:user => User.current, :roles => Role.builtin(false).find(:all, :order => 'position', :limit => 1))
|
||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||
m = Member.new(:user => User.current, :roles => [r])
|
||||
@project.members << m
|
||||
end
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
|
||||
@@ -20,6 +20,7 @@ class Role < ActiveRecord::Base
|
||||
BUILTIN_NON_MEMBER = 1
|
||||
BUILTIN_ANONYMOUS = 2
|
||||
|
||||
named_scope :givable, { :conditions => "builtin = 0", :order => 'position' }
|
||||
named_scope :builtin, lambda { |*args|
|
||||
compare = 'not' if args.first == true
|
||||
{ :conditions => "#{compare} builtin = 0" }
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
<p><label><%= l(:setting_sequential_project_identifiers) %></label>
|
||||
<%= check_box_tag 'settings[sequential_project_identifiers]', 1, Setting.sequential_project_identifiers? %><%= hidden_field_tag 'settings[sequential_project_identifiers]', 0 %></p>
|
||||
|
||||
<p><label><%= l(:setting_new_project_user_role_id) %></label>
|
||||
<%= select_tag('settings[new_project_user_role_id]', options_for_select([["--- #{l(:actionview_instancetag_blank_option)} ---", '']] + Role.find_all_givable.collect {|r| [r.name, r.id]}, Setting.new_project_user_role_id)) %></p>
|
||||
</div>
|
||||
|
||||
<%= submit_tag l(:button_save) %>
|
||||
|
||||
Reference in New Issue
Block a user