#!/usr/bin/perl -w -I/usr/local/eprints/perl_lib ###################################################################### # # EPrints Author Record Removal for Staff # # G.Halse@ru.ac.za, Rhodes University, 20080529 # # Both Rhodes University and I normally release software under the terms of # a three-clause BSD license (http://www.opensource.org/licenses/bsd-license.php). # However, in this instance, a lot of the work is based on EPrints' # create_user script, so I'm obliged to reproduce the more restrictive GPL # ###################################################################### # # This file is not part of GNU EPrints 2, but it could be. # # Copyright (c) 2000-2004 University of Southampton, UK. SO17 1BJ. # # EPrints 2 is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # EPrints 2 is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with EPrints 2; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ###################################################################### =pod =head1 NAME B - remove an existing user from an EPrint archive =head1 SYNOPSIS B I I =head1 DESCRIPTION Remove an existing user from an eprint archive. This is handy for scripting the bulk removal of users. =head1 ARGUMENTS =over 8 =item I The ID of the EPrint archive that the user belongs to. =item I The (numeric) userid of the user to remove. If a user with this userid does not exist then the script will abort with a error. =back =head1 AUTHOR Rhodes University (by way of G.Halse@ru.ac.za) =cut use EPrints::User; use EPrints::Database; use EPrints::Session; use strict; use strict; use Getopt::Long; use Pod::Usage; my $verbose = 0; my $version = 0; my $quiet = 0; my $help = 0; my $man = 0; GetOptions( 'help|?' => \$help, 'man' => \$man, 'version' => \$version, 'verbose+' => \$verbose, 'silent' => \$quiet, 'quiet' => \$quiet ) || pod2usage( 2 ); EPrints::Utils::cmd_version( "remove_user" ) if $version; pod2usage( 1 ) if $help; pod2usage( -exitstatus => 0, -verbose => 2 ) if $man; pod2usage( 2 ) if( scalar @ARGV != 2 ); my $noise = 1; $noise = 0 if( $quiet ); $noise = 1+$verbose if( $verbose ); # Set STDOUT to auto flush (without needing a \n) $|=1; my $session = EPrints::Session->new( 1 , $ARGV[0], $noise); exit unless( defined $session ); my $user = EPrints::User->new($session, $ARGV[1]); unless (defined ($user) and $user) { print STDERR "userid $ARGV[1] does not exist\n"; } else { my $userid = $user->get_value( "userid" ); my $username = $user->get_value( "username" ); if ($noise) { print "$username: "; } my $success = $user->remove(); if ($noise && $success) { print "success\n"; } elsif ($noise) { print "failed\n"; } else { print STDERR "error removing userid $ARGV[1]\n"; } } $session->terminate();