Changeset 2081 for trunk/LATMOS-Accounts


Ignore:
Timestamp:
09/18/17 19:49:35 (7 years ago)
Author:
nanardon
Message:

kill functions related to requests

File:
1 edited

Legend:

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

    r2035 r2081  
    849849} 
    850850 
    851 =head2 get_datarequest ($id) 
    852  
    853 Return user request C<$id> 
    854  
    855 =cut 
    856  
    857 sub get_datarequest { 
    858     my ($self, $id) = @_; 
    859  
    860     my $sth = $self->db->prepare(q{ 
    861         select name from request 
    862         where id = ? 
    863         }); 
    864     $sth->execute($id); 
    865     if (my $res = $sth->fetchrow_hashref) { 
    866         my $accreq = $self->get_object('accreq', $res->{name}); 
    867         return LATMOS::Accounts::Bases::Sql::DataRequest->new($accreq, $id); 
    868     } else { 
    869         return; 
    870     } 
    871 } 
    872  
    873 =head2 list_requests 
    874  
    875 list user request currently waiting in base 
    876  
    877 =cut 
    878  
    879 sub list_requests { 
    880     my ($self, $due) = @_; 
    881  
    882     my $sth = $self->db->prepare( 
    883         sprintf( 
    884             q{ 
    885             select id from request 
    886             where done is null 
    887             %s 
    888             order by apply 
    889             }, 
    890             defined($due) 
    891                 ? 'and apply ' . ($due ? '<' : '>=') . ' now()' 
    892                 : '' 
    893         ) 
    894     ); 
    895     $sth->execute; 
    896     my @ids; 
    897     while (my $res = $sth->fetchrow_hashref) { 
    898         push(@ids, $res->{id}); 
    899     } 
    900  
    901     @ids 
    902 } 
    903  
    904 =head2 list_requests_by_submitter ($id) 
    905  
    906 list user request currently waiting in base ask by user C<$id> 
    907  
    908 =cut 
    909  
    910 sub list_requests_by_submitter { 
    911     my ($self, $id) = @_; 
    912  
    913     my $sth = $self->db->prepare(q{ 
    914         select id from request 
    915         where done is null and "user" = ? 
    916         order by apply 
    917     }); 
    918     $sth->execute($id); 
    919     my @ids; 
    920     while (my $res = $sth->fetchrow_hashref) { 
    921         push(@ids, $res->{id}); 
    922     } 
    923  
    924     @ids 
    925 } 
    926  
    927  
    928 =head2 list_request_by_object ($otype, $id, $req) 
    929  
    930 Return the list of pending request for a specific object 
    931  
    932 C<$req> is an optional forms name to limit search 
    933  
    934 =cut 
    935  
    936 sub list_request_by_object { 
    937     my ($self, $otype, $id, $req) = @_; 
    938  
    939     my $sth = $self->db->prepare(q{ 
    940         select * from request join 
    941         accreq on request.name = accreq.name 
    942         join accreq_attributes on accreq_attributes.okey = accreq.ikey 
    943         where 
    944         request.applied is NULL and 
    945         accreq_attributes.attr = 'oType' and 
    946         accreq_attributes.value = ? 
    947         and request.object = ? 
    948     } . 
    949     ($req ? ' and request.name = ? ' : '') 
    950     . q{ 
    951         order by apply 
    952     }); 
    953     $sth->execute($otype, $id, ($req ? ($req) : ())); 
    954     my @ids; 
    955     while (my $res = $sth->fetchrow_hashref) { 
    956         push(@ids, $res->{id}); 
    957     } 
    958  
    959     @ids 
    960 } 
    961  
    962 =head2 list_pending_requests 
    963  
    964 List user request to apply 
    965  
    966 =cut 
    967  
    968 sub list_pending_requests { 
    969     my ($self) = @_; 
    970  
    971     my $sth = $self->db->prepare(q{ 
    972         select id from request 
    973         where done is null 
    974             and apply < now() 
    975         order by apply 
    976     }); 
    977     $sth->execute; 
    978     my @ids; 
    979     while (my $res = $sth->fetchrow_hashref) { 
    980         push(@ids, $res->{id}); 
    981     } 
    982  
    983     @ids 
    984 } 
    985  
    986 =head2 list_auto_pending_requests 
    987  
    988 List automatic request 
    989  
    990 =cut 
    991  
    992 sub list_auto_pending_requests { 
    993     my ($self) = @_; 
    994  
    995     my $sth = $self->db->prepare(q{ 
    996         select id from request 
    997         where done is null 
    998             and apply < now() 
    999             and automated = true 
    1000         order by apply 
    1001     }); 
    1002     $sth->execute; 
    1003     my @ids; 
    1004     while (my $res = $sth->fetchrow_hashref) { 
    1005         push(@ids, $res->{id}); 
    1006     } 
    1007  
    1008     @ids 
    1009 } 
    1010  
    1011851sub ReportChange { 
    1012852    my ($self, $otype, $name, $ref, $changetype, $message, @args) = @_; 
Note: See TracChangeset for help on using the changeset viewer.