display programs alphabetically
[sgn.git] / cgi-bin / curator / pub_curator.pl
blob217e7299d7b41b9c2522205b16ace25af1b70c42
1 use strict;
2 use warnings;
4 use CXGN::Scrap::AjaxPage;
5 use CXGN::DB::Connection;
6 use CXGN::Login;
7 use CXGN::People::Person;
8 use CXGN::Chado::Publication;
9 use CXGN::Feed;
10 use JSON;
12 my $dbh = CXGN::DB::Connection->new();
13 my($login_person_id,$login_user_type)=CXGN::Login->new($dbh)->verify_session();
15 if ($login_user_type eq 'curator' || $login_user_type eq 'submitter' || $login_user_type eq 'sequencer') {
18 my $doc = CXGN::Scrap::AjaxPage->new();
19 my ($pub_id, $stat, $curator_id, $action) = $doc->get_encoded_arguments("pub_id", "stat", "curator_id", "action");
20 my $pub=CXGN::Chado::Publication->new($dbh, $pub_id);
21 my %error = ();
23 my $json = JSON->new();
24 #Assign a new curator
25 if ($action eq 'assign_curator') {
26 $error{"error"} = "Storing pub_curator works!";
27 eval {
28 $pub->set_curator_id($curator_id);
29 $pub->store_pub_curator();
31 if ($@) {
32 $error{"error"} = $@;
35 my $jobj = $json->objToJson(\%error);
36 print STDERR "JSON FORMAT: $jobj\n";
38 print "Content-Type: text/plain\n\n";
39 print $jobj;
41 #Change the pub_curator status
42 } elsif ($action eq 'change_stat') {
43 $error{"error"} = "Updating pub_curator status to $stat!";
44 eval {
46 $pub->set_status($stat);
47 $pub->set_curated_by($login_person_id);
48 $pub->store_pub_curator();
51 if ($@) {
52 $error{"error"} = $@;
53 warn "pub_curator update failed! (pub_id= $pub_id, status=$stat, assigned_curator=$curator_id, login_person_id=$login_person_id)"; }
54 else {
56 #my $subject="[New pub_curator info stored] pub $pub_id";
57 #my $username= $self->get_user()->get_first_name()." ".$self->get_user()->get_last_name();
58 #my $fdbk_body="user $login_person_id has updated pub_curator status =$stat. \n ";
59 #CXGN::Contact::send_email($subject,$fdbk_body, 'sgn-db-curation@sgn.cornell.edu');
60 #CXGN::Feed::update_feed($subject,$fdbk_body);
62 my $jobj = $json->objToJson(\%error);
63 print STDERR "JSON FORMAT: $jobj\n";
65 print "Content-Type: text/plain\n\n";
66 print $jobj;