version 1.1075.2.125, 2017/03/15 03:39:49
|
version 1.1075.2.134, 2019/07/30 11:10:55
|
Line 80 use JSON::DWIW;
|
Line 80 use JSON::DWIW;
|
use LWP::UserAgent; |
use LWP::UserAgent; |
use Crypt::DES; |
use Crypt::DES; |
use DynaLoader; # for Crypt::DES version |
use DynaLoader; # for Crypt::DES version |
|
use File::Copy(); |
|
use File::Path(); |
|
|
# ---------------------------------------------- Designs |
# ---------------------------------------------- Designs |
use vars qw(%defaultdesign); |
use vars qw(%defaultdesign); |
Line 194 BEGIN {
|
Line 196 BEGIN {
|
{ |
{ |
my $langtabfile = $Apache::lonnet::perlvar{'lonTabDir'}. |
my $langtabfile = $Apache::lonnet::perlvar{'lonTabDir'}. |
'/language.tab'; |
'/language.tab'; |
if ( open(my $fh,"<$langtabfile") ) { |
if ( open(my $fh,'<',$langtabfile) ) { |
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
next if ($line=~/^\#/); |
next if ($line=~/^\#/); |
chomp($line); |
chomp($line); |
Line 215 BEGIN {
|
Line 217 BEGIN {
|
{ |
{ |
my $copyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. |
my $copyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. |
'/copyright.tab'; |
'/copyright.tab'; |
if ( open (my $fh,"<$copyrightfile") ) { |
if ( open (my $fh,'<',$copyrightfile) ) { |
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
next if ($line=~/^\#/); |
next if ($line=~/^\#/); |
chomp($line); |
chomp($line); |
Line 229 BEGIN {
|
Line 231 BEGIN {
|
{ |
{ |
my $sourcecopyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. |
my $sourcecopyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. |
'/source_copyright.tab'; |
'/source_copyright.tab'; |
if ( open (my $fh,"<$sourcecopyrightfile") ) { |
if ( open (my $fh,'<',$sourcecopyrightfile) ) { |
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
next if ($line =~ /^\#/); |
next if ($line =~ /^\#/); |
chomp($line); |
chomp($line); |
Line 243 BEGIN {
|
Line 245 BEGIN {
|
# -------------------------------------------------------------- default domain designs |
# -------------------------------------------------------------- default domain designs |
my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors'; |
my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors'; |
my $designfile = $designdir.'/default.tab'; |
my $designfile = $designdir.'/default.tab'; |
if ( open (my $fh,"<$designfile") ) { |
if ( open (my $fh,'<',$designfile) ) { |
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
next if ($line =~ /^\#/); |
next if ($line =~ /^\#/); |
chomp($line); |
chomp($line); |
Line 257 BEGIN {
|
Line 259 BEGIN {
|
{ |
{ |
my $categoryfile = $Apache::lonnet::perlvar{'lonTabDir'}. |
my $categoryfile = $Apache::lonnet::perlvar{'lonTabDir'}. |
'/filecategories.tab'; |
'/filecategories.tab'; |
if ( open (my $fh,"<$categoryfile") ) { |
if ( open (my $fh,'<',$categoryfile) ) { |
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
next if ($line =~ /^\#/); |
next if ($line =~ /^\#/); |
chomp($line); |
chomp($line); |
Line 272 BEGIN {
|
Line 274 BEGIN {
|
{ |
{ |
my $typesfile = $Apache::lonnet::perlvar{'lonTabDir'}. |
my $typesfile = $Apache::lonnet::perlvar{'lonTabDir'}. |
'/filetypes.tab'; |
'/filetypes.tab'; |
if ( open (my $fh,"<$typesfile") ) { |
if ( open (my $fh,'<',$typesfile) ) { |
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
next if ($line =~ /^\#/); |
next if ($line =~ /^\#/); |
chomp($line); |
chomp($line); |
Line 2260 sub select_form {
|
Line 2262 sub select_form {
|
if ($onchange) { |
if ($onchange) { |
$onchange = ' onchange="'.$onchange.'"'; |
$onchange = ' onchange="'.$onchange.'"'; |
} |
} |
my $selectform = "<select name=\"$name\" size=\"1\"$onchange>\n"; |
my $disabled; |
|
if ($readonly) { |
|
$disabled = ' disabled="disabled"'; |
|
} |
|
my $selectform = "<select name=\"$name\" size=\"1\"$onchange$disabled>\n"; |
my @keys; |
my @keys; |
if (exists($hashref->{'select_form_order'})) { |
if (exists($hashref->{'select_form_order'})) { |
@keys=@{$hashref->{'select_form_order'}}; |
@keys=@{$hashref->{'select_form_order'}}; |
Line 4718 sub blockcheck {
|
Line 4724 sub blockcheck {
|
($env{'request.role'} !~ m{^st\./\Q$cdom\E/\Q$cnum\E})); |
($env{'request.role'} !~ m{^st\./\Q$cdom\E/\Q$cnum\E})); |
next if ($no_userblock); |
next if ($no_userblock); |
|
|
# Retrieve blocking times and identity of locker for course |
# Retrieve blocking times and identity of blocker for course |
# of specified user, unless user has 'evb' privilege. |
# of specified user, unless user has 'evb' privilege. |
|
|
my ($start,$end,$trigger) = |
my ($start,$end,$trigger) = |
Line 5132 sub get_legacy_domconf {
|
Line 5138 sub get_legacy_domconf {
|
my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors'; |
my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors'; |
my $designfile = $designdir.'/'.$udom.'.tab'; |
my $designfile = $designdir.'/'.$udom.'.tab'; |
if (-e $designfile) { |
if (-e $designfile) { |
if ( open (my $fh,"<$designfile") ) { |
if ( open (my $fh,'<',$designfile) ) { |
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
next if ($line =~ /^\#/); |
next if ($line =~ /^\#/); |
chomp($line); |
chomp($line); |
Line 5388 Inputs:
|
Line 5394 Inputs:
|
|
|
=item * $args, optional argument valid values are |
=item * $args, optional argument valid values are |
no_auto_mt_title -> prevents &mt()ing the title arg |
no_auto_mt_title -> prevents &mt()ing the title arg |
|
use_absolute -> for external resource or syllabus, this will |
|
contain https://<hostname> if server uses |
|
https (as per hosts.tab), but request is for http |
|
hostname -> hostname, from $r->hostname(). |
|
|
=item * $advtoolsref, optional argument, ref to an array containing |
=item * $advtoolsref, optional argument, ref to an array containing |
inlineremote items to be added in "Functions" menu below |
inlineremote items to be added in "Functions" menu below |
Line 5413 sub bodytag {
|
Line 5423 sub bodytag {
|
} |
} |
if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); } |
if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); } |
my $httphost = $args->{'use_absolute'}; |
my $httphost = $args->{'use_absolute'}; |
|
my $hostname = $args->{'hostname'}; |
|
|
$function = &get_users_function() if (!$function); |
$function = &get_users_function() if (!$function); |
my $img = &designparm($function.'.img',$domain); |
my $img = &designparm($function.'.img',$domain); |
Line 5501 sub bodytag {
|
Line 5512 sub bodytag {
|
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
$forcereg,$args->{'group'}, |
$forcereg,$args->{'group'}, |
$args->{'bread_crumbs'}, |
$args->{'bread_crumbs'}, |
$advtoolsref,'',\$forbodytag); |
$advtoolsref,'','',\$forbodytag); |
unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') { |
unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') { |
$funclist = $forbodytag; |
$funclist = $forbodytag; |
} |
} |
Line 5547 sub bodytag {
|
Line 5558 sub bodytag {
|
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); |
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); |
if ($env{'request.state'} eq 'construct') { |
if ($env{'request.state'} eq 'construct') { |
$bodytag .= &Apache::lonmenu::innerregister($forcereg, |
$bodytag .= &Apache::lonmenu::innerregister($forcereg, |
$args->{'bread_crumbs'}); |
$args->{'bread_crumbs'},'','',$hostname); |
} elsif ($forcereg) { |
} elsif ($forcereg) { |
$bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, |
$bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, |
$args->{'group'}, |
$args->{'group'}, |
$args->{'hide_buttons'}); |
$args->{'hide_buttons', |
|
$hostname}); |
} else { |
} else { |
my $forbodytag; |
my $forbodytag; |
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
$forcereg,$args->{'group'}, |
$forcereg,$args->{'group'}, |
$args->{'bread_crumbs'}, |
$args->{'bread_crumbs'}, |
$advtoolsref,'',\$forbodytag); |
$advtoolsref,'',$hostname, |
|
\$forbodytag); |
unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') { |
unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') { |
$bodytag .= $forbodytag; |
$bodytag .= $forbodytag; |
} |
} |
Line 6071 td.LC_menubuttons_text {
|
Line 6084 td.LC_menubuttons_text {
|
background: $tabbg; |
background: $tabbg; |
} |
} |
|
|
|
td.LC_zero_height { |
|
line-height: 0; |
|
cellpadding: 0; |
|
} |
|
|
table.LC_data_table { |
table.LC_data_table { |
border: 1px solid #000000; |
border: 1px solid #000000; |
border-collapse: separate; |
border-collapse: separate; |
Line 6743 table.LC_data_table tr > td.LC_docs_entr
|
Line 6761 table.LC_data_table tr > td.LC_docs_entr
|
color: #990000; |
color: #990000; |
} |
} |
|
|
|
.LC_domprefs_email, |
.LC_docs_reinit_warn, |
.LC_docs_reinit_warn, |
.LC_docs_ext_edit { |
.LC_docs_ext_edit { |
font-size: x-small; |
font-size: x-small; |
Line 7897 OFFLOAD
|
Line 7916 OFFLOAD
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> |
<meta name="apple-mobile-web-app-capable" content="yes" />'; |
<meta name="apple-mobile-web-app-capable" content="yes" />'; |
} |
} |
|
$result .= '<meta name="google" content="notranslate" />'."\n"; |
return $result.'</head>'; |
return $result.'</head>'; |
} |
} |
|
|
Line 8082 $args - additional optional args support
|
Line 8102 $args - additional optional args support
|
to lonhtmlcommon::breadcrumbs |
to lonhtmlcommon::breadcrumbs |
group -> includes the current group, if page is for a |
group -> includes the current group, if page is for a |
specific group |
specific group |
|
use_absolute -> for request for external resource or syllabus, this |
|
will contain https://<hostname> if server uses |
|
https (as per hosts.tab), but request is for http |
|
hostname -> hostname, originally from $r->hostname(), (optional). |
|
|
=back |
=back |
|
|
Line 8387 sub end_togglebox {
|
Line 8411 sub end_togglebox {
|
} |
} |
|
|
sub LCprogressbar_script { |
sub LCprogressbar_script { |
my ($id)=@_; |
my ($id,$number_to_do)=@_; |
return(<<ENDPROGRESS); |
if ($number_to_do) { |
|
return(<<ENDPROGRESS); |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
\$('#progressbar$id').progressbar({ |
\$('#progressbar$id').progressbar({ |
Line 8401 sub LCprogressbar_script {
|
Line 8426 sub LCprogressbar_script {
|
// ]]> |
// ]]> |
</script> |
</script> |
ENDPROGRESS |
ENDPROGRESS |
|
} else { |
|
return(<<ENDPROGRESS); |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
\$('#progressbar$id').progressbar({ |
|
value: false, |
|
create: function(event, ui) { |
|
\$('.ui-widget-header', this).css({'background':'#F0F0F0'}); |
|
\$('.ui-progressbar-overlay', this).css({'margin':'0'}); |
|
} |
|
}); |
|
// ]]> |
|
</script> |
|
ENDPROGRESS |
|
} |
} |
} |
|
|
sub LCprogressbarUpdate_script { |
sub LCprogressbarUpdate_script { |
return(<<ENDPROGRESSUPDATE); |
return(<<ENDPROGRESSUPDATE); |
<style type="text/css"> |
<style type="text/css"> |
.ui-progressbar { position:relative; } |
.ui-progressbar { position:relative; } |
|
.progress-label {position: absolute; width: 100%; text-align: center; top: 1px; font-weight: bold; text-shadow: 1px 1px 0 #fff;margin: 0; line-height: 200%; } |
.pblabel { position: absolute; width: 100%; text-align: center; line-height: 1.9em; } |
.pblabel { position: absolute; width: 100%; text-align: center; line-height: 1.9em; } |
</style> |
</style> |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
var LCprogressTxt='---'; |
var LCprogressTxt='---'; |
|
|
function LCupdateProgress(percent,progresstext,id) { |
function LCupdateProgress(percent,progresstext,id,maxnum) { |
LCprogressTxt=progresstext; |
LCprogressTxt=progresstext; |
\$('#progressbar'+id).progressbar('value',percent); |
if ((maxnum == '') || (maxnum == undefined) || (maxnum == null)) { |
|
\$('#progressbar'+id).find('.progress-label').text(LCprogressTxt); |
|
} else if (percent === \$('#progressbar'+id).progressbar( "value" )) { |
|
\$('#progressbar'+id).find('.pblabel').text(LCprogressTxt); |
|
} else { |
|
\$('#progressbar'+id).progressbar('value',percent); |
|
} |
} |
} |
// ]]> |
// ]]> |
</script> |
</script> |
Line 8427 my $LCidcnt;
|
Line 8474 my $LCidcnt;
|
my $LCcurrentid; |
my $LCcurrentid; |
|
|
sub LCprogressbar { |
sub LCprogressbar { |
my ($r)=(@_); |
my ($r,$number_to_do,$preamble)=@_; |
$LClastpercent=0; |
$LClastpercent=0; |
$LCidcnt++; |
$LCidcnt++; |
$LCcurrentid=$$.'_'.$LCidcnt; |
$LCcurrentid=$$.'_'.$LCidcnt; |
my $starting=&mt('Starting'); |
my ($starting,$content); |
my $content=(<<ENDPROGBAR); |
if ($number_to_do) { |
|
$starting=&mt('Starting'); |
|
$content=(<<ENDPROGBAR); |
|
$preamble |
<div id="progressbar$LCcurrentid"> |
<div id="progressbar$LCcurrentid"> |
<span class="pblabel">$starting</span> |
<span class="pblabel">$starting</span> |
</div> |
</div> |
ENDPROGBAR |
ENDPROGBAR |
&r_print($r,$content.&LCprogressbar_script($LCcurrentid)); |
} else { |
|
$starting=&mt('Loading...'); |
|
$LClastpercent='false'; |
|
$content=(<<ENDPROGBAR); |
|
$preamble |
|
<div id="progressbar$LCcurrentid"> |
|
<div class="progress-label">$starting</div> |
|
</div> |
|
ENDPROGBAR |
|
} |
|
&r_print($r,$content.&LCprogressbar_script($LCcurrentid,$number_to_do)); |
} |
} |
|
|
sub LCprogressbarUpdate { |
sub LCprogressbarUpdate { |
my ($r,$val,$text)=@_; |
my ($r,$val,$text,$number_to_do)=@_; |
unless ($val) { |
if ($number_to_do) { |
if ($LClastpercent) { |
unless ($val) { |
$val=$LClastpercent; |
if ($LClastpercent) { |
} else { |
$val=$LClastpercent; |
$val=0; |
} else { |
} |
$val=0; |
|
} |
|
} |
|
if ($val<0) { $val=0; } |
|
if ($val>100) { $val=0; } |
|
$LClastpercent=$val; |
|
unless ($text) { $text=$val.'%'; } |
|
} else { |
|
$val = 'false'; |
} |
} |
if ($val<0) { $val=0; } |
|
if ($val>100) { $val=0; } |
|
$LClastpercent=$val; |
|
unless ($text) { $text=$val.'%'; } |
|
$text=&js_ready($text); |
$text=&js_ready($text); |
&r_print($r,<<ENDUPDATE); |
&r_print($r,<<ENDUPDATE); |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
LCupdateProgress($val,'$text','$LCcurrentid'); |
LCupdateProgress($val,'$text','$LCcurrentid','$number_to_do'); |
// ]]> |
// ]]> |
</script> |
</script> |
ENDUPDATE |
ENDUPDATE |
Line 9574 sub get_secgrprole_info {
|
Line 9638 sub get_secgrprole_info {
|
} |
} |
|
|
sub user_picker { |
sub user_picker { |
my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context,$fixeddom) = @_; |
my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context,$fixeddom,$noinstd) = @_; |
my $currdom = $dom; |
my $currdom = $dom; |
my @alldoms = &Apache::lonnet::all_domains(); |
my @alldoms = &Apache::lonnet::all_domains(); |
if (@alldoms == 1) { |
if (@alldoms == 1) { |
Line 9639 sub user_picker {
|
Line 9703 sub user_picker {
|
&html_escape(\%html_lt); |
&html_escape(\%html_lt); |
&js_escape(\%js_lt); |
&js_escape(\%js_lt); |
my $domform; |
my $domform; |
|
my $allow_blank = 1; |
if ($fixeddom) { |
if ($fixeddom) { |
$domform = &select_dom_form($currdom,'srchdomain',1,1,undef,[$currdom]); |
$allow_blank = 0; |
|
$domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,[$currdom]); |
} else { |
} else { |
$domform = &select_dom_form($currdom,'srchdomain',1,1); |
$domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1); |
} |
} |
my $srchinsel = ' <select name="srchin">'; |
my $srchinsel = ' <select name="srchin">'; |
|
|
Line 9655 sub user_picker {
|
Line 9721 sub user_picker {
|
next if ($option eq 'alc'); |
next if ($option eq 'alc'); |
next if (($option eq 'crs') && ($env{'form.form'} eq 'requestcrs')); |
next if (($option eq 'crs') && ($env{'form.form'} eq 'requestcrs')); |
next if ($option eq 'crs' && !$env{'request.course.id'}); |
next if ($option eq 'crs' && !$env{'request.course.id'}); |
|
next if (($option eq 'instd') && ($noinstd)); |
if ($curr_selected{'srchin'} eq $option) { |
if ($curr_selected{'srchin'} eq $option) { |
$srchinsel .= ' |
$srchinsel .= ' |
<option value="'.$option.'" selected="selected">'.$html_lt{$option}.'</option>'; |
<option value="'.$option.'" selected="selected">'.$html_lt{$option}.'</option>'; |
Line 11416 sub modify_html_refs {
|
Line 11483 sub modify_html_refs {
|
return; |
return; |
} |
} |
} |
} |
if (open(my $fh,"<$container")) { |
if (open(my $fh,'<',$container)) { |
$content = join('', <$fh>); |
$content = join('', <$fh>); |
close($fh); |
close($fh); |
} else { |
} else { |
Line 11481 sub modify_html_refs {
|
Line 11548 sub modify_html_refs {
|
} |
} |
} |
} |
} else { |
} else { |
if (open(my $fh,">$container")) { |
if (open(my $fh,'>',$container)) { |
print $fh $content; |
print $fh $content; |
close($fh); |
close($fh); |
$output = '<p>'.&mt('Updated [quant,_1,reference] in [_2].', |
$output = '<p>'.&mt('Updated [quant,_1,reference] in [_2].', |
Line 11998 sub decompress_uploaded_file {
|
Line 12065 sub decompress_uploaded_file {
|
|
|
sub process_decompression { |
sub process_decompression { |
my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; |
my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; |
|
unless (($dir_root eq '/userfiles') && ($destination =~ m{^(docs|supplemental)/(default|\d+)/\d+$})) { |
|
return '<p class="LC_error">'.&mt('Not extracted.').'<br />'. |
|
&mt('Unexpected file path.').'</p>'."\n"; |
|
} |
|
unless (($docudom =~ /^$match_domain$/) && ($docuname =~ /^$match_courseid$/)) { |
|
return '<p class="LC_error">'.&mt('Not extracted.').'<br />'. |
|
&mt('Unexpected course context.').'</p>'."\n"; |
|
} |
|
unless ($file eq &Apache::lonnet::clean_filename($file)) { |
|
return '<p class="LC_error">'.&mt('Not extracted.').'<br />'. |
|
&mt('Filename contained unexpected characters.').'</p>'."\n"; |
|
} |
my ($dir,$error,$warning,$output); |
my ($dir,$error,$warning,$output); |
if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i) { |
if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i) { |
$error = &mt('Filename not a supported archive file type.'). |
$error = &mt('Filename not a supported archive file type.'). |
Line 12032 sub process_decompression {
|
Line 12111 sub process_decompression {
|
} |
} |
} |
} |
my $numskip = scalar(@to_skip); |
my $numskip = scalar(@to_skip); |
if (($numskip > 0) && |
my $numoverwrite = scalar(@to_overwrite); |
($numskip == $env{'form.archive_itemcount'})) { |
if (($numskip) && (!$numoverwrite)) { |
$warning = &mt('All items in the archive file already exist, and no overwriting of existing files has been requested.'); |
$warning = &mt('All items in the archive file already exist, and no overwriting of existing files has been requested.'); |
} elsif ($dir eq '') { |
} elsif ($dir eq '') { |
$error = &mt('Directory containing archive file unavailable.'); |
$error = &mt('Directory containing archive file unavailable.'); |
} elsif (!$error) { |
} elsif (!$error) { |
my ($decompressed,$display); |
my ($decompressed,$display); |
if ($numskip > 0) { |
if (($numskip) || ($numoverwrite)) { |
my $tempdir = time.'_'.$$.int(rand(10000)); |
my $tempdir = time.'_'.$$.int(rand(10000)); |
mkdir("$dir/$tempdir",0755); |
mkdir("$dir/$tempdir",0755); |
system("mv $dir/$file $dir/$tempdir/$file"); |
if (&File::Copy::move("$dir/$file","$dir/$tempdir/$file")) { |
($decompressed,$display) = |
($decompressed,$display) = |
&decompress_uploaded_file($file,"$dir/$tempdir"); |
&decompress_uploaded_file($file,"$dir/$tempdir"); |
foreach my $item (@to_skip) { |
foreach my $item (@to_skip) { |
if (($item ne '') && ($item !~ /\.\./)) { |
if (($item ne '') && ($item !~ /\.\./)) { |
if (-f "$dir/$tempdir/$item") { |
if (-f "$dir/$tempdir/$item") { |
unlink("$dir/$tempdir/$item"); |
unlink("$dir/$tempdir/$item"); |
} elsif (-d "$dir/$tempdir/$item") { |
} elsif (-d "$dir/$tempdir/$item") { |
system("rm -rf $dir/$tempdir/$item"); |
&File::Path::remove_tree("$dir/$tempdir/$item",{ safe => 1 }); |
|
} |
|
} |
|
} |
|
foreach my $item (@to_overwrite) { |
|
if ((-e "$dir/$tempdir/$item") && (-e "$dir/$item")) { |
|
if (($item ne '') && ($item !~ /\.\./)) { |
|
if (-f "$dir/$item") { |
|
unlink("$dir/$item"); |
|
} elsif (-d "$dir/$item") { |
|
&File::Path::remove_tree("$dir/$item",{ safe => 1 }); |
|
} |
|
&File::Copy::move("$dir/$tempdir/$item","$dir/$item"); |
|
} |
} |
} |
} |
} |
|
if (&File::Copy::move("$dir/$tempdir/$file","$dir/$file")) { |
|
&File::Path::remove_tree("$dir/$tempdir",{ safe => 1 }); |
|
} |
} |
} |
system("mv $dir/$tempdir/* $dir"); |
|
rmdir("$dir/$tempdir"); |
|
} else { |
} else { |
($decompressed,$display) = |
($decompressed,$display) = |
&decompress_uploaded_file($file,$dir); |
&decompress_uploaded_file($file,$dir); |
Line 12073 sub process_decompression {
|
Line 12166 sub process_decompression {
|
if (ref($newdirlistref) eq 'ARRAY') { |
if (ref($newdirlistref) eq 'ARRAY') { |
foreach my $dir_line (@{$newdirlistref}) { |
foreach my $dir_line (@{$newdirlistref}) { |
my ($item,undef,undef,$testdir)=split(/\&/,$dir_line,5); |
my ($item,undef,undef,$testdir)=split(/\&/,$dir_line,5); |
unless (($item =~ /^\.+$/) || ($item eq $file) || |
unless (($item =~ /^\.+$/) || ($item eq $file)) { |
((@to_skip > 0) && (grep(/^\Q$item\E$/,@to_skip)))) { |
|
push(@newitems,$item); |
push(@newitems,$item); |
if ($dirptr&$testdir) { |
if ($dirptr&$testdir) { |
$is_dir{$item} = 1; |
$is_dir{$item} = 1; |
Line 12559 END
|
Line 12651 END
|
sub process_extracted_files { |
sub process_extracted_files { |
my ($context,$docudom,$docuname,$destination,$dir_root,$hiddenelem) = @_; |
my ($context,$docudom,$docuname,$destination,$dir_root,$hiddenelem) = @_; |
my $numitems = $env{'form.archive_count'}; |
my $numitems = $env{'form.archive_count'}; |
return unless ($numitems); |
return if ((!$numitems) || ($numitems =~ /\D/)); |
my @ids=&Apache::lonnet::current_machine_ids(); |
my @ids=&Apache::lonnet::current_machine_ids(); |
my ($prefix,$pathtocheck,$dir,$ishome,$error,$warning,%toplevelitems,%is_dir, |
my ($prefix,$pathtocheck,$dir,$ishome,$error,$warning,%toplevelitems,%is_dir, |
%folders,%containers,%mapinner,%prompttofetch); |
%folders,%containers,%mapinner,%prompttofetch); |
Line 12572 sub process_extracted_files {
|
Line 12664 sub process_extracted_files {
|
} else { |
} else { |
$prefix = $Apache::lonnet::perlvar{'lonDocRoot'}; |
$prefix = $Apache::lonnet::perlvar{'lonDocRoot'}; |
$pathtocheck = "$dir_root/$docudom/$docuname/$destination"; |
$pathtocheck = "$dir_root/$docudom/$docuname/$destination"; |
$dir = "$dir_root/$docudom/$docuname"; |
$dir = "$dir_root/$docudom/$docuname"; |
} |
} |
my $currdir = "$dir_root/$destination"; |
my $currdir = "$dir_root/$destination"; |
(my $docstype,$mapinner{'0'}) = ($destination =~ m{^(docs|supplemental)/(\w+)/}); |
(my $docstype,$mapinner{'0'}) = ($destination =~ m{^(docs|supplemental)/(\w+)/}); |
Line 12661 sub process_extracted_files {
|
Line 12753 sub process_extracted_files {
|
'.'.$containers{$outer},1,1); |
'.'.$containers{$outer},1,1); |
$newseqid{$i} = $newidx; |
$newseqid{$i} = $newidx; |
unless ($errtext) { |
unless ($errtext) { |
$result .= '<li>'.&mt('Folder: [_1] added to course',$docstitle).'</li>'."\n"; |
$result .= '<li>'.&mt('Folder: [_1] added to course', |
|
&HTML::Entities::encode($docstitle,'<>&"')).. |
|
'</li>'."\n"; |
} |
} |
} |
} |
} else { |
} else { |
Line 12670 sub process_extracted_files {
|
Line 12764 sub process_extracted_files {
|
my $url = '/uploaded/'.$docudom.'/'.$docuname.'/'. |
my $url = '/uploaded/'.$docudom.'/'.$docuname.'/'. |
$docstype.'/'.$mapinner{$outer}.'/'.$newidx.'/'. |
$docstype.'/'.$mapinner{$outer}.'/'.$newidx.'/'. |
$title; |
$title; |
if (!-e "$prefix$dir/$docstype/$mapinner{$outer}") { |
if (($outer !~ /\D/) && ($mapinner{$outer} !~ /\D/) && ($newidx !~ /\D/)) { |
mkdir("$prefix$dir/$docstype/$mapinner{$outer}",0755); |
if (!-e "$prefix$dir/$docstype/$mapinner{$outer}") { |
} |
mkdir("$prefix$dir/$docstype/$mapinner{$outer}",0755); |
if (!-e "$prefix$dir/$docstype/$mapinner{$outer}/$newidx") { |
|
mkdir("$prefix$dir/$docstype/$mapinner{$outer}/$newidx"); |
|
} |
|
if (-e "$prefix$dir/$docstype/$mapinner{$outer}/$newidx") { |
|
system("mv $prefix$path $prefix$dir/$docstype/$mapinner{$outer}/$newidx/$title"); |
|
$newdest{$i} = "$prefix$dir/$docstype/$mapinner{$outer}/$newidx"; |
|
unless ($ishome) { |
|
my $fetch = "$newdest{$i}/$title"; |
|
$fetch =~ s/^\Q$prefix$dir\E//; |
|
$prompttofetch{$fetch} = 1; |
|
} |
} |
} |
if (!-e "$prefix$dir/$docstype/$mapinner{$outer}/$newidx") { |
$LONCAPA::map::resources[$newidx]= |
mkdir("$prefix$dir/$docstype/$mapinner{$outer}/$newidx"); |
$docstitle.':'.$url.':false:normal:res'; |
} |
push(@LONCAPA::map::order, $newidx); |
if (-e "$prefix$dir/$docstype/$mapinner{$outer}/$newidx") { |
my ($outtext,$errtext)= |
if (rename("$prefix$path","$prefix$dir/$docstype/$mapinner{$outer}/$newidx/$title")) { |
&LONCAPA::map::storemap('/uploaded/'.$docudom.'/'. |
$newdest{$i} = "$prefix$dir/$docstype/$mapinner{$outer}/$newidx"; |
$docuname.'/'.$folders{$outer}. |
unless ($ishome) { |
'.'.$containers{$outer},1,1); |
my $fetch = "$newdest{$i}/$title"; |
unless ($errtext) { |
$fetch =~ s/^\Q$prefix$dir\E//; |
if (-e "$prefix$dir/$docstype/$mapinner{$outer}/$newidx/$title") { |
$prompttofetch{$fetch} = 1; |
$result .= '<li>'.&mt('File: [_1] added to course',$docstitle).'</li>'."\n"; |
} |
|
} |
|
} |
|
$LONCAPA::map::resources[$newidx]= |
|
$docstitle.':'.$url.':false:normal:res'; |
|
push(@LONCAPA::map::order, $newidx); |
|
my ($outtext,$errtext)= |
|
&LONCAPA::map::storemap('/uploaded/'.$docudom.'/'. |
|
$docuname.'/'.$folders{$outer}. |
|
'.'.$containers{$outer},1,1); |
|
unless ($errtext) { |
|
if (-e "$prefix$dir/$docstype/$mapinner{$outer}/$newidx/$title") { |
|
$result .= '<li>'.&mt('File: [_1] added to course', |
|
&HTML::Entities::encode($docstitle,'<>&"')). |
|
'</li>'."\n"; |
|
} |
} |
} |
|
} else { |
|
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.', |
|
&HTML::Entities::encode($path,'<>&"')).'<br />'; |
} |
} |
} |
} |
} |
} |
} |
} |
} else { |
} else { |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.', |
|
&HTML::Entities::encode($path,'<>&"')).'<br />'; |
} |
} |
} |
} |
for (my $i=1; $i<=$numitems; $i++) { |
for (my $i=1; $i<=$numitems; $i++) { |
Line 12762 sub process_extracted_files {
|
Line 12865 sub process_extracted_files {
|
} |
} |
if ($fullpath ne '') { |
if ($fullpath ne '') { |
if (-e "$prefix$path") { |
if (-e "$prefix$path") { |
system("mv $prefix$path $fullpath/$title"); |
unless (rename("$prefix$path","$fullpath/$title")) { |
|
$warning .= &mt('Failed to rename dependency').'<br />'; |
|
} |
} |
} |
if (-e "$fullpath/$title") { |
if (-e "$fullpath/$title") { |
my $showpath; |
my $showpath; |
Line 12771 sub process_extracted_files {
|
Line 12876 sub process_extracted_files {
|
} else { |
} else { |
$showpath = "/$title"; |
$showpath = "/$title"; |
} |
} |
$result .= '<li>'.&mt('[_1] included as a dependency',$showpath).'</li>'."\n"; |
$result .= '<li>'.&mt('[_1] included as a dependency', |
} |
&HTML::Entities::encode($showpath,'<>&"')). |
unless ($ishome) { |
'</li>'."\n"; |
my $fetch = "$fullpath/$title"; |
unless ($ishome) { |
$fetch =~ s/^\Q$prefix$dir\E//; |
my $fetch = "$fullpath/$title"; |
$prompttofetch{$fetch} = 1; |
$fetch =~ s/^\Q$prefix$dir\E//; |
|
$prompttofetch{$fetch} = 1; |
|
} |
} |
} |
} |
} |
} |
} |
} elsif ($env{'form.archive_'.$referrer{$i}} eq 'discard') { |
} elsif ($env{'form.archive_'.$referrer{$i}} eq 'discard') { |
$warning .= &mt('[_1] is a dependency of [_2], which was discarded.', |
$warning .= &mt('[_1] is a dependency of [_2], which was discarded.', |
$path,$env{'form.archive_content_'.$referrer{$i}}).'<br />'; |
&HTML::Entities::encode($path,'<>&"'), |
|
&HTML::Entities::encode($env{'form.archive_content_'.$referrer{$i}},'<>&"')). |
|
'<br />'; |
} |
} |
} else { |
} else { |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.', |
|
&HTML::Entities::encode($path)).'<br />'; |
} |
} |
} |
} |
if (keys(%todelete)) { |
if (keys(%todelete)) { |
Line 13059 sub upfile_store {
|
Line 13169 sub upfile_store {
|
$env{'form.upfile'}=~s/\n+/\n/gs; |
$env{'form.upfile'}=~s/\n+/\n/gs; |
$env{'form.upfile'}=~s/\n+$//gs; |
$env{'form.upfile'}=~s/\n+$//gs; |
|
|
my $datatoken=$env{'user.name'}.'_'.$env{'user.domain'}. |
my $datatoken = &valid_datatoken($env{'user.name'}.'_'.$env{'user.domain'}. |
'_enroll_'.$env{'request.course.id'}.'_'.time.'_'.$$; |
'_enroll_'.$env{'request.course.id'}.'_'. |
|
time.'_'.$$); |
|
return if ($datatoken eq ''); |
|
|
{ |
{ |
my $datafile = $r->dir_config('lonDaemons'). |
my $datafile = $r->dir_config('lonDaemons'). |
'/tmp/'.$datatoken.'.tmp'; |
'/tmp/'.$datatoken.'.tmp'; |
if ( open(my $fh,">$datafile") ) { |
if ( open(my $fh,'>',$datafile) ) { |
print $fh $env{'form.upfile'}; |
print $fh $env{'form.upfile'}; |
close($fh); |
close($fh); |
} |
} |
Line 13074 sub upfile_store {
|
Line 13187 sub upfile_store {
|
|
|
=pod |
=pod |
|
|
=item * &load_tmp_file($r) |
=item * &load_tmp_file($r,$datatoken) |
|
|
Load uploaded file from tmp, $r should be the HTTP Request object, |
Load uploaded file from tmp, $r should be the HTTP Request object, |
needs $env{'form.datatoken'}, |
$datatoken is the name to assign to the temporary file. |
sets $env{'form.upfile'} to the contents of the file |
sets $env{'form.upfile'} to the contents of the file |
|
|
=cut |
=cut |
|
|
sub load_tmp_file { |
sub load_tmp_file { |
my $r=shift; |
my ($r,$datatoken) = @_; |
|
return if ($datatoken eq ''); |
my @studentdata=(); |
my @studentdata=(); |
{ |
{ |
my $studentfile = $r->dir_config('lonDaemons'). |
my $studentfile = $r->dir_config('lonDaemons'). |
'/tmp/'.$env{'form.datatoken'}.'.tmp'; |
'/tmp/'.$datatoken.'.tmp'; |
if ( open(my $fh,"<$studentfile") ) { |
if ( open(my $fh,'<',$studentfile) ) { |
@studentdata=<$fh>; |
@studentdata=<$fh>; |
close($fh); |
close($fh); |
} |
} |
Line 13096 sub load_tmp_file {
|
Line 13210 sub load_tmp_file {
|
$env{'form.upfile'}=join('',@studentdata); |
$env{'form.upfile'}=join('',@studentdata); |
} |
} |
|
|
|
sub valid_datatoken { |
|
my ($datatoken) = @_; |
|
if ($datatoken =~ /^$match_username\_$match_domain\_enroll_(|$match_domain\_$match_courseid)\_\d+_\d+$/) { |
|
return $datatoken; |
|
} |
|
return; |
|
} |
|
|
=pod |
=pod |
|
|
=item * &upfile_record_sep() |
=item * &upfile_record_sep() |
Line 14038 sub build_recipient_list {
|
Line 14160 sub build_recipient_list {
|
$lastresort = $origmail; |
$lastresort = $origmail; |
} |
} |
|
|
if (($mailing eq 'helpdesk') && ($lastresort ne '')) { |
if (($mailing eq 'helpdeskmail') && ($lastresort ne '')) { |
unless (grep(/^\Q$defdom\E$/,&Apache::lonnet::current_machine_domains())) { |
unless (grep(/^\Q$defdom\E$/,&Apache::lonnet::current_machine_domains())) { |
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
my $machinedom = $Apache::lonnet::perlvar{'lonDefDomain'}; |
my $machinedom = $Apache::lonnet::perlvar{'lonDefDomain'}; |
Line 14118 sub build_recipient_list {
|
Line 14240 sub build_recipient_list {
|
} |
} |
} |
} |
} |
} |
if ($mailing eq 'helpdesk') { |
if ($mailing eq 'helpdeskmail') { |
if ((!@recipients) && ($lastresort ne '')) { |
if ((!@recipients) && ($lastresort ne '')) { |
push(@recipients,$lastresort); |
push(@recipients,$lastresort); |
} |
} |
Line 14223 jsarray (reference to array of categorie
|
Line 14345 jsarray (reference to array of categorie
|
subcats (reference to hash of arrays containing all subcategories within each |
subcats (reference to hash of arrays containing all subcategories within each |
category, -recursive) |
category, -recursive) |
|
|
|
maxd (reference to hash used to hold max depth for all top-level categories). |
|
|
Returns: nothing |
Returns: nothing |
|
|
Side effects: populates trails and allitems hash references. |
Side effects: populates trails and allitems hash references. |
Line 14230 Side effects: populates trails and allit
|
Line 14354 Side effects: populates trails and allit
|
=cut |
=cut |
|
|
sub extract_categories { |
sub extract_categories { |
my ($categories,$cats,$trails,$allitems,$idx,$jsarray,$subcats) = @_; |
my ($categories,$cats,$trails,$allitems,$idx,$jsarray,$subcats,$maxd) = @_; |
if (ref($categories) eq 'HASH') { |
if (ref($categories) eq 'HASH') { |
&gather_categories($categories,$cats,$idx,$jsarray); |
&gather_categories($categories,$cats,$idx,$jsarray); |
if (ref($cats->[0]) eq 'ARRAY') { |
if (ref($cats->[0]) eq 'ARRAY') { |
Line 14256 sub extract_categories {
|
Line 14380 sub extract_categories {
|
if (ref($subcats) eq 'HASH') { |
if (ref($subcats) eq 'HASH') { |
push(@{$subcats->{$item}},&escape($category).':'.&escape($name).':1'); |
push(@{$subcats->{$item}},&escape($category).':'.&escape($name).':1'); |
} |
} |
&recurse_categories($cats,2,$category,$trails,$allitems,\@parents,$subcats); |
&recurse_categories($cats,2,$category,$trails,$allitems,\@parents,$subcats,$maxd); |
} |
} |
} else { |
} else { |
if (ref($subcats) eq 'HASH') { |
if (ref($subcats) eq 'HASH') { |
$subcats->{$item} = []; |
$subcats->{$item} = []; |
} |
} |
|
if (ref($maxd) eq 'HASH') { |
|
$maxd->{$name} = 1; |
|
} |
} |
} |
} |
} |
} |
} |
Line 14299 Side effects: populates trails and allit
|
Line 14426 Side effects: populates trails and allit
|
=cut |
=cut |
|
|
sub recurse_categories { |
sub recurse_categories { |
my ($cats,$depth,$category,$trails,$allitems,$parents,$subcats) = @_; |
my ($cats,$depth,$category,$trails,$allitems,$parents,$subcats,$maxd) = @_; |
my $shallower = $depth - 1; |
my $shallower = $depth - 1; |
if (ref($cats->[$depth]{$category}) eq 'ARRAY') { |
if (ref($cats->[$depth]{$category}) eq 'ARRAY') { |
for (my $k=0; $k<@{$cats->[$depth]{$category}}; $k++) { |
for (my $k=0; $k<@{$cats->[$depth]{$category}}; $k++) { |
Line 14326 sub recurse_categories {
|
Line 14453 sub recurse_categories {
|
} |
} |
} |
} |
&recurse_categories($cats,$deeper,$name,$trails,$allitems,$parents, |
&recurse_categories($cats,$deeper,$name,$trails,$allitems,$parents, |
$subcats); |
$subcats,$maxd); |
pop(@{$parents}); |
pop(@{$parents}); |
} |
} |
} else { |
} else { |
my $item = &escape($category).':'.&escape($parents->[-1]).':'.$shallower; |
my $item = &escape($category).':'.&escape($parents->[-1]).':'.$shallower; |
my $trailstr = join(' -> ',(@{$parents},$category)); |
my $trailstr = join(' » ',(@{$parents},$category)); |
if ($allitems->{$item} eq '') { |
if ($allitems->{$item} eq '') { |
push(@{$trails},$trailstr); |
push(@{$trails},$trailstr); |
$allitems->{$item} = scalar(@{$trails})-1; |
$allitems->{$item} = scalar(@{$trails})-1; |
} |
} |
|
if (ref($maxd) eq 'HASH') { |
|
if ($depth > $maxd->{$parents->[0]}) { |
|
$maxd->{$parents->[0]} = $depth; |
|
} |
|
} |
} |
} |
return; |
return; |
} |
} |
Line 14367 sub assign_categories_table {
|
Line 14499 sub assign_categories_table {
|
my ($cathash,$currcat,$type,$disabled) = @_; |
my ($cathash,$currcat,$type,$disabled) = @_; |
my $output; |
my $output; |
if (ref($cathash) eq 'HASH') { |
if (ref($cathash) eq 'HASH') { |
my (@cats,@trails,%allitems,%idx,@jsarray,@path,$maxdepth); |
my (@cats,@trails,%allitems,%idx,@jsarray,%maxd,@path,$maxdepth); |
&extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx,\@jsarray); |
&extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx,\@jsarray,\%maxd); |
$maxdepth = scalar(@cats); |
$maxdepth = scalar(@cats); |
if (@cats > 0) { |
if (@cats > 0) { |
my $itemcount = 0; |
my $itemcount = 0; |