Ignore:
Timestamp:
03/30/10 22:43:40 (14 years ago)
Author:
nanardon
Message:
  • add functions to find already expired account
File:
1 edited

Legend:

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

    r744 r850  
    157157} 
    158158 
     159sub find_next_expire_users { 
     160    my ($self, $expire) = @_; 
     161 
     162    my $sth= $self->db->prepare(q{ 
     163        select name from "user" where 
     164            expire < now() + ?::interval 
     165            and expire > now() 
     166            and expire is not null 
     167            } . ($self->{wexported} ? '' : 'and exported = true') . q{ 
     168            order by expire 
     169        } 
     170    ); 
     171    $sth->execute($expire || '1 month'); 
     172    my @users; 
     173    while (my $res = $sth->fetchrow_hashref) { 
     174        push(@users, $res->{name}); 
     175    } 
     176    @users 
     177} 
     178 
     179sub find_expired_users { 
     180    my ($self, $expire) = @_; 
     181 
     182    my $sth= $self->db->prepare(q{ 
     183        select name from "user" where 
     184            expire < now() - ?::interval 
     185            and expire is not null 
     186        } . ($self->{wexported} ? '' : 'and exported = true') . q{ 
     187            order by expire 
     188        } 
     189    ); 
     190    $sth->execute($expire || '1 second'); 
     191    my @users; 
     192    while (my $res = $sth->fetchrow_hashref) { 
     193        push(@users, $res->{name}); 
     194    } 
     195    @users 
     196} 
     197 
    1591981; 
    160199 
Note: See TracChangeset for help on using the changeset viewer.