Skip to content

Commit

Permalink
Remove more use of vpopmail-specific mail quota field
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Apr 28, 2024
1 parent 02d3447 commit b5110f6
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 84 deletions.
10 changes: 0 additions & 10 deletions create-user.pl
Expand Up @@ -145,10 +145,6 @@ package virtual_server;
$mquota = shift(@ARGV);
$mquota = 0 if ($mquota eq "UNLIMITED");
}
elsif ($a eq "--qmail-quota") {
$qquota = shift(@ARGV);
$qquota = 0 if ($qquota eq "UNLIMITED");
}
elsif ($a eq "--mysql") {
$db = shift(@ARGV);
push(@dbs, { 'type' => 'mysql', 'name' => $db });
Expand Down Expand Up @@ -221,9 +217,6 @@ package virtual_server;
$mquota =~ /^\d+$/ || &usage("Quota must be a number");
}
}
if ($user->{'mailquota'}) {
!$qquota || $qquota =~ /^\d+$/ || usage("Mail quota must be a number");
}
$err = &valid_mailbox_name($username);
&usage($err) if ($err);
$real =~ /^[^:]*$/ || usage($text{'user_ereal'});
Expand Down Expand Up @@ -335,9 +328,6 @@ package virtual_server;
if (defined($recovery)) {
$user->{'recovery'} = $recovery;
}
if ($user->{'mailquota'}) {
$user->{'qquota'} = $qquota;
}
if (!$user->{'noquota'}) {
# Set quotas, if not using the defaults
$pd = $d->{'parent'} ? &get_domain($d->{'parent'}) : $d;
Expand Down
29 changes: 3 additions & 26 deletions edit_user.cgi
Expand Up @@ -276,18 +276,9 @@ elsif ($user_type eq 'mail') {
# Print quota hidden defaults as
# it has to be always considered
my $showmailquota = $user->{'mailquota'};
my $showquota = !$user->{'noquota'};
my $showhome = &can_mailbox_home($user) && $d && $d->{'home'} &&
!$user->{'fixedhome'};
if ($showmailquota) {
my $qquota_default = $user->{'qquota'} ne "none" &&
$user->{'qquota'} ? 0 : 1;
my $qquota = &ui_hidden("qquota_def", $qquota_default);
$qquota .= &ui_hidden("qquota", $user->{'qquota'})
if (!$qquota_default);
print $qquota;
}
if ($showquota) {
if (&has_home_quotas()) {
my $quota_data = &quota_field(
Expand Down Expand Up @@ -827,33 +818,19 @@ else {
print &ui_hidden_table_end();
$showmailquota = !$mailbox && $user->{'mailquota'};
$showquota = !$mailbox && !$user->{'noquota'};
$showhome = &can_mailbox_home($user) && $d && $d->{'home'} &&
!$mailbox && !$user->{'fixedhome'};
if ($showmailquota || $showquota || $showhome) {
if ($showquota || $showhome) {
# Start quota and home table
my $header2_title = 'user_header2';
$header2_title = 'user_header2a' if (!$showhome);
$header2_title = 'user_header2b' if (!$showmailquota &&
!$showquota);
$header2_title = 'user_header2b' if (!$showquota);
print &ui_hidden_table_start(
$text{$header2_title}, "width=100%", 2, "table2", 0);
}
if ($showmailquota) {
# Show Qmail/VPOPMail quota field
$user->{'qquota'} = "" if ($user->{'qquota'} eq "none");
print &ui_table_row(&hlink($text{'user_qquota'},"qmailquota"),
&ui_radio("qquota_def", $user->{'qquota'} ? 0 : 1,
[ [ 1, $text{'form_unlimit'} ],
[ 0, " " ] ])." ".
&ui_textbox("qquota", $user->{'qquota'} || "", 10)." ".
$text{'form_bytes'},
2, \@tds);
}
if ($showquota) {
# Show quotas field(s)
if (&has_home_quotas()) {
Expand Down Expand Up @@ -914,7 +891,7 @@ else {
2, \@tds);
}
if ($showmailquota || $showquota || $showhome) {
if ($showquota || $showhome) {
print &ui_hidden_table_end("table2");
}
Expand Down
9 changes: 1 addition & 8 deletions feature-mail.pl
Expand Up @@ -2658,10 +2658,6 @@ sub backup_mail
&print_tempfile(UFILE, ":-");
}
}
elsif ($u->{'mailquota'}) {
&print_tempfile(UFILE, ":$u->{'qquota'}");
&print_tempfile(UFILE, ":-");
}
else {
&print_tempfile(UFILE, ":-:-");
}
Expand Down Expand Up @@ -3030,10 +3026,7 @@ sub restore_mail
$uinfo->{'shell'} = $user[6];
$uinfo->{'email'} = $user[7];
$uinfo->{'to'} = \@to;
if ($uinfo->{'mailquota'}) {
$uinfo->{'qquota'} = $user[8];
}
elsif (!$uinfo->{'noquota'}) {
if (!$uinfo->{'noquota'}) {
$uinfo->{'quota'} = $user[8];
$uinfo->{'mquota'} = $user[9];
}
Expand Down
5 changes: 0 additions & 5 deletions list-users.pl
Expand Up @@ -146,10 +146,6 @@ package virtual_server;
($u->{'domainowner'} ? "Server owner" :
$u->{'webowner'} ? "Website manager" :
"Normal user"),"\n";
if ($u->{'mailquota'}) {
print " Mail server quota: ",
$u->{'qquota'},"\n";
}
if (&has_home_quotas() && !$u->{'noquota'}) {
print " Home quota: ",
&quota_show($u->{'quota'}, "home"),"\n";
Expand Down Expand Up @@ -312,7 +308,6 @@ package virtual_server;
$u->{'email'} ? "Yes" : "No",
$shell->{'id'} eq 'nologin' ? "No" : "Yes",
scalar(@{$u->{'dbs'}}) || "No",
$u->{'mailquota'} ? $u->{'qquota'} :
&has_home_quotas() ?
&quota_show($u->{'quota'}, "home") :
"NA";
Expand Down
3 changes: 0 additions & 3 deletions mass_ucreate.cgi
Expand Up @@ -238,9 +238,6 @@ USER: foreach $line (@lines) {
$user->{'quota'} = $quota;
$user->{'mquota'} = $mquota;
}
if ($user->{'mailquota'}) {
$user->{'qquota'} = $qquota;
}
$user->{'dbs'} = \@dbs if (@dbs);

# Check for a Unix clash
Expand Down
1 change: 0 additions & 1 deletion migration-cpanel.pl
Expand Up @@ -1534,7 +1534,6 @@ sub cpanel_migrate_mailboxes
lc($muser);
$uinfo->{'shell'} = $nologin_shell->{'shell'};
$uinfo->{'email'} = lc($muser)."\@$dom";
$uinfo->{'qquota'} = $quota{$muser};
$uinfo->{'quota'} = $quota{$muser};
$uinfo->{'mquota'} = $quota{$muser};
&create_user_home($uinfo, $d, 1);
Expand Down
1 change: 0 additions & 1 deletion migration-directadmin.pl
Expand Up @@ -407,7 +407,6 @@ sub migration_directadmin_migrate
lc($muser);
$uinfo->{'shell'} = $nologin_shell->{'shell'};
$uinfo->{'email'} = lc($muser)."\@$dom";
$uinfo->{'qquota'} = $quota{$muser};
$uinfo->{'quota'} = $quota{$muser};
$uinfo->{'mquota'} = $quota{$muser};
&create_user_home($uinfo, \%dom, 1);
Expand Down
1 change: 0 additions & 1 deletion migration-ensim.pl
Expand Up @@ -413,7 +413,6 @@ sub migration_ensim_migrate
$uinfo->{'email'} = lc($mu).'@'.$dom;
if ($qu) {
$uinfo->{'quota'} = $uinfo->{'mquota'} =
$uinfo->{'qquota'} =
$qu->{'config'}->{'quota'} / &quota_bsize("home");
}
&create_user_home($uinfo, \%dom, 1);
Expand Down
2 changes: 0 additions & 2 deletions migration-plesk.pl
Expand Up @@ -513,7 +513,6 @@ sub migration_plesk_migrate
if (&has_home_quotas()) {
local $q = $mailuser->{'mailbox-quota'} < 0 ? undef :
$mailuser->{'mailbox-quota'}*1024;
$uinfo->{'qquota'} = $q;
$uinfo->{'quota'} = $q / &quota_bsize("home");
$uinfo->{'mquota'} = $q / &quota_bsize("home");
}
Expand Down Expand Up @@ -607,7 +606,6 @@ sub migration_plesk_migrate
if (&has_home_quotas()) {
local $q = $mailuser->{'mbox_quota'} < 0 ? undef :
$mailuser->{'mbox_quota'}*1024;
$uinfo->{'qquota'} = $q;
$uinfo->{'quota'} = $q / &quota_bsize("home");
$uinfo->{'mquota'} = $q / &quota_bsize("home");
}
Expand Down
1 change: 0 additions & 1 deletion migration-plesk9.pl
Expand Up @@ -539,7 +539,6 @@ sub migration_plesk9_migrate
if (&has_home_quotas()) {
local $q = $mailuser->{'mailbox-quota'} < 0 ? undef :
$mailuser->{'mailbox-quota'}*1024;
$uinfo->{'qquota'} = $q;
$uinfo->{'quota'} = $q / &quota_bsize("home");
$uinfo->{'mquota'} = $q / &quota_bsize("home");
}
Expand Down
1 change: 0 additions & 1 deletion migration-psa.pl
Expand Up @@ -417,7 +417,6 @@ sub migration_psa_migrate
}
if (&has_home_quotas()) {
local $q = $mailuser->{'login'}->{'quota'};
$muinfo->{'qquota'} = $q;
$muinfo->{'quota'} = $q / &quota_bsize("home");
$muinfo->{'mquota'} = $q / &quota_bsize("home");
}
Expand Down
5 changes: 1 addition & 4 deletions modify-user.pl
Expand Up @@ -298,7 +298,7 @@ package virtual_server;
defined($pass) &&
&usage("The --pass and --passfile flags cannot be used when ".
"editing a domain owner");
($quota || $mquota || $qquota) &&
($quota || $mquota) &&
&usage("Quotas cannot be changed when editing a domain owner");
(@adddbs || @deldbs) &&
&usage("Databases cannot be changed when editing a domain owner");
Expand Down Expand Up @@ -340,9 +340,6 @@ package virtual_server;
&usage("User's mail quota cannot be higher than domain's ".
"mail quota of $pd->{'quota'}");
}
if (defined($qquota) && $user->{'mailquota'}) {
$user->{'qquota'} = $qquota eq "UNLIMITED" ? 0 : $qquota;
}
@domdbs = &domain_databases($d);
@newdbs = @{$user->{'dbs'}};
foreach $db (@adddbs) {
Expand Down
11 changes: 0 additions & 11 deletions save_user.cgi
Expand Up @@ -200,17 +200,6 @@ else {
# Disable account if requested
&set_pass_disable($user, $in{'disable'});
}
if ($user->{'mailquota'}) {
# Check and save qmail quota
if (!$in{'qquota_def'}) {
$in{'qquota'} =~ /^\d+$/ ||
&error($text{'user_eqquota'});
$user->{'qquota'} = $in{'qquota'};
}
else {
$user->{'qquota'} = 0;
}
}
if (!$user->{'noquota'}) {
# Check and save quota inputs
$qedit = &can_mailbox_quota();
Expand Down
12 changes: 2 additions & 10 deletions virtual-server-lib-funcs.pl
Expand Up @@ -4529,9 +4529,6 @@ sub make_user_substitutions
if ($hash{'umquota'}) {
$hash{'umquota'} = &nice_size($user->{'umquota'}*&quota_bsize("mail"));
}
if ($hash{'qquota'}) {
$hash{'qquota'} = &nice_size($user->{'qquota'});
}
return %hash;
}

Expand Down Expand Up @@ -5629,10 +5626,6 @@ sub users_table
push(@cols, &quota_show($uquota, "home"));
}
}
if ($u->{'mailquota'}) {
push(@cols, $u->{'qquota'} ? &nice_size($u->{'qquota'}) :
$text{'form_unlimit'});
}

if ($config{'show_mailsize'} && $d->{'mail'}) {
# Mailbox link, if this user has email enabled or is the owner
Expand Down Expand Up @@ -10657,7 +10650,7 @@ sub create_initial_user
if ($d) {
local %init;
&read_file("$initial_users_dir/$d->{'id'}", \%init);
foreach my $a ("email", "quota", "mquota", "qquota", "shell") {
foreach my $a ("email", "quota", "mquota", "shell") {
$user->{$a} = $init{$a} if (defined($init{$a}));
}
foreach my $a ("secs", "to") {
Expand Down Expand Up @@ -10685,7 +10678,6 @@ sub create_initial_user
$user->{'fixedhome'} = 0;
$user->{'home'} = &public_html_dir($d);
$user->{'noquota'} = 1;
$user->{'mailquota'} = 0;
$user->{'noprimary'} = 1;
$user->{'noextra'} = 1;
$user->{'noalias'} = 1;
Expand Down Expand Up @@ -10726,7 +10718,7 @@ sub save_initial_user
}
&lock_file("$initial_users_dir/$dom->{'id'}");
local %init;
foreach my $a ("email", "quota", "mquota", "qquota", "shell") {
foreach my $a ("email", "quota", "mquota", "shell") {
$init{$a} = $user->{$a} if (defined($user->{$a}));
}
foreach my $a ("secs", "to") {
Expand Down

0 comments on commit b5110f6

Please sign in to comment.