]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/permission.pm
updates for the perm editor -- FM dance required
[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_perms {
58         my $self = shift;
59         my $client = shift;
60         my $usr = shift;
61
62         my $sth = permission::usr_perm_map->db_Main->prepare('SELECT DISTINCT * FROM permission.usr_perms(?)');
63         $sth->execute("$usr");
64
65         $client->respond( $_->to_fieldmapper ) for ( map { permission::usr_perm_map->construct($_) } $sth->fetchall_hash );
66
67         return undef;
68 }
69 __PACKAGE__->register_method(
70         method          => 'usr_perms',
71         api_name        => 'open-ils.storage.permission.user_perms',
72         argc            => 1,
73         stream          => 1,
74 );
75
76 1;