package EPrints::Plugin::Screen::REPOSITORYID::Toggle; our @ISA = ( "EPrints::Plugin::Screen::EPrint" ); use strict; sub new { my( $class, %params ) = @_; my $self = $class->SUPER::new(%params); # Register action $self->{actions} = [ "toggle" ]; # Register where action appears $self->{appears} = [ { place => "eprint_actions", position => 2000, action => "toggle", }, ]; return $self; } sub allow_toggle { # Return "allow profile" for this action # 1 - allowed by anyone # 2 - allowed by registered users # 4 - allowed by owner of this item # 8 - allowed by editor of this item (according to editorial scope) # NOTE: eprints_actions list will only show actions allowed by owner and/or editor return 4 + 8; } sub action_toggle { my( $self ) = @_; # Get eprint my $eprint = $self->{processor}->{eprint}; # Toggle value of refereed field if( $eprint->is_set( "refereed" ) ) { my $ref = $eprint->get_value( "refereed" ); if( $ref eq "TRUE" ) { $eprint->set_value( "refereed", "FALSE" ); } else { $eprint->set_value( "refereed", "TRUE" ); } } else { $eprint->set_value( "refereed", "TRUE" ); } $eprint->commit; my $session = $eprint->{session}; # Create message to display to user my $msg = $session->make_doc_fragment; $msg->appendChild( $session->make_text( "Refereed has been changed to: " ) ); $msg->appendChild( $eprint->render_value( "refereed" ) ); # Message will be displayed on the next screen the user sees $self->{processor}->add_message( "message", $msg ); # Go back to the View screen $self->{processor}->{screenid} = "EPrint::View"; } 1;