on second though, remove post-only restriction on organism tree image cache flushing...
[sgn.git] / cgi-bin / phenome / merge_locus.pl
bloba1fc888283cbd8e04e097c5f1ba28eb89951b435
1 use strict;
2 use warnings;
4 use CXGN::Scrap::AjaxPage;
5 use CXGN::Login;
6 use CXGN::People::Person;
7 use CXGN::Phenome::Locus;
8 use CXGN::Feed;
9 use CXGN::Contact;
11 use JSON;
13 my %error = ();
14 my $json = JSON->new();
16 my $dbh = CXGN::DB::Connection->new();
17 my($login_person_id,$login_user_type)=CXGN::Login->new($dbh)->verify_session();
19 #print STDERR "merge_locus.pl:login_person_id= $login_person_id\n";
21 if ($login_user_type eq 'curator') {
22 my $doc = CXGN::Scrap::AjaxPage->new();
23 $doc->send_http_header();
24 my ($merged_locus_id, $locus_id) = $doc->get_encoded_arguments("merged_locus_id", "locus_id");
25 print STDERR "merge_locus.pl:merged_locus_id=$merged_locus_id, locus_id = $locus_id\n ";
27 my $locus= CXGN::Phenome::Locus->new($dbh, $locus_id);
29 if ($merged_locus_id && $locus_id ) {
31 my $fail = $locus->merge_locus($merged_locus_id, $login_person_id);
33 if ($fail) {
34 warn "merging locus failed! . $fail";
35 my $message= "merging locus failed!\n $fail ";
36 CXGN::Contact::send_email('Merging locus failed' ,$message, 'sgn-bugs@sgn.cornell.edu');
37 $error{"error"} = $message;
41 else {
42 $error{reload} = 1;
43 my $subject="[New locus merged] locus $locus_id";
44 my $person= CXGN::People::Person->new($dbh, $login_person_id);
45 my $user=$person->get_first_name()." ".$person->get_last_name();
46 my $user_link = qq |http://www.sgn.cornell.edu/solpeople/personal-info.pl?sp_person_id=$login_person_id|;
47 my $locus_link = qq |http://www.sgn.cornell.edu/phenome/locus_display.pl?locus_id=$locus_id|;
49 my $fdbk_body="curator $user ($user_link) merged locus $merged_locus_id with locus $locus_id ($locus_link) \n ";
50 CXGN::Contact::send_email($subject,$fdbk_body, 'sgn-db-curation@sgn.cornell.edu');
51 CXGN::Feed::update_feed($subject,$fdbk_body);
54 my $jobj = $json->encode(\%error);
55 print $jobj;