version 1.100, 2019/07/21 14:26:02
|
version 1.101, 2019/07/23 01:30:35
|
Line 91 sub handler {
|
Line 91 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 119 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 129 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 251 sub handler {
|
Line 250 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,\@trails,\%allitems,\@codetitles); |
Line 393 ENDJS
|
Line 392 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 518 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 620 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}); |
delete($env{'form.'.$key}); |
|
} |
|
} else { |
} else { |
delete($env{'form.'.$key}); |
delete($env{'form.'.$key}); |
} |
} |