Changeset 1079


Ignore:
Timestamp:
07/25/12 14:46:25 (12 years ago)
Author:
nanardon
Message:

Automatically set expire date to aliases

This expiration time is set when a user is set unexported. The delay is still
hardcoded (1 year).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r1075 r1079  
    77use LATMOS::Accounts::Utils; 
    88use LATMOS::Accounts::Log; 
     9use POSIX qw(strftime); 
    910use base qw(LATMOS::Accounts::Bases::Sql::objects); 
    1011 
     
    474475                } 
    475476            } 
     477            my $must_expire = $attr eq 'exported' 
     478                ? ($data{$attr} ? 0 : 1 ) 
     479                : ($data{$attr} ? 1 : 0 ); 
     480 
     481            foreach my $al ($self->get_attributes('aliases')) { 
     482                my $obj = $self->base->get_object('aliases', $al) or next; 
     483                $obj->_set_c_fields( 
     484                    expire => $must_expire 
     485                        ? strftime( 
     486                            "%Y-%m-%d %H:%M:%S", 
     487                            localtime(time + 3600 * 24 * 365) 
     488                          ) 
     489                        : undef, 
     490                ); 
     491            } 
    476492        }; 
    477493        $attr eq 'gidnumber' && $data{$attr} !~ /^\d+$/ and do { 
Note: See TracChangeset for help on using the changeset viewer.