Modify.html 12.8 KB
Newer Older
1
%# BEGIN BPS TAGGED BLOCK {{{
2
%# 
3
4
%# COPYRIGHT:
%#  
Jesse Vincent's avatar
Jesse Vincent committed
5
%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC 
6
%#                                          <jesse@bestpractical.com>
7
%# 
8
9
10
11
%# (Except where explicitly superseded by other copyright notices)
%# 
%# 
%# LICENSE:
12
13
14
15
%# 
%# This work is made available to you under the terms of Version 2 of
%# the GNU General Public License. A copy of that license should have
%# been provided with this software, but in any event can be snarfed
16
%# from www.gnu.org.
17
18
19
20
21
22
%# 
%# This work is distributed in the hope that it will be useful, but
%# WITHOUT ANY WARRANTY; without even the implied warranty of
%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%# General Public License for more details.
%# 
23
24
%# You should have received a copy of the GNU General Public License
%# along with this program; if not, write to the Free Software
Jesse Vincent's avatar
Jesse Vincent committed
25
26
27
%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
%# 02110-1301 or visit their web page on the internet at
%# http://www.gnu.org/copyleft/gpl.html.
28
29
30
31
32
33
34
35
36
%# 
%# 
%# CONTRIBUTION SUBMISSION POLICY:
%# 
%# (The following paragraph is not intended to limit the rights granted
%# to you to modify and distribute this software under the terms of
%# the GNU General Public License and is only of importance to you if
%# you choose to contribute your changes and enhancements to the
%# community by submitting them to Best Practical Solutions, LLC.)
37
%# 
38
39
40
41
42
43
44
45
%# By intentionally submitting any modifications, corrections or
%# derivatives to this work, or any other work intended for use with
%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
%# you are the copyright holder for those contributions and you grant
%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
%# royalty-free, perpetual, license to use, copy, create derivative
%# works based on those contributions, and sublicense and distribute
%# those contributions and any derivatives thereof.
46
%# 
47
%# END BPS TAGGED BLOCK }}}
Linda Julien's avatar
Linda Julien committed
48
49
50
<& /Admin/Elements/Header, Title => $title  &>
<& /Admin/Elements/UserTabs, 
    id => $id, 
51
    UserObj => $UserObj,
52
    current_tab => $current_tab, 
Linda Julien's avatar
Linda Julien committed
53
    Title => $title &>
54

55
<& /Elements/ListActions, actions => \@results &>
56

Ruslan Zakirov's avatar
Ruslan Zakirov committed
57
<form action="<%RT->Config->Get('WebPath')%>/Admin/Users/Modify.html" method="post" enctype="multipart/form-data">
58
%if ($Create) {
Ruslan Zakirov's avatar
Ruslan Zakirov committed
59
<input type="hidden" class="hidden" name="id" value="new" />
60
% } else {
Ruslan Zakirov's avatar
Ruslan Zakirov committed
61
<input type="hidden" class="hidden" name="id" value="<%$UserObj->Id%>" />
62
% }
Jesse Vincent's avatar
Jesse Vincent committed
63
<table width="100%" border="0">
Jesse Vincent's avatar
Jesse Vincent committed
64
<tr>
65

Ruslan Zakirov's avatar
Ruslan Zakirov committed
66
<td valign="top" class="boxcontainer">
Jesse Vincent's avatar
Jesse Vincent committed
67
<&| /Widgets/TitleBox, title => loc('Identity') &>
68

