version 1.102, 2022/02/15 04:28:01
|
version 1.110, 2022/04/05 18:15:30
|
Line 224 use Apache::lonparmset;
|
Line 224 use Apache::lonparmset;
|
use Apache::courseclassifier; |
use Apache::courseclassifier; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
use Crypt::CBC; |
|
|
my $registered_cleanup; |
my $registered_cleanup; |
my $modified_courses; |
my $modified_courses; |
Line 600 sub handler {
|
Line 601 sub handler {
|
); |
); |
if (($phase eq 'process') && ($parm_permission->{'process'})) { |
if (($phase eq 'process') && ($parm_permission->{'process'})) { |
my @allitems = &get_allitems(%prefs); |
my @allitems = &get_allitems(%prefs); |
&Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, |
my $result = &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, |
\@prefs_order,\%prefs,\%values, |
\@prefs_order,\%prefs,\%values, |
$cnum,undef,\@allitems, |
$cnum,undef,\@allitems, |
'coursepref',$parm_permission); |
'coursepref',$parm_permission); |
|
if ((ref($result) eq 'HASH') && (keys(%{$result}))) { |
|
$r->rflush(); |
|
&devalidate_remote_courseprefs($cdom,$cnum,$result); |
|
} |
} elsif (($phase eq 'display') && ($parm_permission->{'display'})) { |
} elsif (($phase eq 'display') && ($parm_permission->{'display'})) { |
my $noedit; |
my $noedit; |
if (ref($parm_permission) eq 'HASH') { |
if (ref($parm_permission) eq 'HASH') { |
Line 811 sub print_config_box {
|
Line 816 sub print_config_box {
|
} |
} |
|
|
sub process_changes { |
sub process_changes { |
my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_; |
my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype,$lastactref) = @_; |
my (%newvalues,$errors); |
my (%newvalues,$errors); |
if (ref($item) eq 'HASH') { |
if (ref($item) eq 'HASH') { |
if (ref($changes) eq 'HASH') { |
if (ref($changes) eq 'HASH') { |
Line 980 sub process_changes {
|
Line 985 sub process_changes {
|
} |
} |
} elsif ($action eq 'linkprot') { |
} elsif ($action eq 'linkprot') { |
if (ref($values) eq 'HASH') { |
if (ref($values) eq 'HASH') { |
$errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course'); |
$errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course',$lastactref); |
} |
} |
} else { |
} else { |
foreach my $entry (@ordered) { |
foreach my $entry (@ordered) { |
Line 1476 sub process_changes {
|
Line 1481 sub process_changes {
|
} |
} |
|
|
sub process_linkprot { |
sub process_linkprot { |
my ($cdom,$cnum,$values,$changes,$context) = @_; |
my ($cdom,$cnum,$values,$changes,$context,$lastactref) = @_; |
my ($dest,$ltiauth,$errors,%linkprot); |
my ($home,$dest,$ltiauth,$privkey,$privnum,$cipher,$errors,%linkprot); |
if (ref($values) eq 'HASH') { |
if (ref($values) eq 'HASH') { |
foreach my $id (keys(%{$values})) { |
foreach my $id (keys(%{$values})) { |
if ($id =~ /^\d+$/) { |
if ($id =~ /^\d+$/) { |
Line 1487 sub process_linkprot {
|
Line 1492 sub process_linkprot {
|
} |
} |
} |
} |
} |
} |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
if ($context eq 'domain') { |
|
$home = &Apache::lonnet::domain($cdom,'primary'); |
|
} else { |
|
$home = &Apache::lonnet::homeserver($cnum,$cdom); |
|
} |
|
if ((($context eq 'domain') && ($domdefs{'linkprotenc_dom'})) || |
|
(($context eq 'course') && ($domdefs{'linkprotenc_crs'}))) { |
|
unless (($home eq 'no_host') || ($home eq '')) { |
|
if (grep(/^\Q$home\E$/,@ids)) { |
|
if (ref($domdefs{'privhosts'}) eq 'ARRAY') { |
|
if (grep(/^\Q$home\E$/,@{$domdefs{'privhosts'}})) { |
|
my %privhash = &Apache::lonnet::restore_dom('lti','private',$cdom,$home,1); |
|
$privkey = $privhash{'key'}; |
|
$privnum = $privhash{'version'}; |
|
if (($privnum) && ($privkey ne '')) { |
|
$cipher = Crypt::CBC->new({'key' => $privkey, |
|
'cipher' => 'DES'}); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
if ($context eq 'domain') { |
if ($context eq 'domain') { |
$dest = '/adm/domainprefs'; |
$dest = '/adm/domainprefs'; |
$ltiauth = 1; |
$ltiauth = 1; |
Line 1567 sub process_linkprot {
|
Line 1597 sub process_linkprot {
|
my $reqitem = 'form.linkprot_requser_'.$idx; |
my $reqitem = 'form.linkprot_requser_'.$idx; |
$env{$reqitem} =~ s/(`)/'/g; |
$env{$reqitem} =~ s/(`)/'/g; |
unless ($idx eq 'add') { |
unless ($idx eq 'add') { |
if ($current{'requser'} ne $env{$reqitem}) { |
if ((!$current{'requser'} && $env{$reqitem}) || |
|
($current{'requser'} && !$env{$reqitem})) { |
$haschanges{$itemid} = 1; |
$haschanges{$itemid} = 1; |
} |
} |
} |
} |
Line 1619 sub process_linkprot {
|
Line 1650 sub process_linkprot {
|
if ($current{'usable'}) { |
if ($current{'usable'}) { |
if ($env{'form.linkprot_changesecret_'.$idx}) { |
if ($env{'form.linkprot_changesecret_'.$idx}) { |
if ($env{$secretitem} ne '') { |
if ($env{$secretitem} ne '') { |
$linkprot{$itemid}{'secret'} = $env{$secretitem}; |
if ($privnum && $cipher) { |
|
$linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem}); |
|
$linkprot{$itemid}{'cipher'} = $privnum; |
|
} else { |
|
$linkprot{$itemid}{'secret'} = $env{$secretitem}; |
|
} |
$haschanges{$itemid} = 1; |
$haschanges{$itemid} = 1; |
} |
} |
} else { |
} else { |
$linkprot{$itemid}{'secret'} = $current{'secret'}; |
$linkprot{$itemid}{'secret'} = $current{'secret'}; |
} |
} |
} elsif ($env{$secretitem} ne '') { |
} elsif ($env{$secretitem} ne '') { |
$linkprot{$itemid}{'secret'} = $env{$secretitem}; |
if ($privnum && $cipher) { |
|
$linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem}); |
|
$linkprot{$itemid}{'cipher'} = $privnum; |
|
} else { |
|
$linkprot{$itemid}{'secret'} = $env{$secretitem}; |
|
} |
$haschanges{$itemid} = 1; |
$haschanges{$itemid} = 1; |
} |
} |
} |
} |
Line 1635 sub process_linkprot {
|
Line 1676 sub process_linkprot {
|
foreach my $entry (keys(%haschanges)) { |
foreach my $entry (keys(%haschanges)) { |
$changes->{$entry} = $linkprot{$entry}; |
$changes->{$entry} = $linkprot{$entry}; |
} |
} |
|
if (ref($lastactref) eq 'HASH') { |
|
$lastactref->{'courselti'} = 1; |
|
} |
} |
} |
return $errors; |
return $errors; |
} |
} |
Line 2141 sub store_changes {
|
Line 2185 sub store_changes {
|
|
|
sub store_linkprot { |
sub store_linkprot { |
my ($cdom,$cnum,$context,$changes,$oldlinkprot) = @_; |
my ($cdom,$cnum,$context,$changes,$oldlinkprot) = @_; |
my ($ltiauth,$lti_save_error,$output,$error,%ltienc,@deletions); |
my ($ltiauth,$home,$lti_save_error,$output,$error,%ltienc,@deletions); |
if ($context eq 'domain') { |
if ($context eq 'domain') { |
$ltiauth = 1; |
$ltiauth = 1; |
|
$home = &Apache::lonnet::domain($cdom,'primary'); |
} else { |
} else { |
|
$home = &Apache::lonnet::homeserver($cnum,$cdom); |
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
} else { |
} else { |
Line 2166 sub store_linkprot {
|
Line 2212 sub store_linkprot {
|
if (exists($oldlinkprot->{$id}{'usable'})) { |
if (exists($oldlinkprot->{$id}{'usable'})) { |
$changes->{$id}->{'usable'} = 1; |
$changes->{$id}->{'usable'} = 1; |
} |
} |
|
if (exists($oldlinkprot->{$id}{'cipher'})) { |
|
$changes->{$id}->{'cipher'} = $oldlinkprot->{$id}{'cipher'}; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
my @ids=&Apache::lonnet::current_machine_ids(); |
if (keys(%ltienc) > 0) { |
if (keys(%ltienc) > 0) { |
if ($context eq 'domain') { |
if ($context eq 'domain') { |
Line 2180 sub store_linkprot {
|
Line 2228 sub store_linkprot {
|
} |
} |
} |
} |
} else { |
} else { |
unless (($chome eq 'no_host') || ($chome eq '')) { |
unless (($home eq 'no_host') || ($home eq '')) { |
my $allowed; |
my $allowed; |
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
if ($allowed) { |
if ($allowed) { |
Line 2202 sub store_linkprot {
|
Line 2250 sub store_linkprot {
|
if (&Apache::lonnet::put('lti',$changes,$cdom,$cnum,1) eq 'ok') { |
if (&Apache::lonnet::put('lti',$changes,$cdom,$cnum,1) eq 'ok') { |
my $hashid=$cdom.'_'.$cnum; |
my $hashid=$cdom.'_'.$cnum; |
&Apache::lonnet::devalidate_cache_new('courselti',$hashid); |
&Apache::lonnet::devalidate_cache_new('courselti',$hashid); |
unless (($chome eq 'no_host') || ($chome eq '')) { |
unless (($home eq 'no_host') || ($home eq '')) { |
if (grep(/^\Q$chome\E$/,@ids)) { |
if (grep(/^\Q$home\E$/,@ids)) { |
&Apache::lonnet::devalidate_cache_new('courseltienc',$hashid); |
&Apache::lonnet::devalidate_cache_new('courseltienc',$hashid); |
} |
} |
} |
} |
Line 2223 sub store_linkprot {
|
Line 2271 sub store_linkprot {
|
if (exists($ltienc{$id}{$title})) { |
if (exists($ltienc{$id}{$title})) { |
if ($title eq 'secret') { |
if ($title eq 'secret') { |
my $length = length($ltienc{$id}{$title}); |
my $length = length($ltienc{$id}{$title}); |
$display .= $desc{$title}.': '.('*' x $length).', '; |
$display .= $desc{$title}.': ['.&mt('not shown').'], '; |
} else { |
} else { |
$display .= $desc{$title}.': '.$ltienc{$id}{$title}.', '; |
$display .= $desc{$title}.': '.$ltienc{$id}{$title}.', '; |
} |
} |
Line 2777 function toggleLinkProtReqUser(form,item
|
Line 2825 function toggleLinkProtReqUser(form,item
|
} |
} |
return; |
return; |
} |
} |
|
|
|
function uncheckLinkProtMakeVis(item,num) { |
|
if (document.getElementById('linkprot_'+item+'_'+num)) { |
|
var currtype = document.getElementById('linkprot_'+item+'_'+num).type; |
|
if (currtype.toLowerCase() == 'checkbox') { |
|
document.getElementById('linkprot_'+item+'_'+num).checked = false; |
|
} |
|
} |
|
return; |
|
} |
ENDSCRIPT |
ENDSCRIPT |
|
|
} |
} |
Line 5585 sub menucollections_display {
|
Line 5643 sub menucollections_display {
|
|
|
sub print_linkprotection { |
sub print_linkprotection { |
my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_; |
my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_; |
unless (ref($settings) eq 'HASH') { |
|
return; |
|
} |
|
|
|
my %linkprotection; |
my %linkprotection; |
my $count = 0; |
my $count = 0; |
Line 5632 sub print_linkprotection {
|
Line 5687 sub print_linkprotection {
|
} |
} |
} |
} |
|
|
if (ref($settings->{'linkprot'}) eq 'HASH') { |
if ((ref($settings) eq 'HASH') && (ref($settings->{'linkprot'}) eq 'HASH')) { |
if (keys(%{$settings->{'linkprot'}})) { |
if (keys(%{$settings->{'linkprot'}})) { |
my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}}); |
my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}}); |
$next += $current[-1]; |
$next += $current[-1]; |
Line 5729 sub print_linkprotection {
|
Line 5784 sub print_linkprotection {
|
'</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'. |
'</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'. |
'<span class="LC_nobreak">'.&mt('New Secret').':'. |
'<span class="LC_nobreak">'.&mt('New Secret').':'. |
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'. |
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'. |
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'. |
'<label><input type="checkbox" name="linkprot_visible_'.$i.'" id="linkprot_visible_'.$i.'" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'. |
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>'; |
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>'; |
} else { |
} else { |
$datatable .= |
$datatable .= |
'<span class="LC_nobreak">'.$desc{'secret'}.':'. |
'<span class="LC_nobreak">'.$desc{'secret'}.':'. |
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'. |
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'. |
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'. |
'<label><input type="checkbox" name="linkprot_visible_'.$i.'" id="linkprot_visible_'.$i.'" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'. |
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>'; |
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>'; |
} |
} |
} |
} |
Line 5755 sub print_linkprotection {
|
Line 5810 sub print_linkprotection {
|
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
'<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n". |
'<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n". |
'<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n". |
'<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n". |
'<td>'; |
'<td width="100%">'; |
my ($usersty,$onclickrequser,%checkedrequser); |
my ($usersty,$onclickrequser,%checkedrequser); |
if ($ltiauth) { |
if ($ltiauth) { |
$usersty = 'display:none'; |
$usersty = 'display:none'; |
Line 5787 sub print_linkprotection {
|
Line 5842 sub print_linkprotection {
|
$datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':<input type="text" size="25" name="linkprot_key_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n". |
$datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':<input type="text" size="25" name="linkprot_key_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n". |
(' 'x2). |
(' 'x2). |
'<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="off"'.$disabled.' />'. |
'<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="off"'.$disabled.' />'. |
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_add.type='."'text'".' } else { this.form.linkprot_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n"; |
'<label><input type="checkbox" name="linkprot_visible_add" id="linkprot_visible_add" onclick="if (this.checked) { this.form.linkprot_secret_add.type='."'text'".' } else { this.form.linkprot_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n"; |
} |
} |
if ($ltiauth) { |
if ($ltiauth) { |
$datatable .= '</fieldset>'. |
$datatable .= '</fieldset>'. |
Line 6505 sub change_clone {
|
Line 6560 sub change_clone {
|
} |
} |
} |
} |
} |
} |
|
return; |
|
} |
|
|
|
sub devalidate_remote_courseprefs { |
|
my ($cdom,$cnum,$cachekeys) = @_; |
|
return unless (ref($cachekeys) eq 'HASH'); |
|
my %servers = &Apache::lonnet::internet_dom_servers($cdom); |
|
my %thismachine; |
|
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); |
|
my @posscached = ('courselti'); |
|
if (keys(%servers)) { |
|
foreach my $server (keys(%servers)) { |
|
next if ($thismachine{$server}); |
|
my @cached; |
|
foreach my $name (@posscached) { |
|
if ($cachekeys->{$name}) { |
|
push(@cached,&escape($name).':'.&escape($cdom.'_'.$cnum)); |
|
} |
|
} |
|
if (@cached) { |
|
&Apache::lonnet::remote_devalidate_cache($server,\@cached); |
|
} |
|
} |
|
} |
return; |
return; |
} |
} |
|
|