#!/usr/local/bin/perl ############################################################################### # Set up all needed modules and objects ############################################################################### use strict; use Getopt::Long; use FindBin; use lib "$FindBin::Bin/../../lib/perl"; use vars qw ($sbeams $sbeamsMOD $q $current_contact_id $current_username $PROG_NAME $USAGE %OPTIONS $QUIET $VERBOSE $DEBUG $DATABASE $TABLE_NAME $PROGRAM_FILE_NAME $CATEGORY $DB_TABLE_NAME @MENU_OPTIONS); use SBEAMS::Connection qw($q); use SBEAMS::Connection::Settings; use SBEAMS::Connection::Tables; use SBEAMS::Inkjet; use SBEAMS::Inkjet::Settings; use SBEAMS::Inkjet::Tables; $sbeams = new SBEAMS::Connection; $sbeamsMOD = new SBEAMS::Inkjet; $sbeamsMOD->setSBEAMS($sbeams); $sbeams->setSBEAMS_SUBDIR($SBEAMS_SUBDIR); #use CGI; #$q = new CGI; ############################################################################### # Set program name and usage banner for command like use ############################################################################### $PROG_NAME = $FindBin::Script; $USAGE = <Authenticate() and exit if it fails or continue if it works. ############################################################################### sub main { #### Do the SBEAMS authentication and exit if a username is not returned exit unless ($current_username = $sbeams->Authenticate( #connect_read_only=>1, #allow_anonymous_access=>1, #permitted_work_groups_ref=>['Proteomics_user','Proteomics_admin'], )); #### Read in the default input parameters my %parameters; my $n_params_found = $sbeams->parse_input_parameters( q=>$q,parameters_ref=>\%parameters); #$sbeams->printDebuggingInfo($q); #### Process generic "state" parameters before we start $sbeams->processStandardParameters( parameters_ref=>\%parameters); #### Decide what action to take based on information so far if ($parameters{action} eq "???") { # Some action } else { $sbeamsMOD->printPageHeader(); handle_request(ref_parameters=>\%parameters); $sbeamsMOD->printPageFooter(); } } # end main ############################################################################### # Handle Request ############################################################################### sub handle_request { my %args = @_; #### Process the arguments list my $ref_parameters = $args{'ref_parameters'} || die "ref_parameters not passed"; my %parameters = %{$ref_parameters}; #### Define some generic varibles my ($i,$element,$key,$value,$line,$result,$sql); my @rows; #### Define variables for Summary Section my $project_id = $parameters{PROJECT_ID} || $sbeams->getCurrent_project_id; my $current_contact_id = $sbeams->getCurrent_contact_id(); my ($first_name, $last_name); #### Show current user context information $sbeams->printUserContext(); #### Get information about the current project from the database $sql = qq~ SELECT C.first_name, C.last_name FROM $TB_CONTACT C WHERE C.contact_id = '$current_contact_id' AND C.record_status != 'D' ~; @rows = $sbeams->selectSeveralColumns($sql); if (@rows) { ($first_name, $last_name) = @{$rows[0]}; } #### Print Project Title print qq~

$first_name $last_name\'s Homepage


~; #### print_tabs my @tab_titles = ("Graphical Overview","Current Project","Projects You Own","Accessible Projects","News And Links"); my $tab_titles_ref = \@tab_titles; my $page_link = "main.cgi"; my $unselected_bg_color = "\#008000"; my $unselected_font_color = "\#FFFFFF"; my $selected_bg_color = "\#DC143C"; my $selected_font_color = "\#FFFFFF"; #### Summary Section if($parameters{'tab'} eq "graphical_overview") { $sbeamsMOD->print_tabs(tab_titles_ref=>$tab_titles_ref, page_link=>$page_link, unselected_bg_color=>$unselected_bg_color, unselected_font_color=>$unselected_font_color, selected_bg_color=>$selected_bg_color, selected_font_color=>$selected_font_color, selected_tab=>0); print_graphical_overview_tab(); }elsif ($parameters{'tab'} eq "current_project"){ $sbeamsMOD->print_tabs(tab_titles_ref=>$tab_titles_ref, page_link=>$page_link, unselected_bg_color=>$unselected_bg_color, unselected_font_color=>$unselected_font_color, selected_bg_color=>$selected_bg_color, selected_font_color=>$selected_font_color, selected_tab=>1); print_current_project_tab(); }elsif($parameters{'tab'} eq "projects_you_own") { $sbeamsMOD->print_tabs(tab_titles_ref=>$tab_titles_ref, page_link=>$page_link, unselected_bg_color=>$unselected_bg_color, unselected_font_color=>$unselected_font_color, selected_bg_color=>$selected_bg_color, selected_font_color=>$selected_font_color, selected_tab=>2); print_projects_you_own_tab(); }elsif($parameters{'tab'} eq "accessible_projects") { $sbeamsMOD->print_tabs(tab_titles_ref=>$tab_titles_ref, page_link=>$page_link, unselected_bg_color=>$unselected_bg_color, unselected_font_color=>$unselected_font_color, selected_bg_color=>$selected_bg_color, selected_font_color=>$selected_font_color, selected_tab=>3); print_accessible_projects_tab(); }elsif($parameters{'tab'} eq "news_and_links") { $sbeamsMOD->print_tabs(tab_titles_ref=>$tab_titles_ref, page_link=>$page_link, unselected_bg_color=>$unselected_bg_color, unselected_font_color=>$unselected_font_color, selected_bg_color=>$selected_bg_color, selected_font_color=>$selected_font_color, selected_tab=>4); print_news_and_links_tab(); }else{ $sbeamsMOD->print_tabs(tab_titles_ref=>$tab_titles_ref, page_link=>$page_link, unselected_bg_color=>$unselected_bg_color, unselected_font_color=>$unselected_font_color, selected_bg_color=>$selected_bg_color, selected_font_color=>$selected_font_color, selected_tab=>0); print_graphical_overview_tab(); } return; } # end handle_request ############################################################################### # print_news_and_links_tab ############################################################################### sub print_news_and_links_tab { my %args = @_; my $SUB_NAME = "print_array_news_tab"; my $file_name = "$PHYSICAL_BASE_DIR/lib/etc/$SBEAMS_SUBDIR/news/current_news.txt"; ## Start News and Links Page print qq~
Inkjet Links
$LINESEPARATOR
Inkjet News
~; ## Print anything in the 'news' file open(INFILE, $file_name) || die "unable to open news file, $file_name"; print qq~

