ui-libification 99% done
authorJamie Cameron <jcameron@webmin.com>
Fri, 12 Dec 2008 01:19:45 +0000 (01:19 +0000)
committerJamie Cameron <jcameron@webmin.com>
Fri, 12 Dec 2008 01:19:45 +0000 (01:19 +0000)
quota/CHANGELOG
quota/acl_security.pl
quota/group_grace_form.cgi
quota/index.cgi
quota/lang/en
quota/quota-lib.pl
quota/user_grace_form.cgi

index 7718a3a..04c8772 100644 (file)
@@ -34,3 +34,5 @@ Quotas are considered active for a filesystem if the usrquota or grpquota option
 If a user to email is a Virtualmin domain owner, send email to the domain's contact address.
 ---- Changes since 1.430 ----
 Email to users and groups who are over quota on some filesystem can also be Cc'd to another address, such as the system administrator.
+---- Changes since 1.440 ----
+Converted all pages to use the new Webmin UI library, for a more consistent look. Also split the Filesystem Quotas page into tabs.
index df5b85e..9e7a1ac 100644 (file)
@@ -7,114 +7,87 @@ sub acl_security_form
 {
 local $groups = &quotas_supported() >= 2;
 
-print "<tr> <td valign=top><b>$text{'acl_fss'}</b></td>\n";
-print "<td colspan=3>\n";
-printf "<input type=radio name=filesys_def value=1 %s> %s\n",
-       $_[0]->{'filesys'} eq '*' ? 'checked' : '', $text{'acl_fall'};
-printf "<input type=radio name=filesys_def value=0 %s> %s<br>\n",
-       $_[0]->{'filesys'} eq '*' ? '' : 'checked', $text{'acl_fsel'};
-print "<select width=150 name=filesys multiple size=3>\n";
-local ($f, %qcan);
-map { $qcan{$_}++ } split(/\s+/, $_[0]->{'filesys'});
-foreach $f (&list_filesystems()) {
-       if ($f->[4]) {
-               printf "<option %s>%s\n",
-                       $qcan{$f->[0]} ? "selected" : "", $f->[0];
-               }
-       }
-print "</select></td> </tr>\n";
-
-print "<tr> <td><b>$text{'acl_ro'}</b></td> <td>\n";
-printf "<input type=radio name=ro value=1 %s> $text{'yes'}\n",
-       $_[0]->{'ro'} ? "checked" : "";
-printf "<input type=radio name=ro value=0 %s> $text{'no'}</td> </tr>\n",
-       $_[0]->{'ro'} ? "" : "checked";
-
-print "<tr> <td colspan=4><hr></td> </tr>\n";
-
-print "<tr> <td><b>$text{'acl_quotaon'}</b></td> <td>\n";
-printf "<input type=radio name=enable value=1 %s> $text{'yes'}\n",
-       $_[0]->{'enable'} ? "checked" : "";
-printf "<input type=radio name=enable value=0 %s> $text{'no'}</td>\n",
-       $_[0]->{'enable'} ? "" : "checked";
-
-print "<td><b>$text{'acl_quotanew'}</b></td> <td>\n";
-printf "<input type=radio name=default value=1 %s> $text{'yes'}\n",
-       $_[0]->{'default'} ? "checked" : "";
-printf "<input type=radio name=default value=0 %s> $text{'no'}</td> </tr>\n",
-       $_[0]->{'default'} ? "" : "checked";
-
-print "<tr> <td><b>$text{'acl_ugrace'}</b></td> <td>\n";
-printf "<input type=radio name=ugrace value=1 %s> $text{'yes'}\n",
-       $_[0]->{'ugrace'} ? "checked" : "";
-printf "<input type=radio name=ugrace value=0 %s> $text{'no'}</td>\n",
-       $_[0]->{'ugrace'} ? "" : "checked";
-
-print "<td><b>$text{'acl_vtotal'}</b></td> <td>\n";
-printf "<input type=radio name=diskspace value=1 %s> $text{'yes'}\n",
-       $_[0]->{'diskspace'} ? "checked" : "";
-printf "<input type=radio name=diskspace value=0 %s> $text{'no'}</td> </tr>\n",
-       $_[0]->{'diskspace'} ? "" : "checked";
-
-print "<tr> <td><b>$text{'acl_maxblocks'}</b></td> <td>\n";
-printf "<input type=radio name=maxblocks_def value=1 %s> %s\n",
-       $_[0]->{'maxblocks'} ? '' : 'checked', $text{'acl_unlimited'};
-printf "<input type=radio name=maxblocks_def value=0 %s>\n",
-       $_[0]->{'maxblocks'} ? 'checked' : '';
-print "<input name=maxblocks size=8 value='$_[0]->{'maxblocks'}'></td>\n";
-
-print "<td><b>$text{'acl_maxfiles'}</b></td> <td>\n";
-printf "<input type=radio name=maxfiles_def value=1 %s> %s\n",
-       $_[0]->{'maxfiles'} ? '' : 'checked', $text{'acl_unlimited'};
-printf "<input type=radio name=maxfiles_def value=0 %s>\n",
-       $_[0]->{'maxfiles'} ? 'checked' : '';
-print "<input name=maxfiles size=8 value='$_[0]->{'maxfiles'}'></td> </tr>\n";
-
-print "<tr> <td><b>$text{'acl_email'}</b></td> <td>\n";
-printf "<input type=radio name=email value=1 %s> $text{'yes'}\n",
-       $_[0]->{'email'} ? "checked" : "";
-printf "<input type=radio name=email value=0 %s> $text{'no'}</td>\n",
-       $_[0]->{'email'} ? "" : "checked";
-
+# Allowed filesystems
+print &ui_table_row($text{'acl_fss'},
+       &ui_radio("filesys_def", $_[0]->{'filesys'} eq '*' ? 1 : 0,
+                 [ [ 1, $text{'acl_fall'} ], [ 0, $text{'acl_fsel'} ] ]).
+       "<br>\n".
+       &ui_select("filesys",
+                  $_[0]->{'filesys'} eq '*' ? [ ] :
+                       [ split(/\s+/, $_[0]->{'filesys'}) ],
+                  [ map { $_->[0] } grep { $_->[4] } &list_filesystems() ],
+                  6, 1, 1, 0), 3);
+
+# Readonly mode
+print &ui_table_row($text{'acl_ro'},
+       &ui_yesno_radio("ro", $_[0]->{'ro'}), 3);
+
+print &ui_table_hr();
+
+# Can enable quotas?
+print &ui_table_row($text{'acl_quotaon'},
+       &ui_yesno_radio("enable", $_[0]->{'enable'}));
+
+# Can edit defaults for new users?
+print &ui_table_row($text{'acl_quotanew'},
+       &ui_yesno_radio("default", $_[0]->{'default'}));
+
+# Can edit user grace times
+print &ui_table_row($text{'acl_ugrace'},
+       &ui_yesno_radio("ugrace", $_[0]->{'ugrace'}));
+
+# Can edit group grace times
 if ($groups) {
-       print "<td><b>$text{'acl_ggrace'}</b></td> <td>\n";
-       printf "<input type=radio name=ggrace value=1 %s> $text{'yes'}\n",
-               $_[0]->{'ggrace'} ? "checked" : "";
-       printf "<input type=radio name=ggrace value=0 %s> $text{'no'}</td>\n",
-               $_[0]->{'ggrace'} ? "" : "checked";
+       print &ui_table_row($text{'acl_ggrace'},
+               &ui_yesno_radio("ggrace", $_[0]->{'ggrace'}));
        }
-print "</tr>\n";
-
-print "<tr> <td colspan=4><hr></td> </tr>\n";
-
-print "<tr> <td valign=top><b>$text{'acl_uquota'}",
-      "</b></td> <td colspan=3>\n";
-printf "<input type=radio name=umode value=0 %s> $text{'acl_uall'}<br>\n",
-       $_[0]->{'umode'} == 0 ? "checked" : "";
-printf "<input type=radio name=umode value=1 %s> $text{'acl_uonly'}\n",
-       $_[0]->{'umode'} == 1 ? "checked" : "";
-printf "<input name=ucan size=40 value='%s'> %s<br>\n",
-       $_[0]->{'umode'} == 1 ? $_[0]->{'users'} : "",
-       &user_chooser_button("ucan", 1);
-printf "<input type=radio name=umode value=2 %s> $text{'acl_uexcept'}\n",
-       $_[0]->{'umode'} == 2 ? "checked" : "";
-printf "<input name=ucannot size=40 value='%s'> %s<br>\n",
-       $_[0]->{'umode'} == 2 ? $_[0]->{'users'} : "",
-       &user_chooser_button("ucannot", 1);
-printf "<input type=radio name=umode value=3 %s> $text{'acl_ugroup'}\n",
-       $_[0]->{'umode'} == 3 ? "checked" : "";
-printf "<input name=upri size=8 value='%s'> %s<br>\n",
-       $_[0]->{'umode'} == 3 ? scalar(getgrgid($_[0]->{'users'})) : "",
-       &group_chooser_button("upri", 0);
-printf "<input type=radio name=umode value=4 %s> $text{'acl_uuid'}\n",
-       $_[0]->{'umode'} == 4 ? "checked" : "";
-printf "<input name=umin size=6 value='%s'> -\n",
-       $_[0]->{'umode'} == 4 ? $_[0]->{'umin'} : "";
-printf "<input name=umax size=6 value='%s'></td> </tr>\n",
-       $_[0]->{'umode'} == 4 ? $_[0]->{'umax'} : "";
 
+# Can see total disk space
+print &ui_table_row($text{'acl_vtotal'},
+       &ui_yesno_radio("diskspace", $_[0]->{'diskspace'}));
+
+# Maximum block quota
+print &ui_table_row($text{'acl_maxblocks'},
+       &ui_opt_textbox("maxblocks", $_[0]->{'maxblocks'}, 8,
+                       $text{'acl_unlimited'}));
+
+# Maximum file quota
+print &ui_table_row($text{'acl_maxfiles'},
+       &ui_opt_textbox("maxfiles", $_[0]->{'maxfiles'}, 8,
+                       $text{'acl_unlimited'}));
+
+# Can edit email notifications?
+print &ui_table_row($text{'acl_email'},
+       &ui_yesno_radio("email", $_[0]->{'email'}));
+
+print &ui_table_hr();
+
+# Allowed users
+print &ui_table_row($text{'acl_uquota'},
+    &ui_radio_table("umode", int($_[0]->{'umode'}),
+       [ [ 0, $text{'acl_uall'} ],
+         [ 1,  $text{'acl_uonly'},
+           &ui_textbox("ucan",
+                       $_[0]->{'umode'} == 1 ? $_[0]->{'users'} : "",
+                       40)." ".&user_chooser_button("ucan", 1) ],
+         [ 2, $text{'acl_uexcept'},
+           &ui_textbox("ucannot",
+                       $_[0]->{'umode'} == 2 ? $_[0]->{'users'} : "",
+                       40)." ".&user_chooser_button("ucannot", 1) ],
+         [ 3, $text{'acl_ugroup'},
+           &ui_group_textbox("upri", $_[0]->{'umode'} == 3 ?
+                               scalar(getgrgid($_[0]->{'users'})) : "") ],
+         [ 4, $text{'acl_uuid'},
+           &ui_textbox("umin",
+                       $_[0]->{'umode'} == 4 ? $_[0]->{'umin'} : "", 6)." - ".
+           &ui_textbox("umax",
+                       $_[0]->{'umode'} == 4 ? $_[0]->{'umax'} : "", 6) ]
+       ]), 3);
+
+# Allowed groups
 if ($groups) {
-       print "<tr> <td colspan=4><hr></td> </tr>\n";
+       print &ui_hr();
+       # XXX
 
        print "<tr> <td valign=top><b>$text{'acl_gquota'}",
              "</b></td> <td colspan=3>\n";
index 2619786..ad72022 100755 (executable)
@@ -11,46 +11,34 @@ $access{'ggrace'} && &can_edit_filesys($in{'filesys'}) ||
 print "$text{'ggracef_info'}<p>\n";
 
 @gr = &get_group_grace($in{'filesys'});
-print "<form action=group_grace_save.cgi>\n";
-print "<input type=hidden name=filesys value=\"$in{'filesys'}\">\n";
-print "<table border width=100%>\n";
-print "<tr $tb> <td colspan=2><b>",&text('ggracef_graces', $in{'filesys'}),"</b></td></tr>\n";
+print &ui_form_start("group_grace_save.cgi");
+print &ui_hidden("filesys", $in{'filesys'});
+print &ui_table_start(&text('ggracef_graces', $in{'filesys'}), undef, 2);
 
-print "<tr $cb> <td width=20%><b>$text{'ggracef_block'}</b></td> <td>\n";
+# Block grace time
+$bfield = &ui_textbox("btime", $gr[0], 6)." ".
+         &select_grace_units("bunits", $gr[1]);
 if (&default_grace()) {
-       printf "<input type=radio name=bdef value=1 %s> $text{'default'}\n",
-               $gr[0] ? "" : "checked";
-       printf "<input type=radio name=bdef value=0 %s>\n",
-               $gr[0] ? "checked" : "";
+       $bfield = &ui_radio("bdef", $gr[0] ? 0 : 1,
+                           [ [ 1, $text{'default'} ],
+                             [ 0, $bfield ] ]);
        }
-print "<input name=btime size=6 value=\"$gr[0]\">";
-&select_units("bunits", $gr[1]);
-print "</td> </tr>\n";
+print &ui_table_row($text{'ugracef_block'}, $bfield);
 
-print "<tr $cb> <td width=20%><b>$text{'ggracef_file'}</b></td> <td>\n";
+# Files grace time
+$ffield = &ui_textbox("ftime", $gr[2], 6)." ".
+         &select_grace_units("funits", $gr[3]);
 if (&default_grace()) {
-       printf "<input type=radio name=fdef value=1 %s> $text{'default'}\n",
-               $gr[2] ? "" : "checked";
-       printf "<input type=radio name=fdef value=0 %s>\n",
-               $gr[2] ? "checked" : "";
+       $ffield = &ui_radio("fdef", $gr[2] ? 0 : 1,
+                           [ [ 1, $text{'default'} ],
+                             [ 0, $ffield ] ]);
        }
-print "<input name=ftime size=6 value=\"$gr[2]\">";
-&select_units("funits", $gr[3]);
-print "</td> </tr>\n";
-
-print "</table>\n";
-print "<input type=submit value=$text{'ggracef_update'}></form>\n";
-
-&ui_print_footer("list_groups.cgi?dir=".&urlize($in{'filesys'}),$text{'ggracef_return'});
-
-sub select_units
-{
-@uarr = &grace_units();
-print "<select name=$_[0]>\n";
-for($i=0; $i<@uarr; $i++) {
-       printf "<option value=$i %s>$uarr[$i]\n",
-               $i == $_[1] ? "selected" : "";
-       }
-print "</select>\n";
-}
+print &ui_table_row($text{'ugracef_file'}, $ffield);
+
+print &ui_table_end();
+print &ui_form_end([ [ undef, $text{'ugracef_update'} ] ]);
+
+&ui_print_footer("list_groups.cgi?dir=".&urlize($in{'filesys'}),
+                $text{'ggracef_return'});
+
 
index 6b732ac..305aa1a 100755 (executable)
@@ -100,28 +100,23 @@ else {
                }
        }
 
+# Buttons to edit and specific user or group
 if ($useractive || $groupactive) {
-       print "<table width=100%><tr>\n";
+       print &ui_hr();
+       print &ui_buttons_start();
        }
 if ($useractive) {
-       print "<form action=user_filesys.cgi>\n";
-       print "<td><input type=submit value=\"$text{'index_euser'}\">\n";
-       print "<input name=user size=8> ",
-             &user_chooser_button("user", 0),"</td></form>\n";
+       print &ui_buttons_row("user_filesys.cgi", $text{'index_euser'},
+                             $text{'index_euserdesc'}, undef,
+                             &ui_user_textbox("user"));
        }
-else { print "<td></td>\n"; }
-
 if ($groupactive) {
-       print "<form action=group_filesys.cgi>\n";
-       print "<td align=right>\n";
-       print "<input type=submit value=\"$text{'index_egroup'}\">\n";
-       print "<input name=group size=8> ",
-             &group_chooser_button("group", 0, $useractive ? 1 : 0),
-             "</td></form>\n";
+       print &ui_buttons_row("group_filesys.cgi", $text{'index_egroup'},
+                             $text{'index_egroupdesc'}, undef,
+                             &ui_group_textbox("group"));
        }
-else { print "<td></td>\n"; }
 if ($useractive || $groupactive) {
-       print "</tr></table>\n";
+       print &ui_buttons_end();
        }
 
 &ui_print_footer("/", $text{'index_return'});
index b48299c..b2a7d2a 100644 (file)
@@ -3,7 +3,7 @@ quota_unlimited=Unlimited
 acl_fss=Filesystems this user can edit
 acl_fall=All filesystems
 acl_fsel=Selected..
-acl_ro=Can only view quota, not edit?
+acl_ro=Can only view quotas, not edit?
 acl_quotaon=Can enable and disable quotas?
 acl_quotanew=Can configure quotas for new users?
 acl_ugrace=Can edit user grace times?
@@ -158,7 +158,9 @@ index_status=Status
 index_action=Action
 index_return=index
 index_euser=Edit User Quotas:
+index_euserdesc=Enter or select a user, and click this button to view his quotas on all filesystems.
 index_egroup=Edit Group Quotas:
+index_egroupdesc=Enter or select a group, and click this button to view its quotas on all filesystems.
 index_nosupport=No local filesystems can support quotas.
 index_mountmod=You can enable quotas for a filesystem in the <a href='$1'>Disk and Network Filesystems</a> module.
 
index 11cdb95..2b8a9d8 100755 (executable)
@@ -353,14 +353,6 @@ if ($mount) {
 return undef;
 }
 
-# print_limit(amount, no-blocks)
-sub print_limit
-{
-if ($_[0] == 0) { print "<td>$text{'quota_unlimited'}</td>\n"; }
-elsif ($bsize && !$_[1]) { print "<td>",&nice_size($_[0]*$bsize),"</td>"; }
-else { print "<td>$_[0]</td>\n"; }
-}
-
 # nice_limit(amount, bsize, no-blocks)
 sub nice_limit
 {
@@ -425,5 +417,14 @@ else {
        }
 }
 
+# select_grace_units(name, value)
+# Returns a menu for selecting grace time units
+sub select_grace_units
+{
+local @uarr = &grace_units();
+return &ui_select($_[0], $_[1],
+       [ map { [ $_, $uarr[$_] ] } (0..$#uarr) ]);
+}
+
 1;
 
index 73bb3e2..3889c1e 100755 (executable)
@@ -13,12 +13,11 @@ print "$text{'ugracef_info'}<p>\n";
 @gr = &get_user_grace($in{'filesys'});
 print &ui_form_start("user_grace_save.cgi");
 print &ui_hidden("filesys", $in{'filesys'});
-print &ui_table_start(&text('ugracef_graces', $in{'filesys'}),
-                     "width=100%", 4);
+print &ui_table_start(&text('ugracef_graces', $in{'filesys'}), undef, 2);
 
 # Block grace time
 $bfield = &ui_textbox("btime", $gr[0], 6)." ".
-         &select_units("bunits", $gr[1]);
+         &select_grace_units("bunits", $gr[1]);
 if (&default_grace()) {
        $bfield = &ui_radio("bdef", $gr[0] ? 0 : 1,
                            [ [ 1, $text{'default'} ],
@@ -28,7 +27,7 @@ print &ui_table_row($text{'ugracef_block'}, $bfield);
 
 # Files grace time
 $ffield = &ui_textbox("ftime", $gr[2], 6)." ".
-         &select_units("funits", $gr[3]);
+         &select_grace_units("funits", $gr[3]);
 if (&default_grace()) {
        $ffield = &ui_radio("fdef", $gr[2] ? 0 : 1,
                            [ [ 1, $text{'default'} ],
@@ -42,10 +41,4 @@ print &ui_form_end([ [ undef, $text{'ugracef_update'} ] ]);
 &ui_print_footer("list_users.cgi?dir=".&urlize($in{'filesys'}),
                 $text{'ugracef_return'});
 
-sub select_units
-{
-local @uarr = &grace_units();
-return &ui_select($_[0], $_[1],
-       [ map { [ $_, $uarr[$_] ] } (0..$#uarr) ]);
-}