Adapt delete options when user has not expired

tags/smeserver-expire-accounts-0.1.7-1
Daniel Berteaud 9 years ago
parent e22a9e4942
commit 4649fc492f
  1. 4
      root/etc/e-smith/web/functions/expireaccounts
  2. 16
      root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/expireaccounts.pm

@ -71,7 +71,7 @@ __DATA__
<field type="select" <field type="select"
id="ExpireDeleteAfterLock" id="ExpireDeleteAfterLock"
value="get_user_prop('ExpireDeleteAfterLock')" value="get_user_prop('ExpireDeleteAfterLock')"
options="'never', '7', '30', '180', '365'"> options="get_delete_options()">
<description>DESC_DELETE_AFTER_LOCK</description> <description>DESC_DELETE_AFTER_LOCK</description>
<label>LABEL_DELETE_AFTER_LOCK</label> <label>LABEL_DELETE_AFTER_LOCK</label>
</field> </field>
@ -93,7 +93,7 @@ __DATA__
<field type="select" <field type="select"
id="ExpireDeleteAfterLock" id="ExpireDeleteAfterLock"
value="get_user_prop('ExpireDeleteAfterLock')" value="get_user_prop('ExpireDeleteAfterLock')"
options="'never', '7', '30', '180', '365'"> options="get_delete_options()">
<description>DESC_DELETE_AFTER_LOCK</description> <description>DESC_DELETE_AFTER_LOCK</description>
<label>LABEL_DELETE_AFTER_LOCK</label> <label>LABEL_DELETE_AFTER_LOCK</label>
</field> </field>

@ -210,6 +210,22 @@ sub get_conf_bool{
return ($val =~ m/^yes|enabled|1|on$/) ? 'enabled' : 'disabled'; return ($val =~ m/^yes|enabled|1|on$/) ? 'enabled' : 'disabled';
} }
sub get_delete_options{
my ($self) = @_;
my $options = [ qw(never 7 30 180 365) ];
my $acctName = $self->{cgi}->param('acctName');
if ($acctName =~ /^(\w[\-\w_\.]*)$/){
$acctName = $1;
my $acct = $a->get($acctName);
my $pass = $acct->prop('PasswordSet') || 'no';
my $locked = $acct->prop('ExpireLockedOn') || '';
if ($pass eq 'no' && $locked !~ m/^\d{4}\-\d{1,2}\-\d{1,2}$/){
$options = [ qw(never) ];
}
}
return $options;
}
sub modify_config{ sub modify_config{
my ($self) = @_; my ($self) = @_;
my $rec = $c->get('ExpireAccounts') || $c->new_record('ExpireAccounts', { type => 'service' }); my $rec = $c->get('ExpireAccounts') || $c->new_record('ExpireAccounts', { type => 'service' });

Loading…
Cancel
Save