From 8f571ec90fade6be6b0221d56b714138b262e018 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 21 Jun 2005 13:54:13 +0000 Subject: [PATCH] adding user group setup CGI git-svn-id: svn://svn.open-ils.org/ILS/trunk@884 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/cgi-bin/usr_group-setup.cgi | 212 +++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100755 Open-ILS/src/cgi-bin/usr_group-setup.cgi diff --git a/Open-ILS/src/cgi-bin/usr_group-setup.cgi b/Open-ILS/src/cgi-bin/usr_group-setup.cgi new file mode 100755 index 0000000000..ce086089c8 --- /dev/null +++ b/Open-ILS/src/cgi-bin/usr_group-setup.cgi @@ -0,0 +1,212 @@ +#!/usr/bin/perl +use strict; + +use OpenILS::Application::Storage; +use OpenILS::Application::Storage::CDBI; + +# I need to abstract the driver loading away... +use OpenILS::Application::Storage::Driver::Pg; + +use CGI qw/:standard start_*/; + +OpenILS::Application::Storage::CDBI->connection('dbi:Pg:host=10.0.0.2;dbname=demo-dev', 'postgres'); +OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1; + +my $cgi = new CGI; + +#------------------------------------------------------------------------------- +# setup part +#------------------------------------------------------------------------------- + +my %org_cols = ( qw/id GroupID name Name parent ParentGroup/ ); + +my @col_display_order = ( qw/id name parent/ ); + +if (my $action = $cgi->param('action')) { + if ( $action eq 'Update' ) { + for my $id ( ($cgi->param('id')) ) { + my $u = permission::group_tree->retrieve($id); + for my $col ( keys %org_cols ) { + $u->$col( $cgi->param($col."_$id") ); + } + $u->update; + } + } elsif ( $action eq 'Add New' ) { + permission::group_tree->create( { map { defined($cgi->param($_)) ? ($_ => $cgi->param($_)) : () } keys %org_cols } ); + } +} + +#------------------------------------------------------------------------------- +# HTML part +#------------------------------------------------------------------------------- + +print < + + + + + + + + +

User Group Hierarchy Setup

+
+HEADER + +my $uri = $cgi->url(-relative=>1); + +my $top; +for my $grp ( permission::group_tree->search( {parent=>undef} ) ) { + my $name = $grp->name; + $name =~ s/'/\\'/og; + print <<" HEADER"; +
+ +
+
+ +HEADER + +#------------------------------------------------------------------------------- +# Logic part +#------------------------------------------------------------------------------- + +if (my $action = $cgi->param('action')) { + if ( $action eq 'child' ) { + my $id = $cgi->param('id'); + if ($id) { + my $node = permission::group_tree->retrieve($id); + #----------------------------------------------------------------------- + # child form + #----------------------------------------------------------------------- + + print "

Edit ".$node->name."

"; + print "
". + "\n"; + + print Tr( + th($org_cols{id}), + td( $node->id() ), + ); + print Tr( + th($org_cols{name}), + td("name() ."\">"), + ); + print Tr( + th($org_cols{depth}), + td(""), + ); + print Tr( + th($org_cols{parent}), + td(""), + ); + + print Tr( "" ); + + print "

"; + + + print "

New Child

"; + + print "
". + "\n"; + + print Tr( + th($org_cols{name}), + td(""), + ); + print Tr( + th($org_cols{depth}), + td(""), + ); + print Tr( "" ); + print "
", + "

"; + } + } +} + +print "
"; + + -- 2.11.0