Add cgi args parser
authorJamie Cameron <jcameron@webmin.com>
Sun, 7 Jun 2009 20:45:46 +0000 (20:45 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sun, 7 Jun 2009 20:45:46 +0000 (20:45 +0000)
quota/cgi_args.pl [new file with mode: 0644]
quota/list_groups.cgi
quota/list_users.cgi

diff --git a/quota/cgi_args.pl b/quota/cgi_args.pl
new file mode 100644 (file)
index 0000000..b23fa49
--- /dev/null
@@ -0,0 +1,37 @@
+
+do 'quota-lib.pl';
+
+sub cgi_args
+{
+my ($cgi) = @_;
+my ($fs) = grep { $_->[5] && &can_edit_filesys($_->[0]) } &list_filesystems();
+my @uinfo = getpwnam($remote_user);
+if ($cgi eq 'list_users.cgi' || $cgi eq 'list_groups.cgi') {
+       # First filesystem
+       return $fs ? 'dir='.&urlize($fs->[0]) : 'none';
+       }
+elsif ($cgi eq 'edit_user_quota.cgi') {
+       # First editable user
+       my $n = &filesystem_users($fs->[0]);
+       return $n ? 'filesys='.&urlize($fs->[0]).
+                   '&user='.&urlize($user{0,'user'}) : 'none';
+       }
+elsif ($cgi eq 'edit_group_quota.cgi') {
+       # First editable group
+       my $n = &filesystem_groups($fs->[0]);
+       return $n ? 'filesys='.&urlize($fs->[0]).
+                   '&group='.&urlize($group{0,'group'}) : 'none';
+       }
+elsif ($cgi eq 'user_filesys.cgi' || $cgi eq 'copy_user_form.cgi') {
+       return defined(@uinfo) ?
+               'user='.&urlize($remote_user) : 'user=root';
+       }
+elsif ($cgi eq 'group_filesys.cgi' || $cgi eq 'copy_group_form.cgi') {
+       if (defined(@uinfo)) {
+               my @ginfo = getgrgid($uinfo[3]);
+               return 'group='.&urlize($ginfo[0]) if (defined(@ginfo));
+               }
+       return 'group=bin';
+       }
+return undef;
+}
index b6c978b..2f19ec2 100755 (executable)
@@ -11,8 +11,8 @@ $whatfailed = $text{'lgroups_failed'};
 $form = 0;
 
 # List quotas
-&ui_print_header(&text('lgroups_quotas', $f),
-                $text{'lgroups_title'}, "", "list_groups");
+&ui_print_header(&text('lgroups_quotas', $f), $text{'lgroups_title'}, "",
+                "list_groups");
 
 # Build and show tabs
 $prog = "list_groups.cgi?dir=".&urlize($f);
index 1473062..220ec7c 100755 (executable)
@@ -11,8 +11,8 @@ $whatfailed = $text{'lusers_failed'};
 $form = 0;
 
 # List quotas
-&ui_print_header(&text('lusers_qoutas', $f),
-                $text{'lusers_title'}, "", "list_users");
+&ui_print_header(&text('lusers_qoutas', $f), $text{'lusers_title'},
+                "", "list_users");
 
 # Build and show tabs
 $prog = "list_users.cgi?dir=".&urlize($f);