$schema = $ldap->schema();
$pft = $schema->attribute("shadowLastChange") ? 2 : 0;
+# Instructions
+print &ui_hidden_start($text{'batch_instr'}, "instr", 0, "batch_form.cgi");
print "$text{'batch_desc'}\n";
print "<p><tt>",$text{'batch_desc'.$pft},"</tt><p>\n";
print "$text{'batch_descafter'}<br>\n";
print "$text{'batch_descafter2'}<br>\n";
-print "$text{'batch_descafter3'}<br>\n";
-
-print "<form action=batch_exec.cgi method=post enctype=multipart/form-data>\n";
-print "<table>\n";
-
-print "<tr> <td valign=top><b>$text{'batch_source'}</b></td> <td>\n";
-print "<input type=radio name=source value=0 checked> ",
- "$text{'batch_source0'} <input type=file name=file><br>\n";
-print "<input type=radio name=source value=1> ",
- "$text{'batch_source1'} <input name=local size=30> ",
- &file_chooser_button("local"),"<br>\n";
-print "<input type=radio name=source value=2> ",
- "$text{'batch_source2'}<br><textarea name=text rows=5 cols=50></textarea>",
- "</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_others'}</b></td>\n";
-print "<td>",&ui_yesno_radio("others", $mconfig{'default_other'} ? 1 : 0),
- "</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_batch'}</b></td>\n";
-print "<td>",&ui_yesno_radio("batch", 1),"</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_makehome'}</b></td>\n";
-print "<td>",&ui_yesno_radio("makehome", 1),"</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_copy'}</b></td>\n";
-print "<td>",&ui_yesno_radio("copy", 1),"</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_movehome'}</b></td>\n";
-print "<td>",&ui_yesno_radio("movehome", 1),"</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_chuid'}</b></td>\n";
-print "<td>",&ui_radio("chuid", 1, [ [ 0, $text{'no'} ],
- [ 1, $text{'home'} ],
- [ 2, $text{'uedit_allfiles'} ] ]),"</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_chgid'}</b></td>\n";
-print "<td>",&ui_radio("chgid", 1, [ [ 0, $text{'no'} ],
- [ 1, $text{'home'} ],
- [ 2, $text{'uedit_allfiles'} ] ]),"</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_delhome'}</b></td>\n";
-print "<td>",&ui_yesno_radio("delhome", 1),"</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_crypt'}</b></td>\n";
-print "<td>",&ui_yesno_radio("crypt", 0),"</td> </tr>\n";
-
-print "<tr> <td><b>$text{'batch_samba'}</b></td>\n";
-print "<td>",&ui_yesno_radio("samba", $config{'samba_def'} ? 1 : 0),"</td> </tr>\n";
-
-print "<tr> <td><input type=submit value=\"$text{'batch_upload'}\"></td> </tr>\n";
-print "</table></form>\n";
+print &ui_hidden_end("instr");
+
+print &ui_form_start("batch_exec.cgi", "form-data");
+print &ui_table_start($text{'batch_header'}, undef, 2);
+
+# Source file
+print &ui_table_row($text{'batch_source'},
+ &ui_radio_table("source", 0,
+ [ [ 0, $text{'batch_source0'}, &ui_upload("file") ],
+ [ 1, $text{'batch_source1'}, &ui_textbox("local", undef, 40)." ".
+ &file_chooser_button("local") ],
+ [ 2, $text{'batch_source2'}, &ui_textarea("text", undef, 5, 60) ]
+ ]));
+
+# Do other modules?
+print &ui_table_row($text{'batch_others'},
+ &ui_yesno_radio("others", $config{'default_other'}));
+
+# Only run post-command at end?
+print &ui_table_row($text{'batch_batch'},
+ &ui_yesno_radio("batch", 0));
+
+# Create home dir
+print &ui_table_row($text{'batch_makehome'},
+ &ui_yesno_radio("makehome", 1));
+
+# Copy files to homes
+print &ui_table_row($text{'batch_copy'},
+ &ui_yesno_radio("copy", 1));
+
+# Move home dirs
+print &ui_table_row($text{'batch_movehome'},
+ &ui_yesno_radio("movehome", 1));
+
+# Update UIDs on files
+print &ui_table_row($text{'batch_chuid'},
+ &ui_radio("chuid", 1, [ [ 0, $text{'no'} ],
+ [ 1, $text{'home'} ],
+ [ 2, $text{'uedit_allfiles'} ] ]));
+
+# Update GIDs on files
+print &ui_table_row($text{'batch_chgid'},
+ &ui_radio("chgid", 1, [ [ 0, $text{'no'} ],
+ [ 1, $text{'home'} ],
+ [ 2, $text{'uedit_allfiles'} ] ]));
+
+# Delete home dirs
+print &ui_table_row($text{'batch_delhome'},
+ &ui_yesno_radio("delhome", 1));
+
+# Encrypt password
+print &ui_table_row($text{'batch_crypt'},
+ &ui_yesno_radio("crypt", 0));
+
+# Create Samba account
+print &ui_table_row($text{'batch_samba'},
+ &ui_yesno_radio("samba", $config{'samba_def'} ? 1 : 0));
+
+print &ui_table_end();
+print &ui_form_end([ [ undef, $text{'batch_upload'} ] ]);
&ui_print_footer("", $text{'index_return'});
if ($in{'confirmed'}) {
foreach $group (@dlist) {
# Show username
- print "<b>",&text('gmass_doing', $group->{'group'}),"</b><br>\n";
+ print "<b>",&text('gmass_doing', $group->{'group'}),
+ "</b><br>\n";
print "<ul>\n";
# Delete from other modules
if ($in{'others'}) {
print "$text{'gdel_other'}<br>\n";
local $error_must_die = 1;
- eval { &other_modules("useradmin_delete_group", $group); };
+ eval { &other_modules("useradmin_delete_group",
+ $group); };
if ($@) {
print &text('udel_failed', $@),"<p>\n";
}
print "$text{'gdel_group'}<br>\n";
&set_group_envs($group, 'DELETE_GROUP');
$merr = &making_changes();
- &error(&text('usave_emaking', "<tt>$merr</tt>")) if (defined($merr));
+ &error(&text('usave_emaking', "<tt>$merr</tt>"))
+ if (defined($merr));
&delete_group($group);
&unlock_user_files();
}
# Ask if the user is sure
- print "<form action=mass_delete_group.cgi>\n";
- foreach $group (@dlist) {
- print "<input type=hidden name=gd value='$group->{'group'}'>\n";
- }
- print "<input type=hidden name=confirmed value=1>\n";
- print "<center><b>",&text('gmass_sure', scalar(@dlist)),"</b><p>\n";
- print "<input type=submit value=\"$text{'gdel_del'}\">\n";
- print "<br><input type=checkbox name=others value=1 checked> ",
- "$text{'gdel_dothers'}<br>\n";
- print "</center><p>\n";
- print "</form>\n";
+ print &ui_confirmation_form(
+ "mass_delete_group.cgi",
+ &text('gmass_sure', scalar(@dlist)),
+ [ map { [ "gd", $_->{'group'} ] } @dlist ],
+ [ [ "confirmed", $text{'gdel_del'} ] ],
+ &ui_checkbox("others", 1, $text{'gdel_dothers'},
+ $mconfig{'default_other'}),
+ );
+
&ui_print_footer("", $text{'index_return'});
}
}
else {
# Ask if the user is sure
- print "<form action=mass_delete_user.cgi>\n";
- print "<input type=hidden name=confirmed value=1>\n";
- print "<input type=hidden name=disable value=1>\n";
- foreach $user (@dlist) {
- print "<input type=hidden name=d value='$user->{'user'}'>\n";
- }
-
- # Show buttons
- print "<center><b>",&text('dmass_sure',
- scalar(@dlist)),"</b<p>\n";
- print "<input type=submit value=\"$text{'dmass_dis'}\">\n";
- print "<br>\n";
- print "</form></center>\n";
+ print &ui_confirmation_form(
+ "mass_delete_user.cgi",
+ &text('dmass_sure', scalar(@dlist)),
+ [ [ "confirmed", 1 ],
+ [ "disable", 1 ],
+ map { [ "d", $_->{'user'} ] } @dlist ],
+ [ [ undef, $text{'dmass_dis'} ] ],
+ );
&ui_print_footer("", $text{'index_return'});
}
&ui_print_footer("", $text{'index_return'});
}
else {
- # Ask if the user is sure
- print "<form action=mass_delete_user.cgi>\n";
- print "<input type=hidden name=confirmed value=1>\n";
- foreach $user (@dlist) {
- print "<input type=hidden name=d value='$user->{'user'}'>\n";
- }
-
# Sum up home directories
foreach $user (@dlist) {
if ($user->{'home'} ne "/" && -d $user->{'home'}) {
}
}
- # Show buttons
- print "<center><b>",&text('umass_sure',
- scalar(@dlist), &nice_size($size*1024)),"</b><p>\n";
- print "<input type=submit value=\"$text{'umass_del1'}\">\n";
- print "<input name=delhome type=submit ",
- "value=\"$text{'umass_del2'}\">\n";
- print "<br>\n";
- printf "<input type=checkbox name=others value=1 %s> %s<br>\n",
- $mconfig{'default_other'} ? "checked" : "",
- $text{'udel_dothers'};
- if ($delete_sys && $delete_sys->{'user'} eq 'root') {
- print "<center><b><font color=#ff0000>$text{'udel_root'}",
- "</font></b><p></center>\n";
- }
- print "</form></center>\n";
+ # Ask if the user is sure
+ print &ui_confirmation_form(
+ "mass_delete_user.cgi",
+ &text('umass_sure', scalar(@dlist),
+ &nice_size($size*1024)),
+ [ [ "confirmed", 1 ],
+ map { [ "d", $_->{'user'} ] } @dlist ],
+ [ [ undef, $text{'umass_del1'} ],
+ [ "delhome", $text{'umass_del2'} ] ],
+ &ui_checkbox("others", 1, $text{'udel_dothers'},
+ $mconfig{'default_other'}),
+ $delete_sys && $delete_sys->{'user'} eq 'root' ?
+ "<font color=#ff0000>$text{'udel_root'}</font>"
+ : ""
+ );
&ui_print_footer("", $text{'index_return'});
}
# Check if any user has this group as his primary
$gid = $ginfo->get_value("gidNumber");
$group = $ginfo->get_value("cn");
-
- setpwent();
- while(@uinfo = getpwent()) {
- if ($uinfo[3] == $gid) {
- $found = $uinfo[0];
+ foreach $u (&list_users()) {
+ if ($u->{'gid'} == $gid) {
+ $found = $u->{'user'};
last;
}
}
- endpwent();
if ($found) {
# Cannot delete
}
else {
# Show confirmation page
- print "<form action=save_user.cgi>\n";
- print "<input type=hidden name=dn value=\"$in{'dn'}\">\n";
- print "<input type=hidden name=delete value=1>\n";
- print "<input type=hidden name=confirm value=1>\n";
-
if ($home ne "/" && -d $home) {
+ # With option to delete home
$size = &nice_size(&disk_usage_kb($home)*1024);
- print "<center><b>",&text('udel_sure', $user, $home,
- $size),"</b><p>\n";
- print "<input type=submit ",
- "value=\"$text{'udel_del1'}\">\n";
- print "<input name=delhome type=submit ",
- "value=\"$text{'udel_del2'}\">\n";
+ $msg = &text('udel_sure', $user, $home, $size);
+ @buts = ( [ undef, $text{'udel_del1'} ],
+ [ "delhome", $text{'udel_del2'} ] );
}
else {
- print "<center><b>",&text('udel_sure2', $user),
- "</b><p>\n";
- print "<input type=submit ",
- "value=\"$text{'udel_del1'}\">\n";
- }
- if ($user eq 'root') {
- print "<b><font color=#ff0000>",
- "$text{'udel_root'}</font></b><p>\n";
- }
-
- if ($config{'imap_host'}) {
- # TODO quota anzeigen
- $imap = &imap_connect();
- $rv = $imap->status("user.".$user, "messages");
- if ($rv->{'Status'} eq 'ok') {
- print "<h4><B>$text{'udel_warnimap'}</B></h4>\n";
- }
- $imap->logout();
- }
-
- printf "<br><input type=checkbox name=others value=1 %s> %s<br>\n",
- $mconfig{'default_other'} ? "checked" : "",
- $text{'udel_dothers'};
- print "</form></center>\n";
+ # Without home
+ $msg = &text('udel_sure2', $user);
+ @buts = ( [ undef, $text{'udel_del1'} ] );
+ }
+ print &ui_confirmation_form(
+ "save_user.cgi",
+ $msg,
+ [ [ "dn", $in{'dn'} ],
+ [ "confirm", 1 ],
+ [ "delete", 1 ] ],
+ \@buts,
+ &ui_checkbox("others", 1, $text{'udel_dothers'},
+ $mconfig{'default_other'}),
+ $user eq 'root' ?
+ "<font color=#ff0000>$text{'udel_root'}</font>" : ""
+ );
}
$ldap->unbind();