Jesse Vincent's avatar
Jesse Vincent committed
69
<table>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
70
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
71
<&|/l&>Username</&>:
Jesse Vincent's avatar
Jesse Vincent committed
72
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
73
<input name="Name" value="<%$UserObj->Name%>" /> <strong><&|/l&>(required)</&></strong>
Jesse Vincent's avatar
Jesse Vincent committed
74
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
75
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
76
<&|/l&>Email</&>:
Jesse Vincent's avatar
Jesse Vincent committed
77
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
78
<input name="EmailAddress" value="<%$UserObj->EmailAddress%>" />
Jesse Vincent's avatar
Jesse Vincent committed
79
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
80
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
81
<&|/l&>Real Name</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
82
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
83
<input name="RealName" value="<%$UserObj->RealName%>" />
Jesse Vincent's avatar
Jesse Vincent committed
84
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
85
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
86
<&|/l&>Nickname</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
87
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
88
<input name="NickName" value="<%$UserObj->NickName%>" />
Jesse Vincent's avatar
Jesse Vincent committed
89
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
90
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
91
<&|/l&>Unix login</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
92
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
93
<input name="Gecos" value="<%$UserObj->Gecos%>" />
Jesse Vincent's avatar
Jesse Vincent committed
94
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
95
<tr><td align="right">
96
<&|/l&>Language</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
97
</td><td>
98
<& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &>
Jesse Vincent's avatar
Jesse Vincent committed
99
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
100
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
101
<&|/l&>Extra info</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
102
</td><td>
Jesse Vincent's avatar
Jesse Vincent committed
103
<textarea name="FreeformContactInfo" cols="20" rows="5"><%$UserObj->FreeformContactInfo%></textarea>
Jesse Vincent's avatar
Jesse Vincent committed
104
105
</td></tr>
</table>
Jesse Vincent's avatar
Jesse Vincent committed
106
</&>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
107
<br />
Jesse Vincent's avatar
Jesse Vincent committed
108
<&| /Widgets/TitleBox, title => loc('Access control') &>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
109
110
111
<input type="hidden" class="hidden" name="SetEnabled" value="1" />
<input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> />
<&|/l&>Let this user access RT</&><br />
112
113


Ruslan Zakirov's avatar
Ruslan Zakirov committed
114
115
<input type="hidden" class="hidden" name="SetPrivileged" value="1" />
<input type="checkbox" class="checkbox" name="Privileged" value="1" <%$PrivilegedChecked%> /> <&|/l&>Let this user be granted rights</&><br />
116
		    
117
% unless (RT->Config->Get('WebExternalAuth') and !RT->Config->Get('WebFallbackToInternalAuth')) {
Jesse Vincent's avatar
Jesse Vincent committed
118
119
<table>
<tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
120
<td align="right">
121
<&|/l&>New Password</&>:
Jesse Vincent's avatar
Jesse Vincent committed
122
</td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
123
<td align="left">
124
<input type="password" name="Pass1" autocomplete="off" />
Jesse Vincent's avatar
Jesse Vincent committed
125
126
</td>
</tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
127
<tr><td align="right">
128
<&|/l&>Retype Password</&>:
Jesse Vincent's avatar
Jesse Vincent committed
129
130
</td>
<td>
131
<input type="password" name="Pass2" autocomplete="off" />
Jesse Vincent's avatar
Jesse Vincent committed
132
133
134
</td>
</tr>
</table>
135
% }
Jesse Vincent's avatar
Jesse Vincent committed
136
</&>
137
<& /Elements/Callback, _CallbackName => 'LeftColumnBottom', UserObj => $UserObj, %ARGS &>
Jesse Vincent's avatar
Jesse Vincent committed
138
</td>
139

Ruslan Zakirov's avatar
Ruslan Zakirov committed
140
<td valign="top" class="boxcontainer">
Jesse Vincent's avatar
Jesse Vincent committed
141
<&| /Widgets/TitleBox, title => loc('Location') &>
Jesse Vincent's avatar
Jesse Vincent committed
142
<table>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
143
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
144
<&|/l&>Organization</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
145
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
146
<input name="Organization" value="<%$UserObj->Organization%>" />
Jesse Vincent's avatar
Jesse Vincent committed
147
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
148
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
149
<&|/l&>Address1</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
150
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
151
<input name="Address1" value="<%$UserObj->Address1%>" />
Jesse Vincent's avatar
Jesse Vincent committed
152
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
153
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
154
<&|/l&>Address2</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
155
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
156
<input name="Address2" value="<%$UserObj->Address2%>" />
Jesse Vincent's avatar
Jesse Vincent committed
157
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
158
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
159
<&|/l&>City</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
160
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
161
<input name="City" value="<%$UserObj->City%>" size="14" />
Jesse Vincent's avatar
Jesse Vincent committed
162

