|
|
|
@ -4,6 +4,7 @@ use strict; |
|
|
|
|
use esmith::ConfigDB; |
|
|
|
|
use esmith::AccountsDB; |
|
|
|
|
use esmith::templates; |
|
|
|
|
use DateTime; |
|
|
|
|
use User::pwent; |
|
|
|
|
|
|
|
|
|
my $a = esmith::AccountsDB->open_ro or |
|
|
|
@ -23,6 +24,8 @@ else{ |
|
|
|
|
@users = ( $a->users ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
my $now = DateTime->now; |
|
|
|
|
|
|
|
|
|
foreach my $user (@users){ |
|
|
|
|
my $userName = $user->key; |
|
|
|
|
|
|
|
|
@ -32,6 +35,21 @@ foreach my $user (@users){ |
|
|
|
|
my $expired = $user->prop('ExpireLockedOn') || ''; |
|
|
|
|
next if $expired !~ /^\d{4}\-\d{1,2}\-\d{1,2}$/; |
|
|
|
|
|
|
|
|
|
# Remove user from all its groups |
|
|
|
|
my @groups = $a->user_group_list($u) || (); |
|
|
|
|
$a->remove_user_from_groups($u, @groups); |
|
|
|
|
event_signal('group-modify', @groups) if (scalar @groups); |
|
|
|
|
|
|
|
|
|
# Set forward if needed |
|
|
|
|
my $fwd = $user->prop('ExpireForwardAfterLock') || ''; |
|
|
|
|
if ($fwd ne ''){ |
|
|
|
|
$rec->set_prop('ForwardAddress', $fwd); |
|
|
|
|
$rec->set_prop('EmailForward', 'forward'); |
|
|
|
|
} |
|
|
|
|
# Remove expiration settings now that the account is locked |
|
|
|
|
$user->delete_prop('ExpireLockOn'); |
|
|
|
|
$user->delete_prop('ExpireLastNotifiedOn'); |
|
|
|
|
|
|
|
|
|
my $home = getpwnam($userName)->dir; |
|
|
|
|
mkdir $home . '/.lock-auto-reply' unless -d $home . '/.lock-auto-reply'; |
|
|
|
|
esmith::templates::processTemplate ({ |