ui-lib conversion and perl niceness

This commit is contained in:
Jamie Cameron
2013-12-16 17:11:16 -08:00
parent fcb70ab992
commit 449b885ef7
3 changed files with 24 additions and 18 deletions

View File

@@ -2,37 +2,39 @@
# edit_sync.cgi
# Display unix/webmin user synchronization
use strict;
use warnings;
require './acl-lib.pl';
our (%in, %text, %config, %access);
$access{'sync'} && $access{'create'} && $access{'delete'} ||
&error($text{'sync_ecannot'});
&ui_print_header(undef, $text{'sync_title'}, "");
@glist = &list_groups();
my @glist = &list_groups();
if (!@glist) {
print "<p>$text{'sync_nogroups'}<p>\n";
&ui_print_footer("", $text{'index_return'});
exit;
}
print "<form action=save_sync.cgi>\n";
print "<b>$text{'sync_desc'}</b><p>\n";
printf "<input type=checkbox name=create value=1 %s> %s<p>\n",
$config{'sync_create'} ? "checked" : "", $text{'sync_create'};
printf "<input type=checkbox name=delete value=1 %s> %s<p>\n",
$config{'sync_delete'} ? "checked" : "", $text{'sync_delete'};
printf "<input type=checkbox name=unix value=1 %s> %s<p>\n",
$config{'sync_unix'} ? "checked" : "", $text{'sync_unix'};
print &ui_form_start("save_sync.cgi");
print &ui_table_start(undef, undef, 2);
print "$text{'sync_group'} <select name=group>\n";
foreach $g (@glist) {
printf "<option %s>%s\n",
$g->{'name'} eq $config{'sync_group'} ? "selected" : "",
$g->{'name'},
"</option>";
}
print "</select><p>\n";
# Sync on creation / deletion
print &ui_table_row($text{'sync_when'},
&ui_checkbox("create", 1, $text{'sync_create'}, $config{'sync_create'}).
"<br>\n".
&ui_checkbox("delete", 1, $text{'sync_delete'}, $config{'sync_delete'}).
"<br>\n".
&ui_checkbox("unix", 1, $text{'sync_unix'}, $config{'sync_unix'}));
print "<input type=submit value='$text{'save'}'></form>\n";
# Assign new users to group
print &ui_table_row($text{'sync_group'},
&ui_select("group", $config{'sync_group'},
[ map { $_->{'name'} } @glist ]));
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'save'} ] ]);
&ui_print_footer("", $text{'index_return'});

View File

@@ -292,6 +292,7 @@ convert_users=Users to convert
sync_title=Unix User Synchronization
sync_desc=This form allows you to configure the automatic synchronization of Unix users created through Webmin and users in this module.
sync_nogroups=No Webmin groups have been defined on your system. At least one group must be created to set the access for created users.
sync_when=When to synchronize
sync_create=Create a Webmin user when a Unix user is created.
sync_update=Update the matching Webmin user when a Unix user is updated.
sync_delete=Delete the matching Webmin user when a Unix user is deleted.

View File

@@ -2,7 +2,10 @@
# save_sync.cgi
# Save unix/webmin user synchronization
use strict;
use warnings;
require './acl-lib.pl';
our (%in, %text, %config, %access, $module_config_directory);
&ReadParse();
$access{'sync'} && $access{'create'} && $access{'delete'} ||
&error($text{'sync_ecannot'});