Jesse Vincent's avatar
Jesse Vincent committed
163
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
164
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
165
<&|/l&>State</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
166
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
167
<input name="State" value="<%$UserObj->State%>" size="3" />
Jesse Vincent's avatar
Jesse Vincent committed
168

Jesse Vincent's avatar
Jesse Vincent committed
169
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
170
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
171
<&|/l&>Zip</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
172
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
173
<input name="Zip" value="<%$UserObj->Zip%>" size="9" />
Jesse Vincent's avatar
Jesse Vincent committed
174
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
175
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
176
<&|/l&>Country</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
177
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
178
<input name="Country" value="<%$UserObj->Country%>" />
Jesse Vincent's avatar
Jesse Vincent committed
179
180
</td></tr>
</table>
Jesse Vincent's avatar
Jesse Vincent committed
181
</&>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
182
<br />
Jesse Vincent's avatar
Jesse Vincent committed
183
<&| /Widgets/TitleBox, title => loc('Phone numbers') &>
Jesse Vincent's avatar
Jesse Vincent committed
184
<table>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
185
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
186
<&|/l&>Residence</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
187
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
188
<input name="HomePhone" value="<%$UserObj->HomePhone%>" size="13" /><br />
Jesse Vincent's avatar
Jesse Vincent committed
189
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
190
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
191
<&|/l&>Work</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
192
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
193
<input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size="13" /><br />
Jesse Vincent's avatar
Jesse Vincent committed
194
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
195
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
196
<&|/l&>Mobile</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
197
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
198
<input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size="13" /><br />
Jesse Vincent's avatar
Jesse Vincent committed
199
</td></tr>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
200
<tr><td align="right">
Jesse Vincent's avatar
Jesse Vincent committed
201
<&|/l&>Pager</&>: 
Jesse Vincent's avatar
Jesse Vincent committed
202
</td><td>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
203
<input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size="13" /><br />
Jesse Vincent's avatar
Jesse Vincent committed
204
</td>
205
</tr>
Jesse Vincent's avatar
Jesse Vincent committed
206
</table>
Thomas Sibley's avatar
Thomas Sibley committed
207
</&>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
208
<br />
Jesse Vincent's avatar
Jesse Vincent committed
209
<&| /Widgets/TitleBox, title => loc('Custom Fields') &>
Jesse Vincent's avatar
Jesse Vincent committed
210
<table>
211
212
% my $CFs = $UserObj->CustomFields;
% while (my $CF = $CFs->Next) {
Ruslan Zakirov's avatar
Ruslan Zakirov committed
213
<tr valign="top"><td align="right">
214
<% $CF->Name %>:
Jesse Vincent's avatar
Jesse Vincent committed
215
</td><td>
216
% if ($UserObj->id) {
217
<& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
218
219
220
% } else {
<& /Elements/EditCustomField, %ARGS, NamePrefix => 'Object-RT::User-new-CustomField-', CustomField => $CF &>
% }
Jesse Vincent's avatar
Jesse Vincent committed
221
</td></tr>
222
% }
Jesse Vincent's avatar
Jesse Vincent committed
223
</table>
Jesse Vincent's avatar
Jesse Vincent committed
224
</&>
225
226
<& /Elements/Callback, _CallbackName => 'RightColumnBottom', UserObj => $UserObj, %ARGS &>
</td></tr>
Jesse Vincent's avatar
Jesse Vincent committed
227
228
<tr>
<td colspan="2">
Jesse Vincent's avatar
Jesse Vincent committed
229
<&| /Widgets/TitleBox, title => loc('Comments about this user') &>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
230
<textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments%></textarea>
Jesse Vincent's avatar
Jesse Vincent committed
231
</&>
232
%if (!$Create && $UserObj->Privileged) {
Ruslan Zakirov's avatar
Ruslan Zakirov committed
233
<br />
Jesse Vincent's avatar
Jesse Vincent committed
234
<&| /Widgets/TitleBox, title => loc('Signature') &>
Ruslan Zakirov's avatar
Ruslan Zakirov committed
235
<textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature%></textarea>
Jesse Vincent's avatar
Jesse Vincent committed
236
</&>
237
238
% }

