--- loncom/interface/coursecatalog.pm 2006/09/25 00:16:56 1.5 +++ loncom/interface/coursecatalog.pm 2007/01/14 01:59:37 1.19 @@ -1,3 +1,7 @@ +# The LearningOnline Network with CAPA +# Handler for displaying the course catalog interface +# +# $Id: coursecatalog.pm,v 1.19 2007/01/14 01:59:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -28,11 +32,11 @@ use strict; use lib qw(/home/httpd/lib/perl); use Apache::Constants qw(:common); use Apache::loncommon; +use Apache::lonhtmlcommon; use Apache::lonnet; use Apache::lonlocal; -use Apache::lonsupportreq; +use Apache::courseclassifier; use Apache::lonacc; -use lib '/home/httpd/lib/perl/'; use LONCAPA; sub handler { @@ -42,11 +46,76 @@ sub handler { if ($r->header_only) { return OK; } + my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); + my $lonid=$cookies{'lonID'}; + my $lonidsdir=$r->dir_config('lonIDsDir'); + my $handle; + if ($lonid) { + $handle=&LONCAPA::clean_handle($lonid->value); + } + if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { + &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle); + } &Apache::lonacc::get_posted_cgi($r); &Apache::lonlocal::get_language_handle($r); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['sortby']); - my $codedom = $Apache::lonnet::perlvar{'lonDefDomain'}; - my $ccode = ''; + my $codedom = &Apache::lonnet::default_login_domain(); + + if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { + $codedom = $env{'user.domain'}; + if ($env{'request.role.domain'} ne '') { + $codedom = $env{'request.role.domain'}; + } + } + my $formname = 'coursecatalog'; + my $domdesc = $Apache::lonnet::domaindescription{$codedom}; + + &Apache::lonhtmlcommon::clear_breadcrumbs(); + if ($env{'form.coursenum'} ne '' && &user_is_known()) { + &course_details($r,$codedom,$formname,$domdesc); + } else { + my $numtitles = &course_selector($r,$codedom,$formname,$domdesc); + if ($env{'form.state'} eq 'listing') { + $r->print(&print_course_listing($codedom,$numtitles).''); + } + } + $r->print(&Apache::loncommon::end_page()); + return OK; +} + +sub course_details { + my ($r,$codedom,$formname,$domdesc) = @_; + my $output; + my %add_entries = (topmargin => "0", + marginheight => "0",); + my $start_page = + &Apache::loncommon::start_page('Course Catalog','', + { + 'add_entries' => \%add_entries, + 'no_inline_link' => 1,}); + $r->print($start_page); + if ($env{'form.numtitles'} > 0) { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>"/adm/coursecatalog", + text=>"Select courses"}); + } + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>"javascript:document.$formname.submit()", + text=>"Course listing"}, + {text=>"Course details"}); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Details')); + $r->print(''.&mt('Detailed course information:').''. + '