--- loncom/interface/coursecatalog.pm 2007/01/12 23:37:22 1.18
+++ loncom/interface/coursecatalog.pm 2007/12/10 23:54:40 1.24
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.18 2007/01/12 23:37:22 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.24 2007/12/10 23:54:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -46,22 +46,24 @@ sub handler {
if ($r->header_only) {
return OK;
}
- my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
- my $lonid=$cookies{'lonID'};
+ my $handle = &Apache::lonnet::check_for_valid_session($r);
my $lonidsdir=$r->dir_config('lonIDsDir');
- my $handle;
- if ($lonid) {
- $handle=&LONCAPA::clean_handle($lonid->value);
- }
- if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
+ if ($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 $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};
+ my $domdesc = &Apache::lonnet::domain($codedom,'description');
&Apache::lonhtmlcommon::clear_breadcrumbs();
if ($env{'form.coursenum'} ne '' && &user_is_known()) {
@@ -87,10 +89,13 @@ sub course_details {
'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=>"/adm/coursecatalog",
- text=>"Select courses"},
- {href=>"javascript:document.$formname.submit()",
+ ({href=>"javascript:document.$formname.submit()",
text=>"Course listing"},
{text=>"Course details"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Details'));
@@ -123,7 +128,7 @@ sub course_selector {
my $totcodes = 0;
my $jscript = '';
my ($numtitles,$lasttitle);
- $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom,$totcodes);
+ $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom);
if ($totcodes > 0) {
$format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);
if ($format_reply eq 'ok') {
@@ -204,11 +209,16 @@ function setCourseId(caller) {
'no_inline_link' => 1,});
$r->print($start_page);
if ($env{'form.state'} eq 'listing') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/coursecatalog",
- text=>"Select courses"},
- {text=>"Course listing"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Listing'));
+ if ($numtitles > 0) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/coursecatalog",
+ text=>"Select courses"},
+ {text=>"Course listing"});
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({text=>"Course listing"});
+ }
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Listing'));
} else {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"/adm/coursecatalog",
@@ -267,7 +277,8 @@ function setCourseId(caller) {
if ($numtitles > 0) {
$r->print('');
}
- $r->print('');
+ $r->print('');
if (($numtitles > 0) && ($env{'form.state'} eq 'listing')) {
$r->print('
');
}
@@ -420,7 +431,7 @@ sub print_course_listing {
if ($env{'form.coursenum'} ne '') {
%courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.',
$env{'form.coursenum'},
- undef,undef,'Course');
+ undef,undef,'Course',1);
if (keys(%courses) == 0) {
$output .= &mt('The courseID provided does not match a course in this domain.');
return $output;
@@ -446,11 +457,11 @@ sub construct_data_table {
if (($details eq '') || ($env{'form.showdetails'})) {
$sortname{'Code'} = 'code';
$sortname{'Title'} = 'title';
- $sortname{'Owner'} = 'owner';
+ $sortname{'Owner(s)'} = 'owner';
}
my $output = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row();
- my @coltitles = ('Code','Sections','Crosslisted','Title','Owner');
+ my @coltitles = ('Count','Code','Sections','Crosslisted','Title','Owner(s)');
if (ref($usersections) eq 'HASH') {
$coltitles[1] = 'Your Section';
}
@@ -458,6 +469,8 @@ sub construct_data_table {
$output .= '