catch error when trial has no phenotype data. closes #407
[sgn.git] / cgi-bin / phenome / claim_locus_ownership.pl
bloba1032665b3a68b6e06800723c60f01738e63f9e0
2 use strict;
3 use warnings;
5 use CXGN::Page;
6 use CXGN::Login;
7 use CXGN::People;
8 use CXGN::Contact;
9 use CXGN::Phenome::Locus;
11 use CatalystX::GlobalContext qw( $c );
13 my $dbh = $c->dbc->dbh;
15 my $page=CXGN::Page->new("claim_locus_ownership.pl","Naama");
16 my %args=$page->get_all_encoded_arguments();
17 my $locus_id=$args{locus_id};
18 my $locus=CXGN::Phenome::Locus->new($dbh, $locus_id);
19 my $sp_person_id = CXGN::Login->new($dbh)->verify_session();
21 my @owners= $locus->get_owners();
23 my $user = CXGN::People::Person -> new($dbh, $sp_person_id);
24 if ((grep { $_ =~ /^$sp_person_id$/ } @owners) ) {
25 $page->header();
26 print <<HEREDOC;
28 <h3>You are already the owner of the locus.<br>
29 Next time you can click on the 'login' link in the top right corner of every SGN page.<br><br>
30 <a href="/locus/$locus_id/view">Go back</a> to the locus page.</h3>
32 HEREDOC
33 $page->footer();
34 exit();
37 my $username=$user->get_first_name()." ".$user->get_last_name();
38 my $usermail=$user->get_private_email();
39 my $replyto= 'sgn-feedback@sgn.cornell.edu';
42 my $subject="[Locus ownership] Request editor privileges for locus $locus_id";
43 my $fdbk_body="$username has requested to obtain ownership for locus $locus_id\nsp_person_id = $sp_person_id, $usermail";
46 my $user_body= "Dear $username,\n\nYour request for obtaining editor privileges for SGN locus ID $locus_id will be processed shortly.\nA confirmation email will be sent to you once the request is confirmed. After that you should be able now to edit this locus' details.\n\n Thank you for using SGN!\nhttp://www.sgn.cornell.edu/";
50 $page->header();
52 if ($args{action} eq 'confirm') {
53 confirm_dialog($locus_id);
55 elsif ($args{action} eq 'request') {
57 print <<END_HEREDOC;
59 Your request for edit permissions on locus id: $locus_id<br />
60 has been sent to the SGN development team.<br /><br />
61 A reply will be sent to you shortly.<br /><br />
63 <a href="locus_display.pl?locus_id=$locus_id">Go back</a> to the locus page.
66 END_HEREDOC
67 CXGN::Contact::send_email($subject,$fdbk_body, 'sgn-db-curation@sgn.cornell.edu');
68 CXGN::Contact::send_email($subject,$user_body, $usermail, $replyto);
71 $page->footer();
74 sub confirm_dialog {
76 #my $self = shift;
78 my $locus_id = shift;
79 my $back_link = qq| <a href="locus_display.pl?locus_id=$locus_id">Go back</a> to the locus page without requesting edit privileges|;
82 print qq {
83 <form>
84 Request edit privileges for locus id: $locus_id?
85 <input type="hidden" name="action" value="request" />
86 <input type="hidden" name="locus_id" value="$locus_id" />
87 <input type="submit" value="Sumbit request" />
88 </form>
90 $back_link