Changeset 2081 for trunk/LATMOS-Accounts/lib
- Timestamp:
- 09/18/17 19:49:35 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm
r2035 r2081 849 849 } 850 850 851 =head2 get_datarequest ($id)852 853 Return user request C<$id>854 855 =cut856 857 sub get_datarequest {858 my ($self, $id) = @_;859 860 my $sth = $self->db->prepare(q{861 select name from request862 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_requests874 875 list user request currently waiting in base876 877 =cut878 879 sub list_requests {880 my ($self, $due) = @_;881 882 my $sth = $self->db->prepare(883 sprintf(884 q{885 select id from request886 where done is null887 %s888 order by apply889 },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 @ids902 }903 904 =head2 list_requests_by_submitter ($id)905 906 list user request currently waiting in base ask by user C<$id>907 908 =cut909 910 sub list_requests_by_submitter {911 my ($self, $id) = @_;912 913 my $sth = $self->db->prepare(q{914 select id from request915 where done is null and "user" = ?916 order by apply917 });918 $sth->execute($id);919 my @ids;920 while (my $res = $sth->fetchrow_hashref) {921 push(@ids, $res->{id});922 }923 924 @ids925 }926 927 928 =head2 list_request_by_object ($otype, $id, $req)929 930 Return the list of pending request for a specific object931 932 C<$req> is an optional forms name to limit search933 934 =cut935 936 sub list_request_by_object {937 my ($self, $otype, $id, $req) = @_;938 939 my $sth = $self->db->prepare(q{940 select * from request join941 accreq on request.name = accreq.name942 join accreq_attributes on accreq_attributes.okey = accreq.ikey943 where944 request.applied is NULL and945 accreq_attributes.attr = 'oType' and946 accreq_attributes.value = ?947 and request.object = ?948 } .949 ($req ? ' and request.name = ? ' : '')950 . q{951 order by apply952 });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 @ids960 }961 962 =head2 list_pending_requests963 964 List user request to apply965 966 =cut967 968 sub list_pending_requests {969 my ($self) = @_;970 971 my $sth = $self->db->prepare(q{972 select id from request973 where done is null974 and apply < now()975 order by apply976 });977 $sth->execute;978 my @ids;979 while (my $res = $sth->fetchrow_hashref) {980 push(@ids, $res->{id});981 }982 983 @ids984 }985 986 =head2 list_auto_pending_requests987 988 List automatic request989 990 =cut991 992 sub list_auto_pending_requests {993 my ($self) = @_;994 995 my $sth = $self->db->prepare(q{996 select id from request997 where done is null998 and apply < now()999 and automated = true1000 order by apply1001 });1002 $sth->execute;1003 my @ids;1004 while (my $res = $sth->fetchrow_hashref) {1005 push(@ids, $res->{id});1006 }1007 1008 @ids1009 }1010 1011 851 sub ReportChange { 1012 852 my ($self, $otype, $name, $ref, $changetype, $message, @args) = @_;
Note: See TracChangeset
for help on using the changeset viewer.