--- loncom/interface/coursecatalog.pm 2007/01/12 23:37:22 1.18
+++ loncom/interface/coursecatalog.pm 2008/03/08 04:00:53 1.27
@@ -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.27 2008/03/08 04:00:53 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",
@@ -221,8 +231,10 @@ function setCourseId(caller) {
$r->print(&mt('Choose which course(s) to list. '));
$r->print('
');
for (my $k=0; $k<$lasttitle-1; $k++) {
- my @unsorted = @{$cat_items{$codetitles[$k]}};
- my @items;
+ my (@items,@unsorted);
+ if (ref($cat_items{$codetitles[$k]}) eq 'ARRAY') {
+ @unsorted = @{$cat_items{$codetitles[$k]}};
+ }
&Apache::courseclassifier::sort_cats($k,\%cat_order,\@codetitles,\@unsorted,\@items);
my @longitems;
if (defined($cat_titles{$codetitles[$k]})) {
@@ -249,12 +261,18 @@ function setCourseId(caller) {
''."\n".''."\n".
''
);
+ my $show_selfenroll_status;
+ if ($env{'form.showselfenroll'}) {
+ $show_selfenroll_status = 'checked="checked" ';
+ }
if (&user_is_dc($codedom)) {
my $showdetails_status;
if ($env{'form.showdetails'}) {
$showdetails_status = 'checked="checked" ';
- }
- $r->print('
'.&mt('Show full details for each course (DC only)').'
');
+ }
+ $r->print('
');
+ } else {
+ $r->print('
');
}
$r->print('
');
if ($numtitles > 4) {
@@ -267,7 +285,8 @@ function setCourseId(caller) {
if ($numtitles > 0) {
$r->print('');
}
- $r->print('');
+ $r->print('');
if (($numtitles > 0) && ($env{'form.state'} eq 'listing')) {
$r->print('
');
}
@@ -401,7 +420,8 @@ sub search_courselist {
}
}
my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.',
- undef,undef,'Course',1);
+ undef,undef,'Course',1,
+ $env{'form.showselfenroll'});
return %courses;
}
@@ -420,7 +440,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;
@@ -435,22 +455,25 @@ sub print_course_listing {
$output = &mt('Note for students: If you are officially enrolled in a course but the course is not listed in your LON-CAPA courses, click the "Show more details" link for the specific course and check the default access dates and/or automated enrollment settings.
');
}
}
- $output .= &construct_data_table($knownuser,\%courses,$details);
+ my $now = time;
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
+ $output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig);
$output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']);
return $output;
}
sub construct_data_table {
- my ($knownuser,$courses,$details,$usersections) = @_;
+ my ($knownuser,$courses,$details,$usersections,$now,$domconfig) = @_;
my %sortname;
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 +481,8 @@ sub construct_data_table {
$output .= '