Ignore:
Timestamp:
12/27/16 09:51:29 (8 years ago)
Author:
nanardon
Message:

Add summary option to delunexpireduser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Delexpiredusers.pm

    r1878 r1879  
    4545 
    4646A copy of warning are sent to this email address 
     47 
     48=head2 summary 
     49 
     50If set, send a summmary to this address 
    4751 
    4852=head2 to 
     
    172176            } 
    173177            $self->{_base}->commit; 
     178        } 
     179    } 
     180 
     181    if (my $sumto = $self->{syncm}->ini->val($self->{name}, 'summary')) { 
     182        my @summary; 
     183        foreach my $manager (sort keys %expired) { 
     184            foreach (@{$expired{$manager}{users}}) { 
     185                push(@summary, sprintf("%s - %s (%s, %s)\n", 
     186                        $_->id, 
     187                        ($expired{$manager}{manager} 
     188                            ? $expired{$manager}{manager}->get_attributes('displayName') 
     189                            : $manager), 
     190                        $_->get_attributes('displayName'), 
     191                        $_->get_attributes('expireText'), 
     192                    ) 
     193                ); 
     194            } 
     195        } 
     196 
     197        if (@summary) { 
     198            my %mail = ( 
     199                Subject => 'LATMOS expired account (to disable)', 
     200                'X-LATMOS-Reason' => 'Account expiration', 
     201                To => $sumto, 
     202            ); 
     203            my $summail = LATMOS::Accounts::Mail->new( 
     204                $self, \join('', @summary), {} 
     205            ); 
     206            if ($summail->process(\%mail)) { 
     207                la_log(LA_NOTICE, "Expiration summary mail sent to %s", 
     208                    $self->val('_default_', 'expire_summary_to'), 
     209                ); 
     210            } 
    174211        } 
    175212    } 
Note: See TracChangeset for help on using the changeset viewer.