Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
Add a parallel authentication routine
(section)
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== changing the way the puid is displayed, and selected === As defined earlier, the puid is a text field in the user object, and will contain a puid in the form of ''1234:5678#My+department''. Standard eprints functionality for a text field is to display the contents in an input field, and allow the user to edit it. This is no use to us, as we want the user to select between one of three options: * None * Current: Dept 1 * New: Dept 2 (depending, of course, on what is currently set and whether there is a mis-match between <code>user->puid</code> and the puid from ''myCookie'') We can alter the way the object deals with a field using local functions. In <code>archives/''ARCHIVEID''/cfg/cfg.d/user_fields.pl</code>, we add references to the functions for rendering the field and for changing the value. These two methods return DOM fragments of XML: <pre> { 'name' => 'puid', 'type' => 'text', 'render_single_value' => \&render_puid, 'render_input' => \&select_puid, }, </pre> In <code>archives/''ARCHIVEID''/cfg/cfg.d/user_fields.pl</code> we also add the two methods: <pre> sub render_puid { my ( $session, $field, $value ) = @_; if(!EPrints::Utils::is_set($value)) { return $session->make_text("You have no automatic authentication"); } # split the value into two parts, on the first # (there may be more than one..) my ( $rawpuid, $inst) = split /#/, $value, 2; $inst =~ s/\+/ /g; if( !EPrints::Utils::is_set($inst) ) { return $session->make_text( "You have an institution defined, but it is un-named"); } $inst =~ s/\+/ /g; # we should have an institutionl name set, but just in case... return $session->make_text( "Your defined authenticating institution is $inst") } sub select_puid { my ( $field, $session, $puid, $dataset, $staff, $hidden_fields, $user, $basename ) = @_; my @order = ('none'); my $desc = { none => 'No PUID stuff' }; my $values = { 'none' => '' }; my $default = 'none'; if( EPrints::Utils::is_set( $value ) ) { push @order, 'old'; $values->{old} = $value; my ($uid, $org) = split /\#/, $value; $org =~ s/\+/ /g; $desc->{old} = "Current value: $org"; $default = 'old'; } my $cookie_puid = $session->puid_from_cookie; if( defined $cookie_puid && $cookie_puid ne $value ) { push @order, 'new'; $values->{new} = $cookie_puid; my ($uid, $org) = split /\#/, $cookie_puid; $org =~ s/\+/ /g; $desc->{new} = "New value: $org"; } my $div = $session->make_element( "div" ); foreach my $bit ( @order ) { my $div2 = $session->make_element( "div" ); my $label = $session->make_element( "label" ); $div->appendChild( $div2 ); $div2->appendChild( $label ); my %iopts = ( type=>'radio', name=>$basename, value=>$values->{$bit} ); if( $default eq $bit ) { $iopts{checked} = 'checked'; } $label->appendChild( $session->make_element( "input", %iopts ) ); $label->appendChild( $session->make_text( " ".$desc->{$bit} ) ); } return $div; } </pre>
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)