version 1.100, 2019/07/21 14:26:02
|
version 1.103, 2021/04/29 17:45:22
|
Line 59 sub handler {
|
Line 59 sub handler {
|
|
|
my $serverdefdom = &Apache::lonnet::default_login_domain(); |
my $serverdefdom = &Apache::lonnet::default_login_domain(); |
my $codedom = $serverdefdom; |
my $codedom = $serverdefdom; |
|
my $hostname = $r->hostname(); |
|
|
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { |
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { |
$codedom = $env{'user.domain'}; |
$codedom = $env{'user.domain'}; |
Line 91 sub handler {
|
Line 92 sub handler {
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} |
} |
my %domconfig = |
my $crscats = &Apache::lonnet::get_dom_cats($codedom); |
&Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($codedom); |
my $knownuser = &user_is_known(); |
my $knownuser = &user_is_known(); |
my $canviewall = &canview_all($knownuser,$codedom); |
my $canviewall = &canview_all($knownuser,$codedom); |
|
|
my ($cathash,$cattype); |
my ($cathash,$cattype); |
if (ref($domconfig{'coursecategories'}) eq 'HASH') { |
if (ref($crscats) eq 'HASH') { |
$cathash = $domconfig{'coursecategories'}{'cats'}; |
%{$cathash} = %{$crscats}; |
if ($knownuser || $canviewall) { |
|
$cattype = $domconfig{'coursecategories'}{'auth'}; |
|
} else { |
|
$cattype = $domconfig{'coursecategories'}{'unauth'}; |
|
} |
|
if ($cattype eq '') { |
|
$cattype = 'std'; |
|
} |
|
} else { |
} else { |
$cathash = {}; |
$cathash = {}; |
|
} |
|
if ($knownuser || $canviewall) { |
|
$cattype = $domdefaults{'catauth'}; |
|
} else { |
|
$cattype = $domdefaults{'catunauth'}; |
|
} |
|
if ($cattype eq '') { |
$cattype = 'std'; |
$cattype = 'std'; |
} |
} |
if ($cattype eq 'none') { |
if ($cattype eq 'none') { |
Line 120 sub handler {
|
Line 120 sub handler {
|
if ($knownuser || $canviewall) { |
if ($knownuser || $canviewall) { |
$r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>'); |
$r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>'); |
} else { |
} else { |
if ($domconfig{'coursecategories'}{'auth'} eq 'none') { |
if ($domdefaults{'catauth'} eq 'none') { |
$r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>'); |
$r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>'); |
} else { |
} else { |
$r->print('<div>'.&mt('The catalog of LON-CAPA courses/communities provided for: "[_1]" is only available to users who are logged in.',$domdesc).'</div>'); |
$r->print('<div>'.&mt('The catalog of LON-CAPA courses/communities provided for: "[_1]" is only available to users who are logged in.',$domdesc).'</div>'); |
Line 130 sub handler {
|
Line 130 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
my $cnum; |
my $cnum; |
if ($cattype eq 'codesrch') { |
if ($cattype eq 'codesrch') { |
my ($uniquecode,$codemsg,$brtext); |
my ($uniquecode,$codemsg,$brtext); |
if ($env{'form.uniquecode'}) { |
if ($env{'form.uniquecode'}) { |
Line 139 sub handler {
|
Line 139 sub handler {
|
} |
} |
my $js = '<script type="text/javascript">'."\n". |
my $js = '<script type="text/javascript">'."\n". |
'// <![CDATA['."\n". |
'// <![CDATA['."\n". |
&courselink_javascript($r)."\n". |
&courselink_javascript($hostname)."\n". |
'// ]]>'."\n". |
'// ]]>'."\n". |
'</script>'."\n"; |
'</script>'."\n"; |
$r->print(&Apache::loncommon::start_page('Search for a Course/Community',$js)); |
$r->print(&Apache::loncommon::start_page('Search for a Course/Community',$js)); |
Line 192 sub handler {
|
Line 192 sub handler {
|
if ($courseinfo{$codedom.'_'.$cnum}{'showsyllabus'}) { |
if ($courseinfo{$codedom.'_'.$cnum}{'showsyllabus'}) { |
my $usehttp = 0; |
my $usehttp = 0; |
if (($ENV{'SERVER_PORT'} == 443) && ($courseinfo{$codedom.'_'.$cnum}{'extsyllplain'})) { |
if (($ENV{'SERVER_PORT'} == 443) && ($courseinfo{$codedom.'_'.$cnum}{'extsyllplain'})) { |
unless (&Apache::lonnet::uses_sts()) { |
unless ((&Apache::lonnet::uses_sts()) || |
|
(&Apache::lonnet::waf_allssl($hostname))) { |
$usehttp = 1; |
$usehttp = 1; |
} |
} |
} |
} |
Line 251 sub handler {
|
Line 252 sub handler {
|
$toplevelstr =~ s/,$//; |
$toplevelstr =~ s/,$//; |
$maxdepthstr =~ s/,$//; |
$maxdepthstr =~ s/,$//; |
} |
} |
&validate_input($codedom,\@cats,\%maxd,$domconfig{'coursecategories'}); |
&validate_input($codedom,\@cats,\%maxd,$cathash); |
my ($numtitles,@codetitles); |
my ($numtitles,@codetitles); |
if (($env{'form.coursenum'} ne '') && ($knownuser)) { |
if (($env{'form.coursenum'} ne '') && ($knownuser)) { |
&course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems,\@codetitles); |
&course_details($r,$codedom,$formname,$domdesc,$hostname,\@trails, |
|
\%allitems,\@codetitles); |
} else { |
} else { |
my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats); |
my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats); |
my $wasacctext = &get_wasactive_text(); |
my $wasacctext = &get_wasactive_text(); |
Line 282 function setCatDepth(depth) {
|
Line 284 function setCatDepth(depth) {
|
} |
} |
document.coursecats.catalog_maxdepth.value = depth; |
document.coursecats.catalog_maxdepth.value = depth; |
} else { |
} else { |
document.coursecats.currcat_0.value = ''; |
document.coursecats.currcat_0.value = ''; |
document.coursecats.catalog_maxdepth.value = ''; |
document.coursecats.catalog_maxdepth.value = ''; |
} |
} |
document.coursecats.submit(); |
document.coursecats.submit(); |
Line 300 function setCourseId(caller) {
|
Line 302 function setCourseId(caller) {
|
} |
} |
|
|
ENDSCRIPT |
ENDSCRIPT |
$catjs .= &courselink_javascript($r); |
$catjs .= &courselink_javascript($hostname); |
if (&user_is_dc($codedom) || $canviewall) { |
if (&user_is_dc($codedom) || $canviewall) { |
$catjs .= <<ENDTOGGJS |
$catjs .= <<ENDTOGGJS |
|
|
Line 393 ENDJS
|
Line 395 ENDJS
|
} |
} |
|
|
sub validate_input { |
sub validate_input { |
my ($codedom,$cats,$maxd,$configref) = @_; |
my ($codedom,$cats,$maxd,$crscatsref) = @_; |
my $currcat = ''; |
my $currcat = ''; |
my $depth = 0; |
my $depth = 0; |
if ($env{'form.catalog_maxdepth'} ne '') { |
if ($env{'form.catalog_maxdepth'} ne '') { |
Line 519 sub validate_input {
|
Line 521 sub validate_input {
|
if (exists($env{'form.currcat_0'})) { |
if (exists($env{'form.currcat_0'})) { |
unless ($env{'form.currcat_0'} =~ /^(instcode|communities|placement)\Q::0\E$/) { |
unless ($env{'form.currcat_0'} =~ /^(instcode|communities|placement)\Q::0\E$/) { |
if ($env{'form.currcat_0'} =~ /^.+\Q::0\E$/) { |
if ($env{'form.currcat_0'} =~ /^.+\Q::0\E$/) { |
if (ref($configref) eq 'HASH') { |
if (ref($crscatsref) eq 'HASH') { |
if (ref($configref->{'cats'}) eq 'HASH') { |
unless (exists($crscatsref->{$env{'form.currcat_0'}})) { |
unless (exists($configref->{'cats'}->{$env{'form.currcat_0'}})) { |
|
delete($env{'form.currcat_0'}); |
|
} |
|
} else { |
|
delete($env{'form.currcat_0'}); |
delete($env{'form.currcat_0'}); |
} |
} |
} else { |
} else { |
Line 625 sub validate_input {
|
Line 623 sub validate_input {
|
foreach my $key (keys(%currcats)) { |
foreach my $key (keys(%currcats)) { |
if ($env{'form.'.$key} eq '') { |
if ($env{'form.'.$key} eq '') { |
delete($env{'form.'.$key}); |
delete($env{'form.'.$key}); |
} elsif (ref($configref) eq 'HASH') { |
} elsif (ref($crscatsref) eq 'HASH') { |
if (ref($configref->{'cats'}) eq 'HASH') { |
unless (exists($crscatsref->{$env{'form.'.$key}})) { |
unless (exists($configref->{'cats'}->{$env{'form.'.$key}})) { |
|
delete($env{'form.'.$key}); |
|
} |
|
} else { |
|
delete($env{'form.'.$key}); |
delete($env{'form.'.$key}); |
} |
} |
} else { |
} else { |
Line 644 sub validate_input {
|
Line 638 sub validate_input {
|
sub get_instcode_allowable { |
sub get_instcode_allowable { |
my ($codedom,$possvalref) = @_; |
my ($codedom,$possvalref) = @_; |
return 1 unless (ref($possvalref) eq 'HASH'); |
return 1 unless (ref($possvalref) eq 'HASH'); |
my $caller = 'global'; |
my $instcats = &Apache::lonnet::get_dom_instcats($codedom); |
my %coursecodes = (); |
if (ref($instcats) eq 'HASH') { |
my %codes = (); |
if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH')) { |
my @codetitles = (); |
my %codes = %{$instcats->{'codes'}}; |
my %cat_titles = (); |
my @codetitles = @{$instcats->{'codetitles'}}; |
my %cat_order = (); |
|
my $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom); |
|
if ($totcodes > 0) { |
|
if (&Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes, |
|
\%codes,\@codetitles,\%cat_titles,\%cat_order) eq 'ok') { |
|
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my %local_to_standard; |
my %local_to_standard; |
for (my $i=0; $i<@codetitles; $i++) { |
for (my $i=0; $i<@codetitles; $i++) { |
Line 673 sub get_instcode_allowable {
|
Line 662 sub get_instcode_allowable {
|
} |
} |
|
|
sub course_details { |
sub course_details { |
my ($r,$codedom,$formname,$domdesc,$trails,$allitems,$codetitles) = @_; |
my ($r,$codedom,$formname,$domdesc,$hostname,$trails,$allitems,$codetitles) = @_; |
my $output; |
my $output; |
my %add_entries = (topmargin => "0", |
my %add_entries = (topmargin => "0", |
marginheight => "0",); |
marginheight => "0",); |
my $js = '<script type="text/javascript">'."\n". |
my $js = '<script type="text/javascript">'."\n". |
&courselink_javascript($r).'</script>'."\n"; |
&courselink_javascript($hostname).'</script>'."\n"; |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Course/Community Catalog',$js, |
&Apache::loncommon::start_page('Course/Community Catalog',$js, |
{'add_entries' => \%add_entries, }); |
{'add_entries' => \%add_entries, }); |
Line 742 END
|
Line 731 END
|
} |
} |
|
|
sub courselink_javascript { |
sub courselink_javascript { |
my ($r) = @_; |
my ($hostname) = @_; |
my $hostname = $r->hostname(); |
|
return <<"END"; |
return <<"END"; |
|
|
function ToSyllabus(cdom,cnum,usehttp) { |
function ToSyllabus(cdom,cnum,usehttp) { |
Line 778 END
|
Line 766 END
|
|
|
sub instcode_course_selector { |
sub instcode_course_selector { |
my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles,$cattype,$canviewall) = @_; |
my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles,$cattype,$canviewall) = @_; |
my %coursecodes = (); |
|
my %codes = (); |
|
my %cat_titles = (); |
my %cat_titles = (); |
my %cat_order = (); |
my %cat_order = (); |
my %cat_items; |
my %cat_items = (); |
my $caller = 'global'; |
|
my $format_reply; |
|
my %add_entries = (topmargin => "0", |
my %add_entries = (topmargin => "0", |
marginheight => "0",); |
marginheight => "0",); |
my ($jscript,$totcodes,$numtitles,$lasttitle) = |
my ($jscript,$totcodes,$numtitles,$lasttitle) = |
Line 1530 sub construct_data_table {
|
Line 1514 sub construct_data_table {
|
foreach my $course (@{$Sortby{$item}}) { |
foreach my $course (@{$Sortby{$item}}) { |
$output.=&Apache::loncommon::start_data_table_row(); |
$output.=&Apache::loncommon::start_data_table_row(); |
$output.=&courseinfo_row($courseinfo{$course},$knownuser,$details, |
$output.=&courseinfo_row($courseinfo{$course},$knownuser,$details, |
\$count,$now,$course,$trails,$allitems,\%numbers,$canviewall); |
\$count,$now,$course,$trails,$allitems, |
|
\%numbers,$canviewall,$hostname); |
$output.=&Apache::loncommon::end_data_table_row(); |
$output.=&Apache::loncommon::end_data_table_row(); |
} |
} |
} |
} |
Line 1852 sub count_students {
|
Line 1837 sub count_students {
|
} |
} |
|
|
sub courseinfo_row { |
sub courseinfo_row { |
my ($info,$knownuser,$details,$countref,$now,$course,$trails,$allitems,$numbers,$canviewall) = @_; |
my ($info,$knownuser,$details,$countref,$now,$course,$trails,$allitems, |
|
$numbers,$canviewall,$hostname) = @_; |
my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items, |
my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items, |
$accessdates,$showsyllabus,$counts,$autoenrollment,$output,$categories, |
$accessdates,$showsyllabus,$counts,$autoenrollment,$output,$categories, |
$extsyllplain); |
$extsyllplain); |
Line 1899 sub courseinfo_row {
|
Line 1885 sub courseinfo_row {
|
if ($showsyllabus) { |
if ($showsyllabus) { |
my $usehttp = 0; |
my $usehttp = 0; |
if (($ENV{'SERVER_PORT'} == 443) && ($extsyllplain)) { |
if (($ENV{'SERVER_PORT'} == 443) && ($extsyllplain)) { |
unless (&Apache::lonnet::uses_sts()) { |
unless ((&Apache::lonnet::uses_sts()) || |
|
(&Apache::lonnet::waf_allssl(hostname))) { |
$usehttp = 1; |
$usehttp = 1; |
} |
} |
} |
} |