Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
EPrints User preference for Screen::Items/eprint_status (file to be saved in EPRINTS_ROOT/bin/local/)
#!/usr/bin/perl -w
# Usage: ~/bin/local/get_user_preferences ARCHIVEID USERID
# NOTE: If you save this to a location other that EPRINTS_ROOT/bin/local/ the 'use lib' statement
# below will need to be adjusted accordingly
use FindBin;
use lib "$FindBin::Bin/../../perl_lib";
use EPrints;
use strict;
use Data::Dumper;
$|=1;
my $noise = 1;
my $repoid = $ARGV[0];
my $userid = $ARGV[1];
my $doit = $ARGV[2];
my $session = new EPrints::Session( 1 , $repoid , $noise );
if( !defined $session )
{
print STDERR "Failed to load repository: $repoid\n";
exit 1;
}
if( !defined $userid )
{
print STDERR "Please supply a userid\n";
exit 1;
}
my $user = EPrints::DataObj::User->new( $session, $userid );
if( !defined $user )
{
$session->get_repository->log( "User #$userid not found\n" );
exit 1;
}
print $user->get_value( "username" ), " (", $user->get_value( "email" ), ")\n";
my $val = $user->preference( 'Screen::Items/eprint_status' );
print "Existing user preference for 'Screen::Items/eprint_status':\n";
print Dumper( $val );
$session->terminate();
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.