#!/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_*/; our %config; do '../setup.pl'; OpenILS::Application::Storage::CDBI->connection($config{dsn},$config{usr}); OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1; my $cgi = new CGI; #------------------------------------------------------------------------------- # HTML part #------------------------------------------------------------------------------- print < Home

Superuser Setup


HEADER #------------------------------------------------------------------------------- # setup part #------------------------------------------------------------------------------- my %user_cols = ( qw/id SysID active Active usrname Username profile UserProfile passwd Password prefix Prefix first_given_name FirstName second_given_name MiddleName family_name LastName suffix Suffix dob Birthdate email Email day_phone DayPhone evening_phone EveningPhone other_phone CellPhone home_ou HomeLib ident_type IdentificationType ident_value Identification_value photo_url PhotoURL/ ); my @col_display_order = ( qw/id active usrname passwd profile prefix first_given_name second_given_name family_name suffix dob email day_phone evening_phone other_phone home_ou ident_type ident_value photo_url/ ); my @required_cols = ( qw/profile usrname passwd profile ident_type ident_value first_given_name family_name dob/ ); #------------------------------------------------------------------------------- # Logic part #------------------------------------------------------------------------------- if (my $action = $cgi->param('action')) { if ( $action eq 'Update Selected' ) { for my $id ( ($cgi->param('id')) ) { my $u = actor::user->retrieve($id); for my $col ( @col_display_order ) { $u->$col( $cgi->param($col."_$id") ); } $u->active( 'f' ) unless ($cgi->param("active_$id")); $u->update; } } elsif ( $action eq 'Add New' ) { my $u = actor::user->create( { map { defined($cgi->param($_)) ? ($_ => $cgi->param($_)) : () } keys %user_cols } ); $u->super_user('t'); $u->update; } } #------------------------------------------------------------------------------- # Form part #------------------------------------------------------------------------------- { #----------------------------------------------------------------------- # User form #----------------------------------------------------------------------- print "
". "\n"; for my $col ( @col_display_order ) { print th($user_cols{$col}); } print ''; for my $row ( sort { $a->usrname cmp $b->usrname } actor::user->search( { super_user => 't' } ) ) { print "\n"; print td($row->id); print td("active){"checked"}}.">"); print td(""); print td(""); print ""; print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print ""; print ""; print td(""); print td(""); print "\n"; } print ""; print td(); # id print td(""); print td(""); print td(""); print ""; print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print td(""); print ""; print ""; print td(""); print td(""); print "
Update
"; print " | "; print ""; "

"; } print "";