]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/permission.pm
adding "post_filter" based class-search method
[working/Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Storage / Publisher / permission.pm
1 package OpenILS::Application::Storage::Publisher::permission;
2 use base qw/OpenILS::Application::Storage/;
3 #use OpenILS::Application::Storage::CDBI::config;
4
5
6 sub retrieve_all {
7         my $self = shift;
8         my $client = shift;
9
10         for my $rec ( permission::grp_tree->retrieve_all ) {
11                 $client->respond( $rec->to_fieldmapper );
12         }
13
14         return undef;
15 }
16 __PACKAGE__->register_method(
17         method          => 'retrieve_all',
18         api_name        => 'open-ils.storage.direct.permission.grp_tree.retrieve.all',
19         argc            => 3,
20         stream          => 1,
21 );
22
23 sub usr_has_perm {
24         my $self = shift;
25         my $client = shift;
26         my $usr = shift;
27         my $perm = shift;
28         my $target = shift;
29
30         return permission::usr_grp_map->db_Main->selectrow_arrayref(<<" SQL",{}, "$usr", "$perm", "$target")->[0];
31                 SELECT permission.usr_has_perm(?,?,?)
32         SQL
33 }
34 __PACKAGE__->register_method(
35         method          => 'usr_has_perm',
36         api_name        => 'open-ils.storage.permission.user_has_perm',
37         argc            => 3,
38 );
39
40 sub usr_perms {
41         my $self = shift;
42         my $client = shift;
43         my $usr = shift;
44
45         my $sth = permission::usr_perm_map->db_Main->prepare('SELECT DISTINCT * FROM permission.usr_perms(?)');
46         $sth->execute("$usr");
47
48         $client->respond( $_->to_fieldmapper ) for ( map { permission::usr_perm_map->construct($_) } $sth->fetchall_hash );
49
50         return undef;
51 }
52 __PACKAGE__->register_method(
53         method          => 'usr_perms',
54         api_name        => 'open-ils.storage.permission.user_perms',
55         argc            => 2,
56         stream          => 1,
57 );
58
59 1;