--- loncom/interface/coursecatalog.pm 2006/10/16 19:39:51 1.7
+++ loncom/interface/coursecatalog.pm 2007/01/12 21:07:37 1.17
@@ -1,3 +1,7 @@
+# The LearningOnline Network with CAPA
+# Handler for displaying the course catalog interface
+#
+# $Id: coursecatalog.pm,v 1.17 2007/01/12 21:07:37 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,6 +46,16 @@ 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']);
@@ -50,13 +64,13 @@ sub handler {
my $domdesc = $Apache::lonnet::domaindescription{$codedom};
&Apache::lonhtmlcommon::clear_breadcrumbs();
- if ($env{'form.coursenum'} ne '') {
+ if ($env{'form.coursenum'} ne '' && &user_is_known()) {
&course_details($r,$codedom,$formname,$domdesc);
} else {
&course_selector($r,$codedom,$formname,$domdesc);
if ($env{'form.state'} eq 'listing') {
$r->print('
'.&print_course_listing($codedom).' ');
- }
+ }
}
$r->print(&Apache::loncommon::end_page());
return OK;
@@ -226,6 +240,13 @@ function setCourseId(caller) {
''."\n".''."\n".
''
);
+ 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('');
if ($numtitles > 4) {
$r->print('
'.$codetitles[$numtitles-1].' '."\n".
@@ -242,6 +263,18 @@ function setCourseId(caller) {
return;
}
+sub user_is_dc {
+ my ($codedom) = @_;
+ if (exists($env{'user.role.dc./'.$codedom.'/'})) {
+ my $livedc = 1;
+ my $now = time;
+ my ($start,$end)=split(/\./,$env{'user.role.dc./'.$codedom.'/'});
+ if ($start && $start>$now) { $livedc = 0; }
+ if ($end && $end <$now) { $livedc = 0; }
+ return $livedc;
+ }
+ return;
+}
sub recurse_options {
my ($currkey,$currlist,$level,$cat,$cat_options,$data,$by_year,$by_sem,$by_dept) = @_;
@@ -355,6 +388,13 @@ sub print_course_listing {
my ($domain) = @_;
my $output;
my %courses;
+ my $knownuser = &user_is_known();
+ my $details = $env{'form.coursenum'};
+ if (&user_is_dc($domain)) {
+ if ($env{'form.showdetails'}) {
+ $details = 1;
+ }
+ }
if ($env{'form.coursenum'} ne '') {
%courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.',
$env{'form.coursenum'},
@@ -369,17 +409,29 @@ sub print_course_listing {
$output = &mt('No courses match the criteria you selected.');
return $output;
}
- $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.
');
+ 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.