@@ -0,0 +1,29 | |||
|
1 | <div class="box" style="margin-top: 16px;"> | |
|
2 | <h3><%= l(:label_project_plural) %></h3> | |
|
3 | ||
|
4 | <% @user.memberships.each do |membership| %> | |
|
5 | <%= start_form_tag({ :action => 'edit_membership', :id => @user, :membership_id => membership }, :class => "tabular") %> | |
|
6 | <p style="margin:0;padding-top:0;"> | |
|
7 | <label><%= membership.project.name %></label> | |
|
8 | <select name="membership[role_id]"> | |
|
9 | <%= options_from_collection_for_select @roles, "id", "name", membership.role_id %> | |
|
10 | </select> | |
|
11 | <%= submit_tag l(:button_change), :class => "button-small" %> | |
|
12 | <%= link_to l(:button_delete), {:action => 'destroy_membership', :id => @user, :membership_id => membership }, :confirm => l(:text_are_you_sure), :post => true, :class => 'pic picDelete' %> | |
|
13 | </p> | |
|
14 | <%= end_form_tag %> | |
|
15 | <% end %> | |
|
16 | <hr /> | |
|
17 | <p> | |
|
18 | <label><%=l(:label_project_new)%></label><br/> | |
|
19 | <%= start_form_tag({ :action => 'edit_membership', :id => @user }) %> | |
|
20 | <select name="membership[project_id]"> | |
|
21 | <%= options_from_collection_for_select @projects, "id", "name", @membership.project_id %> | |
|
22 | </select> | |
|
23 | <select name="membership[role_id]"> | |
|
24 | <%= options_from_collection_for_select @roles, "id", "name", @membership.role_id %> | |
|
25 | </select> | |
|
26 | <%= submit_tag l(:button_add) %> | |
|
27 | <%= end_form_tag %> | |
|
28 | </p> | |
|
29 | </div> No newline at end of file |
|
1 | NO CONTENT: new file 100644, binary diff hidden |
@@ -1,92 +1,113 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class UsersController < ApplicationController |
|
19 | 19 | layout 'base' |
|
20 | 20 | before_filter :require_admin |
|
21 | 21 | |
|
22 | 22 | helper :sort |
|
23 | 23 | include SortHelper |
|
24 | 24 | helper :custom_fields |
|
25 | 25 | include CustomFieldsHelper |
|
26 | 26 | |
|
27 | 27 | def index |
|
28 | 28 | list |
|
29 | 29 | render :action => 'list' unless request.xhr? |
|
30 | 30 | end |
|
31 | 31 | |
|
32 | 32 | def list |
|
33 | 33 | sort_init 'login', 'asc' |
|
34 | 34 | sort_update |
|
35 | 35 | @user_count = User.count |
|
36 | 36 | @user_pages = Paginator.new self, @user_count, |
|
37 | 37 | 15, |
|
38 | 38 | @params['page'] |
|
39 | 39 | @users = User.find :all,:order => sort_clause, |
|
40 | 40 | :limit => @user_pages.items_per_page, |
|
41 | 41 | :offset => @user_pages.current.offset |
|
42 | 42 | |
|
43 | 43 | render :action => "list", :layout => false if request.xhr? |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | def add |
|
47 | 47 | if request.get? |
|
48 | 48 | @user = User.new(:language => $RDM_DEFAULT_LANG) |
|
49 | 49 | @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) } |
|
50 | 50 | else |
|
51 | 51 | @user = User.new(params[:user]) |
|
52 | 52 | @user.admin = params[:user][:admin] || false |
|
53 | 53 | @user.login = params[:user][:login] |
|
54 | 54 | @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id |
|
55 | 55 | @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) } |
|
56 | 56 | @user.custom_values = @custom_values |
|
57 | 57 | if @user.save |
|
58 | 58 | flash[:notice] = l(:notice_successful_create) |
|
59 | 59 | redirect_to :action => 'list' |
|
60 | 60 | end |
|
61 | 61 | end |
|
62 | 62 | @auth_sources = AuthSource.find(:all) |
|
63 | 63 | end |
|
64 | 64 | |
|
65 | 65 | def edit |
|
66 | 66 | @user = User.find(params[:id]) |
|
67 | 67 | if request.get? |
|
68 | 68 | @custom_values = UserCustomField.find(:all).collect { |x| @user.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } |
|
69 | 69 | else |
|
70 | 70 | @user.admin = params[:user][:admin] if params[:user][:admin] |
|
71 | 71 | @user.login = params[:user][:login] if params[:user][:login] |
|
72 | 72 | @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id |
|
73 | 73 | if params[:custom_fields] |
|
74 | 74 | @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) } |
|
75 | 75 | @user.custom_values = @custom_values |
|
76 | 76 | end |
|
77 | 77 | if @user.update_attributes(params[:user]) |
|
78 | 78 | flash[:notice] = l(:notice_successful_update) |
|
79 | 79 | redirect_to :action => 'list' |
|
80 | 80 | end |
|
81 | 81 | end |
|
82 | 82 | @auth_sources = AuthSource.find(:all) |
|
83 | @roles = Role.find :all | |
|
84 | @projects = Project.find(:all) - @user.projects | |
|
85 | @membership ||= Member.new | |
|
86 | end | |
|
87 | ||
|
88 | def edit_membership | |
|
89 | @user = User.find(params[:id]) | |
|
90 | @membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user) | |
|
91 | @membership.attributes = params[:membership] | |
|
92 | if request.post? and @membership.save | |
|
93 | flash[:notice] = l(:notice_successful_update) | |
|
94 | end | |
|
95 | redirect_to :action => 'edit', :id => @user and return | |
|
96 | end | |
|
97 | ||
|
98 | def destroy_membership | |
|
99 | @user = User.find(params[:id]) | |
|
100 | if request.post? and Member.find(params[:membership_id]).destroy | |
|
101 | flash[:notice] = l(:notice_successful_update) | |
|
102 | end | |
|
103 | redirect_to :action => 'edit', :id => @user and return | |
|
83 | 104 | end |
|
84 | 105 | |
|
85 | 106 | def destroy |
|
86 | 107 | User.find(params[:id]).destroy |
|
87 | 108 | redirect_to :action => 'list' |
|
88 | 109 | rescue |
|
89 | 110 | flash[:notice] = "Unable to delete user" |
|
90 | 111 | redirect_to :action => 'list' |
|
91 | 112 | end |
|
92 | 113 | end |
@@ -1,6 +1,8 | |||
|
1 | 1 | <h2><%=l(:label_user)%></h2> |
|
2 | 2 | |
|
3 | 3 | <% labelled_tabular_form_for :user, @user, :url => { :action => "edit" } do |f| %> |
|
4 | 4 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
5 | 5 | <%= submit_tag l(:button_save) %> |
|
6 | 6 | <% end %> |
|
7 | ||
|
8 | <%= render :partial => 'memberships' %> No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now