version 1.86, 2015/05/04 15:43:48
|
version 1.88.2.4, 2019/07/19 13:18:27
|
Line 80 sub handler {
|
Line 80 sub handler {
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom); |
&Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom); |
my $knownuser = &user_is_known(); |
my $knownuser = &user_is_known(); |
my $canviewall = &canview_all(); |
my $canviewall = &canview_all($knownuser,$codedom); |
|
|
my ($cathash,$cattype); |
my ($cathash,$cattype); |
if (ref($domconfig{'coursecategories'}) eq 'HASH') { |
if (ref($domconfig{'coursecategories'}) eq 'HASH') { |
Line 207 sub handler {
|
Line 207 sub handler {
|
$r->print('<br />'.&Apache::loncommon::end_page()); |
$r->print('<br />'.&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} else { |
} else { |
if ($env{'form.coursenum'}) { |
if ($env{'form.coursenum'} ne '') { |
$cnum = $env{'form.coursenum'}; |
if ($env{'form.coursenum'} =~ /^$LONCAPA::match_courseid$/) { |
|
$cnum = $env{'form.coursenum'}; |
|
} else { |
|
delete($env{'form.coursenum'}); |
|
} |
} |
} |
} |
} |
|
|
if ($env{'form.catalog_maxdepth'} ne '') { |
my (@cats,@trails,%allitems,%idx,@jsarray,%subcathash,$subcats,%maxd, |
$env{'form.catalog_maxdepth'} =~ s{\D}{}g; |
$toplevelstr,$maxdepthstr); |
} |
|
|
|
my (@cats,@trails,%allitems,%idx,@jsarray,%subcathash,$subcats); |
|
if ($env{'form.withsubcats'}) { |
if ($env{'form.withsubcats'}) { |
$subcats = \%subcathash; |
$subcats = \%subcathash; |
} |
} |
&Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems, |
&Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems, |
\%idx,\@jsarray,$subcats); |
\%idx,\@jsarray,$subcats,\%maxd); |
|
if (ref($cats[0]) eq 'ARRAY') { |
|
foreach my $item (@{$cats[0]}) { |
|
$toplevelstr .= "'".&js_escape($item)."::0',"; |
|
$maxdepthstr .= "'$maxd{$item}',"; |
|
} |
|
$toplevelstr =~ s/,$//; |
|
$maxdepthstr =~ s/,$//; |
|
} |
|
&validate_input(\@cats,\%maxd); |
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 231 sub handler {
|
Line 241 sub handler {
|
my $catjs = <<"ENDSCRIPT"; |
my $catjs = <<"ENDSCRIPT"; |
|
|
function setCatDepth(depth) { |
function setCatDepth(depth) { |
document.coursecats.catalog_maxdepth.value = depth; |
var depth = parseInt(depth); |
if (depth == '') { |
if (depth !== NaN) { |
|
if (depth > 0) { |
|
var possmaxd = 0; |
|
var toplevel = new Array($toplevelstr); |
|
var maxdepths = new Array($maxdepthstr); |
|
if (toplevel.length) { |
|
for (var i=0; i<toplevel.length; i++) { |
|
var item = unescape(toplevel[i]); |
|
if (item == document.coursecats.currcat_0.value) { |
|
possmaxd = maxdepths[i]; |
|
break; |
|
} |
|
} |
|
} |
|
if (depth > possmaxd) { |
|
depth = possmaxd; |
|
} |
|
} |
|
document.coursecats.catalog_maxdepth.value = depth; |
|
} else { |
document.coursecats.currcat_0.value = ''; |
document.coursecats.currcat_0.value = ''; |
|
document.coursecats.catalog_maxdepth.value = ''; |
} |
} |
document.coursecats.submit(); |
document.coursecats.submit(); |
return; |
return; |
Line 295 ENDTOGGJS
|
Line 325 ENDTOGGJS
|
if (!$deeper) { |
if (!$deeper) { |
$alert = &mt('Choose a category to display'); |
$alert = &mt('Choose a category to display'); |
} |
} |
|
&js_escape(\$alert); |
$catjs .= <<ENDJS; |
$catjs .= <<ENDJS; |
function check_selected() { |
function check_selected() { |
if (document.coursecats.$selitem.options[document.coursecats.$selitem.selectedIndex].value == "") { |
if (document.coursecats.$selitem.options[document.coursecats.$selitem.selectedIndex].value == "") { |
Line 339 ENDJS
|
Line 370 ENDJS
|
return OK; |
return OK; |
} |
} |
|
|
|
sub validate_input { |
|
my ($cats,$maxd) = @_; |
|
my $currcat = ''; |
|
my $depth = 0; |
|
if ($env{'form.catalog_maxdepth'} ne '') { |
|
$env{'form.catalog_maxdepth'} =~ s{\D}{}g; |
|
} |
|
if ((ref($cats) eq 'ARRAY') && (ref($maxd) eq 'HASH')) { |
|
if (ref($cats->[0]) eq 'ARRAY') { |
|
if (@{$cats->[0]} == 1) { |
|
if ($cats->[0][0] eq 'instcode') { |
|
$currcat = 'instcode::0'; |
|
} elsif ($cats->[0][0] eq 'communities') { |
|
$currcat = 'communities::0'; |
|
} elsif ($cats->[0][0] eq 'placement') { |
|
$currcat = 'placement::0'; |
|
} else { |
|
my $name = $cats->[0][0]; |
|
$currcat = &escape($name).'::0'; |
|
} |
|
if (exists($maxd->{$cats->[0][0]})) { |
|
if ($env{'form.catalog_maxdepth'} <= $maxd->{$cats->[0][0]}) { |
|
$depth = $env{'form.catalog_maxdepth'}; |
|
} else { |
|
$depth = $maxd->{$cats->[0][0]}; |
|
} |
|
} |
|
} elsif ((@{$cats->[0]} > 1) && ($env{'form.currcat_0'} ne '')) { |
|
my ($escname) = ($env{'form.currcat_0'} =~ /^([^:]+)\:\:0$/); |
|
if ($escname =~ /^instcode|communities|placement$/) { |
|
$currcat = $env{'form.currcat_0'}; |
|
if (exists($maxd->{$escname})) { |
|
if ($env{'form.catalog_maxdepth'} <= $maxd->{$escname}) { |
|
$depth = $env{'form.catalog_maxdepth'}; |
|
} else { |
|
$depth = $maxd->{$escname}; |
|
} |
|
} else { |
|
$depth = 1; |
|
} |
|
} elsif ($escname ne '') { |
|
my $name = &unescape($escname); |
|
if (grep(/^\Q$name\E$/,@{$cats->[0]})) { |
|
$currcat = $env{'form.currcat_0'}; |
|
if (exists($maxd->{$name})) { |
|
if ($env{'form.catalog_maxdepth'} <= $maxd->{$name}) { |
|
$depth = $env{'form.catalog_maxdepth'}; |
|
} else { |
|
$depth = $maxd->{$name}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
$env{'form.currcat_0'} = $currcat; |
|
$env{'form.catalog_maxdepth'} = $depth; |
|
return; |
|
} |
|
|
sub course_details { |
sub course_details { |
my ($r,$codedom,$formname,$domdesc,$trails,$allitems,$codetitles) = @_; |
my ($r,$codedom,$formname,$domdesc,$trails,$allitems,$codetitles) = @_; |
my $output; |
my $output; |
Line 454 sub instcode_course_selector {
|
Line 546 sub instcode_course_selector {
|
'</script>'; |
'</script>'; |
if ($totcodes) { |
if ($totcodes) { |
if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) { |
if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) { |
$add_entries{'onLoad'} = 'setElements();'; |
$add_entries{'onload'} = 'setElements();'; |
} |
} |
if (&user_is_dc($codedom) || $canviewall) { |
if (&user_is_dc($codedom) || $canviewall) { |
$add_entries{'onLoad'} .= ' toggleStatuses();toggleWasActive();' |
$add_entries{'onload'} .= ' toggleStatuses();toggleWasActive();' |
} |
} |
&cat_header($r,$codedom,$js,\%add_entries,$catlinks,$numtitles,$cattype); |
&cat_header($r,$codedom,$js,\%add_entries,$catlinks,$numtitles,$cattype); |
my $cat_maxdepth = $env{'form.catalog_maxdepth'}; |
my $cat_maxdepth = $env{'form.catalog_maxdepth'}; |
Line 741 sub additional_filters {
|
Line 833 sub additional_filters {
|
$showhidden_status = 'checked="checked" '; |
$showhidden_status = 'checked="checked" '; |
} |
} |
my @currstatuses = &Apache::loncommon::get_env_multiple('form.showcounts'); |
my @currstatuses = &Apache::loncommon::get_env_multiple('form.showcounts'); |
my $dc_title = &Apache::lonnet::plaintext('dc'); |
|
my ($details_text,$hidden_text,$statusdisplay,$cellborder); |
my ($details_text,$hidden_text,$statusdisplay,$cellborder); |
my $wasactivedisplay = 'none'; |
my $wasactivedisplay = 'none'; |
if ($env{'form.showdetails'}) { |
if ($env{'form.showdetails'}) { |
Line 755 sub additional_filters {
|
Line 846 sub additional_filters {
|
$cellborder = 'border-left: 0px'; |
$cellborder = 'border-left: 0px'; |
} |
} |
if ($env{'form.currcat_0'} eq 'communities::0') { |
if ($env{'form.currcat_0'} eq 'communities::0') { |
$details_text = &mt('Show full details for each community ([_1] only)',$dc_title); |
$details_text = &mt('Show full details for each community (domain staff only)'); |
$hidden_text = &mt('Include communities set to be hidden from catalog ([_1] only)',$dc_title); |
$hidden_text = &mt('Include communities set to be hidden from catalog (domain staff only)'); |
} else { |
} else { |
$details_text = &mt('Show full details for each course ([_1] only)',$dc_title); |
$details_text = &mt('Show full details for each course (domain staff only)'); |
$hidden_text = &mt('Include courses set to be hidden from catalog ([_1] only)',$dc_title); |
$hidden_text = &mt('Include courses set to be hidden from catalog (domain staff only)'); |
} |
} |
if ($is_dc) { |
if ($is_dc) { |
$output .= '<span class="LC_nobreak">'. |
$output .= '<span class="LC_nobreak">'. |
Line 874 sub user_is_dc {
|
Line 965 sub user_is_dc {
|
} |
} |
|
|
sub canview_all { |
sub canview_all { |
|
my ($knownuser,$codedom) = @_; |
my $canviewall = 0; |
my $canviewall = 0; |
my $page = 'coursecatalog'; |
my $page = 'coursecatalog'; |
if (&LONCAPA::lonauthcgi::can_view($page)) { |
if (&LONCAPA::lonauthcgi::can_view($page)) { |
$canviewall = 1; |
$canviewall = 1; |
} elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) { |
} elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) { |
$canviewall= 1; |
$canviewall= 1; |
|
} elsif (($knownuser) && ($codedom ne '')) { |
|
if (&Apache::lonnet::allowed('dcd',$codedom)) { |
|
$canviewall = 1; |
|
} |
} |
} |
return $canviewall; |
return $canviewall; |
} |
} |
Line 1602 sub identify_sections {
|
Line 1698 sub identify_sections {
|
sub get_valid_classes { |
sub get_valid_classes { |
my ($seclist,$xlist_items,$crscode,$owners,$cdom,$cnum) = @_; |
my ($seclist,$xlist_items,$crscode,$owners,$cdom,$cnum) = @_; |
my $response; |
my $response; |
my %validations; |
my (@sections,@xlists,%possclasses,%okclasses,%validations); |
@{$validations{'sections'}} = (); |
@{$validations{'sections'}} = (); |
@{$validations{'xlists'}} = (); |
@{$validations{'xlists'}} = (); |
my $totalitems = 0; |
my $totalitems = 0; |
if ($seclist) { |
if ($seclist) { |
foreach my $sec (split(/, /,$seclist)) { |
@sections = split(/,\s+/,$seclist); |
my $class = $crscode.$sec; |
map { $possclasses{$crscode.$_} = 1; } @sections; |
if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owners, |
} |
$class) eq 'ok') { |
if ($xlist_items) { |
|
@xlists = split(/,\s+/,$xlist_items); |
|
map { $possclasses{$_} = 1; } @xlists; |
|
} |
|
my %okclasses = &Apache::lonnet::auto_validate_instclasses($cdom,$cnum,$owners, |
|
\%possclasses); |
|
if (keys(%okclasses)) { |
|
foreach my $sec (@sections) { |
|
if ($okclasses{$crscode.$sec}) { |
if (!grep(/^\Q$sec$\E/,@{$validations{'sections'}})) { |
if (!grep(/^\Q$sec$\E/,@{$validations{'sections'}})) { |
push(@{$validations{'sections'}},$sec); |
push(@{$validations{'sections'}},$sec); |
$totalitems ++; |
$totalitems ++; |
} |
} |
} |
} |
} |
} |
} |
foreach my $item (@xlists) { |
if ($xlist_items) { |
if ($okclasses{$item}) { |
foreach my $item (split(/, /,$xlist_items)) { |
if (!grep(/^\Q$item\E$/,@{$validations{'xlists'}})) { |
if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owners, |
|
$item) eq 'ok') { |
|
if (!grep(/^\Q$item$\E/,@{$validations{'xlists'}})) { |
|
push(@{$validations{'xlists'}},$item); |
push(@{$validations{'xlists'}},$item); |
$totalitems ++; |
$totalitems ++; |
} |
} |