Jesse Vincent's avatar
Jesse Vincent committed
239
240
241
</td>
</tr>
</table>
242

243
<& /Elements/Submit, Label => loc('Save Changes') &>
244
</form>
245

246
<%INIT>
247

Linda Julien's avatar
Linda Julien committed
248
my $current_tab;
249
my $UserObj = new RT::User($session{'CurrentUser'});
250
my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
251

252
253
my ($val, $msg);

254
if ($Create) {
Linda Julien's avatar
Linda Julien committed
255
    $current_tab = 'Admin/Users/Modify.html?Create=1';
256
    $title = loc("Create a new user");
257
258
} 
else {
259

260
261
262
    $current_tab = 'Admin/Users/Modify.html?id='.$id if $id;

    if ( defined $id && $id eq 'new') {
Jesse Vincent's avatar
Jesse Vincent committed
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
	( $val, $msg ) = $UserObj->Create(
	    Name                  => $Name,
	    EmailAddress          => $ARGS{'EmailAddress'},
	    Name                  => $ARGS{'Name'},
	    Comments              => $ARGS{'Comments'},
	    Signature             => $ARGS{'Signature'},
	    EmailAddress          => $ARGS{'EmailAddress'},
	    FreeformContactInfo   => $ARGS{'FreeformContactInfo'},
	    Organization          => $ARGS{'Organization'},
	    RealName              => $ARGS{'RealName'},
	    NickName              => $ARGS{'NickName'},
	    Lang                  => $ARGS{'Lang'},
	    EmailEncoding         => $ARGS{'EmailEncoding'},
	    WebEncoding           => $ARGS{'WebEncoding'},
	    ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
	    ContactInfoSystem     => $ARGS{'ContactInfoSystem'},
	    Gecos                 => $ARGS{'Gecos'},
	    ExternalAuthId        => $ARGS{'ExternalAuthId'},
	    AuthSystem            => $ARGS{'AuthSystem'},
	    HomePhone             => $ARGS{'HomePhone'},
	    WorkPhone             => $ARGS{'WorkPhone'},
	    MobilePhone           => $ARGS{'MobilePhone'},
	    PagerPhone            => $ARGS{'PagerPhone'},
	    Address1              => $ARGS{'Address1'},
	    Address2              => $ARGS{'Address2'},
	    City                  => $ARGS{'City'},
	    State                 => $ARGS{'State'},
	    Zip                   => $ARGS{'Zip'},
	    Country               => $ARGS{'Country'},
	    Privileged           => $ARGS{'Privileged'},
	    Disabled            => ($ARGS{'Enabled'} ? 0 : 1)
	);

Jesse Vincent's avatar
Jesse Vincent committed
296
297
	if ($val) {
		push @results, $msg;
298
299
300
301
302
303
304
        foreach my $key ( keys %ARGS) {
            # Convert custom fields on the "new" object to custom fields on the one we've just created
            if ($key =~ /^Object-RT::User-new-CustomField-(.*)$/) {
            $ARGS{'Object-RT::User-'.$val.'-CustomField-'.$1} = delete $ARGS{$key};
            }
        }
        push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
Jesse Vincent's avatar
Jesse Vincent committed
305
	} else {
306
		push @results, loc('User could not be created: [_1]', $msg);
Jesse Vincent's avatar
Jesse Vincent committed
307
	}
308
    } else {
309
310
	    $UserObj->Load($id) || $UserObj->Load($Name) 
            || Abort("Couldn't load user '" . ( $Name || '') . "'");
311
        $val = $UserObj->Id();
312
313
314
    }

    if ($val) {
315
	$title = loc("Modify the user [_1]", $UserObj->Name);
Jesse Vincent's avatar
Jesse Vincent committed
316
    }
317
318
319

    # If the create failed
    else {
320
	$title = loc("Create a new user");
321
	$Create = 1;
Jesse Vincent's avatar
Jesse Vincent committed
322
    }
323
}
324
325
326
327




