permission stuff
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 20 Jun 2005 21:27:02 +0000 (21:27 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 20 Jun 2005 21:27:02 +0000 (21:27 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@880 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/permission.pm [new file with mode: 0644]
Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/permission.pm [new file with mode: 0644]
Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm

index d667899..1e839bd 100644 (file)
@@ -427,4 +427,17 @@ sub modify_from_fieldmapper {
        money::credit_payment->has_a( xact => 'money::billable_transaction' );
        money::credit_payment->has_a( accepting_usr => 'actor::user' );
 
+       permission::grp_tree->has_a( parent => 'permission::grp_tree' );
+
+       permission::grp_perm_map->has_a( grp => 'permission::grp_tree' );
+       permission::grp_perm_map->has_a(  perm => 'permission::perm_list' );
+       permission::grp_perm_map->has_a(  depth => 'actor::org_unit_type' );
+       
+       permission::usr_perm_map->has_a( usr => 'actor::usr' );
+       permission::usr_perm_map->has_a(  perm => 'permission::perm_list' );
+       permission::usr_perm_map->has_a(  depth => 'actor::org_unit_type' );
+       
+       permission::usr_grp_map->has_a(  usr => 'actor::usr' );
+       permission::usr_grp_map->has_a(  grp => 'permission::grp_tree' );
+
 1;
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/permission.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/permission.pm
new file mode 100644 (file)
index 0000000..ce2c8da
--- /dev/null
@@ -0,0 +1,34 @@
+package OpenILS::Application::Storage::CDBI::permission;
+our $VERSION = 1;
+
+#-------------------------------------------------------------------------------
+package permission;
+use base qw/OpenILS::Application::Storage::CDBI/;
+#-------------------------------------------------------------------------------
+package permission::perm_list;
+use base qw/permission/;
+__PACKAGE__->table('permission_perm_list');
+__PACKAGE__->columns(All => qw/id code/);
+#-------------------------------------------------------------------------------
+package permission::grp_tree;
+use base qw/permission/;
+__PACKAGE__->table('permission_grp_tree');
+__PACKAGE__->columns(All => qw/id name parent/);
+#-------------------------------------------------------------------------------
+package permission::usr_grp_map;
+use base qw/permission/;
+__PACKAGE__->table('permission_usr_grp_map');
+__PACKAGE__->columns(All => qw/id usr grp/);
+#-------------------------------------------------------------------------------
+package permission::usr_perm_map;
+use base qw/permission/;
+__PACKAGE__->table('permission_usr_perm_map');
+__PACKAGE__->columns(All => qw/id usr perm depth/);
+#-------------------------------------------------------------------------------
+package permission::grp_perm_map;
+use base qw/permission/;
+__PACKAGE__->table('permission_grp_perm_map');
+__PACKAGE__->columns(All => qw/id grp perm depth/);
+#-------------------------------------------------------------------------------
+1;
+
index 159c245..c095eec 100644 (file)
 
 
        #-------------------------------------------------------------------------------
+
+       package permission::perm_list;
+
+       permission::perm_list->sequence( 'permission.perm_list_id_seq' );
+       permission::perm_list->table('permission.perm_list');
+
+       #-------------------------------------------------------------------------------
+
+       package permission::grp_tree;
+
+       permission::grp_tree->sequence( 'permission.grp_tree_id_seq' );
+       permission::grp_tree->table('permission.grp_tree');
+
+       #-------------------------------------------------------------------------------
+
+       package permission::usr_grp_map;
+
+       permission::usr_grp_map->sequence( 'permission.usr_grp_map_id_seq' );
+       permission::usr_grp_map->table('permission.usr_grp_map');
+
+       #-------------------------------------------------------------------------------
+
+       package permission::usr_perm_map;
+
+       permission::usr_perm_map->sequence( 'permission.usr_perm_map_id_seq' );
+       permission::usr_perm_map->table('permission.usr_perm_map');
+
+       #-------------------------------------------------------------------------------
+
+       package permission::grp_perm_map;
+
+       permission::grp_perm_map->sequence( 'permission.grp_perm_map_id_seq' );
+       permission::grp_perm_map->table('permission.grp_perm_map');
+
+       #-------------------------------------------------------------------------------
+
+
 }
 
 1;
index b02e0a5..b5fa321 100644 (file)
@@ -281,6 +281,7 @@ use OpenILS::Application::Storage::Publisher::asset;
 use OpenILS::Application::Storage::Publisher::biblio;
 use OpenILS::Application::Storage::Publisher::config;
 use OpenILS::Application::Storage::Publisher::metabib;
+use OpenILS::Application::Storage::Publisher::permission;
 ';
 
 for my $fmclass ( (Fieldmapper->classes) ) {
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/permission.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/permission.pm
new file mode 100644 (file)
index 0000000..9b42d30
--- /dev/null
@@ -0,0 +1,40 @@
+package OpenILS::Application::Storage::Publisher::permission;
+use base qw/OpenILS::Application::Storage/;
+#use OpenILS::Application::Storage::CDBI::config;
+
+
+sub usr_has_perm {
+       my $self = shift;
+       my $client = shift;
+       my $usr = shift;
+       my $perm = shift;
+
+       return permission::usr_grp_map->db_Main->selectrow_arrayref(<<" SQL",{}, "$usr", "$perm")->[0];
+               SELECT permission.usr_has_perm(?,?)
+       SQL
+}
+__PACKAGE__->register_method(
+       method          => 'usr_has_perm',
+       api_name        => 'open-ils.storage.permission.user_has_perm',
+       argc            => 2,
+);
+
+sub usr_perms {
+       my $self = shift;
+       my $client = shift;
+       my $usr = shift;
+
+       my $sth = permission::usr_perm_map->db_Main->prepare('SELECT permission.usr_perms(?)');
+       $sth->execute("$usr");
+
+       $client->respond( $_->to_fieldmapper ) for ( map { permission::usr_perm_map->construct($_) } $sth->fetchall_hash );
+
+       return undef;
+}
+__PACKAGE__->register_method(
+       method          => 'usr_perms',
+       api_name        => 'open-ils.storage.permission.user_perms',
+       argc            => 2,
+);
+
+1;
index 55cf67e..8911444 100644 (file)
@@ -150,6 +150,12 @@ sub _init {
                                                                     proto_fields       => { copies => 1 } },
                'Fieldmapper::asset::call_number_note'          => { hint => 'acnn'    },
 
+               'Fieldmapper::permission::perm_list'            => { hint => 'ppl'    },
+               'Fieldmapper::permission::grp_tree'             => { hint => 'pgt'    },
+               'Fieldmapper::permission::usr_grp_map'          => { hint => 'pugm'   },
+               'Fieldmapper::permission::usr_perm_map'         => { hint => 'pupm'   },
+               'Fieldmapper::permission::grp_perm_map'         => { hint => 'pgpm'   },
+
                'Fieldmapper::ex'                               => { hint => 'ex',
                                                                     virtual => 1,
                                                                     proto_fields => {