#!/usr/local/bin/perl
-# edit_passwd.cgi
+# Show password change form
require './passwd-lib.pl';
&ReadParse();
@user = getpwnam($in{'user'});
@user || &error($text{'passwd_euser'});
&can_edit_passwd(\@user) || &error($text{'passwd_ecannot'});
-
-# Show password change form
&ui_print_header(undef, $text{'passwd_title'}, "");
-print "<form action=save_passwd.cgi method=post>\n";
-print "<input type=hidden name=user value='$user[0]'>\n";
-print "<input type=hidden name=one value='$in{'one'}'>\n";
-print "<table border>\n";
-print "<tr $tb> <td><b>$text{'passwd_header'}</b></td> </tr>\n";
-print "<tr $cb> <td><table>\n";
+print &ui_form_start("save_passwd.cgi", "post");
+print &ui_hidden("user", $user[0]);
+print &ui_hidden("one", $in{'one'});
+print &ui_table_start($text{'passwd_header'}, undef, 2);
+
+# Login and real name
%uconfig = &foreign_config("useradmin");
-print "<tr> <td><b>$text{'passwd_for'}</b></td>\n";
$user[6] =~ s/,.*$// if ($uconfig{'extra_real'});
-print "<td>$user[0]",( $user[6] ? " ($user[6])" : "" ),
- "</td> </tr>\n";
+print &ui_table_row($text{'passwd_for'},
+ $user[0].( $user[6] ? " ($user[6])" : "" ));
+# Old password field
if ($access{'old'} == 1 ||
$access{'old'} == 2 && $user[0] ne $remote_user) {
- print "<tr> <td><b>$text{'passwd_old'}</b></td>\n";
- print "<td><input name=old size=25 type=password></td> </tr>\n";
+ print &ui_table_row($text{'passwd_old'},
+ &ui_password("old", undef, 30));
}
-print "<tr> <td><b>$text{'passwd_new'}</b></td>\n";
-print "<td><input name=new size=25 type=password></td> </tr>\n";
+# New password
+print &ui_table_row($text{'passwd_new'},
+ &ui_password("new", undef, 30));
+# New password again
if ($access{'repeat'}) {
- print "<tr> <td><b>$text{'passwd_repeat'}</b></td>\n";
- print "<td><input name=repeat size=25 type=password></td> </tr>\n";
+ print &ui_table_row($text{'passwd_repeat'},
+ &ui_password("repeat", undef, 30));
}
+# Force change at next login
if (!$config{'passwd_cmd'} && $access{'expire'}) {
&foreign_require("useradmin", "user-lib.pl");
$pft = &useradmin::passfiles_type();
($uuser) = grep { $_->{'user'} eq $in{'user'} }
&useradmin::list_users();
if ($uuser->{'max'} && ($pft == 2 || $pft == 5)) {
- print "<tr> <td colspan=2>\n";
- print "<input type=checkbox name=expire value=1> ",
- "$text{'passwd_expire'}</td> </tr>\n";
+ print &ui_table_row(" ",
+ &ui_checkbox("expire", 1, $text{'passwd_expire'}, 0));
}
}
+# Change in other modules
if ($access{'others'} == 2) {
- print "<tr> <td colspan=2>\n";
- print "<input type=checkbox name=others value=1 checked> ",
- "$text{'passwd_others'}</td> </tr>\n";
+ print &ui_table_row(" ",
+ &ui_checkbox("others", 1, $text{'passwd_others'}, 1));
}
-print "<tr> <td colspan=2>\n";
-print "<input type=submit value='$text{'passwd_change'}'>\n";
-print "<input type=reset value='$text{'passwd_reset'}'></td> </tr>\n";
+print &ui_table_end();
+print &ui_form_end([ [ undef, $text{'passwd_change'} ] ]);
-print "</table></td></tr></table></form>\n";
&ui_print_footer($in{'one'} ? ( "/", $text{'index'} ) :
( "", $text{'index_return'} ));
# Display a list of users whose passwords can be changed
require './passwd-lib.pl';
+
+# Show an error if we don't know how to change passwords
if (!$config{'passwd_cmd'} && !&foreign_check("useradmin")) {
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
print "<p>$text{'index_euseradmin'}<p>\n";
if ($config{'max_users'} && @ulist > $config{'max_users'}) {
# Show as form for entering a username
print "$text{'index_toomany'}<br>\n";
- print "<form action=edit_passwd.cgi>\n";
- print "<input type=submit value='$text{'index_user'}'>\n";
+ print &ui_form_start("edit_passwd.cgi");
+ print &ui_submit($text{'index_user'});
if ($config{'input_type'}) {
- print "<select name=user>\n";
- foreach $u (@ulist) {
- print "<option>$u->[0]\n";
- }
- print "</select>\n";
+ print &ui_select("user", undef,
+ [ map { $_->[0] } @ulist ]);
}
else {
- print "<input name=user size=13> ",
- &user_chooser_button("user",0);
+ print &ui_user_textbox("user");
}
- print "</form>\n";
+ print &ui_form_end();
}
elsif (@ulist) {
# Show as table of users
- print "<table border width=100%>\n";
- print "<tr $tb> <td><b>$text{'index_header'}</b></td> </tr>\n";
- print "<tr $cb> <td><table width=100%>\n";
+ @grid = ( );
for($i=0; $i<@ulist; $i++) {
if ($i%4 == 0) { print "<tr>\n"; }
- print "<td width=25%><a href=\"edit_passwd.cgi?",
- "user=$ulist[$i]->[0]\">",
- &html_escape($ulist[$i]->[0])."</a></td>\n";
- if ($i%4 == 3) { print "</tr>\n"; }
+ push(@grid, "<a href=\"edit_passwd.cgi?".
+ "user=$ulist[$i]->[0]\">".
+ &html_escape($ulist[$i]->[0])."</a>");
}
- while($i++ % 4) { print "<td width=25%></td>\n"; }
- print "</table></td> </tr></table><p>\n";
+ print &ui_grid_table(\@grid, 4, 100, undef, undef,
+ $text{'index_header'});
}
else {
# No users available