This commit was generated by cvs2svn to compensate for changes in r2526,
[freeside.git] / rt / webrt / Admin / Users / Modify.html
1 <& /Admin/Elements/Header, Title => $title &>
2 <& /Admin/Elements/UserTabs, id => $id, current_subtab => '/Admin/Elements/Modify.html?id='.$id &>
3
4 <& /Elements/ListActions, actions => \@results &>
5
6 <FORM ACTION="<%$RT::WebPath%>/Admin/Users/Modify.html" METHOD=POST>
7 %if ($Create) {
8 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
9 % } else {
10 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
11 % }
12
13 <TABLE WIDTH=100% BORDER=0>
14 <TR>
15
16 <TD VALIGN=TOP ROWSPAN=2>
17 <& /Elements/TitleBoxStart, title => 'Identity' &>
18
19 Username: <input name="Name" value="<%$UserObj->Name%>"> <b>(required)</b> <BR>
20 Email: <input name="EmailAddress" value="<%$UserObj->EmailAddress%>"><BR>
21 Real Name: <input name="RealName" value="<%$UserObj->RealName%>"> <BR>
22 Nickname: <input name="NickName" value="<%$UserObj->NickName%>">
23 <BR>
24 Unix login: <input name="Gecos" value="<%$UserObj->Gecos%>">
25 <BR>
26 Extra info: <textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
27 <& /Elements/TitleBoxEnd &>
28 </TD>
29 <TD VALIGN=TOP>
30 <& /Elements/TitleBoxStart, title => 'Access control' &>
31 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
32 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>>
33 Let this user access RT<BR>
34
35
36 <INPUT TYPE=HIDDEN NAME="SetPrivileged" VALUE="1">
37 <INPUT TYPE=CHECKBOX NAME="Privileged" VALUE="1" <%$PrivilegedChecked%>> Let this user be granted rights<BR>
38                     
39 % unless ($RT::WebExternalAuth) {
40 <TABLE>
41 <TR>
42 <TD ALIGN=RIGHT>
43 New Password:
44 </TD>
45 <TD ALIGN=LEFT>
46 <input type=password name="Pass1">
47 </TD>
48 </TR>
49 <TR><TD ALIGN=RIGHT>
50 Retype Password:
51 </TD>
52 <TD>
53 <input type=password name="Pass2">
54 </TD>
55 </TR>
56 </TABLE>
57 % }
58 <& /Elements/TitleBoxEnd &>
59 </TD>
60 <TR>
61
62 <TD VALIGN=TOP>
63 <& /Elements/TitleBoxStart, title => 'Location' &>
64 Organization: <input name="Organization" value="<%$UserObj->Organization%>">
65 <BR>
66 Address1: <input name="Address1" value="<%$UserObj->Address1%>">
67 <BR>
68 Address2: <input name="Address2" value="<%$UserObj->Address2%>">
69 <BR>
70 City: <input name="City" value="<%$UserObj->City%>" size=14>
71
72 State: <input name="State" value="<%$UserObj->State%>" size=3>
73
74 Zip: <input name="Zip" value="<%$UserObj->Zip%>" size=9>
75 <BR>
76 Country: <input name="Country" value="<%$UserObj->Country%>">
77 <BR>
78
79
80 <& /Elements/TitleBoxEnd &>
81 </TD>
82 </TR>
83 <TR>
84 <TD COLSPAN=2 VALIGN=TOP>
85
86
87 <& /Elements/TitleBoxStart, title => 'Phone numbers' &>
88 Home: <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13>
89
90 Work: <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13>
91
92 Mobile: <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13>
93
94 Pager: <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13>
95 <& /Elements/TitleBoxEnd &>
96 <BR>
97 <& /Elements/TitleBoxStart, title => 'Comments about this user' &>
98 <TEXTAREA name="Comments" COLS=80 ROWS=5 WRAP=VIRTUAL><%$UserObj->Comments%></TEXTAREA>
99 <& /Elements/TitleBoxEnd &>
100
101
102 %if ($UserObj->Privileged) {
103 <BR>
104 <& /Elements/TitleBoxStart, title => 'Signature' &>
105 <TEXTAREA COLS=80 ROWS=5 name="Signature" WRAP=HARD>
106 <%$UserObj->Signature%></TEXTAREA>
107 <& /Elements/TitleBoxEnd &>
108 % }
109
110 </TD>
111
112 </TR>
113 </TABLE>
114
115
116 <& /Elements/Submit &>
117 </form>
118
119
120 <%INIT>
121
122 my $UserObj = new RT::User($session{'CurrentUser'});
123 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
124
125 my ($val, $msg);
126
127 if ($Create) {
128     $title = "Create a new user";
129
130 else {
131
132     if ($id eq 'new') {
133         ($val, $msg) = $UserObj->Create( Name => $Name,
134                                          EmailAddress => $ARGS{'EmailAddress'}
135                                        );
136         if ($val) {
137                 push @results, $msg;
138         } else {
139                 push @results, 'User could not be created: '. $msg;
140         }       
141         
142     }
143     else {
144         $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
145         $val = $UserObj->Id();
146     }
147
148     if ($val) {
149         $title = "Modify the user ". $UserObj->Name;
150     }   
151
152     # If the create failed
153     else {
154         $title = "Create a new user";
155         $Create = 1;
156     }    
157
158     
159
160 }
161
162
163
164
165 # If we have a user to modify, lets try. 
166 if ($UserObj->Id) {
167     
168     my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo 
169                     Organization RealName NickName Lang EmailEncoding WebEncoding 
170                     ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
171                     AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
172                 Address2 City State Zip Country 
173                    );
174     
175     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
176                                             Object => $UserObj,
177                                             ARGSRef => \%ARGS );
178     push (@results,@fieldresults);
179
180
181 # {{{ Deal with special fields: Privileged, Enabled and Password
182 if  ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
183 my  ($code, $msg) = $UserObj->SetPrivileged($Privileged);
184      push @results, 'Privileged status: '. $msg;
185 }
186
187 #we're asking about enabled on the web page but really care about disabled.
188 if ($Enabled == 1) {
189     $Disabled = 0;
190 }       
191 else {
192     $Disabled = 1;
193 }
194 if  ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) { 
195     my  ($code, $msg) = $UserObj->SetDisabled($Disabled);
196     push @results, 'Enabled status '. $msg;
197 }
198
199
200 #TODO: make this report errors properly
201 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
202     my ($code, $msg);
203     ($code, $msg) = $UserObj->SetPassword($Pass1);
204     push @results, 'Password: '. $msg;
205 }
206
207 # }}}
208 }
209
210
211 # {{{ Do some setup for the ui
212 unless ($UserObj->Disabled()) {
213     $EnabledChecked ="CHECKED";
214 }
215
216 if ($UserObj->Privileged()) {  
217     $PrivilegedChecked = "CHECKED";
218 }
219
220 # }}}
221 </%INIT>
222
223
224 <%ARGS>
225 $id => undef
226 $Name  => undef
227 $Comments  => undef
228 $Signature  => undef
229 $EmailAddress  => undef
230 $FreeformContactInfo => undef
231 $Organization  => undef
232 $RealName  => undef
233 $NickName  => undef
234 $Privileged => undef
235 $SetPrivileged => undef
236 $Enabled => undef
237 $SetEnabled => undef
238 $Lang  => undef
239 $EmailEncoding  => undef
240 $WebEncoding => undef
241 $ExternalContactInfoId  => undef
242 $ContactInfoSystem  => undef
243 $Gecos => undef
244 $ExternalAuthId  => undef
245 $AuthSystem  => undef
246 $HomePhone => undef
247 $WorkPhone  => undef
248 $MobilePhone  => undef
249 $PagerPhone  => undef
250 $Address1 => undef
251 $Address2  => undef
252 $City  => undef
253 $State  => undef
254 $Zip  => undef
255 $Country => undef
256 $Pass1 => undef
257 $Pass2=> undef
258 $Create=> undef
259 </%ARGS>