diff --git a/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_fields_automatic.pl b/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_fields_automatic.pl index c135374..f62bf05 100755 --- a/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_fields_automatic.pl +++ b/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_fields_automatic.pl @@ -30,18 +30,59 @@ my @docs = $eprint->get_all_documents(); my $textstatus = "none"; - if( scalar @docs > 0 ) + ## NJS 2008-07-24 + # We want documents with staffonly security level to be invisible to normal + # users, as they are effectively "internal use only". Visibility with + # restricted access is now provided by the new embargo security level. + # + # The rules for setting text status are: + # * "none" if there are no documents at all (count = 0), or if there are + # no _visible_ documents (count > 0 but all have security level + # staffonly) + # * "restricted" if there is at least one document with security level + # embargo or user (these are visible but inaccessible to some users) + # * "public" otherwise + # + my $numdocs = scalar @docs; + foreach my $doc ( @docs ) { - $textstatus = "public"; - foreach my $doc ( @docs ) + my $security = $doc->get_value( "security" ); + + $numdocs-- if ( $security eq "staffonly" ); + + # Public and staffonly will always exist, but we don't know how many + # other intermediate values there might be in between (in addition + # to user and embargo), so we check for not equal to public/staffonly + # rather than equal to everything else. We can drop out of the loop + # at this point. We also set $numdocs to zero to ensure that the + # text status isn't changed to public after the loop. + # + # Note we include the eprint status check from the is_public method + # to ensure behaviour consistent with the original code. + if ( ( ( $security ne "public" ) && ( $security ne "staffonly" ) ) || + ( $eprint->get_value( "eprint_status" ) ne "archive" ) ) { - if( !$doc->is_public ) - { - $textstatus = "restricted"; - last; - } + $textstatus = "restricted"; + $numdocs = 0; + last; } } + $textstatus = "public" if ( $numdocs > 0 ); + +# Original code follows: +# if( scalar @docs > 0 ) +# { +# $textstatus = "public"; +# foreach my $doc ( @docs ) +# { +# if( !$doc->is_public ) +# { +# $textstatus = "restricted"; +# last; +# } +# } +# } +## END NJS 2008-07-24 $eprint->set_value( "full_text_status", $textstatus );