use conf key project_name to customize the top level page to the current site.
[sgn.git] / cgi-bin / solpeople / top-level.pl
blob7f15c71e8c73f05f38ed7bf2fce0d663345521ef
1 use strict;
3 use CXGN::DB::Connection;
4 use CXGN::Page;
5 use CXGN::Login;
6 use CXGN::People;
7 use CXGN::People::Person;
8 use CXGN::BlastWatch;
9 use CXGN::Phenome::Locus;
10 use CXGN::Cview::MapFactory;
11 use CXGN::Page::FormattingHelpers qw/info_section_html page_title_html
12 info_table_html simple_selectbox_html
13 html_optional_show/;
15 our $c;
16 use CatalystX::GlobalContext qw($c);
19 my $page = CXGN::Page->new( "solpeople main menu", "john" );
20 my $dbh = CXGN::DB::Connection->new();
21 my $site_name = $c->config->{project_name};
23 my $sp_person_id = CXGN::Login->new($dbh)->verify_session();
25 my $sp = CXGN::People::Person->new( $dbh, $sp_person_id );
26 unless ($sp_person_id) {
27 $page->error_page( "Login ID not found.",
28 "", "", "Login ID not found: $sp_person_id" );
30 unless ( $sp->get_username() ) {
31 $page->error_page( "Username not found.",
32 "", "", "Username not found for sp_person_id '$sp_person_id'" );
34 my $username = $sp->get_first_name() . " " . $sp->get_last_name();
36 #my $research_update=$sp->get_research_update();
37 #my $contact_update=$sp->get_contact_update();
39 $page->add_style( text => <<EOS);
40 div#queryTable
42 margin: 0px 0px 0px 0px;
43 display: none;
45 EOS
46 $page->header();
48 print <<END_HTML;
50 <script type = "text/javascript">
51 <!--
52 function toggleLayer(whichLayer) {
53 if (document.getElementById) {
54 var style2 = document.getElementById(whichLayer).style;
55 style2.display = style2.display? "":"block";
57 else if (document.all) {
58 var style2 = document.all[whichLayer].style;
59 style2.display = style2.display? "":"block";
61 else if (document.layers) {
62 var style2 = document.layers[whichLayer].style;
63 style2.display = style2.display? "":"block";
66 function showSequence(sequence) {
67 document.getElementById("Heading").innerHTML="<strong>Full sequence: </strong>";
68 document.getElementById("fullSequence").innerHTML=sequence;
70 function hideSequence() {
71 document.getElementById("Heading").innerHTML="";
72 document.getElementById("fullSequence").innerHTML="";
74 //-->
75 </script>
76 END_HTML
78 print page_title_html("My $site_name");
79 print qq|<div align="center">Welcome <b>$username</b></div>\n|;
80 print
81 qq|<div align="right" style="margin-bottom: 0.5em">Not $username? <a href="login.pl?logout=yes">[log out]</a></div>\n|;
82 print info_section_html( title => 'General Tools', contents => <<EOHTML);
83 <a href="personal-info.pl?action=edit&sp_person_id=$sp_person_id">View or update personal (contact and research) information</a><br />
84 <a href="change-account.pl?action=edit&sp_person_id=$sp_person_id">Update account information</a><br />
85 <a href="/forum/topics.pl">Post to SGN forum</a><br />
86 EOHTML
87 my $queries =
88 qq|<div id="queryTable">|
89 . CXGN::BlastWatch::get_queries( $dbh, $sp_person_id )
90 . '</div>';
91 print info_section_html( title => 'BLAST Watch', contents => <<EOHTML);
92 <div style="margin-bottom: 1em">BLAST Watch is an SGN service that lets users submit recurring BLAST queries to SGN. Our software repeats your BLAST search every week and notifies you by email if the BLAST results change.</div>
93 <a href="/tools/blast/watch/index.pl">Submit a query to SGN BLAST Watch</a><br />
94 <a href="javascript:toggleLayer('queryTable');" title="View your BLAST Watch queries">View your BLAST Watch queries</a>
95 $queries
96 EOHTML
98 #return 1 if the first term is eq to one of the other terms given
99 sub in(@) {
100 my $t = shift;
101 ( grep { $t eq $_ } @_ ) ? 1 : 0;
104 #now assemble the sequencing tools stuff
105 if ( in( $sp->get_user_type, qw/curator sequencer/ ) ) {
107 #make a form for uploading TPF and AGP files
108 my $tpf_agp_upload = do {
109 if ( $sp->get_user_type eq 'curator' ) {
110 tpf_agp_upload_forms(<<EOHTML);
111 <!-- the string 'TYPE' will be replaced in each instance by tpf_agp_upload_forms() -->
112 <label for="chrnuminputTYPE">For Chromosome #: </label><input id="chrnuminputTYPE" name="chr" type="text" size="2" maxlength="2" />
113 EOHTML
115 elsif ( $sp->get_user_type eq 'sequencer'
116 and my @projects =
117 grep { $_ >= 1 && $_ <= 12 }
118 $sp->get_projects_associated_with_person )
120 my $chrinput =
121 @projects > 1
122 ? simple_selectbox_html(
123 name => 'chr',
124 choices => \@projects,
125 label => 'For Chromosome #:',
127 : qq|For Chromosome #: <b>$projects[0]</b> <input type="hidden" value="$projects[0]" name="chr" />|;
128 tpf_agp_upload_forms($chrinput);
132 print info_section_html( title => 'Sequencer Tools', contents => <<EOHTML);
133 <a href="attribute_bacs.pl">Attribute a BAC to your chromosome sequencing project</a><br />
134 <a href="/maps/physical/clone_il_view.pl">View/update BAC IL mapping information (list view)</a><br />
135 <div style="vertical-align: middle; font-weight: bold"><a href="/maps/physical/clone_reg.pl">View/update all BAC registry info (list view) <img style="border: none" src="/documents/img/new.gif" /></a></div>
136 <a href="/sequencing/tpf.pl">View TPF Files</a><br />
137 <a href="/sequencing/agp.pl">View AGP Files</a><br />
138 $tpf_agp_upload
139 EOHTML
142 # if( in( $sp->get_user_type(), qw/submitter curator/ ) )
144 # print info_section_html(title => 'EST Submission Pages', contents => <<EOHTML);
145 # <a href="/data-submit/top-level.pl">Data submission start page</a>
146 # EOHTML
149 if ( in( $sp->get_user_type(), qw/submitter curator/ ) ) {
150 print info_section_html( title => 'QTL data submission',
151 contents => <<EOHTML);
152 <a href="/phenome/qtl_form.pl">Upload and analyse your QTL data</a>
153 EOHTML
156 my @pops = CXGN::Phenome::Population->my_populations($sp_person_id);
158 if (@pops) {
159 my $pop_list = my_populations(@pops);
160 print info_section_html( title => 'Populations', contents => $pop_list );
163 if ( $sp->get_user_type() eq 'curator' ) {
164 print info_section_html( title => 'Curator Tools', contents => <<EOHTML);
165 <a href="/solpeople/admin/crash_test.pl">Test website error handling</a><br />
166 <a href="/solpeople/admin/stats.pl">View user stats</a><br />
167 <a href="/solpeople/admin/quick_create_account.pl">Create new user account</a><br />
168 <a href="/solpeople/admin/create_organization.pl">Create new organization</a>
169 EOHTML
172 if ( $sp->get_user_type() =~ /curator/i ) {
173 my $publications =
174 qq| <a href= "/search/pub_search.pl">Search the SGN publication database </a><br />|;
175 $publications .=
176 qq| <a href= "/search/pub_search.pl?w9b3_assigned_to=$sp_person_id">See your assigned publications</a><br />|;
177 $publications .=
178 qq| <a href= "/search/pub_search.pl?w9b3_status=pending">See publications pending curation</a><br />|;
179 $publications .=
180 qq| <a href= "/chado/fetch_pubmed.pl">Load new publications from PubMed</a><br />|;
182 print info_section_html(
183 title => 'Literature mining',
184 contents => $publications
188 if ( $sp->get_user_type() =~ /submitter|curator|sequencer/i ) {
190 my @loci =
191 CXGN::Phenome::Locus::get_locus_ids_by_editor( $dbh, $sp_person_id );
192 my $top = 50;
193 my $more = 0;
194 my $max = @loci;
195 if ( @loci > 24 ) {
196 $more = @loci - 24;
197 $max = 24;
200 my $locus_editor_info = qq { None.<br /> };
201 if ( @loci > 0 ) {
202 $locus_editor_info = "";
205 for ( my $i = 0 ; $i < ($max) ; $i++ ) {
206 my $locus = CXGN::Phenome::Locus->new( $dbh, $loci[$i] );
207 my $symbol = $locus->get_locus_symbol();
208 my $locus_id = $locus->get_locus_id();
210 $locus_editor_info .=
211 qq { <a href="/phenome/locus_display.pl?locus_id=$locus_id&amp;action=view">$symbol</a> };
213 if ($more) {
214 $locus_editor_info .=
215 qq|<br><b>and <a href="/search/locus_search.pl?w8e4_editor=$sp_person_id">$more more</a></b><br />|;
218 print info_section_html(
219 title => 'Loci with Editor Privileges',
220 contents => $locus_editor_info
223 my @annotated_loci =
224 CXGN::Phenome::Locus::get_locus_ids_by_annotator( $dbh, $sp_person_id );
226 my $more = 0;
227 my $max = @annotated_loci;
228 if ( @annotated_loci > 24 ) {
229 $more = @annotated_loci - 24;
230 $max = 24;
233 my ( $locus_annotations, $more_annotations );
235 for ( my $i = 0 ; $i < $top ; $i++ ) {
236 my $locus = CXGN::Phenome::Locus->new( $dbh, $annotated_loci[$i] );
237 my $symbol = $locus->get_locus_symbol();
238 my $locus_id = $locus->get_locus_id();
240 if ( $i < $max ) {
241 $locus_annotations .=
242 qq | <a href="/phenome/locus_display.pl?locus_id=$locus_id&amp;action=view">$symbol</a> |;
244 else {
245 $more_annotations .=
246 qq { <a href="/phenome/locus_display.pl?locus_id=$locus_id&amp;action=view">$symbol</a> };
250 if ($more) {
251 $locus_annotations .= " and $more more, not shown.<br />";
253 $locus_annotations .=
254 html_optional_show( 'locus_annotations', 'Show more',
255 qq|<div class="minorbox">$more_annotations</div> |,
259 $locus_annotations .=
260 qq| <a href="../phenome/recent_annotated_loci.pl">[View annotated loci by date]</a> |;
261 print info_section_html(
262 title => 'Annotated Loci',
263 contents => $locus_annotations
266 my $map_factory = CXGN::Cview::MapFactory->new($dbh);
267 my @user_maps = $map_factory->get_user_maps();
268 my $html = "";
270 if ( @user_maps > 0 ) {
271 $html .=
272 "<table alt=\"\" ><tr><td><i>Name</i></td><td></td><td></td><td><i>status</i></td></tr>";
273 foreach my $um (@user_maps) {
274 my $public = " (not public) ";
275 if ( $um->get_map()->get_is_public() ) { $public = "(public)"; }
276 $html .=
277 "<tr><td><b>"
278 . $um->get_short_name()
279 . "</b></td><td> <a href=\"/cview/umap.pl?action=view&amp;user_map_id="
280 . $um->get_id()
281 . "\" >[view]</a></td><td><a href=\"/cview/umap.pl?action=edit&amp;user_map_id="
282 . $um->get_id()
283 . "\">[configure]</a></td><td>$public</td></tr>";
286 $html .= "</table>";
289 # BROKEN!
290 # print info_section_html(title => 'User Maps', contents=> <<EOHTML);
291 # <a href="/cview/upload_usermap.pl">Upload new user map</a><br />
292 # <br />
293 # $html
294 #EOHTML
298 my $user_type = $sp->get_user_type();
299 my $user_info = {
300 user => qq{ Your current user status is <b>$user_type</b>. Please contact <a href="mailto:sgn-feedback\@sgn.cornell.edu">SGN</a> to upgrade to a <b>submitter</b> account with more privileges. Submitters can upload user maps, EST data, and become locus editors. },
302 submitter => qq{ Your current user status is <b>$user_type</b>. You have the maximum user privileges on SGN. Please contact <a href="mailto:sgn-feedback\@sgn.cornell.edu">SGN</a> if you would like to change your user status.},
304 curator => qq{ Your current user status is <b>$user_type</b>. },
306 sequencer => qq{ Your current user status is <b>$user_type</b>. You have maximum user privileges on SGN. },
308 genefamily_editor => qq{ Your current user status is <b>$user_type</b>. },
311 print info_section_html( title => 'User Status',
312 contents => $user_info->{$user_type} );
314 $page->footer();
316 #returns a string containing a TPF and an AGP upload form,
317 #with the single argument interpolated in
318 sub tpf_agp_upload_forms {
319 my $chrinput = shift;
320 my ( $chrinput_agp, $chrinput_tpf ) = ( $chrinput, $chrinput );
321 $chrinput_agp =~ s/TYPE/_agp/g;
322 $chrinput_tpf =~ s/TYPE/_tpf/g;
323 return <<EOHTML;
324 <div style="margin-top: 1em">
325 <b>Upload Accessioned Golden Path (AGP) File</b><br />
326 <form action="/sequencing/agp.pl" method="post" enctype="multipart/form-data">
327 $chrinput_agp
328 <input type="hidden" name="filetype" value="agp" />
329 <label for="agpinput">File: </label>
330 <input id="agpinput" type="file" name="agp_file" value="Upload AGP file" /><input type="submit" value="Submit" />
331 </form>
332 </div>
333 <div style="margin-top: 1em">
334 <b>Upload Tiling Path Format (TPF) File</b><br />
335 <form action="/sequencing/tpf.pl" method="post" enctype="multipart/form-data">
336 $chrinput_tpf
337 <input type="hidden" name="filetype" value="tpf" />
338 <label for="tpfinput">File: </label>
339 <input id="tpfinput" type="file" name="tpf_file" value="Upload TPF file" /><input type="submit" value="Submit" />
340 </form>
341 </div>
342 EOHTML
345 sub my_populations {
346 my @pops = @_;
347 my $pop_list;
349 foreach my $pops (@pops) {
350 my $pop_name = $pops->get_name();
351 my $pop_id = $pops->get_population_id();
352 my $is_public = $pops->get_privacy_status();
353 if ($is_public) { $is_public = 'is publicly available'; }
354 if ( !$is_public ) { $is_public = 'is not publicly available yet'; }
355 $pop_list .=
356 qq |<a href="/phenome/population.pl?population_id=$pop_id">$pop_name</a> <i>($is_public)</i><br/>|;
358 return $pop_list;