~; while () { my $textline = $_; if ($textline =~ /^Title:(.*)/){ print qq ~

$1

~; }elsif($textline =~/^Posted:(.*)/){ print qq~ Posted on: $1
~; }elsif($textline =~/\w/){ print qq~$textline~; } } print qq~

~; ## Finish up News and Links Page print qq~
~; return; } ############################################################################### # print_current_project_tab ############################################################################### sub print_current_project_tab { my %args = @_; my $SUB_NAME = "print_current_project_tab"; #$sbeams->printCurrentProject(page_link=>'ProjectHome.cgi'); ## Define standard variables my ($sql, @rows); my $current_contact_id = $sbeams->getCurrent_contact_id(); my (%array_requests, %array_scans, %quantitation_files); my $project_id = $sbeams->getCurrent_project_id(); my ($project_name, $project_tag, $project_status, $project_desc); my ($pi_first_name, $pi_last_name, $pi_contact_id, $username); #### Get information about the current project from the database $sql = qq~ SELECT P.name,P.project_tag,P.project_status,P.description,C.first_name,C.last_name,C.contact_id,UL.username FROM $TB_PROJECT P JOIN $TB_CONTACT C ON ( P.PI_contact_id = C.contact_id ) JOIN $TB_USER_LOGIN UL ON ( UL.contact_id = C.contact_id) WHERE P.project_id = '$project_id' ~; @rows = $sbeams->selectSeveralColumns($sql); if (@rows) { ($project_name,$project_tag,$project_status,$project_desc,$pi_first_name,$pi_last_name,$pi_contact_id,$username) = @{$rows[0]}; } #### Print out some information about this project print qq~

Summary of $project_name: [More Information]

~; #### Get all the array information for this project my $n_array_requests = 0; my $n_array_scans = 0; my $n_quantitation_files = 0; if ($project_id > 0) { $sql = qq~ SELECT array_request_id, n_slides, date_created FROM $TBIJ_ARRAY_REQUEST WHERE project_id = '$project_id' AND record_status != 'D' ~; @rows = $sbeams->selectSeveralColumns($sql); foreach my $row(@rows){ my @temp_row = @{$row}; $array_requests{$temp_row[0]} = "$temp_row[2] ($temp_row[1] slides)"; $n_array_requests++; } $sql = qq~ SELECT ASCAN.array_scan_id, ASCAN.stage_location FROM $TBIJ_ARRAY_SCAN ASCAN JOIN $TBIJ_ARRAY A ON ( A.array_id = ASCAN.array_id ) JOIN $TBIJ_ARRAY_QUANTITATION AQ ON ( AQ.array_scan_id = ASCAN.array_scan_id ) WHERE A.project_id = '$project_id' AND ASCAN.record_status != 'D' AND A.record_status != 'D' AND AQ.record_status != 'D' ~; %array_scans = $sbeams->selectTwoColumnHash($sql); $sql = qq~ SELECT AQ.array_quantitation_id, AQ.stage_location FROM $TBIJ_ARRAY_SCAN ASCAN JOIN $TBIJ_ARRAY A ON ( A.array_id = ASCAN.array_id ) JOIN $TBIJ_ARRAY_QUANTITATION AQ ON ( AQ.array_scan_id = ASCAN.array_scan_id ) WHERE A.project_id = '$project_id' AND ASCAN.record_status != 'D' AND A.record_status != 'D' AND AQ.record_status != 'D' ~; %quantitation_files = $sbeams->selectTwoColumnHash($sql); foreach my $key (keys %array_scans) { $n_array_scans++; } foreach my $key (keys %quantitation_files){ $n_quantitation_files++; } } print qq~
PI: $pi_first_name $pi_last_name
Status: $project_status
Project Tag: $project_tag
Description:$project_desc
Array Requests: $n_array_requests
Array Scans: $n_array_scans
Array Quantitations: $n_quantitation_files
Access Privileges:[View/Edit]
$LINESEPARATOR ~; return; } ############################################################################### # print_projects_you_own_tab ############################################################################### sub print_projects_you_own_tab { my %args = @_; my $SUB_NAME = "print_projects_you_own_tab"; $sbeams->printProjectsYouOwn(); return; } ############################################################################### # print_accessible_projects_tab ############################################################################### sub print_accessible_projects_tab { my %args = @_; my $SUB_NAME = "print_accessible_projects_tab"; $sbeams->printProjectsYouHaveAccessTo(); return; } ############################################################################### # print_graphical_overview_tab ############################################################################### sub print_graphical_overview_tab { my %args = @_; my $SUB_NAME = "print_graphical_overview_tab"; #### Print out graphic print qq!

!; # Depending on user context, the image map links will be printed? print qq!

!; return; }