328
# If we have a user to modify, lets try. 
329
if ($UserObj->Id && $id ne 'new') {
Jesse Vincent's avatar
Jesse Vincent committed
330

331
332
333
334
    my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo 
		    Organization RealName NickName Lang EmailEncoding WebEncoding 
		    ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
		    AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
Jesse Vincent's avatar
Jesse Vincent committed
335
		    Address2 City State Zip Country 
336
		   );
Jesse Vincent's avatar
Jesse Vincent committed
337

338
339
340
341
    my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
					    Object => $UserObj,
					    ARGSRef => \%ARGS );
    push (@results,@fieldresults);
Linda Julien's avatar
Linda Julien committed
342
    push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
343

344

Jesse Vincent's avatar
Jesse Vincent committed
345
346
347
348
349
    # {{{ Deal with special fields: Privileged, Enabled
    if  ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
         my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
         push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
    }
350

Jesse Vincent's avatar
Jesse Vincent committed
351
352
353
354
355
356
357
    #we're asking about enabled on the web page but really care about disabled.
    $Disabled = $Enabled ? 0 : 1;

    if  ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) { 
        my  ($code, $msg) = $UserObj->SetDisabled($Disabled);
        push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
    }
358
359


Jesse Vincent's avatar
Jesse Vincent committed
360
    # }}}
361
362
}

Jesse Vincent's avatar
Jesse Vincent committed
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
if ( $UserObj->Id ) {
    my $password_not_set;
    # Deal with Password field
    if ( !$Pass1 and !$Pass2 ) {
	$password_not_set = 1;
    } elsif ( $Pass1 ne $Pass2 ) {
	$password_not_set = 1;
        push @results, loc("Passwords do not match.");
    } elsif ( $Pass1 eq $Pass2 and !$UserObj->IsPassword($Pass1) ) {
        my ($code, $msg) = $UserObj->SetPassword($Pass1);
        push @results, loc_fuzzy($msg);
	$password_not_set = 1 unless $code;
    }
    if ($id eq 'new' and $password_not_set) {
	push @results, loc("A password was not set, so user won't be able to login.");
    } 
379
380
}

381

382
# Do some setup for the ui
Ruslan Zakirov's avatar
Ruslan Zakirov committed
383
unless ( $UserObj->id && $UserObj->Disabled ) {
384
385
    $EnabledChecked ="CHECKED";
}
386

387
if (!$Create && $UserObj->Privileged()) {  
388
389
390
    $PrivilegedChecked = "CHECKED";
}

Jesse Vincent's avatar
Jesse Vincent committed
391
392
393
394
# set the id, so the the menu will have the right info, this needs to
# be done here to avoid creating and then modifying a user
$id = $UserObj->Id;

395
396
397
398
399
</%INIT>


<%ARGS>
$id => undef
400
$Name  => undef
401
402
403
404
405
406
407
$Comments  => undef
$Signature  => undef
$EmailAddress  => undef
$FreeformContactInfo => undef
$Organization  => undef
$RealName  => undef
$NickName  => undef
408
$Privileged => undef
409
$SetPrivileged => undef
410
411
$Enabled => undef
$SetEnabled => undef
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
$Lang  => undef
$EmailEncoding  => undef
$WebEncoding => undef
$ExternalContactInfoId  => undef
$ContactInfoSystem  => undef
$Gecos => undef
$ExternalAuthId  => undef
$AuthSystem  => undef
$HomePhone => undef
$WorkPhone  => undef
$MobilePhone  => undef
$PagerPhone  => undef
$Address1 => undef
$Address2  => undef
$City  => undef
$State  => undef
$Zip  => undef
$Country => undef
$Pass1 => undef
$Pass2=> undef
432
$Create=> undef
433
</%ARGS>