Commit 8fa4521c authored by Keith Jolley's avatar Keith Jolley
Browse files

Support for submitter usergroups.

Submitters can edit any isolate submitted by themseleves or any member
of a user group that they belong to.
parent 5a1c9ef7
......@@ -267,13 +267,17 @@ sub print_provenance_form_elements {
my ( @users, %usernames );
my $user_data;
if ( $user_info->{'status'} eq 'submitter' ) {
$user_data = $self->{'datastore'}->run_query( "SELECT id,user_name,first_name,surname FROM users WHERE user_name=?",
$self->{'username'}, { fetch => 'all_arrayref', slice => {} } );
} else {
$user_data = $self->{'datastore'}->run_query(
"SELECT id,user_name,first_name,surname FROM users WHERE id>0 ORDER BY surname, first_name, user_name",
undef, { fetch => 'all_arrayref', slice => {} }
"SELECT id,user_name,first_name,surname FROM users WHERE id=? OR id IN (SELECT user_id FROM user_group_members WHERE "
. "user_group IN (SELECT user_group FROM user_group_members WHERE user_id=?)) ORDER BY surname, first_name, user_name"
,
[ $user_info->{'id'}, $user_info->{'id'} ], { fetch => 'all_arrayref', slice => {} }
);
} else {
$user_data =
$self->{'datastore'}
->run_query( "SELECT id,user_name,first_name,surname FROM users WHERE id>0 ORDER BY surname, first_name, user_name",
undef, { fetch => 'all_arrayref', slice => {} } );
}
foreach (@$user_data) {
push @users, $_->{'id'};
......
......@@ -285,17 +285,10 @@ sub _prepare_metaset_updates {
sub _print_interface {
my ( $self, $data ) = @_;
my $q = $self->{'cgi'};
my $qry = "select id,user_name,first_name,surname from users WHERE id>0 order by surname";
my $user_data = $self->{'datastore'}->run_query( $qry, undef, { fetch => 'all_arrayref', slice => {} } );
my ( @users, %usernames );
foreach my $user_hashref (@$user_data) {
push @users, $user_hashref->{'id'};
$usernames{ $user_hashref->{'id'} } = "$user_hashref->{'surname'}, $user_hashref->{'first_name'} ($user_hashref->{'user_name'})";
}
say "<div>";
if ( $self->can_modify_table('isolates') ) {
say "<div class=\"box queryform\" id=\"isolate_update\" style=\"float:left;margin-right:0.5em\">";
say "<div class=\"scrollable\">";
say qq(<div class="box queryform" id="isolate_update" style="float:left;margin-right:0.5em">);
say qq(<div class="scrollable">);
say $q->start_form;
$q->param( 'sent', 1 );
say $q->hidden($_) foreach qw(page db sent);
......
......@@ -2058,8 +2058,11 @@ sub initiate_view {
my $user_info = $self->{'datastore'}->get_user_info_from_username($username);
return if !$user_info;
if ( $user_info->{'status'} eq 'submitter' ) {
$self->{'db'}->do( "CREATE TEMPORARY VIEW temp_view AS SELECT * FROM $self->{'system'}->{'view'} WHERE sender=?",
undef, $user_info->{'id'} );
$self->{'db'}->do(
"CREATE TEMPORARY VIEW temp_view AS SELECT * FROM $self->{'system'}->{'view'} WHERE sender=? OR sender IN "
. "(SELECT user_id FROM user_group_members WHERE user_group IN (SELECT user_group FROM user_group_members WHERE user_id=?))",
undef, $user_info->{'id'}, $user_info->{'id'}
);
$self->{'system'}->{'view'} = 'temp_view';
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment