version 1.160.6.118.2.17, 2024/01/02 02:46:18
|
version 1.160.6.118.2.18, 2024/02/25 05:54:21
|
Line 595 sub handler {
|
Line 595 sub handler {
|
col2 => 'Settings'}, |
col2 => 'Settings'}, |
{col1 => 'Rules for shared secrets', |
{col1 => 'Rules for shared secrets', |
col2 => 'Settings'}, |
col2 => 'Settings'}, |
|
{col1 => 'Link Protectors in Courses', |
|
col2 => 'Values'}, |
{col1 => 'Link Protectors', |
{col1 => 'Link Protectors', |
col2 => 'Settings'}, |
col2 => 'Settings'}, |
{col1 => 'Consumers', |
{col1 => 'Consumers', |
Line 936 sub print_config_box {
|
Line 938 sub print_config_box {
|
$colspan = ' colspan="2"'; |
$colspan = ' colspan="2"'; |
} elsif ($action eq 'passwords') { |
} elsif ($action eq 'passwords') { |
$output .= $item->{'print'}->('middle',$dom,$confname,$settings,\$rowtotal); |
$output .= $item->{'print'}->('middle',$dom,$confname,$settings,\$rowtotal); |
|
} elsif ($action eq 'lti') { |
|
$output .= $item->{'print'}->('upper',$dom,$settings,\$rowtotal).' |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td> |
|
<table class="LC_nested"> |
|
<tr class="LC_info_row"> |
|
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td> |
|
<td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> |
|
</tr>'."\n". |
|
$item->{'print'}->('middle',$dom,$settings,\$rowtotal); |
} else { |
} else { |
$output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal); |
$output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal); |
} |
} |
|
my $hdridx = 2; |
|
if ($action eq 'lti') { |
|
$hdridx = 3; |
|
} |
$output .= ' |
$output .= ' |
</table> |
</table> |
</td> |
</td> |
Line 947 sub print_config_box {
|
Line 966 sub print_config_box {
|
<td> |
<td> |
<table class="LC_nested"> |
<table class="LC_nested"> |
<tr class="LC_info_row"> |
<tr class="LC_info_row"> |
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td> |
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[$hdridx]->{'col1'}).'</td> |
<td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> |
<td class="LC_right_item">'.&mt($item->{'header'}->[$hdridx]->{'col2'}).'</td> |
</tr>'."\n"; |
</tr>'."\n"; |
if ($action eq 'coursecategories') { |
if ($action eq 'coursecategories') { |
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); |
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); |
Line 958 sub print_config_box {
|
Line 977 sub print_config_box {
|
} else { |
} else { |
$output .= $item->{'print'}->('lower',$dom,$settings,\$rowtotal); |
$output .= $item->{'print'}->('lower',$dom,$settings,\$rowtotal); |
} |
} |
|
$hdridx ++; |
$output .= ' |
$output .= ' |
</tr> |
</tr> |
</table> |
</table> |
Line 967 sub print_config_box {
|
Line 987 sub print_config_box {
|
<td> |
<td> |
<table class="LC_nested"> |
<table class="LC_nested"> |
<tr class="LC_info_row"> |
<tr class="LC_info_row"> |
<td class="LC_left_item'.$leftnobr.'"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col1'}).'</td> |
<td class="LC_left_item'.$leftnobr.'"'.$colspan.'>'.&mt($item->{'header'}->[$hdridx]->{'col1'}).'</td> |
<td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col2'}).'</td></tr>'."\n"; |
<td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[$hdridx]->{'col2'}).'</td></tr>'."\n"; |
if ($action eq 'passwords') { |
if ($action eq 'passwords') { |
$output .= $item->{'print'}->('bottom',$dom,$confname,$settings,\$rowtotal); |
$output .= $item->{'print'}->('bottom',$dom,$confname,$settings,\$rowtotal); |
} else { |
} else { |
Line 5273 sub print_lti {
|
Line 5293 sub print_lti {
|
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($position,$dom,$settings,$rowtotal) = @_; |
my $itemcount = 1; |
my $itemcount = 1; |
my ($datatable,$css_class); |
my ($datatable,$css_class); |
my (%rules,%encrypt,%privkeys,%linkprot); |
my (%rules,%encrypt,%privkeys,%linkprot,%suggestions); |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if ($position eq 'top') { |
if ($position eq 'top') { |
if (exists($settings->{'encrypt'})) { |
if (exists($settings->{'encrypt'})) { |
Line 5296 sub print_lti {
|
Line 5316 sub print_lti {
|
} |
} |
} |
} |
} |
} |
} elsif ($position eq 'middle') { |
} elsif ($position eq 'upper') { |
if (exists($settings->{'rules'})) { |
if (exists($settings->{'rules'})) { |
if (ref($settings->{'rules'}) eq 'HASH') { |
if (ref($settings->{'rules'}) eq 'HASH') { |
%rules = %{$settings->{'rules'}}; |
%rules = %{$settings->{'rules'}}; |
} |
} |
} |
} |
|
} elsif ($position eq 'middle') { |
|
if (exists($settings->{'suggested'})) { |
|
if (ref($settings->{'suggested'}) eq 'HASH') { |
|
%suggestions = %{$settings->{'suggested'}}; |
|
} |
|
} |
} elsif ($position eq 'lower') { |
} elsif ($position eq 'lower') { |
if (exists($settings->{'linkprot'})) { |
if (exists($settings->{'linkprot'})) { |
if (ref($settings->{'linkprot'}) eq 'HASH') { |
if (ref($settings->{'linkprot'}) eq 'HASH') { |
Line 5312 sub print_lti {
|
Line 5338 sub print_lti {
|
} |
} |
} |
} |
} else { |
} else { |
foreach my $key ('encrypt','private','rules','linkprot') { |
foreach my $key ('encrypt','private','rules','linkprot','suggestions') { |
if (exists($settings->{$key})) { |
if (exists($settings->{$key})) { |
delete($settings->{$key}); |
delete($settings->{$key}); |
} |
} |
Line 5321 sub print_lti {
|
Line 5347 sub print_lti {
|
} |
} |
if ($position eq 'top') { |
if ($position eq 'top') { |
$datatable = &secrets_form($dom,'ltisec',\%encrypt,\%privkeys,$rowtotal); |
$datatable = &secrets_form($dom,'ltisec',\%encrypt,\%privkeys,$rowtotal); |
} elsif ($position eq 'middle') { |
} elsif ($position eq 'upper') { |
$datatable = &password_rules('ltisecrets',\$itemcount,\%rules); |
$datatable = &password_rules('ltisecrets',\$itemcount,\%rules); |
$$rowtotal += $itemcount; |
$$rowtotal += $itemcount; |
|
} elsif ($position eq 'middle') { |
|
$datatable = &linkprot_suggestions(\%suggestions,\$itemcount); |
|
$$rowtotal += $itemcount; |
} elsif ($position eq 'lower') { |
} elsif ($position eq 'lower') { |
$datatable .= &Apache::courseprefs::print_linkprotection($dom,'',$settings,$rowtotal,'','','domain'); |
$datatable .= &Apache::courseprefs::print_linkprotection($dom,'',$settings,$rowtotal,'','','domain'); |
} else { |
} else { |
my ($switchserver,$switchmessage); |
my ($switchserver,$switchmessage); |
$switchserver = &check_switchserver($dom); |
$switchserver = &check_switchserver($dom); |
Line 5911 sub ltimenu_titles {
|
Line 5940 sub ltimenu_titles {
|
); |
); |
} |
} |
|
|
|
sub linkprot_suggestions { |
|
my ($suggested,$itemcount) = @_; |
|
my $count = 0; |
|
my $next = 1; |
|
my %lt = &Apache::lonlocal::texthash( |
|
'name' => 'Suggested Launcher', |
|
'info' => 'Recommendations', |
|
); |
|
my ($datatable,$css_class,$dest); |
|
if (ref($suggested) eq 'HASH') { |
|
my @current = sort { $a <=> $b } keys(%{$suggested}); |
|
$next += $current[-1]; |
|
for (my $i=0; $i<@current; $i++) { |
|
my $num = $current[$i]; |
|
my %values; |
|
if (ref($suggested->{$num}) eq 'HASH') { |
|
%values = %{$suggested->{$num}}; |
|
} else { |
|
next; |
|
} |
|
$css_class = $$itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= |
|
'<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
|
'<label><input type="checkbox" name="linkprot_suggested_del" value="'.$i.'" />'."\n". |
|
&mt('Delete?').'</label></span></td><td>'."\n". |
|
'<div class="LC_floatleft"><fieldset><legend>'.$lt{'name'}.'</legend>'."\n". |
|
'<input type="text" size="15" name="linkprot_suggested_name_'.$i.'" value="'.$values{'name'}.'" autocomplete="off" />'."\n". |
|
'</fieldset></div>'. |
|
'<div class="LC_floatleft"><fieldset><legend>'.$lt{'info'}.'</legend>'."\n". |
|
'<textarea cols="55" rows="5" name="linkprot_suggested_info_'.$i.'">'.$values{'info'}.'</textarea>'. |
|
'</fieldset></div>'. |
|
'<div style="padding:0;clear:both;margin:0;border:0"></div>'."\n". |
|
'<input type="hidden" name="linkprot_suggested_id_'.$i.'" value="'.$num.'" /></td></tr>'."\n"; |
|
$$itemcount ++; |
|
} |
|
} |
|
$css_class = $$itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
|
'<input type="hidden" name="linkprot_suggested_maxnum" value="'.$next.'" />'."\n". |
|
'<input type="checkbox" name="linkprot_suggested_add" value="1" />'.&mt('Add').'</span></td>'."\n". |
|
'<td>'."\n". |
|
'<div class="LC_floatleft"><fieldset><legend>'.$lt{'name'}.'</legend>'."\n". |
|
'<input type="text" size="15" name="linkprot_suggested_name_add" value="" autocomplete="off" />'."\n". |
|
'</fieldset></div>'. |
|
'<div class="LC_floatleft"><fieldset><legend>'.$lt{'info'}.'</legend>'."\n". |
|
'<textarea cols="55" rows="5" name="linkprot_suggested_info_add"></textarea>'. |
|
'</fieldset></div>'. |
|
'<div style="padding:0;clear:both;margin:0;border:0"></div>'."\n". |
|
'</td></tr>'."\n"; |
|
return $datatable; |
|
} |
|
|
sub print_coursedefaults { |
sub print_coursedefaults { |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($position,$dom,$settings,$rowtotal) = @_; |
Line 13173 sub lti_security_results {
|
Line 13252 sub lti_security_results {
|
off => &mt('Encryption of stored external tool secrets defined in domain disabled'), |
off => &mt('Encryption of stored external tool secrets defined in domain disabled'), |
}, |
}, |
); |
); |
|
|
} |
} |
my @types= ('crs','dom'); |
my @types= ('crs','dom'); |
if ($context eq 'lti') { |
if ($context eq 'lti') { |
Line 13269 sub lti_security_results {
|
Line 13347 sub lti_security_results {
|
} |
} |
} elsif ($item eq 'linkprot') { |
} elsif ($item eq 'linkprot') { |
next; |
next; |
|
} elsif ($item eq 'suggested') { |
|
if ((ref($secchanges->{'suggested'}) eq 'HASH') && |
|
(ref($newsec->{'suggested'}) eq 'HASH')) { |
|
my $suggestions; |
|
foreach my $id (sort { $a <=> $b } keys(%{$secchanges->{'suggested'}})) { |
|
if (ref($newsec->{'suggested'}->{$id}) eq 'HASH') { |
|
my $name = $newsec->{'suggested'}->{$id}->{'name'}; |
|
my $info = $newsec->{'suggested'}->{$id}->{'info'}; |
|
$suggestions .= '<li>'.&mt('Launcher: [_1]',$name).'<br />'. |
|
&mt('Recommend: [_1]','<pre>'.$info.'</pre>'). |
|
'</li>'; |
|
} else { |
|
$suggestions .= '<li>'.&mt('Recommendations deleted for Launcher: [_1]', |
|
$newsec->{'suggested'}->{$id}).'</li>'; |
|
} |
|
} |
|
if ($suggestions) { |
|
$output .= '<li>'.&mt('Hints in Courses for Link Protector Configuration'). |
|
'<ul>'.$suggestions.'</ul>'. |
|
'</li>'; |
|
} |
|
} |
} |
} |
} |
} |
if ($needs_update) { |
if ($needs_update) { |
Line 13340 sub modify_lti {
|
Line 13440 sub modify_lti {
|
} |
} |
} |
} |
if (ref($currltisec{'linkprot'}) eq 'HASH') { |
if (ref($currltisec{'linkprot'}) eq 'HASH') { |
foreach my $id (%{$currltisec{'linkprot'}}) { |
foreach my $id (keys(%{$currltisec{'linkprot'}})) { |
next if ($id !~ /^\d+$/); |
next if ($id !~ /^\d+$/); |
unless (exists($linkprotchg{$id})) { |
unless (exists($linkprotchg{$id})) { |
if (ref($currltisec{'linkprot'}{$id}) eq 'HASH') { |
if (ref($currltisec{'linkprot'}{$id}) eq 'HASH') { |
Line 13362 sub modify_lti {
|
Line 13462 sub modify_lti {
|
if ($proterror) { |
if ($proterror) { |
$errors .= '<li>'.$proterror.'</li>'; |
$errors .= '<li>'.$proterror.'</li>'; |
} |
} |
|
|
|
my (%delsuggested,%suggids,@suggested);; |
|
if (ref($currltisec{'suggested'}) eq 'HASH') { |
|
my $maxnum = $env{'form.linkprot_suggested_maxnum'}; |
|
my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_suggested_del'); |
|
for (my $i=0; $i<$maxnum; $i++) { |
|
my $itemid = $env{'form.linkprot_suggested_id_'.$i}; |
|
$itemid =~ s/\D+//g; |
|
if ($itemid) { |
|
if (ref($currltisec{'suggested'}->{$itemid}) eq 'HASH') { |
|
push(@suggested,$i); |
|
$suggids{$i} = $itemid; |
|
if ((@todelete > 0) && (grep(/^$i$/,@todelete))) { |
|
if (ref($currltisec{'suggested'}{$itemid}) eq 'HASH') { |
|
$delsuggested{$itemid} = $currltisec{'suggested'}{$itemid}{'name'}; |
|
} |
|
} else { |
|
if ($env{'form.linkprot_suggested_name_'.$i} eq '') { |
|
$delsuggested{$itemid} = $currltisec{'suggested'}{$itemid}{'name'}; |
|
} else { |
|
$env{'form.linkprot_suggested_name_'.$i} =~ s/(`)/'/g; |
|
$env{'form.linkprot_suggested_info_'.$i} =~ s/(`)/'/g; |
|
$newltisec{'suggested'}{$itemid}{'name'} = $env{'form.linkprot_suggested_name_'.$i}; |
|
$newltisec{'suggested'}{$itemid}{'info'} = $env{'form.linkprot_suggested_info_'.$i}; |
|
if (($currltisec{'suggested'}{$itemid}{'name'} ne $newltisec{'suggested'}{$itemid}{'name'}) || |
|
($currltisec{'suggested'}{$itemid}{'info'} ne $newltisec{'suggested'}{$itemid}{'info'})) { |
|
$secchanges{'suggested'}{$itemid} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
foreach my $key (keys(%delsuggested)) { |
|
$newltisec{'suggested'}{$key} = $delsuggested{$key}; |
|
$secchanges{'suggested'}{$key} = 1; |
|
} |
|
if (($env{'form.linkprot_suggested_add'}) && |
|
($env{'form.linkprot_suggested_name_add'} ne '')) { |
|
$env{'form.linkprot_suggested_name_add'} =~ s/(`)/'/g; |
|
$env{'form.linkprot_suggested_info_add'} =~ s/(`)/'/g; |
|
my ($newsuggid,$errormsg) = &get_lti_id($dom,$env{'form.linkprot_suggested_name_add'},'suggested'); |
|
if ($newsuggid) { |
|
$newltisec{'suggested'}{$newsuggid}{'name'} = $env{'form.linkprot_suggested_name_add'}; |
|
$newltisec{'suggested'}{$newsuggid}{'info'} = $env{'form.linkprot_suggested_info_add'}; |
|
$secchanges{'suggested'}{$newsuggid} = 1; |
|
} else { |
|
my $error = &mt('Failed to acquire unique ID for new Link Protectors in Courses Suggestion'); |
|
if ($errormsg) { |
|
$error .= ' ('.$errormsg.')'; |
|
} |
|
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
|
} |
|
} |
my (@items,%deletions,%itemids); |
my (@items,%deletions,%itemids); |
if ($env{'form.lti_add'}) { |
if ($env{'form.lti_add'}) { |
my $consumer = $env{'form.lti_consumer_add'}; |
my $consumer = $env{'form.lti_consumer_add'}; |
$consumer =~ s/(`)/'/g; |
$consumer =~ s/(`)/'/g; |
($newid,my $error) = &get_lti_id($dom,$consumer); |
($newid,my $errormsg) = &get_lti_id($dom,$consumea,'lt'r); |
if ($newid) { |
if ($newid) { |
$itemids{'add'} = $newid; |
$itemids{'add'} = $newid; |
push(@items,'add'); |
push(@items,'add'); |
$changes{$newid} = 1; |
$changes{$newid} = 1; |
} else { |
} else { |
my $error = &mt('Failed to acquire unique ID for new LTI configuration'); |
my $error = &mt('Failed to acquire unique ID for new LTI configuration'); |
|
if ($errormsg) { |
|
$error .= ' ('.$errormsg.')'; |
|
} |
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
} |
} |
} |
} |
Line 13966 sub modify_lti {
|
Line 14124 sub modify_lti {
|
} |
} |
$resulttext .= '</ul>'; |
$resulttext .= '</ul>'; |
if (ref($lastactref) eq 'HASH') { |
if (ref($lastactref) eq 'HASH') { |
if (($secchanges{'encrypt'}) || ($secchanges{'private'})) { |
if (($secchanges{'encrypt'}) || ($secchanges{'private'}) || (exists($secchanges{'suggested'}))) { |
|
&Apache::lonnet::get_domain_defaults($dom,1); |
$lastactref->{'domdefaults'} = 1; |
$lastactref->{'domdefaults'} = 1; |
} |
} |
} |
} |
Line 14005 sub get_priv_creds {
|
Line 14164 sub get_priv_creds {
|
} |
} |
|
|
sub get_lti_id { |
sub get_lti_id { |
my ($domain,$consumer) = @_; |
my ($domain,$consumer,$dbname) = @_; |
# get lock on lti db |
unless (($dbname eq 'lti') || ($dbname eq 'suggested')) { |
|
return ('','invalid db'); |
|
} |
|
# get lock on db |
my $lockhash = { |
my $lockhash = { |
lock => $env{'user.name'}. |
lock => $env{'user.name'}. |
':'.$env{'user.domain'}, |
':'.$env{'user.domain'}, |
}; |
}; |
my $tries = 0; |
my $tries = 0; |
my $gotlock = &Apache::lonnet::newput_dom('lti',$lockhash,$domain); |
my $gotlock = &Apache::lonnet::newput_dom($dbname,$lockhash,$domain); |
my ($id,$error); |
my ($id,$error); |
|
|
while (($gotlock ne 'ok') && ($tries<10)) { |
while (($gotlock ne 'ok') && ($tries<10)) { |
$tries ++; |
$tries ++; |
sleep (0.1); |
sleep (0.1); |
$gotlock = &Apache::lonnet::newput_dom('lti',$lockhash,$domain); |
$gotlock = &Apache::lonnet::newput_dom($dbname,$lockhash,$domain); |
} |
} |
if ($gotlock eq 'ok') { |
if ($gotlock eq 'ok') { |
my %currids = &Apache::lonnet::dump_dom('lti',$domain); |
my %currids = &Apache::lonnet::dump_dom($dbname,$domain); |
if ($currids{'lock'}) { |
if ($currids{'lock'}) { |
delete($currids{'lock'}); |
delete($currids{'lock'}); |
if (keys(%currids)) { |
if (keys(%currids)) { |
Line 14033 sub get_lti_id {
|
Line 14195 sub get_lti_id {
|
$id = 1; |
$id = 1; |
} |
} |
if ($id) { |
if ($id) { |
unless (&Apache::lonnet::newput_dom('lti',{ $id => $consumer },$domain) eq 'ok') { |
unless (&Apache::lonnet::newput_dom($dbname,{ $id => $consumer },$domain) eq 'ok') { |
$error = 'nostore'; |
$error = 'nostore'; |
} |
} |
} else { |
} else { |
$error = 'nonumber'; |
$error = 'nonumber'; |
} |
} |
} |
} |
my $dellockoutcome = &Apache::lonnet::del_dom('lti',['lock'],$domain); |
my $dellockoutcome = &Apache::lonnet::del_dom($dbname,['lock'],$domain); |
} else { |
} else { |
$error = 'nolock'; |
$error = 'nolock'; |
} |
} |