allow circ.reshelving_complete.interval ou setting to override the default reshelving...
[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            => 0,
20         stream          => 1,
21 );
22
23 sub retrieve_perms {
24         my $self = shift;
25         my $client = shift;
26
27         for my $rec ( sort { $a->code cmp $b->code } permission::perm_list->retrieve_all ) {
28                 $client->respond( $rec->to_fieldmapper );
29         }
30
31         return undef;
32 }
33 __PACKAGE__->register_method(
34         method          => 'retrieve_perms',
35         api_name        => 'open-ils.storage.direct.permission.perm_list.retrieve.all',
36         argc            => 0,
37         stream          => 1,
38 );
39
40 sub usr_has_perm {
41         my $self = shift;
42         my $client = shift;
43         my $usr = shift;
44         my $perm = shift;
45         my $target = shift;
46
47         return permission::usr_grp_map->db_Main->selectrow_arrayref(<<" SQL",{}, "$usr", "$perm", "$target")->[0];
48                 SELECT permission.usr_has_perm(?,?,?)
49         SQL
50 }
51 __PACKAGE__->register_method(
52         method          => 'usr_has_perm',
53         api_name        => 'open-ils.storage.permission.user_has_perm',
54         argc            => 3,
55 );
56
57 sub usr_has_home_perm {
58         my $self = shift;
59         my $client = shift;
60         my $usr = shift;
61         my $perm = shift;
62         my $target = shift;
63
64         return permission::usr_grp_map->db_Main->selectrow_arrayref(<<" SQL",{}, "$usr", "$perm", "$target")->[0];
65                 SELECT permission.usr_has_home_perm(?,?,?)
66         SQL
67 }
68 __PACKAGE__->register_method(
69         method          => 'usr_has_home_perm',
70         api_name        => 'open-ils.storage.permission.user_has_home_perm',
71         argc            => 3,
72 );
73
74 sub usr_has_work_perm {
75         my $self = shift;
76         my $client = shift;
77         my $usr = shift;
78         my $perm = shift;
79         my $target = shift;
80
81         return permission::usr_grp_map->db_Main->selectrow_arrayref(<<" SQL",{}, "$usr", "$perm", "$target")->[0];
82                 SELECT permission.usr_has_work_perm(?,?,?)
83         SQL
84 }
85 __PACKAGE__->register_method(
86         method          => 'usr_has_work_perm',
87         api_name        => 'open-ils.storage.permission.user_has_work_perm',
88         argc            => 3,
89 );
90
91 sub usr_perms {
92         my $self = shift;
93         my $client = shift;
94         my $usr = shift;
95
96         my $sth = permission::usr_perm_map->db_Main->prepare('SELECT DISTINCT * FROM permission.usr_perms(?)');
97         $sth->execute("$usr");
98
99         $client->respond( $_->to_fieldmapper ) for ( map { permission::usr_perm_map->construct($_) } $sth->fetchall_hash );
100
101         return undef;
102 }
103 __PACKAGE__->register_method(
104         method          => 'usr_perms',
105         api_name        => 'open-ils.storage.permission.user_perms',
106         argc            => 1,
107         stream          => 1,
108 );
109
110 1;