EPrints Technical Mailing List Archive

Message: #07823


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] Disabling/hiding email field in eprint form


Thanks for the quick response. I tinkered a file that seems to do the job (attached and at the end of this email in case that the attachment does not work). 

Best regards. 

>>>>>>>>>>>>>>>>
use EPrints;

use strict;

my $session = EPrints::Session->new();

# security?

my $content = "text/xml";
$session->send_http_header( content_type=>$content );
my $family = $session->param( "_name_family" );
my $given = $session->param( "_name_given" );

my $database = $session->get_database;
my $dataset = $session->dataset( "eprint" );
my $name_field = $dataset->get_field( "creators_name" );

my @fields = ($name_field->get_sql_names);

my $Q_table = $database->quote_identifier($dataset->get_sql_table_name);
my $Q_name_table = $database->quote_identifier($dataset->get_sql_sub_table_name($name_field));
my $Q_eprintid = $database->quote_identifier( "eprintid" );
my $Q_pos = $database->quote_identifier( "pos" );
my $Q_num_matches = $database->quote_identifier( "num_matches" );
my $Q_eprint_status = $database->quote_identifier( "eprint_status" );

my $sql = "SELECT COUNT($Q_table.$Q_eprintid) ".$database->sql_AS." $Q_num_matches," .
	join(",", map { $database->quote_identifier($_) } @fields) .
	" FROM $Q_table" .
	" LEFT JOIN $Q_name_table" .
	" ON $Q_table.$Q_eprintid=$Q_name_table.$Q_eprintid" .
	" WHERE " .
	" $Q_table.$Q_eprint_status=".$database->quote_value( "archive" );
if( EPrints::Utils::is_set( $family ) )
{
	$sql .= " AND ".$database->quote_identifier("creators_name_family").$database->sql_LIKE().$database->quote_value(EPrints::Database::prep_like_value($family).'%');
}
if( EPrints::Utils::is_set( $given ) )
{
	$sql .= " AND ".$database->quote_identifier("creators_name_given").$database->sql_LIKE().$database->quote_value(EPrints::Database::prep_like_value($given).'%');
}

my @rows;

my $sth = $session->get_database->prepare_select( $sql, 'limit' => 40 );
$session->get_database->execute( $sth , $sql );
while( my @row = $sth->fetchrow_array )
{
	my $cnt = shift @row;
	my $name = $name_field->value_from_sql_row( $session, \@row );

	my $item = {};
	push @rows, $item;

	my $frag = $session->make_doc_fragment;

	$frag->appendChild( $name_field->render_single_value( $session, $name ) );

	$frag->appendChild( $session->html_phrase( 'cgi/lookup/name:authored', count => $session->make_text( $cnt ) ) );

	$item->{xhtml} = $frag;
	$item->{values} = [
		"for:value:relative:_name_family" => $name->{family},
		"for:value:relative:_name_given" => $name->{given},
		"for:value:relative:_name_honourific" => $name->{honourific},
		"for:value:relative:_name_lineage" => $name->{lineage},
	];
}

$sth->finish();

my $ul = EPrints::Extras::render_lookup_list( $session, \@rows );

$session->send_http_header( content_type => "text/xml; charset=UTF-8" );

binmode(STDOUT,":utf8");
print <<END;
<?xml version="1.0" encoding="UTF-8" ?>

END
print EPrints::XML::to_string( $ul, "utf-8", 1 );

EPrints::XML::dispose( $ul );

$session->terminate;

>>>>>>>>>>>>>>>>


-----Ursprüngliche Nachricht-----
Von: Newman D.R. <drn@ecs.soton.ac.uk> 
Gesendet: Montag, 13. Mai 2019 17:36
An: eprints-tech@ecs.soton.ac.uk; Stefan Wellsandt <wel@biba.uni-bremen.de>
Betreff: Re: [EP-tech] Disabling/hiding email field in eprint form

Hi Stefan,

It is likely the change you made will have broken the script at EPRINTS_PATH/cgi/users/lookup/name.  You should copy this to EPRINTS_PATH/archives/ARCHIVE_NAME/cgi/users/lookup/name and edit remove any reference to creators_id or things derived from this. 

Unfortunately, it is not particularly straightforward to advise on how to exactly modify the file so it will work but if you have a working understanding of SQL and Perl you should be able to figure this out.

Does anyone already have a modified cgi/users/lookup/name for this purpose, it seems like something many repositories may need.

Regards

David Newman



On Mon, 2019-05-13 at 15:22 +0000, Stefan Wellsandt via Eprints-tech
wrote:
> Hello,
>  
> I want to hide/disable the email address for authors in the workflow.
> I tried to remove the sub-field in the eprints_fields file but that 
> also seems to disable the auto-complete feature. Does anyone have an 
> idea how to hide the field without breaking the auto-complete?
>  
> Best regards
> Stefan
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-
> tech
> *** Archive: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cdff9288772534813d68f08d6d7bd515c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=L%2FqavQG0ii7T%2FpPcXwYtKhBTvWj%2BJ9YuIAmBYKRZpWc%3D&amp;reserved=0
> *** EPrints community wiki: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cdff9288772534813d68f08d6d7bd515c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=WIP7eWXqak13TfOJXfYMh9bXIjW7bIBhppfmbIFE6oQ%3D&amp;reserved=0
> *** EPrints developers Forum: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fforum.eprints.org%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cdff9288772534813d68f08d6d7bd515c%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=sGjIQIM7PE8wuwTMrYM90phfPUgssw8OZKn7hSRxfAE%3D&amp;reserved=0

Attachment: no_id_name.pl
Description: no_id_name.pl