[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface coursecatalog.pm
raeburn
raeburn at source.lon-capa.org
Fri Jul 26 16:38:44 EDT 2019
raeburn Fri Jul 26 20:38:44 2019 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface coursecatalog.pm
Log:
- For 2.11
Backport 1.91, 1.92, 1.98
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.88.2.5 loncom/interface/coursecatalog.pm:1.88.2.6
--- loncom/interface/coursecatalog.pm:1.88.2.5 Fri Jul 26 15:32:34 2019
+++ loncom/interface/coursecatalog.pm Fri Jul 26 20:38:43 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.88.2.5 2019/07/26 15:32:34 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.88.2.6 2019/07/26 20:38:43 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -124,7 +124,7 @@
}
my $js = '<script type="text/javascript">'."\n".
'// <![CDATA['."\n".
- &courselink_javascript()."\n".
+ &courselink_javascript($r)."\n".
'// ]]>'."\n".
'</script>'."\n";
$r->print(&Apache::loncommon::start_page('Search for a Course/Community',$js));
@@ -175,8 +175,14 @@
$courseinfo{$codedom.'_'.$cnum}{$item});
if ($item eq 'title') {
if ($courseinfo{$codedom.'_'.$cnum}{'showsyllabus'}) {
+ my $usehttp = 0;
+ if (($ENV{'SERVER_PORT'} == 443) && ($courseinfo{$codedom.'_'.$cnum}{'extsyllplain'})) {
+ unless (&Apache::lonnet::uses_sts()) {
+ $usehttp = 1;
+ }
+ }
$r->print(' <font size="-2">'.
- '<a href="javascript:ToSyllabus('."'$codedom','$cnum'".')">'.
+ '<a href="javascript:ToSyllabus('."'$codedom','$cnum','$usehttp'".')">'.
&mt('Syllabus').'</a></font>');
}
}
@@ -279,7 +285,7 @@
}
ENDSCRIPT
- $catjs .= &courselink_javascript();
+ $catjs .= &courselink_javascript($r);
if (&user_is_dc($codedom) || $canviewall) {
$catjs .= <<ENDTOGGJS
@@ -642,7 +648,7 @@
my %add_entries = (topmargin => "0",
marginheight => "0",);
my $js = '<script type="text/javascript">'."\n".
- &courselink_javascript().'</script>'."\n";
+ &courselink_javascript($r).'</script>'."\n";
my $start_page =
&Apache::loncommon::start_page('Course/Community Catalog',$js,
{'add_entries' => \%add_entries, });
@@ -705,9 +711,11 @@
}
sub courselink_javascript {
+ my ($r) = @_;
+ my $hostname = $r->hostname();
return <<"END";
-function ToSyllabus(cdom,cnum) {
+function ToSyllabus(cdom,cnum,usehttp) {
if (cdom == '' || cdom == null) {
return;
}
@@ -715,6 +723,13 @@
return;
}
document.linklaunch.action = "/public/"+cdom+"/"+cnum+"/syllabus";
+ if (usehttp == 1) {
+ var hostname = '$hostname';
+ if (hostname != '') {
+ document.linklaunch.action = 'http://'+hostname+document.linklaunch.action;
+ }
+ document.linklaunch.action += '?usehttp=1';
+ }
document.linklaunch.submit();
}
@@ -1540,7 +1555,7 @@
$cleandesc=~s/'/\\'/g;
$cleandesc =~ s/^\s+//;
my ($cdom,$cnum)=split(/\_/,$course);
- my ($instcode,$singleowner,$ttype,$selfenroll_types,
+ my ($instcode,$singleowner,$ttype,$selfenroll_types,$extsyllplain,
$selfenroll_start,$selfenroll_end, at owners,%ownernames,$categories);
if (ref($courses->{$course}) eq 'HASH') {
$descr = $courses->{$course}{'description'};
@@ -1551,6 +1566,7 @@
$selfenroll_start = $courses->{$course}{'selfenroll_start_date'};
$selfenroll_end = $courses->{$course}{'selfenroll_end_date'};
$categories = $courses->{$course}{'categories'};
+ $extsyllplain = $courses->{$course}{'extsyllplain'};
push(@owners,$singleowner);
if ($courses->{$course}{'co-owners'} ne '') {
foreach my $item (split(/,/,$courses->{$course}{'co-owners'})) {
@@ -1594,6 +1610,7 @@
$courseinfo{$course}{'selfenroll_start'} = $selfenroll_start;
$courseinfo{$course}{'selfenroll_end'} = $selfenroll_end;
$courseinfo{$course}{'categories'} = $categories;
+ $courseinfo{$course}{'extsyllplain'} = $extsyllplain;
my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum);
my @classids;
@@ -1778,7 +1795,8 @@
sub courseinfo_row {
my ($info,$knownuser,$details,$countref,$now,$course,$trails,$allitems,$numbers,$canviewall) = @_;
my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items,
- $accessdates,$showsyllabus,$counts,$autoenrollment,$output,$categories);
+ $accessdates,$showsyllabus,$counts,$autoenrollment,$output,$categories,
+ $extsyllplain);
if (ref($info) eq 'HASH') {
$cdom = $info->{'cdom'};
$cnum = $info->{'cnum'};
@@ -1792,6 +1810,7 @@
$counts = $info->{'counts'};
$autoenrollment = $info->{'autoenrollment'};
$showsyllabus = $info->{'showsyllabus'};
+ $extsyllplain = $info->{'extsyllplain'};
$categories = $info->{'categories'};
} else {
$output = '<td colspan="8">'.&mt('No information available for [_1].',
@@ -1819,7 +1838,13 @@
'<td>'.$xlist_items.'</td>'.
'<td>'.$title.' <font size="-2">';
if ($showsyllabus) {
- $output .= '<a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a>';
+ my $usehttp = 0;
+ if (($ENV{'SERVER_PORT'} == 443) && ($extsyllplain)) {
+ unless (&Apache::lonnet::uses_sts()) {
+ $usehttp = 1;
+ }
+ }
+ $output .= '<a href="javascript:ToSyllabus('."'$cdom','$cnum','$usehttp'".')">'.&mt('Syllabus').'</a>';
} else {
$output .= ' ';
}
More information about the LON-CAPA-cvs
mailing list