Option to show hard and soft quota percentages
authorJamie Cameron <jcameron@webmin.com>
Mon, 9 Jul 2007 21:18:34 +0000 (21:18 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 9 Jul 2007 21:18:34 +0000 (21:18 +0000)
quota/list_groups.cgi
quota/list_users.cgi

index 180804f..7711b40 100755 (executable)
@@ -46,7 +46,12 @@ elsif ($n) {
        push(@hcols, "");
        push(@tds, "");
        ($binfo, $finfo) = &filesystem_info($f, \%group, $n, $fsbsize);
-       $cols1 = 3 + ($threshold_pc != 101 ? 1 : 0) +
+       $show_pc_hblocks = $threshold_pc != 101 &&
+                          $config{'pc_show'} >= 1;
+       $show_pc_sblocks = $threshold_pc != 101 &&
+                          $config{'pc_show'}%2 == 0;
+       $cols1 = 3 + ($show_pc_hblocks ? 1 : 0) +
+                    ($show_pc_sblocks ? 1 : 0) +
                     ($config{'show_grace'} ? 1 : 0);
        $cols2 = 3 + ($config{'show_grace'} ? 1 : 0);
        push(@hcols, ($bsize ? $text{'lusers_space'} :
@@ -66,9 +71,12 @@ elsif ($n) {
                push(@tds, "width=5");
                }
        push(@hcols, $text{'lgroups_group'});
-       if ($threshold_pc != 101) {
+       if ($show_pc_hblocks) {
                push(@hcols, $text{'lusers_pc_hblocks'});
                }
+       if ($show_pc_sblocks) {
+               push(@hcols, $text{'lusers_pc_sblocks'});
+               }
        push(@hcols, $text{'lusers_used'}, $text{'lusers_soft'},
                    $text{'lusers_hard'},
                    $config{'show_grace'} ? ( $text{'lusers_grace'} ) : ( ));
@@ -122,12 +130,18 @@ elsif ($n) {
                                "</a>");
                        }
                 my $pc_hblocks=0;
+                my $pc_sblocks=0;
                 if($group{$i,'hblocks'}) {
                         $pc_hblocks = 100 * $group{$i,'ublocks'};
                         $pc_hblocks/= $group{$i,'hblocks'};
                         $pc_hblocks = int($pc_hblocks);
                        }
-               if ($threshold_pc != 101) {
+                if($group{$i,'sblocks'}) {
+                        $pc_sblocks = 100 * $group{$i,'ublocks'};
+                        $pc_sblocks/= $group{$i,'sblocks'};
+                        $pc_sblocks = int($pc_sblocks);
+                       }
+               if ($show_pc_hblocks) {
                        if ($pc_hblocks > $threshold_pc) {
                                push(@cols, "<font color=#ff0000>".
                                        &html_escape($pc_hblocks)."%</font>");
@@ -136,7 +150,15 @@ elsif ($n) {
                                push(@cols, &html_escape($pc_hblocks)."%");
                                }
                        }
-               local $ublocks = $group{$i,'ublocks'}; 
+               if ($show_pc_sblocks) {
+                       if ($pc_sblocks > $threshold_pc) {
+                               push(@cols, "<font color=#ff0000>".
+                                       &html_escape($pc_sblocks)."%</font>");
+                               }
+                       else {
+                               push(@cols, &html_escape($pc_sblocks)."%");
+                               }
+                       }local $ublocks = $group{$i,'ublocks'}; 
                if ($bsize) {
                        $ublocks = &nice_size($ublocks*$bsize);
                        }
index 36aaea8..d079341 100755 (executable)
@@ -47,7 +47,12 @@ elsif ($n) {
        push(@hcols, "");
        push(@tds, "");
        ($binfo, $finfo) = &filesystem_info($f, \%user, $n, $fsbsize);
-       $cols1 = 3 + ($threshold_pc != 101 ? 1 : 0) +
+       $show_pc_hblocks = $threshold_pc != 101 &&
+                          $config{'pc_show'} >= 1;
+       $show_pc_sblocks = $threshold_pc != 101 &&
+                          $config{'pc_show'}%2 == 0;
+       $cols1 = 3 + ($show_pc_hblocks ? 1 : 0) +
+                    ($show_pc_sblocks ? 1 : 0) +
                     ($config{'show_grace'} ? 1 : 0);
        $cols2 = 3 + ($config{'show_grace'} ? 1 : 0);
        push(@hcols, ($bsize ? $text{'lusers_space'} :
@@ -67,9 +72,12 @@ elsif ($n) {
                push(@tds, "width=5");
                }
        push(@hcols, $text{'lusers_user'});
-       if ($threshold_pc != 101) {
+       if ($show_pc_hblocks) {
                push(@hcols, $text{'lusers_pc_hblocks'});
                }
+       if ($show_pc_sblocks) {
+               push(@hcols, $text{'lusers_pc_sblocks'});
+               }
        push(@hcols, $text{'lusers_used'}, $text{'lusers_soft'},
                    $text{'lusers_hard'},
                    $config{'show_grace'} ? ( $text{'lusers_grace'} ) : ( ));
@@ -124,12 +132,18 @@ elsif ($n) {
                                "</a>");
                        }
                 my $pc_hblocks=0;
+                my $pc_sblocks=0;
                 if($user{$i,'hblocks'}) {
                         $pc_hblocks = 100 * $user{$i,'ublocks'};
                         $pc_hblocks/= $user{$i,'hblocks'};
                         $pc_hblocks = int($pc_hblocks);
                        }
-               if ($threshold_pc != 101) {
+                if($user{$i,'sblocks'}) {
+                        $pc_sblocks = 100 * $user{$i,'ublocks'};
+                        $pc_sblocks/= $user{$i,'sblocks'};
+                        $pc_sblocks = int($pc_sblocks);
+                       }
+               if ($show_pc_hblocks) {
                        if ($pc_hblocks > $threshold_pc) {
                                push(@cols, "<font color=#ff0000>".
                                        &html_escape($pc_hblocks)."%</font>");
@@ -138,6 +152,15 @@ elsif ($n) {
                                push(@cols, &html_escape($pc_hblocks)."%");
                                }
                        }
+               if ($show_pc_sblocks) {
+                       if ($pc_sblocks > $threshold_pc) {
+                               push(@cols, "<font color=#ff0000>".
+                                       &html_escape($pc_sblocks)."%</font>");
+                               }
+                       else {
+                               push(@cols, &html_escape($pc_sblocks)."%");
+                               }
+                       }
                local $ublocks = $user{$i,'ublocks'}; 
                if ($bsize) {
                        $ublocks = &nice_size($ublocks*$bsize);