4 use CXGN
::Scrap
::AjaxPage
;
6 use CXGN
::People
::Person
;
8 use CatalystX
::GlobalContext
'$c';
10 my $dbh = $c->dbc->dbh;
12 my ( $login_person_id, $login_user_type ) =
13 CXGN
::Login
->new($dbh)->verify_session();
15 if ( $login_user_type eq 'curator' ) {
16 my $doc = CXGN
::Scrap
::AjaxPage
->new();
17 $doc->send_http_header();
18 my ( $user_info, $object_type, $object_id, $sp_person_id ) =
19 $doc->get_encoded_arguments( "user_info", "object_type", "object_id",
22 #query for retreiving user information
24 my $user_query = $dbh->prepare(
25 "SELECT sp_person_id, first_name, last_name, user_type FROM sgn_people.sp_person
26 WHERE (first_name ilike '%$user_info%' OR last_name ilike '%$user_info%')
30 $user_query->execute();
31 my ( $sp_person_id, $first_name, $last_name, $user_type ) =
32 $user_query->fetchrow_array();
36 my $person = CXGN
::People
::Person
->new( $dbh, $sp_person_id );
37 @roles = $person->get_roles;
38 my $role_string = join ',', @roles;
39 $users .= "$sp_person_id*$last_name, $first_name [$role_string]|";
40 ( $sp_person_id, $first_name, $last_name, $user_type ) =
41 $user_query->fetchrow_array();
46 #setting the new object owner. Only curators can do this.
47 #if the user has a 'user' account it will be updated to a 'submitter' first
48 #executed when javascript sends object_type and object_id , and sp_person_id args
49 if ( $object_type && $object_id ) {
50 my $new_owner = CXGN
::People
::Person
->new( $dbh, $sp_person_id );
54 #if the new owner is not a submitter, assign that role
55 if ( !$new_owner->has_role('submitter') ) {
56 $new_owner->add_role('submitter');
59 if ( $object_type eq 'locus' ) {
60 $query = $dbh->prepare(
61 "INSERT INTO phenome.locus_owner (sp_person_id, locus_id, granted_by)
64 $query->execute( $sp_person_id, $object_id, $login_person_id );
66 #if the current owner of the locus is a logged-in SGN curator, do an obsolete..
67 if ( $login_user_type eq 'curator' ) {
68 my $remove_curator_query =
69 "UPDATE phenome.locus_owner SET obsolete='t', modified_date= now()
70 WHERE locus_id=? AND sp_person_id IN (SELECT sp_person_id FROM sgn_people.sp_person_roles WHERE sp_role_id = (SELECT sp_role_id FROM sgn_people.sp_roles WHERE name = 'curator') )";
71 my $remove_curator_sth =
72 $dbh->prepare($remove_curator_query);
73 $remove_curator_sth->execute($object_id);
77 elsif ( $object_type eq 'individual' ) {
78 $query = $dbh->prepare(
79 "UPDATE phenome.individual SET sp_person_id= ?
80 WHERE indvidual_id= ?"
82 $query->execute( $sp_person_id, $object_id );
85 elsif ( $object_type eq 'stock' ) {
87 $c->dbic_schema( 'Bio::Chado::Schema', 'sgn_chado', $sp_person_id )
88 ->resultset("Stock::Stock")
89 ->find( { stock_id
=> $object_id } );
90 $stock->create_stockprops(
91 { 'sp_person_id' => $sp_person_id },
95 'allow_duplicate_values' => 1
104 my $message = "assigning $object_type owner failed! $@";
110 "[New $object_type owner assigned] $object_type $object_id";
111 my $person = CXGN
::People
::Person
->new( $dbh, $login_person_id );
113 $person->get_first_name() . " " . $person->get_last_name();
115 qq |solgenomics
.net
/solpeople/personal
-info
.pl?sp_person_id
=$login_person_id|;
118 'locus' => qq |solgenomics
.net
/locus/$object_id/view/|,
119 'stock' => qq |solgenomics
.net
/stock/$object_id/view/|,
121 my $object_link = $links{$object_type};
122 my $owner = CXGN
::People
::Person
->new( $dbh, $sp_person_id );
124 $owner->get_first_name() . " " . $owner->get_last_name();
126 qq |solgenomics
.net
/solpeople/personal
-info
.pl?sp_person_id
=$sp_person_id|;
128 "curator $user ($user_link) has assigned a new owner ($owner_name, $owner_link) for $object_type $object_link \n ";
129 CXGN
::Contact
::send_email
( $subject, $fdbk_body,
130 'sgn-db-curation@sgn.cornell.edu' );
131 CXGN
::Feed
::update_feed
( $subject, $fdbk_body );