--- loncom/interface/lonsupportreq.pm 2004/07/19 16:35:12 1.6 +++ loncom/interface/lonsupportreq.pm 2006/03/23 22:01:57 1.31 @@ -1,12 +1,39 @@ +# +# $Id: lonsupportreq.pm,v 1.31 2006/03/23 22:01:57 albertel Exp $ +# +# Copyright Michigan State University Board of Trustees +# +# This file is part of the LearningOnline Network with CAPA (LON-CAPA). +# +# LON-CAPA is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LON-CAPA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LON-CAPA; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# /home/httpd/html/adm/gpl.txt +# +# http://www.lon-capa.org/ +# + package Apache::lonsupportreq; use strict; use lib qw(/home/httpd/lib/perl); use MIME::Types; use MIME::Lite; +use CGI::Cookie(); use Apache::Constants qw(:common); use Apache::loncommon(); -use Apache::lonnet(); +use Apache::lonnet; use Apache::lonlocal; sub handler { @@ -17,11 +44,14 @@ sub handler { if ($r->header_only) { return OK; } + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['origurl','function']); + if ($r->uri eq '/adm/helpdesk') { + &Apache::loncommon::get_posted_cgi($r); + } + my $function = $env{'form.function'}; + my $origurl = &Apache::lonnet::unescape($env{'form.origurl'}); + my $action = $env{'form.action'}; - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','origurl','function']); - my $action = $ENV{'form.action'}; - my $function = $ENV{'form.function'}; - my $origurl = &Apache::lonnet::unescape($ENV{'form.origurl'}); if ($action eq 'process') { &print_request_receipt($r,$origurl,$function); } else { @@ -32,32 +62,59 @@ sub handler { sub print_request_form { my ($r,$origurl,$function) = @_; - my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server); - my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0",marginheight="0"',1); + my ($os,$browser,$bversion,$uhost,$uname,$udom,$uhome,$urole,$usec,$email,$cid,$cdom,$cnum,$ctitle,$ccode,$sectionlist,$lastname,$firstname,$server,$formname); my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) { - $tablecolor = '#CCCCFF'; + $tablecolor = '#EEEE99'; + } + $ccode = ''; + $os = $env{'browser.os'}; + $browser = $env{'browser.type'}; + $bversion = $env{'browser.version'}; + $uhost = $env{'request.host'}; + $uname = $env{'user.name'}; + $udom = $env{'user.domain'}; + $uhome = $env{'user.home'}; + $urole = $env{'request.role'}; + $usec = $env{'request.course.sec'}; + $cid = $env{'request.course.id'}; + $formname = 'logproblem'; + if ($origurl =~ m-^http://-) { + $server = $origurl; + } else { + $server = 'http://'.$ENV{'SERVER_NAME'}.$origurl; } - $os = $ENV{'browser.os'}; - $browser = $ENV{'browser.type'}; - $bversion = $ENV{'browser.version'}; - $uhost = $ENV{'request.host'}; - $uname = $ENV{'user.name'}; - $udom = $ENV{'user.domain'}; - $uhome = $ENV{'user.home'}; - $urole = $ENV{'request.role'}; - $usec = $ENV{'request.course.sec'}; - $cid = $ENV{'request.course.id'}; - $server = $ENV{'SERVER_NAME'}; - my $scripttag = (<= 0) { + return true; + } + return false; + } +} END + if ($cid =~ m/_/) { ($cdom,$cnum) = split/_/,$cid; } @@ -67,17 +124,17 @@ END $ccode = $csettings{'internal.coursecode'}; $sectionlist = $csettings{'internal.sectionnums'}; } - if ($ENV{'environment.critnotification'}) { - $email = $ENV{'environment.critnotification'}; + if ($env{'environment.critnotification'}) { + $email = $env{'environment.critnotification'}; } - if (!$email && $ENV{'environment.notification'}) { - $email = $ENV{'environment.notification'}; + if (!$email && $env{'environment.notification'}) { + $email = $env{'environment.notification'}; } - if ($ENV{'environment.lastname'}) { - $lastname = $ENV{'environment.lastname'}; + if ($env{'environment.lastname'}) { + $lastname = $env{'environment.lastname'}; } - if ($ENV{'environment.firstname'}) { - $firstname = $ENV{'environment.firstname'}; + if ($env{'environment.firstname'}) { + $firstname = $env{'environment.firstname'}; } my @sections = split/,/,$sectionlist; my %groupid = (); @@ -85,8 +142,15 @@ END my ($sec,$grp) = split/:/,$_; $groupid{$sec} = $grp; } - my $defdom = $Apache::lonnet::perlvar{'lonDefDomain'}; - my $codedom = $defdom; + my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'}; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['codedom']); + if (exists($env{'form.codedom'})) { + $codedom = $env{'form.codedom'}; + } + my $details_title; + if ($codedom) { + $details_title = '
('.$codedom.')'; + } my %coursecodes = (); my %codes = (); my @codetitles = (); @@ -99,7 +163,11 @@ END my $totcodes = 0; my $format_reply; my $jscript = ''; - + my $loaditems = qq| +function initialize_codes() { + return; +} + |; if ($cdom) { $codedom = $cdom; } @@ -116,23 +184,33 @@ END $totcodes = &retrieve_instcodes(\%coursecodes,$codedom,$totcodes); } if ($totcodes > 0) { - $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order); if ($ccode eq '') { - my $numtypes = @codetitles; - &build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles); - &javascript_code_selections($numtypes,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles); + $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order); + if ($format_reply eq 'ok') { + my $numtypes = @codetitles; + &build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles); + &javascript_code_selections($formname,$numtypes,\%cat_titles,\$jscript,\%idlist,\%idnums,\%idlist_titles,\@codetitles); + $loaditems = ''; + } } } - $r->print(< - - LON-CAPA support request - - -$bodytag + + my $js = ''; + my $add_entries = + 'topmargin="0" marginheight="0" onLoad="initialize_codes()"', + my $start_page = + &Apache::loncommon::start_page('Support Request',$js, + { 'function' => $function, + 'add_entries' => $add_entries, + 'only_body' => 1,}); + $r->print($start_page); + + if ($r->uri eq '/adm/helpdesk') { + &print_header($r,$origurl); + } + $r->print(<<"END"); +
@@ -702,13 +890,84 @@ END
@@ -143,7 +221,6 @@ $bodytag
- END - if (defined($ENV{'user.name'})) { + if (defined($env{'user.name'})) { $r->print(< END } + $r->print(<
@@ -168,9 +245,10 @@ END } elsif (defined($lastname) && $lastname ne '') { $fullname= " $lastname"; } - $r->print('
'); + $r->print(''); } $r->print(< 
@@ -233,10 +311,10 @@ END } if ($udomform eq '') { $udomform = 'domain: '; - $udomform .= &Apache::loncommon::select_dom_form('','udom'); + $udomform .= &Apache::loncommon::select_dom_form($codedom,'udom'); } if ($unameform eq '') { - $unameform= 'username  '; + $unameform= 'username  '; } $r->print($unameform.$udomform.'
Enter the username you use to log-in to your LON-CAPA system, and choose your domain.'); } @@ -264,7 +342,7 @@ END
- http://$server$origurl + $server
@@ -303,7 +381,7 @@ END
-
Course Details: + Course Details:$details_title
@@ -313,20 +391,81 @@ END
END - if ($coursecodes{$cnum}) { - foreach (@codetitles) { - $r->print(''.$_.': '.$codes{$cnum}{$_}.'; '); + if ($cnum) { + if ($coursecodes{$cnum}) { + foreach (@codetitles) { + $r->print(''.$_.': '.$codes{$cnum}{$_}.'; '); + } + $r->print(' '); + } else { + $r->print('Enter institutional course code:  + '); } - $r->print(' '); } else { - $r->print('Enter institutional course code:  + if ($totcodes > 0) { + my $numtitles = @codetitles; + if ($numtitles == 0) { + $r->print('Enter institutional course code:  '); + } else { + my $lasttitle = $numtitles; + if ($numtitles > 4) { + $lasttitle = 4; + } + $r->print(''); + for (my $i=1; $i<$numtitles; $i++) { + $r->print('' + ); + } + $r->print('
'.$codetitles[0].'
'."\n". + '
'.$codetitles[$i].'
'."\n". + ''."\n". + '
'); + if ($numtitles > 4) { + $r->print('

'.$codetitles[$numtitles].'
'."\n". + ''."\n"); + } + } + } else { + $r->print('Enter institutional course code:  + '); + } } if ($ctitle) { $r->print('
Title: '.$ctitle.''); } else { $r->print('
Enter course title:  - '); + '); } $r->print(< @@ -354,12 +493,13 @@ END
END if ($sectionlist) { - $r->print("". + " \n"); foreach (sort keys %groupid) { if ($_ eq $groupid{$_} || $groupid{$_} eq '') { - $r->print("\n"); } else { - $r->print("\n"); } } $r->print(""); @@ -426,7 +566,7 @@ END
@@ -454,6 +594,7 @@ END
@@ -469,7 +610,7 @@ END
-   +     @@ -489,14 +630,18 @@ END
+ END + $r->print(&Apache::loncommon::end_page()); return; } sub print_request_receipt { my ($r,$url,$function) = @_; - my @envvars = ('lonID','HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME','browser.os','browser.type','browser.version','user.home','request.role'); + my @ENVvars = ('HTTP_HOST','HTTP_USER_AGENT','REMOTE_ADDR','SERVER_ADDR','SERVER_NAME'); + my @envvars = ('browser.os','browser.type','browser.version','user.home','request.role'); my @loncvars = ('user.name','user.domain','request.course.sec','request.course.id'); + my @cookievars = ('lonID'); my $bodytag = &Apache::loncommon::bodytag('',$function,'topmargin="0" marginheight="0"',1); my $admin = $Apache::lonnet::perlvar{'lonAdminMail'}; @@ -506,63 +651,84 @@ sub print_request_receipt { my $fontcolor = &Apache::loncommon::designparm($function.'.font'); my $vlinkcolor = &Apache::loncommon::designparm($function.'.vlink'); my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); - my @formvars = ('username','email','uname','udom','origurl','phone','section','coursecode','title','subject','description','screenshot'); - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars); + my @formvars = ('username','email','uname','udom','sourceurl','phone','section','coursecode','title','subject','description','screenshot'); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},\@formvars); + my $coursecode = $env{'form.coursecode'}; + if ($coursecode eq '') { + if (defined($env{'form.Year'})) { + $coursecode .= $env{'form.Year'}; + } + if (defined($env{'form.Semester'})) { + $coursecode .= $env{'form.Semester'}; + } + if (defined($env{'form.Department'})) { + $coursecode .= $env{'form.Department'}; + } + if (defined($env{'form.Number'})) { + $coursecode .= $env{'form.Number'}; + } + } my $supportmsg = qq| -Name: $ENV{'form.username'} -Email: $ENV{'form.email'} -Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'} -Tel: $ENV{'form.phone'} -Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'} -Subject: $ENV{'form.subject'} -Description: $ENV{'form.description'} -URL: $ENV{'form.origurl'} +Name: $env{'form.username'} +Email: $env{'form.email'} +Username/domain: $env{'form.uname'} - $env{'form.udom'} +Tel: $env{'form.phone'} +Course Information: $env{'form.title'} - $coursecode - section: $env{'form.section'} +Subject: $env{'form.subject'} +Description: $env{'form.description'} +URL: $env{'form.sourceurl'} Date/Time: $reporttime |; - my $descrip = $ENV{'form.description'}; + my $descrip = $env{'form.description'}; $descrip =~ s#\n#
#g; my $displaymsg = qq| -Name: $ENV{'form.username'}
-Email: $ENV{'form.email'}
-Username/domain: $ENV{'form.uname'} - $ENV{'form.udom'}
-Tel: $ENV{'form.phone'}
-Course Information: $ENV{'form.title'} - $ENV{'form.coursecode'} - section: $ENV{'form.section'}
-Subject: $ENV{'form.subject'}
+Name: $env{'form.username'}
+Email: $env{'form.email'}
+Username/domain: $env{'form.uname'} - $env{'form.udom'}
+Tel: $env{'form.phone'}
+Course Information: $env{'form.title'} - $coursecode - section: $env{'form.section'}
+Subject: $env{'form.subject'}
Description: $descrip
-URL: $ENV{'form.origurl'}
+URL: $env{'form.sourceurl'}
Date/Time: $reporttime
|; - - if ($to =~ m/^[^\@]+\@[^\@]+$/) { - $r->print(< - - LON-CAPA support request recorded - + my $html=&Apache::lonxml::xmlbegin(); + my $head = &Apache::loncommon::head('LON-CAPA support request recorded'); + $r->print(<<"END"); +$html +$head $bodytag -

A support request has been sent to $to

+
+ +
END - } else { - $to = 'helpdesk@lon-capa.org'; - $r->print(< - - LON-CAPA support request recorded - -$bodytag + if ($r->uri eq '/adm/helpdesk') { + &print_header($r,$url,'process'); + } + if ($to =~ m/^[^\@]+\@[^\@]+$/) { + $r->print("

A support request has been sent to $to

"); + } else { + $to = $admin; + if ($to =~ m/^[^\@]+\@[^\@]+$/) { + $r->print("

A support request has been sent to $to

"); +END + } else { + $r->print(<Warning: Problem with support e-mail address -As the e-mail address provided for this LON-CAPA server ($to) does not appear to be a valid e-mail address, your support request has not been sent to the LON-CAPA support staff at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University. +As the e-mail address provided for this LON-CAPA server ($to) does not appear to be a valid e-mail address, your support request has not been sent to the LON-CAPA support staff or administrator at your institution. Instead a copy has been sent to the LON-CAPA support team at Michigan State University. END + $to = 'helpdesk@lon-capa.org'; + } } - if (defined($ENV{'form.email'})) { - if ($ENV{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) { - $from = $ENV{'form.email'}; + if (defined($env{'form.email'})) { + if ($env{'form.email'} =~ m/^[^\@]+\@[^\@]+$/) { + $from = $env{'form.email'}; } } - my $subject = $ENV{'form.subject'}; + my $subject = $env{'form.subject'}; $subject =~ s#(`)#'#g; $subject =~ s#\$#\(\$\)#g; $supportmsg =~ s#(`)#'#g; @@ -573,9 +739,9 @@ END my $attachmentpath = ''; my $attachmentsize = ''; - if (defined($ENV{'user.name'})) { - if ($ENV{'form.screenshot.filename'}) { - $attachmentsize = length($ENV{'form.screenshot'}); + if (defined($env{'user.name'})) { + if ($env{'form.screenshot.filename'}) { + $attachmentsize = length($env{'form.screenshot'}); if ($attachmentsize > 131072) { $displaymsg .= "
The uploaded screenshot file ($attachmentsize bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded."; } else { @@ -584,13 +750,25 @@ END } } + my %cookies = (); + my $cookie=CGI::Cookie->parse($r->header_in('Cookie')); + if ($$cookie{'lonID'} =~ /lonID=(\w+);/) { + $cookies{'lonID'} = $1; + } + if ($attachmentpath =~ m-/([^/]+)$-) { $fname = $1; - $displaymsg .= "
An uploaded screenshot file - $fname ($attachmentsize bytes) was included in the request sent by $ENV{'user.name'} from LON-CAPA domain: $ENV{'user.domain'}"; + $displaymsg .= "
An uploaded screenshot file - $fname ($attachmentsize bytes) was included in the request sent by $env{'user.name'} from LON-CAPA domain: $env{'user.domain'}"; $supportmsg .= "\n"; - foreach (@envvars) { + foreach (@cookievars) { + $supportmsg .= "$_: $cookies{$_}\n"; + } + foreach (@ENVvars) { $supportmsg .= "$_: $ENV{$_}\n"; } + foreach (@envvars) { + $supportmsg .= "$_: $env{$_}\n"; + } } my $msg = MIME::Lite->new( @@ -610,24 +788,24 @@ END } else { my $envdata = ''; - foreach (@envvars) { + foreach (@cookievars) { + $envdata .= "$_: $cookies{$_}\n"; + } + foreach (@ENVvars) { $envdata .= "$_: $ENV{$_}\n"; } + foreach (@envvars) { + $envdata .= "$_: $env{$_}\n"; + } foreach (@loncvars) { - $envdata .= "$_: $ENV{$_}\n"; + $envdata .= "$_: $env{$_}\n"; } $msg->attach(Type => 'TEXT', Data => $envdata); } ### Send it: - # ->send can cause an sh launch which can pass all of %ENV along - # which can be to large for /bin/sh's little mind - my %oldENV=%ENV; - undef(%ENV); $msg->send('sendmail'); - %ENV=%oldENV; - undef(%oldENV); if ($attachmentpath =~ m#$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+#) { unlink($attachmentpath); @@ -680,11 +858,21 @@ END
|); - foreach (@envvars) { - unless($ENV{$_} eq '') { + foreach (@cookievars) { + unless($cookies{$_} eq '') { + $r->print("$_: $cookies{$_}, "); + } + } + foreach (@ENVvars) { + unless($ENV{$_} eq '') { $r->print("$_: $ENV{$_}, "); } } + foreach (@envvars) { + unless($env{$_} eq '') { + $r->print("$_: $env{$_}, "); + } + } $r->print("
"); + $r->print(&Apache::loncommon::end_page()); +} + +sub print_header { + my ($r,$origurl,$action) = @_; + my $location=&Apache::loncommon::lonhttpdurl("/adm"); + my $tablecolor = '#EEEE99'; + my ($component_url); + my $helpdesk_link = ''; + if ($action eq 'process') { + $helpdesk_link = ''; + } + my %lt = &Apache::lonlocal::texthash ( + login => 'Log-in help', + ask => 'Ask helpdesk', + getst => 'Getting started guide', + back => 'Back to last location' + ); + my ($getstartlink,$getstarttext); + if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/gettingstarted.html') { + $getstartlink = qq| $lt{'getst'}|; + $getstarttext = ' '.&mt('and the "Getting started" guide').' '; + } + $r->print(<   + +
  LON-CAPA help/support + + + + +
+ + + + +
+ + + + +
+ + + + $getstartlink + + +
(Login help) $lt{'login'} $helpdesk_link(Ask helpdesk) $lt{'ask'}  (Back to last location) $lt{'back'} 
+
+
+
+
+ +   + + +   + +END + unless ($action eq 'process') { + $r->print(' + + '.&mt(' +Please review the information in "Log-in help"').$getstarttext.' '.&mt('if you are unable to log-in').'. '.&mt('If your problem is still unresolved, the form below can be used to send a question to the LON-CAPA helpdesk').'.
'.&mt('Note').': '.&mt('Student questions about course content should be directed to the course instructor').'.

+ + '); + } + $r->print(' +'); + return; } sub retrieve_instcodes { my ($coursecodes,$codedom,$totcodes) = @_; - my %courses = &Apache::lonnet::courseiddump($codedom,'.',1); + my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.','.'); foreach my $course (keys %courses) { - if ($courses{$course} =~ m/^[^:]*:([^:]+)$/) { + if ($courses{$course} =~ m/^[^:]*:([^:]+)/) { $$coursecodes{$course} = &Apache::lonnet::unescape($1); $totcodes ++; } @@ -737,7 +996,6 @@ sub build_code_selections { } $$idlist{$$codetitles[0]} = join('","',@contents); $$idnums{$$codetitles[0]} = scalar(@contents); - print STDERR "idnums for {$$codetitles[0] is $$idnums{$$codetitles[0]}\n"; if (defined($$cat_titles{$$codetitles[0]})) { $$idlist_titles{$$codetitles[0]} = join('","',@contents_titles); } @@ -755,7 +1013,6 @@ sub build_code_selections { } $$idlist{$$codetitles[1]}{$key_a} = join('","',@sorted_a); $$idnums{$$codetitles[1]}{$key_a} = scalar(@sorted_a); - print STDERR "idnums for {$$codetitles[1] and $key_a is $$idnums{$$codetitles[1]}{$key_a}\n"; if (defined($$cat_titles{$$codetitles[1]})) { $$idlist_titles{$$codetitles[1]}{$key_a} = join('","',@sorted_a_titles); } @@ -770,9 +1027,9 @@ sub build_code_selections { my @sorted_b = (); my @sorted_b_titles = (); &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[2]}{$key_a}{$key_b}},\@sorted_b); - if (defined($$cat_titles{$$codetitles[1]})) { + if (defined($$cat_titles{$$codetitles[2]})) { foreach (@sorted_b) { - push @sorted_b_titles, $$cat_titles{$$codetitles[1]}{$_}; + push @sorted_b_titles, $$cat_titles{$$codetitles[2]}{$_}; } } $$idlist{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_b); @@ -790,9 +1047,18 @@ sub build_code_selections { %{$$idlist{$$codetitles[3]}{$key_a}{$key_b}} = (); foreach my $key_c (keys %{$idarrays{$$codetitles[3]}{$key_a}{$key_b}}) { my @sorted_c = (); + my @sorted_c_titles = (); &sort_cats($num,$cat_order,$codetitles,\@{$idarrays{$$codetitles[3]}{$key_a}{$key_b}{$key_c}},\@sorted_c); + if (defined($$cat_titles{$$codetitles[3]})) { + foreach (@sorted_c) { + push @sorted_c_titles, $$cat_titles{$$codetitles[3]}{$_}; + } + } $$idlist{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = join('","',@sorted_c); $$idnums{$$codetitles[3]}{$key_a}{$key_b}{$key_c} = scalar(@sorted_c); + if (defined($$cat_titles{$$codetitles[3]})) { + $$idlist_titles{$$codetitles[2]}{$key_a}{$key_b} = join('","',@sorted_c_titles); + } } } } @@ -806,7 +1072,13 @@ sub build_code_selections { %{$$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}} = (); foreach my $key_d (keys %{$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}}) { my @sorted_d = (); + my @sorted_d_titles = (); &sort_cats($num,$cat_order,$codetitles,$idarrays{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d},\@sorted_d); + if (defined($$cat_titles{$$codetitles[4]})) { + foreach (@sorted_d) { + push @sorted_d_titles, $$cat_titles{$$codetitles[4]}{$_}; + } + } $$idlist{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = join('","',@sorted_d); $$idnums{$$codetitles[4]}{$key_a}{$key_b}{$key_c}{$key_d} = scalar(@sorted_d); } @@ -837,7 +1109,6 @@ sub recurse_list { if ($num == 0) { if (!grep/^$$codes{$cid}{$$codetitles[0]}$/,@{$$idarrays{$$codetitles[0]}}) { push @{$$idarrays{$$codetitles[0]}}, $$codes{$cid}{$$codetitles[0]}; - print STDERR "Adding $$codes{$cid}{$$codetitles[0]} to $$codetitles[0]\n"; } } elsif ($num == 1) { if (defined($$idarrays{$$codetitles[1]}{$$codes{$cid}{$$codetitles[0]}})) { @@ -913,101 +1184,186 @@ sub recurse_list { } sub javascript_code_selections { - my ($numcats,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_; + my ($formname,$numcats,$cat_titles,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_; + my $numtitles = @{$codetitles}; + my @seltitles = (); + for (my $j=0; $j<$numtitles; $j++) { + $seltitles[$j] = 'id'.$$codetitles[$j]; + } + my $seltitle_str = join('","',@seltitles); + my @longtitles = (); + for (my $i=0; $i<$numtitles; $i++) { + if (defined($$cat_titles{$$codetitles[$i]})) { + $longtitles[$i] = 1; + } else { + $longtitles[$i] = 0; + } + } + my $longtitles_str = join('","',@longtitles); $$script_tag .= <