--- loncom/interface/coursecatalog.pm 2007/01/10 03:57:51 1.16
+++ loncom/interface/coursecatalog.pm 2014/04/28 22:12:55 1.84
@@ -1,3 +1,7 @@
+# The LearningOnline Network with CAPA
+# Handler for displaying the course catalog interface
+#
+# $Id: coursecatalog.pm,v 1.84 2014/04/28 22:12:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,221 +46,810 @@ 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 $formname = 'coursecatalog';
- my $domdesc = $Apache::lonnet::domaindescription{$codedom};
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['sortby','showdom']);
+ 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';
+ if ($env{'form.showdom'} ne '') {
+ $env{'form.showdom'} = &LONCAPA::clean_domain($env{'form.showdom'});
+ if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') {
+ $codedom = $env{'form.showdom'};
+ } else {
+ $env{'form.showdom'} = '';
+ }
+ }
+ my $domdesc = &Apache::lonnet::domain($codedom,'description');
&Apache::lonhtmlcommon::clear_breadcrumbs();
- if ($env{'form.coursenum'} ne '' && &user_is_known()) {
- &course_details($r,$codedom,$formname,$domdesc);
+
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom);
+ my $knownuser = &user_is_known();
+
+ my ($cathash,$cattype);
+ if (ref($domconfig{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconfig{'coursecategories'}{'cats'};
+ if ($knownuser) {
+ $cattype = $domconfig{'coursecategories'}{'auth'};
+ } else {
+ $cattype = $domconfig{'coursecategories'}{'unauth'};
+ }
} else {
- &course_selector($r,$codedom,$formname,$domdesc);
- if ($env{'form.state'} eq 'listing') {
- $r->print('
'.&print_course_listing($codedom).'
');
- }
+ $cathash = {};
+ $cattype = 'std';
+ }
+ if ($cattype eq 'none') {
+ $r->print(&Apache::loncommon::start_page('Course/Community Catalog'));
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/coursecatalog",
+ text=>"Course/Community Catalog"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));
+ if ($knownuser) {
+ $r->print('
'; + if ($env{'form.currcat_0'} eq 'communities::0') { + $output .= &mt('The courseID provided does not match a community in this domain.'); + } else { + $output .= &mt('The courseID provided does not match a course in this domain.'); + } + $output .= '
'; return $output; } } else { - %courses = &search_courselist($domain); + if ($env{'form.currcat_0'} eq 'instcode::0') { + %courses = &search_official_courselist($domain,$numtitles,$codetitles); + } else { + %courses = &search_courselist($domain,$subcats); + } if (keys(%courses) == 0) { - $output = &mt('No courses match the criteria you selected.'); + $output = ''; + if ($env{'form.currcat_0'} eq 'communities::0') { + $output .= &mt('No communities match the criteria you selected.'); + } else { + $output .= &mt('No courses match the criteria you selected.'); + } + $output .= '
'; return $output; } - if ($knownuser && !$env{'form.showdetails'}) { - $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.'.$lt{$item}.' | '. + ' | '.$numbers{$item}.' | '. + '
'.$lt{$status}.' | '. + ' | '.$numbers{$status}.' | '. + '
'.$lt{'cr_'.$status}.' | '. + ' | '.$creditsum{$status}.' |