version 1.484.2.85.2.3, 2020/07/19 14:25:35
|
version 1.627, 2017/05/10 00:03:08
|
Line 43 use Apache::lonnavdisplay();
|
Line 43 use Apache::lonnavdisplay();
|
use Apache::lonextresedit(); |
use Apache::lonextresedit(); |
use Apache::lontemplate(); |
use Apache::lontemplate(); |
use Apache::lonsimplepage(); |
use Apache::lonsimplepage(); |
use Apache::loncourserespicker(); |
use Apache::lonhomework(); |
|
use Apache::lonpublisher(); |
use HTML::Entities; |
use HTML::Entities; |
use HTML::TokeParser; |
use HTML::TokeParser; |
use GDBM_File; |
use GDBM_File; |
use File::MMagic; |
use File::MMagic; |
|
use File::Copy; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Cwd; |
use Cwd; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
Line 233 ENDJS
|
Line 235 ENDJS
|
} else { |
} else { |
&Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles, |
&Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles, |
'dumpdocs',$cdom,$cnum); |
'dumpdocs',$cdom,$cnum); |
} |
} |
my @todump = &Apache::loncommon::get_env_multiple('form.archive'); |
my @todump = &Apache::loncommon::get_env_multiple('form.archive'); |
my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages, |
my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages, |
%newcontent,%has_simpleprobs); |
%newcontent,%has_simpleprobs); |
Line 244 ENDJS
|
Line 246 ENDJS
|
if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) { |
if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) { |
$tocopy{$1} = $name; |
$tocopy{$1} = $name; |
$display{$item} = $1; |
$display{$item} = $1; |
$lookup{$1} = $item; |
$lookup{$1} = $item; |
} elsif ($res eq 'lib/templates/simpleproblem.problem') { |
} elsif ($res eq 'lib/templates/simpleproblem.problem') { |
$simpleproblems{$item} = { |
$simpleproblems{$item} = { |
symb => $resources{$item}, |
symb => $resources{$item}, |
Line 344 $contents{content}.'
|
Line 346 $contents{content}.'
|
</div>'; |
</div>'; |
} |
} |
if ($contents{webreferences}) { |
if ($contents{webreferences}) { |
$content .= ' |
$content .= ' |
<div class="LC_Box"> |
<div class="LC_Box"> |
<h4 class="LC_hcell">'.&mt('Web References').'</h4>'. |
<h4 class="LC_hcell">'.&mt('Web References').'</h4>'. |
$contents{webreferences}.' |
$contents{webreferences}.' |
Line 354 $contents{webreferences}.'
|
Line 356 $contents{webreferences}.'
|
</body> |
</body> |
</html> |
</html> |
'; |
'; |
$newcontent{'/'.$simplepages{$item}{res}} = $content; |
$newcontent{'/'.$simplepages{$item}{res}} = $content; |
} |
} |
} |
} |
foreach my $item (keys(%tocopy)) { |
foreach my $item (keys(%tocopy)) { |
unless ($item=~/\.(sequence|page)$/) { |
unless ($item=~/\.(sequence|page)$/) { |
my $currurlpath = $prefix.$item; |
my $currurlpath = $prefix.$item; |
my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath); |
my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath); |
Line 388 $contents{webreferences}.'
|
Line 390 $contents{webreferences}.'
|
if ($simpleproblems{$num}) { |
if ($simpleproblems{$num}) { |
$newfilename=$title.'/'.$simpleproblems{$num}{'name'}; |
$newfilename=$title.'/'.$simpleproblems{$num}{'name'}; |
} else { |
} else { |
$newfilename=$title.'/'.$replacehash{$item}; |
$newfilename=$title.'/'.$replacehash{$item}; |
} |
} |
$newfilename=~s/\.(\w+)$//; |
$newfilename=~s/\.(\w+)$//; |
my $ext=$1; |
my $ext=$1; |
$newfilename=&clean($newfilename); |
$newfilename=&clean($newfilename); |
$newfilename.='.'.$ext; |
$newfilename.='.'.$ext; |
my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); |
my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); |
if ($newrelpath ne $replacehash{$item}) { |
if ($newrelpath ne $replacehash{$item}) { |
$replacehash{$item} = $newrelpath; |
$replacehash{$item} = $newrelpath; |
} |
} |
my @dirs=split(/\//,$newfilename); |
my @dirs=split(/\//,$newfilename); |
my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca"; |
my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca"; |
my $makepath=$path; |
my $makepath=$path; |
my $fail; |
my $fail; |
my $origin; |
my $origin; |
for (my $i=0;$i<$#dirs;$i++) { |
for (my $i=0;$i<$#dirs;$i++) { |
$makepath.='/'.$dirs[$i]; |
$makepath.='/'.$dirs[$i]; |
unless (-e $makepath) { |
unless (-e $makepath) { |
unless(mkdir($makepath,0755)) { |
unless(mkdir($makepath,0755)) { |
$fail = &mt('Directory creation failed.'); |
$fail = &mt('Directory creation failed.'); |
} |
} |
} |
} |
} |
} |
if ($i == 0) { |
if ($i == 0) { |
$result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: '; |
$result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: '; |
} else { |
} else { |
$depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '. |
$depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '. |
'<span class="LC_fontsize_small" style="font-weight: bold;">'. |
'<span class="LC_fontsize_small" style="font-weight: bold;">'. |
&mt('(dependency)').'</span>: '; |
&mt('(dependency)').'</span>: '; |
} |
} |
if (-e $path.'/'.$newfilename) { |
if (-e $path.'/'.$newfilename) { |
$fail = &mt('Destination already exists -- not overwriting.'); |
$fail = &mt('Destination already exists -- not overwriting.'); |
} else { |
} else { |
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) || |
if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) || |
($item =~ /^simpleproblem_/)) { |
($item =~ /^simpleproblem_/)) { |
Line 442 $contents{webreferences}.'
|
Line 444 $contents{webreferences}.'
|
while (my $token = $parser->get_token) { |
while (my $token = $parser->get_token) { |
if ($token->[0] eq 'S') { |
if ($token->[0] eq 'S') { |
if (($token->[1] eq 'resource') && |
if (($token->[1] eq 'resource') && |
($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && |
($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && |
($changes{$token->[2]->{'id'}})) { |
($changes{$token->[2]->{'id'}})) { |
my $id = $token->[2]->{'id'}; |
my $id = $token->[2]->{'id'}; |
$updatedcontent .= '<'.$token->[1]; |
$updatedcontent .= '<'.$token->[1]; |
foreach my $attrib (@{$token->[3]}) { |
foreach my $attrib (@{$token->[3]}) { |
next unless ($attrib =~ /^(src|type|title|id)$/); |
next unless ($attrib =~ /^(src|type|title|id)$/); |
if ($attrib eq 'src') { |
if ($attrib eq 'src') { |
my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); |
my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); |
if ($file) { |
if ($file) { |
$updatedcontent .= ' '.$attrib.'="'.$file.'"'; |
$updatedcontent .= ' '.$attrib.'="'.$file.'"'; |
} else { |
} else { |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
} |
} |
} else { |
} else { |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
$updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; |
Line 468 $contents{webreferences}.'
|
Line 470 $contents{webreferences}.'
|
} |
} |
} |
} |
print $fh $updatedcontent; |
print $fh $updatedcontent; |
} else { |
} else { |
print $fh &Apache::lonclonecourse::rewritefile( |
print $fh &Apache::lonclonecourse::rewritefile( |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item), |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item), |
(%replacehash,$crs => '') |
(%replacehash,$crs => '') |
); |
); |
} |
} |
} else { |
} else { |
print $fh |
print $fh |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item); |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item); |
} |
} |
} else { |
} else { |
$fail = &mt('Source does not exist.'); |
$fail = &mt('Source does not exist.'); |
} |
} |
} |
} |
$fh->close(); |
$fh->close(); |
} else { |
} else { |
$fail = &mt('Could not write to destination.'); |
$fail = &mt('Could not write to destination.'); |
} |
} |
} |
} |
my $text; |
my $text; |
if ($fail) { |
if ($fail) { |
$text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>'; |
$text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>'; |
} else { |
} else { |
$text = '<span class="LC_success">'.&mt('ok').'</span>'; |
$text = '<span class="LC_success">'.&mt('ok').'</span>'; |
} |
} |
if ($i == 0) { |
if ($i == 0) { |
$result .= $text; |
$result .= $text; |
} else { |
} else { |
$depresult .= $text.'</li>'; |
$depresult .= $text.'</li>'; |
} |
} |
} |
} |
$r->print($result); |
$r->print($result); |
if ($depresult) { |
if ($depresult) { |
Line 514 $contents{webreferences}.'
|
Line 516 $contents{webreferences}.'
|
$r->rflush(); |
$r->rflush(); |
my ($preamble,$formname); |
my ($preamble,$formname); |
$formname = 'dumpdoc'; |
$formname = 'dumpdoc'; |
unless ($home==1) { |
unless ($home==1) { |
$preamble = '<div class="LC_left_float">'. |
$preamble = '<div class="LC_left_float">'. |
'<fieldset><legend>'. |
'<fieldset><legend>'. |
&mt('Select the Authoring Space'). |
&mt('Select the Authoring Space'). |
'</legend><select name="authorspace">'; |
'</legend><select name="authorspace">'; |
} |
} |
my @orderspaces = (); |
my @orderspaces = (); |
foreach my $key (sort(keys(%outhash))) { |
foreach my $key (sort(keys(%outhash))) { |
if ($key=~/^home_(.+)$/) { |
if ($key=~/^home_(.+)$/) { |
if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) { |
if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) { |
unshift(@orderspaces,$1); |
unshift(@orderspaces,$1); |
} else { |
} else { |
push(@orderspaces,$1); |
push(@orderspaces,$1); |
} |
} |
} |
} |
} |
} |
if ($home>1) { |
if ($home>1) { |
$preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>'; |
$preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>'; |
} |
} |
foreach my $user (@orderspaces) { |
foreach my $user (@orderspaces) { |
if ($home==1) { |
if ($home==1) { |
$preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />'; |
$preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />'; |
} else { |
} else { |
$preamble .= '<option value="'.$user.'">'.$user.' - '. |
$preamble .= '<option value="'.$user.'">'.$user.' - '. |
&Apache::loncommon::plainname(split(/\:/,$user)).'</option>'; |
&Apache::loncommon::plainname(split(/\:/,$user)).'</option>'; |
} |
} |
} |
} |
unless ($home==1) { |
unless ($home==1) { |
$preamble .= '</select></fieldset></div>'."\n"; |
$preamble .= '</select></fieldset></div>'."\n"; |
} |
} |
my $title=$origcrsdata{'description'}; |
my $title=$origcrsdata{'description'}; |
$title=~s/[\/\s]+/\_/gs; |
$title=~s/[\/\s]+/\_/gs; |
$title=&clean($title); |
$title=&clean($title); |
$preamble .= '<div class="LC_left_float">'. |
$preamble .= '<div class="LC_left_float">'. |
'<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'. |
'<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'. |
'<input type="text" size="50" name="authorfolder" value="'. |
'<input type="text" size="50" name="authorfolder" value="'. |
$title.'" />'. |
$title.'" />'. |
'</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n"; |
'</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n"; |
my %uploadedfiles; |
my %uploadedfiles; |
&tiehash(); |
&tiehash(); |
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { |
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { |
my ($ext)=($file=~/\.(\w+)$/); |
my ($ext)=($file=~/\.(\w+)$/); |
# FIXME Check supplemental here |
# FIXME Check supplemental here |
my $title=$hash{'title_'.$hash{ |
my $title=$hash{'title_'.$hash{ |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; |
if (!$title) { |
if (!$title) { |
$title=$file; |
$title=$file; |
} else { |
} else { |
$title=~s|/|_|g; |
$title=~s|/|_|g; |
} |
} |
$title=~s/\.(\w+)$//; |
$title=~s/\.(\w+)$//; |
$title=&clean($title); |
$title=&clean($title); |
$title.='.'.$ext; |
$title.='.'.$ext; |
# $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>" |
# $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>" |
$uploadedfiles{$file} = $title; |
$uploadedfiles{$file} = $title; |
} |
} |
&untiehash(); |
&untiehash(); |
$r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef, |
$r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef, |
undef,undef,$preamble,$home,\%uploadedfiles)); |
undef,undef,$preamble,$home,\%uploadedfiles)); |
} |
} |
Line 601 sub recurse_html {
|
Line 603 sub recurse_html {
|
} else { |
} else { |
$relfile = $dependency; |
$relfile = $dependency; |
$depurl = $currurlpath; |
$depurl = $currurlpath; |
$depurl =~ s{[^/]+$}{}; |
$depurl =~ s{[^/]+$}{}; |
$depurl .= $dependency; |
$depurl .= $dependency; |
($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); |
($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); |
} |
} |
next if ($relfile eq ''); |
next if ($relfile eq ''); |
my $newname = $replacehash->{$container}; |
my $newname = $replacehash->{$container}; |
$newname =~ s{[^/]+$}{}; |
$newname =~ s{[^/]+$}{}; |
$replacehash->{$newcontainer} = $newname.$relfile; |
$replacehash->{$newcontainer} = $newname.$relfile; |
$deps->{$item}{$newcontainer} = 1; |
$deps->{$item}{$newcontainer} = 1; |
my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$}); |
my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$}); |
my $depfile = &Apache::lonnet::filelocation('',$depurl); |
my $depfile = &Apache::lonnet::filelocation('',$depurl); |
my $type = $mm->checktype_filename($depfile); |
my $type = $mm->checktype_filename($depfile); |
if ($type eq 'text/html') { |
if ($type eq 'text/html') { |
Line 676 sub group_import {
|
Line 678 sub group_import {
|
my @deleted; |
my @deleted; |
if (ref($ltitoolsref->{$toolid}) eq 'HASH') { |
if (ref($ltitoolsref->{$toolid}) eq 'HASH') { |
$toolhash{'id'} = $toolid; |
$toolhash{'id'} = $toolid; |
if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') || |
if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'window')) { |
($toolhash{'target'} eq 'window')) { |
|
if ($toolhash{'target'} eq 'window') { |
if ($toolhash{'target'} eq 'window') { |
foreach my $item ('width','height') { |
foreach my $item ('width','height') { |
$toolhash{$item} =~ s/^\s+//; |
$toolhash{$item} =~ s/^\s+//; |
Line 695 sub group_import {
|
Line 696 sub group_import {
|
} elsif ($residx) { |
} elsif ($residx) { |
$toolhash{'target'} = $toolsettings{'target'}; |
$toolhash{'target'} = $toolsettings{'target'}; |
if ($toolhash{'target'} eq 'window') { |
if ($toolhash{'target'} eq 'window') { |
foreach my $item ('width','height') { |
foreach my $item ('width','height') { |
$toolhash{$item} = $toolsettings{$item}; |
$toolhash{$item} = $toolsettings{$item}; |
} |
} |
} |
} |
Line 715 sub group_import {
|
Line 716 sub group_import {
|
} |
} |
} |
} |
} |
} |
} elsif ($toolhash{'target'} eq 'tab') { |
|
foreach my $item ('width','height') { |
|
delete($toolhash{$item}); |
|
if ($residx) { |
|
if ($toolsettings{$item}) { |
|
push(@deleted,$item); |
|
} |
|
} |
|
} |
|
} |
} |
if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') { |
if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') { |
foreach my $item ('label','title','linktext','explanation') { |
foreach my $item ('label','title','linktext','explanation') { |
Line 753 sub group_import {
|
Line 745 sub group_import {
|
if ($putres eq 'ok') { |
if ($putres eq 'ok') { |
if (@deleted) { |
if (@deleted) { |
&Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum); |
&Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum); |
} |
} |
} |
} |
} |
} |
} |
} |
Line 770 sub group_import {
|
Line 762 sub group_import {
|
} |
} |
if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) { |
if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) { |
&contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap, |
&contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap, |
\%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps); |
\%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps); |
$importuploaded = 1; |
$importuploaded = 1; |
} elsif ($url =~ m{^/res/.+\.(page|sequence)$}) { |
} elsif ($url =~ m{^/res/.+\.(page|sequence)$}) { |
next if ($allmaps->{$url}); |
next if ($allmaps->{$url}); |
Line 810 $initialtext
|
Line 802 $initialtext
|
</html> |
</html> |
END |
END |
$env{'form.output'}=$newhtml; |
$env{'form.output'}=$newhtml; |
my $result = |
my $result = |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom, |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom, |
'output', |
'output', |
"$filepath/$residx/$fname.html"); |
"$filepath/$residx/$fname.html"); |
Line 835 END
|
Line 827 END
|
removefrommap => \%removefrommap, |
removefrommap => \%removefrommap, |
removeparam => \%removeparam, |
removeparam => \%removeparam, |
); |
); |
my ($result,$msgsarray,$lockerror) = |
my ($result,$msgsarray,$lockerror) = |
&apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated); |
&apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated); |
if (keys(%import_errors) > 0) { |
if (keys(%import_errors) > 0) { |
$fixuperrors = |
$fixuperrors = |
Line 936 sub log_docs {
|
Line 928 sub log_docs {
|
sub docs_change_log { |
sub docs_change_log { |
my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_; |
my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_; |
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); |
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); |
my $navmap; |
my $navmap; |
my $js = '<script type="text/javascript">'."\n". |
my $js = '<script type="text/javascript">'."\n". |
'// <![CDATA['."\n". |
'// <![CDATA['."\n". |
&Apache::loncommon::display_filter_js('docslog')."\n". |
&Apache::loncommon::display_filter_js('docslog')."\n". |
&editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag, |
&editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag, |
$coursedom,$coursenum,'',$canedit,'',\$navmap)."\n". |
$coursedom,$coursenum,'','',$canedit,'',\$navmap)."\n". |
&history_tab_js()."\n". |
&history_tab_js()."\n". |
&Apache::lonratedt::editscript('simple')."\n". |
&Apache::lonratedt::editscript('simple')."\n". |
'// ]]>'."\n". |
'// ]]>'."\n". |
Line 1166 sub update_paste_buffer {
|
Line 1158 sub update_paste_buffer {
|
# Construct identifiers for current contents of user's paste buffer |
# Construct identifiers for current contents of user's paste buffer |
if (@currpaste) { |
if (@currpaste) { |
foreach my $suffix (@currpaste) { |
foreach my $suffix (@currpaste) { |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
my $mapidx = $env{'docs.markedcopy_map_'.$suffix}; |
my $mapidx = $env{'docs.markedcopy_map_'.$suffix}; |
if (($cid =~ /^$match_domain(?:_)$match_courseid$/) && |
if (($cid =~ /^$match_domain(?:_)$match_courseid$/) && |
($url ne '')) { |
($url ne '')) { |
if ($url eq '/res/lib/templates/simpleproblem.problem') { |
$pasteurls{$cid.'_'.$url.'_'.$mapidx} = 1; |
$pasteurls{$cid.'_'.$mapidx} = 1; |
} |
} elsif ($url =~ m{^/res/$match_domain/$match_username/}) { |
|
$pasteurls{$url} = 1; |
|
} else { |
|
$pasteurls{$cid.'_'.$url} = 1; |
|
} |
|
} |
|
} |
} |
} |
} |
|
|
Line 1187 sub update_paste_buffer {
|
Line 1173 sub update_paste_buffer {
|
|
|
my @pathitems = split(/\&/,$env{'form.folderpath'}); |
my @pathitems = split(/\&/,$env{'form.folderpath'}); |
my @folderconf = split(/\:/,$pathitems[-1]); |
my @folderconf = split(/\:/,$pathitems[-1]); |
my $ispage = $folderconf[5]; |
my $ispage = $folderconf[4]; |
|
|
foreach my $item (@possibles) { |
foreach my $item (@possibles) { |
my ($orderidx,$cmd) = split(/:/,$item); |
my ($orderidx,$cmd) = split(/:/,$item); |
Line 1200 sub update_paste_buffer {
|
Line 1186 sub update_paste_buffer {
|
$env{'form.folderpath'},\%curr_groups); |
$env{'form.folderpath'},\%curr_groups); |
next if ($denied{'copy'}); |
next if ($denied{'copy'}); |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
if ($url eq '/res/lib/templates/simpleproblem.problem') { |
next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx})); |
next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx})); |
|
} elsif ($url =~ m{^/res/$match_domain/$match_username/}) { |
|
next if (exists($pasteurls{$url})); |
|
} else { |
|
next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url})); |
|
} |
|
my ($suffix,$errortxt,$locknotfreed) = |
my ($suffix,$errortxt,$locknotfreed) = |
&new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste'); |
&new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste'); |
if ($suffix ne '') { |
if ($suffix ne '') { |
Line 1303 sub print_paste_buffer {
|
Line 1283 sub print_paste_buffer {
|
next if ($suffix =~ /\D/); |
next if ($suffix =~ /\D/); |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
my $mapidx = $env{'docs.markedcopy_map_'.$suffix}; |
my $mapidx = $env{'docs.markedcopy_map_'.$suffix}; |
if (($cid =~ /^$match_domain\_$match_courseid$/) && |
if (($cid =~ /^$match_domain\_$match_courseid$/) && |
($url ne '')) { |
($url ne '')) { |
$clipboardcount ++; |
$clipboardcount ++; |
Line 1359 sub print_paste_buffer {
|
Line 1339 sub print_paste_buffer {
|
} else { |
} else { |
$canpaste = 0; |
$canpaste = 0; |
$nopaste = &mt('Paste from another course unavailable.'); |
$nopaste = &mt('Paste from another course unavailable.'); |
} |
} |
} |
} |
} |
} |
if ($canpaste) { |
if ($canpaste) { |
push(@pasteable,$suffix); |
push(@pasteable,$suffix); |
} |
} |
} |
} |
my $buffer; |
my $buffer; |
if ($is_external) { |
if ($is_external) { |
Line 1426 sub print_paste_buffer {
|
Line 1406 sub print_paste_buffer {
|
my $value = &mt('Paste to current folder'); |
my $value = &mt('Paste to current folder'); |
if ($container eq 'page') { |
if ($container eq 'page') { |
$value = &mt('Paste to current page'); |
$value = &mt('Paste to current page'); |
} |
} |
$buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2); |
$buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2); |
} |
} |
$buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2); |
$buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2); |
Line 1603 function checkClipboard() {
|
Line 1583 function checkClipboard() {
|
if (document.pasteform.pasting.length > 1) { |
if (document.pasteform.pasting.length > 1) { |
for (var i=0; i<document.pasteform.pasting.length; i++) { |
for (var i=0; i<document.pasteform.pasting.length; i++) { |
document.pasteform.pasting[i].checked = true; |
document.pasteform.pasting[i].checked = true; |
} |
} |
} |
} |
return; |
return; |
} |
} |
Line 1659 sub do_paste_from_buffer {
|
Line 1639 sub do_paste_from_buffer {
|
foreach my $suffix (@topaste) { |
foreach my $suffix (@topaste) { |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix}); |
my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix}); |
# Supplemental content may only include certain types of content |
# Supplemental content may only include certain types of content |
# Early out if pasted content is not supported in Supplemental area |
# Early out if pasted content is not supported in Supplemental area |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
Line 1681 sub do_paste_from_buffer {
|
Line 1661 sub do_paste_from_buffer {
|
} |
} |
$srcdom{$suffix} = $srcd; |
$srcdom{$suffix} = $srcd; |
$srcnum{$suffix} = $srcn; |
$srcnum{$suffix} = $srcn; |
} elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) { |
} elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) || |
|
($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg|ext\.tool)$})) { |
|
my $srctype= $1; |
my ($srcd,$srcn) = split(/_/,$cid); |
my ($srcd,$srcn) = split(/_/,$cid); |
# When paste buffer was populated using an active role in a different course |
# When paste buffer was populated using an active role in a different course |
# check for mdc privilege in the course from which the resource was pasted |
# check for mdc privilege in the course from which the resource was pasted |
Line 1691 sub do_paste_from_buffer {
|
Line 1673 sub do_paste_from_buffer {
|
next; |
next; |
} |
} |
} |
} |
# When buffer was populated using an active role in a different course |
if (($srctype eq 'ext.tool') && ($srcd ne $coursedom)) { |
# disallow pasting of External Tool if course is in a different domain. |
|
if ($srcd ne $coursedom) { |
|
$notindom{$suffix} = 1; |
$notindom{$suffix} = 1; |
next; |
next; |
} |
} |
$srcdom{$suffix} = $srcd; |
$srcdom{$suffix} = $srcd; |
$srcnum{$suffix} = $srcn; |
$srcnum{$suffix} = $srcn; |
} elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) || |
|
($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$})) { |
|
my ($srcd,$srcn) = split(/_/,$cid); |
|
# When paste buffer was populated using an active role in a different course |
|
# check for mdc privilege in the course from which the resource was pasted |
|
if (($srcd ne $coursedom) || ($srcn ne $coursenum)) { |
|
unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) { |
|
$notincrs{$suffix} = 1; |
|
next; |
|
} |
|
} |
|
$srcdom{$suffix} = $srcd; |
|
$srcnum{$suffix} = $srcn; |
|
} |
} |
$srcmapidx{$suffix} = $mapidx; |
$srcmapidx{$suffix} = $mapidx; |
push(@dopaste,$suffix); |
push(@dopaste,$suffix); |
if ($url=~/\.(page|sequence)$/) { |
if ($url=~/\.(page|sequence)$/) { |
$is_map{$suffix} = 1; |
$is_map{$suffix} = 1; |
} |
} |
|
|
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) { |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) { |
my $oldprefix = $1; |
my $oldprefix = $1; |
# When pasting content from Main Content to Supplemental Content and vice versa |
# When pasting content from Main Content to Supplemental Content and vice versa |
# URLs will contain different paths (which depend on whether pasted item is |
# URLs will contain different paths (which depend on whether pasted item is |
# a folder/page or a document). |
# a folder/page or a document). |
if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) { |
if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) { |
$prefixchg{$suffix} = 'docstosupp'; |
$prefixchg{$suffix} = 'docstosupp'; |
} elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) { |
} elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) { |
Line 1763 sub do_paste_from_buffer {
|
Line 1729 sub do_paste_from_buffer {
|
%msgs = &Apache::lonlocal::texthash ( |
%msgs = &Apache::lonlocal::texthash ( |
notinsupp => 'Paste failed: content type is not supported within Supplemental Content', |
notinsupp => 'Paste failed: content type is not supported within Supplemental Content', |
notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.', |
notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.', |
notindom => 'Paste failed: Item is an external tool from a course in a different donain.', |
notindom => 'Paste failed: Item is an external tool from a course in a different donain.', |
duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.', |
duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.', |
); |
); |
|
|
Line 1792 sub do_paste_from_buffer {
|
Line 1758 sub do_paste_from_buffer {
|
# Retrieve information about all course maps in main content area |
# Retrieve information about all course maps in main content area |
|
|
my $allmaps = {}; |
my $allmaps = {}; |
my (@toclear,%mapurls,%lockerrs,%msgerrs,%results,$donechk); |
if ($folder =~ /^default/) { |
|
$allmaps = |
|
&Apache::loncommon::allmaps_incourse($coursedom,$coursenum, |
|
$env{"course.$env{'request.course.id'}.home"}, |
|
$env{'request.course.id'}); |
|
} |
|
|
|
my (@toclear,%mapurls,%lockerrs,%msgerrs,%results); |
|
|
# Loop over the items to paste |
# Loop over the items to paste |
foreach my $suffix (@dopaste) { |
foreach my $suffix (@dopaste) { |
Line 1805 sub do_paste_from_buffer {
|
Line 1778 sub do_paste_from_buffer {
|
} |
} |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}); |
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); |
my $oldurl = $url; |
my $oldurl = $url; |
if ($is_map{$suffix}) { |
if ($is_map{$suffix}) { |
# If pasting a map, check if map contains other maps |
# If pasting a map, check if map contains other maps |
my (%hierarchy,%titles); |
my (%hierarchy,%titles); |
if (($folder =~ /^default/) && (!$donechk)) { |
|
$allmaps = |
|
&Apache::loncommon::allmaps_incourse($coursedom,$coursenum, |
|
$env{"course.$env{'request.course.id'}.home"}, |
|
$env{'request.course.id'}); |
|
$donechk = 1; |
|
} |
|
&contained_map_check($url,$folder,$coursenum,$coursedom, |
&contained_map_check($url,$folder,$coursenum,$coursedom, |
\%removefrommap,\%removeparam,\%addedmaps, |
\%removefrommap,\%removeparam,\%addedmaps, |
\%hierarchy,\%titles,$allmaps); |
\%hierarchy,\%titles,$allmaps); |
Line 1858 sub do_paste_from_buffer {
|
Line 1824 sub do_paste_from_buffer {
|
$coursenum,$srcdom{$suffix},$srcnum{$suffix}, |
$coursenum,$srcdom{$suffix},$srcnum{$suffix}, |
$allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
$allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
\%zombies,\%params,\%mapmoves,\%mapchanges, |
\%zombies,\%params,\%mapmoves,\%mapchanges, |
\%tomove,\%newsubdir,\%newurls,\%resdatacopy); |
\%tomove,\%newsubdir,\%newurls,\%resdatacopy); |
} |
} |
} elsif ($url=~m {^/res/}) { |
} elsif ($url=~m {^/res/}) { |
# published map can only exist once, so remove from paste buffer when done |
# published map can only exist once, so remove from paste buffer when done |
Line 1874 sub do_paste_from_buffer {
|
Line 1840 sub do_paste_from_buffer {
|
} |
} |
if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) { |
if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) { |
my $prefix = $1; |
my $prefix = $1; |
my $fromothercrs; |
my $fromothercrs; |
#need to copy the db contents to a new one, unless this is a move. |
#need to copy the db contents to a new one, unless this is a move. |
my %info = ( |
my %info = ( |
src => $url, |
src => $url, |
Line 1909 sub do_paste_from_buffer {
|
Line 1875 sub do_paste_from_buffer {
|
next; |
next; |
} |
} |
if ($lockerr{$prefix}) { |
if ($lockerr{$prefix}) { |
$lockerrs{$suffix} = $lockerr{$prefix}; |
$lockerrs{$suffix} = $lockerr{$prefix}; |
} |
} |
} |
} |
} |
} |
Line 1948 sub do_paste_from_buffer {
|
Line 1914 sub do_paste_from_buffer {
|
if ($newdocsdir eq '') { |
if ($newdocsdir eq '') { |
$newdocsdir = 'default'; |
$newdocsdir = 'default'; |
} |
} |
if (($prefixchg{$suffix}) || |
if (($prefixchg{$suffix}) || |
($srcdom{$suffix} ne $coursedom) || |
($srcdom{$suffix} ne $coursedom) || |
($srcnum{$suffix} ne $coursenum) || |
($srcnum{$suffix} ne $coursenum) || |
($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) { |
($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) { |
Line 1985 sub do_paste_from_buffer {
|
Line 1951 sub do_paste_from_buffer {
|
} |
} |
} |
} |
|
|
# Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update |
# Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update |
# resourcedata for simpleproblems copied from another course |
# resourcedata for simpleproblems copied from another course |
unless ($allresult eq 'fail') { |
unless ($allresult eq 'fail') { |
my %updated = ( |
my %updated = ( |
rewrites => \%rewrites, |
rewrites => \%rewrites, |
Line 2166 sub dbcopy {
|
Line 2132 sub dbcopy {
|
if ($prefix eq 'ext.tool') { |
if ($prefix eq 'ext.tool') { |
$prefix = 'exttool'; |
$prefix = 'exttool'; |
} |
} |
if (($dbref->{'cdom'} =~ /^$match_domain$/) && |
if (($dbref->{'cdom'} =~ /^$match_domain$/) && |
($dbref->{'cnum'} =~ /^$match_courseid$/)) { |
($dbref->{'cnum'} =~ /^$match_courseid$/)) { |
my $db_name; |
my $db_name; |
my $marker = (split(m{/},$url))[4]; |
my $marker = (split(m{/},$url))[4]; |
Line 2188 sub dbcopy {
|
Line 2154 sub dbcopy {
|
if (!$suffix) { |
if (!$suffix) { |
if ($prefix eq 'smppg') { |
if ($prefix eq 'smppg') { |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url); |
} elsif ($prefix eq 'exttool') { |
|
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url); |
|
} else { |
} else { |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url); |
} |
} |
Line 2210 sub dbcopy {
|
Line 2174 sub dbcopy {
|
my $content = &Apache::lonnet::getfile($photo); |
my $content = &Apache::lonnet::getfile($photo); |
unless ($content eq '-1') { |
unless ($content eq '-1') { |
$env{'form.'.$suffix.'.photourl'} = $content; |
$env{'form.'.$suffix.'.photourl'} = $content; |
$newphoto = |
$newphoto = |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname"); |
&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname"); |
delete($env{'form.'.$suffix.'.photourl'}); |
delete($env{'form.'.$suffix.'.photourl'}); |
} |
} |
Line 2282 sub copy_templated_files {
|
Line 2246 sub copy_templated_files {
|
my @simpleprobqtypes = qw(radio option string essay numerical); |
my @simpleprobqtypes = qw(radio option string essay numerical); |
my $qtype=$srcparms{$srcprefix.'questiontype'}; |
my $qtype=$srcparms{$srcprefix.'questiontype'}; |
if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) { |
if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) { |
my %newdata = ( |
my %newdata; |
$newprefix.'questiontype' => $qtype, |
|
); |
|
foreach my $type (@simpleprobqtypes) { |
foreach my $type (@simpleprobqtypes) { |
if ($type eq $qtype) { |
if ($type eq $qtype) { |
$newdata{"$weightprefix.$type.weight"}=1; |
$newdata{"$weightprefix.$type.weight"}=1; |
Line 2378 sub contained_map_check {
|
Line 2340 sub contained_map_check {
|
if ($token->[1] eq 'resource') { |
if ($token->[1] eq 'resource') { |
next if ($token->[2]->{'type'} eq 'zombie'); |
next if ($token->[2]->{'type'} eq 'zombie'); |
my $ressrc = $token->[2]->{'src'}; |
my $ressrc = $token->[2]->{'src'}; |
if ($folder =~ /^supplemental/) { |
if ($ressrc =~ m{^/adm/($match_domain)/$match_courseid/\d+/ext\.tool$}) { |
|
my $srcdom = $1; |
|
unless ($srcdom eq $coursedom) { |
|
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
|
next; |
|
} |
|
} elsif ($folder =~ /^supplemental/) { |
unless (&supp_pasteable($ressrc)) { |
unless (&supp_pasteable($ressrc)) { |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
next; |
next; |
Line 2397 sub contained_map_check {
|
Line 2365 sub contained_map_check {
|
$addedmaps->{$ressrc} = [$url]; |
$addedmaps->{$ressrc} = [$url]; |
} |
} |
} |
} |
&contained_map_check($ressrc,$folder,$coursenum,$coursedom, |
&contained_map_check($ressrc,$folder,$coursenum,$coursedom,$removefrommap, |
$removefrommap,$removeparam, |
$removeparam,$addedmaps,$hierarchy,$titles,$allmaps); |
$addedmaps,$hierarchy,$titles,$allmaps); |
|
} |
} |
} elsif ($token->[1] eq 'param') { |
} elsif ($token->[1] eq 'param') { |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
Line 2450 sub url_paste_fixups {
|
Line 2417 sub url_paste_fixups {
|
} |
} |
next if ($token->[2]->{'type'} eq 'external'); |
next if ($token->[2]->{'type'} eq 'external'); |
if ($token->[2]->{'type'} eq 'zombie') { |
if ($token->[2]->{'type'} eq 'zombie') { |
next if ($skip); |
next if ($skip); |
$zombies->{$oldurl}{$id} = $ressrc; |
$zombies->{$oldurl}{$id} = $ressrc; |
$changed = 1; |
$changed = 1; |
} elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
} elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
Line 2731 sub apply_fixups {
|
Line 2698 sub apply_fixups {
|
} |
} |
} |
} |
if (ref($resdatacopy{$key}) eq 'HASH') { |
if (ref($resdatacopy{$key}) eq 'HASH') { |
my ($gotnewmapname,$newmapname,$srcfolder,$srccontainer); |
if ($newsubdir{$key}) { |
|
|
|
} |
foreach my $idx (keys(%{$resdatacopy{$key}})) { |
foreach my $idx (keys(%{$resdatacopy{$key}})) { |
if (ref($resdatacopy{$key}{$idx}) eq 'HASH') { |
if (ref($resdatacopy{$key}{$idx}) eq 'HASH') { |
my $srcurl = $resdatacopy{$key}{$idx}{'src'}; |
my $srcurl = $resdatacopy{$key}{$idx}{'src'}; |
Line 2741 sub apply_fixups {
|
Line 2710 sub apply_fixups {
|
($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) { |
($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) { |
my $srcdom = $resdatacopy{$key}{$idx}{'cdom'}; |
my $srcdom = $resdatacopy{$key}{$idx}{'cdom'}; |
my $srcnum = $resdatacopy{$key}{$idx}{'cnum'}; |
my $srcnum = $resdatacopy{$key}{$idx}{'cnum'}; |
unless ($gotnewmapname) { |
my ($newmapname) = ($key =~ m{/([^/]+)$}); |
($newmapname) = ($key =~ m{/([^/]+)$}); |
my ($srcfolder,$srccontainer) = split(/\./,$newmapname); |
($srcfolder,$srccontainer) = split(/\./,$newmapname); |
|
if ($newsubdir{$key}) { |
|
$newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/; |
|
} |
|
$gotnewmapname = 1; |
|
} |
|
my $srcmapinfo = $srcfolder.':'.$idx; |
my $srcmapinfo = $srcfolder.':'.$idx; |
if ($srccontainer eq 'page') { |
if ($srccontainer eq 'page') { |
$srcmapinfo .= ':1'; |
$srcmapinfo .= ':1'; |
} |
} |
|
if ($newsubdir{$key}) { |
|
$newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/; |
|
} |
©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom, |
©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom, |
$cnum,$template,$idx,$newmapname); |
$cnum,$template,$idx,$newmapname); |
} |
} |
Line 2775 sub apply_fixups {
|
Line 2741 sub apply_fixups {
|
} |
} |
} |
} |
} |
} |
my $total = scalar(@LONCAPA::map::order) - 1; |
for (my $i=0; $i<@LONCAPA::map::order; $i++) { |
for (my $i=$total; $i>=0; $i--) { |
|
my $idx = $LONCAPA::map::order[$i]; |
my $idx = $LONCAPA::map::order[$i]; |
if (defined($LONCAPA::map::resources[$idx])) { |
if (defined($LONCAPA::map::resources[$idx])) { |
my $changed; |
my $changed; |
Line 2786 sub apply_fixups {
|
Line 2751 sub apply_fixups {
|
splice(@LONCAPA::map::order,$i,1); |
splice(@LONCAPA::map::order,$i,1); |
if (ref($currparam{$idx}) eq 'ARRAY') { |
if (ref($currparam{$idx}) eq 'ARRAY') { |
foreach my $name (@{$currparam{$idx}}) { |
foreach my $name (@{$currparam{$idx}}) { |
&LONCAPA::map::delparameter($idx,$name); |
&LONCAPA::map::delparameter($idx,'parameter_'.$name); |
} |
} |
} |
} |
next; |
next; |
Line 2828 sub apply_fixups {
|
Line 2793 sub apply_fixups {
|
foreach my $idx (keys(%remparam)) { |
foreach my $idx (keys(%remparam)) { |
if (ref($remparam{$idx}) eq 'ARRAY') { |
if (ref($remparam{$idx}) eq 'ARRAY') { |
foreach my $name (@{$remparam{$idx}}) { |
foreach my $name (@{$remparam{$idx}}) { |
&LONCAPA::map::delparameter($idx,$name); |
&LONCAPA::map::delparameter($idx,'parameter_'.$name); |
} |
} |
} |
} |
} |
} |
Line 2936 sub update_parameter {
|
Line 2901 sub update_parameter {
|
'randomorder' => {}, |
'randomorder' => {}, |
); |
); |
foreach my $which (keys(%allchecked)) { |
foreach my $which (keys(%allchecked)) { |
$env{'form.all'.$which} =~ s/,$//; |
$env{'form.all'.$which} =~ s/,$//; |
if ($which eq 'randompick') { |
if ($which eq 'randompick') { |
foreach my $item (split(/,/,$env{'form.all'.$which})) { |
foreach my $item (split(/,/,$env{'form.all'.$which})) { |
my ($res,$value) = split(/:/,$item); |
my ($res,$value) = split(/:/,$item); |
Line 2963 sub update_parameter {
|
Line 2928 sub update_parameter {
|
foreach my $which (keys(%allchecked)) { |
foreach my $which (keys(%allchecked)) { |
if (($which eq 'randompick' || $which eq 'randomorder')) { |
if (($which eq 'randompick' || $which eq 'randomorder')) { |
next if (!$is_map); |
next if (!$is_map); |
} |
} |
my $oldvalue = 0; |
my $oldvalue = 0; |
my $newvalue = 0; |
my $newvalue = 0; |
if ($allchecked{$which}{$res}) { |
if ($allchecked{$which}{$res}) { |
Line 3015 sub update_parameter {
|
Line 2980 sub update_parameter {
|
$oldvalue = 1; |
$oldvalue = 1; |
} |
} |
if ($env{'form.'.$which.'_'.$idx}) { |
if ($env{'form.'.$which.'_'.$idx}) { |
$newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx} |
$newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx} |
: 1; |
: 1; |
} |
} |
if ($oldvalue ne $newvalue) { |
if ($oldvalue ne $newvalue) { |
$haschanges = 1; |
$haschanges = 1; |
Line 3025 sub update_parameter {
|
Line 2990 sub update_parameter {
|
if ($which eq 'randompick') { |
if ($which eq 'randompick') { |
$storeval = $newvalue; |
$storeval = $newvalue; |
} |
} |
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval, |
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval, |
$parameter_type{$which}); |
$parameter_type{$which}); |
&remember_parms($idx,$which,'set',$storeval); |
&remember_parms($idx,$which,'set',$storeval); |
} else { |
} else { |
&LONCAPA::map::delparameter($idx,'parameter_'.$which); |
&LONCAPA::map::delparameter($idx,'parameter_'.$which); |
&remember_parms($idx,$which,'del'); |
&remember_parms($idx,$which,'del'); |
} |
} |
} |
} |
return $haschanges; |
return $haschanges; |
} |
} |
return; |
|
} |
} |
|
|
sub handle_edit_cmd { |
sub handle_edit_cmd { |
Line 3120 sub editor {
|
Line 3084 sub editor {
|
undef(@LONCAPA::map::zombies); |
undef(@LONCAPA::map::zombies); |
} |
} |
$folder = 'default'; |
$folder = 'default'; |
$container = 'sequence'; |
$container = 'sequence'; |
} else { |
} else { |
($errtext,$fatal) = &mapread($coursenum,$coursedom, |
($errtext,$fatal) = &mapread($coursenum,$coursedom, |
$folder.'.'.$container); |
$folder.'.'.$container); |
return $errtext if ($fatal); |
return $errtext if ($fatal); |
} |
} |
|
|
Line 3467 sub editor {
|
Line 3431 sub editor {
|
if (@allidx > 0) { |
if (@allidx > 0) { |
my $path; |
my $path; |
if ($env{'form.folderpath'}) { |
if ($env{'form.folderpath'}) { |
$path = |
$path = |
&HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
&HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
} |
} |
if (@allidx > 1) { |
if (@allidx > 1) { |
$to_show .= |
$to_show .= |
&Apache::loncommon::continue_data_table_row(). |
&Apache::loncommon::continue_data_table_row(). |
'<td colspan="2"> </td>'. |
'<td colspan="2"> </td>'. |
'<td>'. |
'<td>'. |
Line 3503 sub editor {
|
Line 3467 sub editor {
|
} |
} |
my $noresmsg; |
my $noresmsg; |
if ($allowed && $hiddentop && !$supplementalflag) { |
if ($allowed && $hiddentop && !$supplementalflag) { |
$noresmsg = &mt('Main Content Hidden'); |
$noresmsg = &mt('Main Content Hidden'); |
} else { |
} else { |
$noresmsg = &mt('Currently empty'); |
$noresmsg = &mt('Currently empty'); |
} |
} |
Line 3548 sub multiple_check_form {
|
Line 3512 sub multiple_check_form {
|
return unless (ref($listsref) eq 'HASH'); |
return unless (ref($listsref) eq 'HASH'); |
my $disabled; |
my $disabled; |
unless ($canedit) { |
unless ($canedit) { |
$disabled = 'disabled="disabled"'; |
$disabled = 'disabled="disabled"'; |
} |
} |
my $output = |
my $output = |
'<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'. |
'<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'. |
Line 3586 sub multiple_check_form {
|
Line 3550 sub multiple_check_form {
|
'</label></span></td>'."\n". |
'</label></span></td>'."\n". |
'<td class="LC_docs_entry_parameter">'. |
'<td class="LC_docs_entry_parameter">'. |
'<span class="LC_nobreak LC_docs_copy">'. |
'<span class="LC_nobreak LC_docs_copy">'. |
'<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy'). |
'<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'. $disabled.' />'.&mt('Copy'). |
'</label></span></td>'. |
'</label></span></td>'. |
'</tr></table>'."\n"; |
'</tr></table>'."\n"; |
} |
} |
Line 3628 sub process_file_upload {
|
Line 3592 sub process_file_upload {
|
my $quotatype = 'unofficial'; |
my $quotatype = 'unofficial'; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$quotatype = 'community'; |
$quotatype = 'community'; |
|
} elsif ($crstype eq 'Placement') { |
|
$quotatype = 'placement'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
$quotatype = 'official'; |
$quotatype = 'official'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
Line 3821 sub entryline {
|
Line 3787 sub entryline {
|
$renametitle=~s/"/%22/g; |
$renametitle=~s/"/%22/g; |
$renametitle=~s/ /%20/g; |
$renametitle=~s/ /%20/g; |
$oldtitle = $renametitle; |
$oldtitle = $renametitle; |
$renametitle=~s/\'\;/\\\'/g; |
$renametitle=~s/\'/\\\'/g; |
my $line=&Apache::loncommon::start_data_table_row(); |
my $line=&Apache::loncommon::start_data_table_row(); |
my ($form_start,$form_end,$form_common,$form_param); |
my ($form_start,$form_end,$form_common,$form_param); |
# Edit commands |
# Edit commands |
Line 3901 END
|
Line 3867 END
|
'sv' => 'Save', |
'sv' => 'Save', |
'ul' => 'URL', |
'ul' => 'URL', |
'ti' => 'Title', |
'ti' => 'Title', |
'er' => 'Editing rights unavailable for your current role.', |
'er' => 'Editing rights unavailable for your current role.', |
); |
); |
my %denied = &action_restrictions($coursenum,$coursedom,$url, |
my %denied = &action_restrictions($coursenum,$coursedom,$url, |
$env{'form.folderpath'}, |
$env{'form.folderpath'}, |
Line 4050 END
|
Line 4016 END
|
my ($editlink,$extresform,$anchor,$hiddenres,$nomodal); |
my ($editlink,$extresform,$anchor,$hiddenres,$nomodal); |
my $orig_url = $url; |
my $orig_url = $url; |
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; |
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; |
if ($container eq 'page') { |
$url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}; |
$url=~s{^http(|s)(:|:)//}{/ext/}; |
|
} else { |
|
$url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}; |
|
} |
|
if (!$supplementalflag && $residx && $symb) { |
if (!$supplementalflag && $residx && $symb) { |
if ((!$isfolder) && (!$ispage)) { |
if ((!$isfolder) && (!$ispage)) { |
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
if (($url =~ m{^ext/}) && ($container eq 'page')) { |
$url=&Apache::lonnet::clutter($url); |
$url=&Apache::lonnet::clutter_with_no_wrapper($url); |
|
} else { |
|
$url=&Apache::lonnet::clutter($url); |
|
} |
|
if ($url=~/^\/*uploaded\//) { |
if ($url=~/^\/*uploaded\//) { |
$url=~/\.(\w+)$/; |
$url=~/\.(\w+)$/; |
my $embstyle=&Apache::loncommon::fileembstyle($1); |
my $embstyle=&Apache::loncommon::fileembstyle($1); |
Line 4073 END
|
Line 4031 END
|
} elsif ($url!~/\.(sequence|page)$/) { |
} elsif ($url!~/\.(sequence|page)$/) { |
$url='/adm/coursedocs/showdoc'.$url; |
$url='/adm/coursedocs/showdoc'.$url; |
} |
} |
} elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) { |
} elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) { |
my $wrapped = $1; |
my $wrapped = $1; |
my $exturl = $2; |
my $exturl = $2; |
if (($wrapped eq '') && ($container ne 'page')) { |
if ($wrapped eq '') { |
$url='/adm/wrapper'.$url; |
$url='/adm/wrapper'.$url; |
} |
} |
if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) { |
if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) { |
$nomodal = 1; |
$nomodal = 1; |
} |
} |
} elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) { |
} elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) { |
$url='/adm/wrapper'.$url; |
$url='/adm/wrapper'.$url; |
} elsif ($url eq "/public/$coursedom/$coursenum/syllabus") { |
} elsif ($url eq "/public/$coursedom/$coursenum/syllabus") { |
if (($ENV{'SERVER_PORT'} == 443) && |
if (($ENV{'SERVER_PORT'} == 443) && |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
unless (&Apache::lonnet::uses_sts()) { |
$url .= '?usehttp=1'; |
$url .= '?usehttp=1'; |
|
} |
|
$nomodal = 1; |
$nomodal = 1; |
} |
} |
} |
} |
if (&Apache::lonnet::symbverify($symb,$url)) { |
if (&Apache::lonnet::symbverify($symb,$url)) { |
my $shownsymb = $symb; |
my $shownsymb = $symb; |
if ($isexternal) { |
if ($isexternal) { |
$url =~ s/\#[^#]+$//; |
if ($url =~ /^([^#]+)#([^#]+)$/) { |
if ($container eq 'page') { |
$url = $1; |
$url = &Apache::lonnet::clutter($url); |
$anchor = $2; |
|
if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) { |
|
$shownsymb = $1.&escape('#').$anchor; |
|
} |
} |
} |
} |
} |
unless ($env{'request.role.adv'}) { |
unless ($env{'request.role.adv'}) { |
Line 4111 END
|
Line 4070 END
|
} |
} |
} |
} |
if ($url ne '') { |
if ($url ne '') { |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb); |
$url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&'); |
} |
} |
} elsif (!$env{'request.role.adv'}) { |
} elsif (!$env{'request.role.adv'}) { |
my $checkencrypt; |
my $checkencrypt; |
Line 4124 END
|
Line 4083 END
|
} |
} |
if (ref($$navmapref)) { |
if (ref($$navmapref)) { |
if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') { |
if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') { |
$checkencrypt = 1; |
$checkencrypt = 1; |
} |
} |
} |
} |
} |
} |
Line 4132 END
|
Line 4091 END
|
my $shownsymb = &Apache::lonenc::encrypted($symb); |
my $shownsymb = &Apache::lonenc::encrypted($symb); |
my $shownurl = &Apache::lonenc::encrypted($url); |
my $shownurl = &Apache::lonenc::encrypted($url); |
if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) { |
if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) { |
$url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb); |
$url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&'); |
if ($env{'request.enc'} ne '') { |
if ($env{'request.enc'} ne '') { |
delete($env{'request.enc'}); |
delete($env{'request.enc'}); |
} |
} |
Line 4152 END
|
Line 4111 END
|
$url = $1; |
$url = $1; |
$anchor = $2; |
$anchor = $2; |
if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) { |
if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) { |
unless (&Apache::lonnet::uses_sts()) { |
if ($hostname ne '') { |
if ($hostname ne '') { |
$url = 'http://'.$hostname.$url; |
$url = 'http://'.$hostname.$url; |
|
} |
|
$url .= (($url =~ /\?/) ? '&':'?').'usehttp=1'; |
|
} |
} |
$nomodal = 1; |
$nomodal = 1; |
} |
} |
Line 4164 END
|
Line 4120 END
|
} elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) { |
} elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) { |
if (($ENV{'SERVER_PORT'} == 443) && |
if (($ENV{'SERVER_PORT'} == 443) && |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
unless (&Apache::lonnet::uses_sts()) { |
if ($hostname ne '') { |
if ($hostname ne '') { |
$url = 'http://'.$hostname.$url; |
$url = 'http://'.$hostname.$url; |
|
} |
|
$url .= (($url =~ /\?/) ? '&':'?').'usehttp=1'; |
|
} |
} |
|
$url .= (($url =~ /\?/) ? '&':'?').'usehttp=1'; |
$nomodal = 1; |
$nomodal = 1; |
} |
} |
} |
} |
Line 4202 END
|
Line 4156 END
|
my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1); |
my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1); |
unless (@resources) { |
unless (@resources) { |
$hiddenmap = 1; |
$hiddenmap = 1; |
unless ($env{'request.role.adv'}) { |
unless ($env{'request.role.adv'}) { |
$url = ''; |
$url = ''; |
$hiddenfolder = 1; |
$hiddenfolder = 1; |
} |
} |
Line 4218 END
|
Line 4172 END
|
} |
} |
} |
} |
} |
} |
|
|
# Append randompick number, hidden, and encrypted with ":" to foldername, |
# Append randompick number, hidden, and encrypted with ":" to foldername, |
# so it gets transferred between levels |
# so it gets transferred between levels |
$folderpath.=$containerarg.'&'.$foldername. |
$folderpath.=$containerarg.'&'.$foldername. |
':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage; |
':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage; |
unless ($url eq '') { |
unless ($url eq '') { |
$url.='folderpath='.&escape($folderpath); |
$url.='folderpath='.&escape($folderpath); |
Line 4257 $form_common."\n".
|
Line 4211 $form_common."\n".
|
$form_param."\n". |
$form_param."\n". |
$form_common."\n". |
$form_common."\n". |
'<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'. |
'<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'. |
$form_end; |
$form_end; |
} |
} |
} elsif ($supplementalflag && !$allowed) { |
} elsif ($supplementalflag && !$allowed) { |
my $isexttool; |
my $isexttool; |
Line 4334 $form_end;
|
Line 4288 $form_end;
|
$anchor = '#'.&HTML::Entities::encode($anchor,'"<>&'); |
$anchor = '#'.&HTML::Entities::encode($anchor,'"<>&'); |
} |
} |
} |
} |
|
|
if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) { |
if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) { |
$link = 'http://'.$hostname.$url; |
$link = 'http://'.$hostname.$url; |
} else { |
} else { |
$link = $url; |
$link = $url; |
} |
} |
$link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.$anchor); |
$link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'. |
|
(($anchor ne '')?$anchor:'')); |
if ($nomodal) { |
if ($nomodal) { |
$line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'. |
$line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'. |
'<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>'; |
'<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>'; |
Line 4362 $form_end;
|
Line 4316 $form_end;
|
$line.=&Apache::loncommon::modal_link($link,$title,600,500); |
$line.=&Apache::loncommon::modal_link($link,$title,600,500); |
} |
} |
} elsif (($hiddenfolder) || ($hiddenres)) { |
} elsif (($hiddenfolder) || ($hiddenres)) { |
$line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>'; |
$line.=$title.' <span class="LC_warning LC_docs_reinit_warn">'.&mt('(Hidden)').'</span>'; |
} else { |
} else { |
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>'; |
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>'; |
} |
} |
Line 4511 sub new_timebased_suffix {
|
Line 4465 sub new_timebased_suffix {
|
} |
} |
} |
} |
if ($freedlock ne 'ok') { |
if ($freedlock ne 'ok') { |
$locknotfreed = |
$locknotfreed = |
'<div class="LC_error">'. |
'<div class="LC_error">'. |
&mt('There was a problem removing a lockfile.').' '; |
&mt('There was a problem removing a lockfile.').' '; |
if ($type eq 'paste') { |
if ($type eq 'paste') { |
Line 4519 sub new_timebased_suffix {
|
Line 4473 sub new_timebased_suffix {
|
$locknotfreed = |
$locknotfreed = |
'<div class="LC_error">'. |
'<div class="LC_error">'. |
&mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '. |
&mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '. |
|
|
&mt('As a result addition of items to the clipboard will be unavailable until your next log-in.'); |
&mt('As a result addition of items to the clipboard will be unavailable until your next log-in.'); |
} else { |
} else { |
$locknotfreed .= |
$locknotfreed .= |
&mt('This will prevent addition of items to the clipboard until your next log-in.'); |
&mt('This will prevent addition of items to the clipboard until your next log-in.'); |
} |
} |
Line 4584 sub untiehash {
|
Line 4538 sub untiehash {
|
|
|
|
|
sub checkonthis { |
sub checkonthis { |
my ($r,$url,$level,$title,$checkstale)=@_; |
my ($r,$url,$level,$title)=@_; |
$url=&unescape($url); |
$url=&unescape($url); |
$alreadyseen{$url}=1; |
$alreadyseen{$url}=1; |
$r->rflush(); |
$r->rflush(); |
Line 4599 sub checkonthis {
|
Line 4553 sub checkonthis {
|
$r->print('<a href="'.$url.'" target="cat">'. |
$r->print('<a href="'.$url.'" target="cat">'. |
($title?$title:$url).'</a> '); |
($title?$title:$url).'</a> '); |
if ($url=~/^\/res\//) { |
if ($url=~/^\/res\//) { |
my $updated; |
|
if (($checkstale) && ($url !~ m{^/res/lib/templates/}) && |
|
($url !~ /\.\d+\.\w+$/)) { |
|
$updated = &Apache::lonnet::remove_stale_resfile($url); |
|
} |
|
my $result=&Apache::lonnet::repcopy( |
my $result=&Apache::lonnet::repcopy( |
&Apache::lonnet::filelocation('',$url)); |
&Apache::lonnet::filelocation('',$url)); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
if ($updated) { |
|
$r->print('<br />'); |
|
for (my $i=0;$i<=$level*5;$i++) { |
|
$r->print(' '); |
|
} |
|
$r->print('- '.&mt('Outdated copy removed')); |
|
} |
|
$r->rflush(); |
$r->rflush(); |
&Apache::lonnet::countacc($url); |
&Apache::lonnet::countacc($url); |
$url=~/\.(\w+)$/; |
$url=~/\.(\w+)$/; |
Line 4648 sub checkonthis {
|
Line 4590 sub checkonthis {
|
&Apache::lonnet::metadata($url,'dependencies'); |
&Apache::lonnet::metadata($url,'dependencies'); |
foreach my $dep (split(/\,/,$dependencies)) { |
foreach my $dep (split(/\,/,$dependencies)) { |
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) { |
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) { |
&checkonthis($r,$dep,$level+1,'',$checkstale); |
&checkonthis($r,$dep,$level+1); |
} |
} |
} |
} |
} elsif ($result eq 'unavailable') { |
} elsif ($result eq 'unavailable') { |
Line 4662 sub checkonthis {
|
Line 4604 sub checkonthis {
|
} else { |
} else { |
$r->print('<span class="LC_error">'.&mt('access denied').'</span>'); |
$r->print('<span class="LC_error">'.&mt('access denied').'</span>'); |
} |
} |
if (($updated) && ($result ne 'ok')) { |
|
$r->print('<br />'.&mt('Outdated copy removed')); |
|
} |
|
} |
} |
} |
} |
} |
} |
Line 4717 sub list_symbs {
|
Line 4656 sub list_symbs {
|
$r->print(&endContentScreen()); |
$r->print(&endContentScreen()); |
} |
} |
|
|
sub short_urls { |
|
my ($r,$canedit) = @_; |
|
my $crstype = &Apache::loncommon::course_type(); |
|
my $formname = 'shortenurl'; |
|
$r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs')); |
|
$r->print(&startContentScreen('tools')); |
|
my ($navmap,$errormsg) = |
|
&Apache::loncourserespicker::get_navmap_object($crstype,'shorturls'); |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my (%maps,%resources,%titles); |
|
if (!ref($navmap)) { |
|
$r->print($errormsg. |
|
&endContentScreen()); |
|
return ''; |
|
} else { |
|
$r->print('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n"); |
|
$r->rflush(); |
|
my $readonly; |
|
if ($canedit) { |
|
my ($numnew,$errors) = &Apache::loncommon::make_short_symbs($cdom,$cnum,$navmap); |
|
if ($numnew) { |
|
$r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>'); |
|
} |
|
if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) { |
|
$r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>'); |
|
foreach my $error (@{$errors}) { |
|
$r->print('<li>'.$error.'</li>'); |
|
} |
|
$r->print('</ul><br />'); |
|
} |
|
} else { |
|
$readonly = 1; |
|
} |
|
my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum); |
|
$r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef, |
|
undef,undef,undef,undef,undef,\%currtiny,$readonly)); |
|
} |
|
$r->print(&endContentScreen()); |
|
} |
|
|
|
sub contentverifyform { |
|
my ($r) = @_; |
|
my $crstype = &Apache::loncommon::course_type(); |
|
$r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content')); |
|
$r->print(&startContentScreen('tools')); |
|
$r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>'); |
|
$r->print('<form method="post" action="/adm/coursedocs"><p>'. |
|
&mt('Include a check if files copied from elsewhere are up to date (will increase verification time)?'). |
|
' <span class="LC_nobreak">'. |
|
'<label><input type="radio" name="checkstale" value="0" checked="checked" />'. |
|
&mt('No').'</label>'.(' 'x2). |
|
'<label><input type="radio" name="checkstale" value="1" />'. |
|
&mt('Yes').'</label></span></p><p>'. |
|
'<input type="submit" value="'.&mt('Verify content').' "/>'. |
|
'<input type="hidden" value="1" name="tools" />'. |
|
'<input type="hidden" value="1" name="verify" /></p></form>'); |
|
$r->print(&endContentScreen()); |
|
return; |
|
} |
|
|
|
sub verifycontent { |
sub verifycontent { |
my ($r,$checkstale) = @_; |
my ($r) = @_; |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
$r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content')); |
$r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content')); |
Line 4802 sub verifycontent {
|
Line 4679 sub verifycontent {
|
} |
} |
} |
} |
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) { |
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) { |
&checkonthis($r,$hash{$key},0,$hash{'title_'.$1},$checkstale); |
&checkonthis($r,$hash{$key},0,$hash{'title_'.$1}); |
} |
} |
} |
} |
&untiehash(); |
&untiehash(); |
Line 4874 sub checkversions {
|
Line 4751 sub checkversions {
|
} |
} |
if ($haschanged) { |
if ($haschanged) { |
if (&Apache::lonnet::put('resourceversions',\%newsetversions, |
if (&Apache::lonnet::put('resourceversions',\%newsetversions, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
$r->print(&Apache::loncommon::confirmwrapper( |
$r->print(&Apache::loncommon::confirmwrapper( |
&Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved')))); |
&Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved')))); |
} else { |
} else { |
Line 5007 ENDHEADERS
|
Line 4884 ENDHEADERS
|
return; |
return; |
} |
} |
$r->print( |
$r->print( |
'<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'. |
'<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'. |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
'<th>'.&mt('Resources').'</th>'. |
'<th>'.&mt('Resources').'</th>'. |
Line 5050 ENDHEADERS
|
Line 4927 ENDHEADERS
|
$setversions{$linkurl}, |
$setversions{$linkurl}, |
'set_version_'.$linkurl, |
'set_version_'.$linkurl, |
{'select_form_order' => ['',1..$currentversion,'mostrecent'], |
{'select_form_order' => ['',1..$currentversion,'mostrecent'], |
'' => '', |
'' => '', |
'mostrecent' => &mt('most recent'), |
'mostrecent' => &mt('most recent'), |
map {$_,$_} (1..$currentversion)},'',$readonly)); |
map {$_,$_} (1..$currentversion)},'',$readonly)); |
my $lastold=1; |
my $lastold=1; |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
my $url=$root.'.'.$prevvers.'.'.$extension; |
my $url=$root.'.'.$prevvers.'.'.$extension; |
Line 5189 sub startContentScreen {
|
Line 5066 sub startContentScreen {
|
if (($mode eq 'navmaps') || ($mode eq 'supplemental')) { |
if (($mode eq 'navmaps') || ($mode eq 'supplemental')) { |
$output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n"; |
$output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n"; |
$output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n"; |
$output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n"; |
|
$output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n"; |
$output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>'; |
$output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>'; |
} else { |
} else { |
$output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n"; |
$output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n"; |
Line 5226 sub handler {
|
Line 5104 sub handler {
|
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
|
|
# get docroot |
|
my $londocroot = $r->dir_config('lonDocRoot'); |
|
|
# graphics settings |
# graphics settings |
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/'); |
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/'); |
|
|
# |
# |
# --------------------------------------------- Initialize help topics for this |
# --------------------------------------------- Initialize help topics for this |
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', |
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', |
'Adding_External_Resource','Adding_External_Tool', |
'Adding_External_Resource','Adding_External_Tool', |
'Navigate_Content','Adding_Folders','Docs_Overview', |
'Navigate_Content','Adding_Folders','Docs_Overview', |
'Load_Map','Supplemental','Score_Upload_Form', |
'Load_Map','Supplemental','Score_Upload_Form', |
'Adding_Pages','Importing_LON-CAPA_Resource', |
'Adding_Pages','Importing_LON-CAPA_Resource', |
'Importing_IMS_Course','Uploading_From_Harddrive', |
'Importing_IMS_Course','Uploading_From_Harddrive', |
'Course_Roster','Web_Page','Dropbox','Simple_Problem') { |
'Course_Roster','Web_Page','Dropbox','Simple_Problem') { |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); |
} |
} |
Line 5252 sub handler {
|
Line 5133 sub handler {
|
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); |
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); |
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); |
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); |
|
|
my ($allowed,$canedit,$canview,$disabled); |
my ($allowed,$canedit,$canview,$noendpage,$disabled); |
# URI is /adm/supplemental when viewing supplemental docs in non-edit mode. |
# URI is /adm/supplemental when viewing supplemental docs in non-edit mode. |
unless ($r->uri eq '/adm/supplemental') { |
unless ($r->uri eq '/adm/supplemental') { |
# does this user have privileges to modify content. |
# does this user have privileges to modify content. |
Line 5269 sub handler {
|
Line 5150 sub handler {
|
$disabled = ' disabled="disabled"'; |
$disabled = ' disabled="disabled"'; |
} |
} |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); |
if ($env{'form.inhibitmenu'}) { |
|
unless ($env{'form.inhibitmenu'} eq 'yes') { |
|
delete($env{'form.inhibitmenu'}); |
|
} |
|
} |
|
|
|
if ($allowed && $env{'form.verify'}) { |
if ($allowed && $env{'form.verify'}) { |
&init_breadcrumbs('verify','Verify Content','Docs_Verify_Content'); |
&init_breadcrumbs('verify','Verify Content','Docs_Verify_Content'); |
if (!$canedit) { |
&verifycontent($r); |
&verifycontent($r); |
|
} elsif (($env{'form.checkstale'} ne '') && ($env{'form.checkstale'} =~ /^\d$/)) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1&verify=1&checkstale=$env{'form.checkstale'}", |
|
text=>'Results', |
|
faq=>273, |
|
bug=>'Instructor Interface'}); |
|
&verifycontent($r,$env{'form.checkstale'}); |
|
} else { |
|
&contentverifyform($r); |
|
} |
|
} elsif ($allowed && $env{'form.listsymbs'}) { |
} elsif ($allowed && $env{'form.listsymbs'}) { |
&init_breadcrumbs('listsymbs','List Content IDs'); |
&init_breadcrumbs('listsymbs','List Content IDs'); |
&list_symbs($r); |
&list_symbs($r); |
} elsif ($allowed && $env{'form.shorturls'}) { |
|
&init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs'); |
|
&short_urls($r,$canedit); |
|
} elsif ($allowed && $env{'form.docslog'}) { |
} elsif ($allowed && $env{'form.docslog'}) { |
&init_breadcrumbs('docslog','Show Log'); |
&init_breadcrumbs('docslog','Show Log'); |
my $folder = $env{'form.folder'}; |
my $folder = $env{'form.folder'}; |
Line 5307 sub handler {
|
Line 5169 sub handler {
|
} elsif ($canedit && $env{'form.dumpcourse'}) { |
} elsif ($canedit && $env{'form.dumpcourse'}) { |
&init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space'); |
&init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space'); |
&dumpcourse($r); |
&dumpcourse($r); |
} elsif ($allowed && $env{'form.exportcourse'}) { |
} elsif ($canedit && $env{'form.exportcourse'}) { |
&init_breadcrumbs('exportcourse','IMS Export'); |
&init_breadcrumbs('exportcourse','IMS Export'); |
&Apache::imsexport::exportcourse($r); |
&Apache::imsexport::exportcourse($r); |
} else { |
} else { |
|
if ($canedit && $env{'form.authorrole'}) { |
|
$noendpage = 1; |
|
my ($redirect,$error) = &makenewproblem($r,$coursedom,$coursenum); |
|
if ($redirect) { |
|
if (($env{'form.newresourceadd'}) && ($env{'form.folderpath'})) { |
|
my $container = 'sequence'; |
|
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain, |
|
$is_random_order,$container) = |
|
&Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1); |
|
my (@folders)=split('&',$env{'form.folderpath'}); |
|
$env{'form.foldername'}=&unescape(pop(@folders)); |
|
my $folder=pop(@folders); |
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
|
$folder.'.'.$container); |
|
my $warning; |
|
if ($fatal) { |
|
if ($container eq 'page') { |
|
$warning = &mt('An error occurred retrieving the contents of the current page.'); |
|
} else { |
|
$warning = &mt('An error occurred retrieving the contents of the current folder.'); |
|
} |
|
} else { |
|
my $url = $redirect; |
|
my $srcfile = $londocroot.$url; |
|
$url =~ s{^/priv/}{/res/}; |
|
my $targetfile = $londocroot.$url; |
|
my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes')); |
|
my $output = &Apache::lonpublisher::batchpublish($r,$srcfile,$targetfile,$nokeyref,1); |
|
$env{'form.folder'} = $folder; |
|
&snapshotbefore(); |
|
my $title = &LONCAPA::map::qtunescape($env{'form.newresourcetitle'}); |
|
my $ext = 'false'; |
|
my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url)); |
|
$LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url). |
|
':'.$ext.':normal:res'; |
|
push(@LONCAPA::map::order,$newidx); |
|
&LONCAPA::map::storeparameter($newidx,'parameter_hiddenresource','yes', |
|
'string_yesno'); |
|
&remember_parms($newidx,'hiddenresource','set','yes'); |
|
($errtext,$fatal) = |
|
&storemap($coursenum, $coursedom, $folder.'.'.$container,1); |
|
&log_differences($plain); |
|
&mark_hash_old(); |
|
$r->internal_redirect($redirect); |
|
return OK; |
|
} |
|
} |
|
} |
|
} |
# |
# |
# Done catching special calls |
# Done catching special calls |
# The whole rest is for course and supplemental documents and utilities menu |
# The whole rest is for course and supplemental documents and utilities menu |
Line 5321 sub handler {
|
Line 5232 sub handler {
|
'forcesupplement','forcestandard', |
'forcesupplement','forcestandard', |
'tools','symb','command','supppath']); |
'tools','symb','command','supppath']); |
|
|
foreach my $item ('forcesupplement','forcestandard','tools') { |
|
next if ($env{'form.'.$item} eq ''); |
|
unless ($env{'form.'.$item} eq '1') { |
|
delete($env{'form.'.$item}); |
|
} |
|
} |
|
|
|
if ($env{'form.command'}) { |
|
unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) { |
|
delete($env{'form.command'}); |
|
} |
|
} |
|
|
|
if ($env{'form.symb'}) { |
|
my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
|
unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) { |
|
delete($env{'form.symb'}); |
|
} |
|
} |
|
|
|
# standard=1: this is a "new-style" course with an uploaded map as top level |
# standard=1: this is a "new-style" course with an uploaded map as top level |
# standard=2: this is a "old-style" course, and there is nothing we can do |
# standard=2: this is a "old-style" course, and there is nothing we can do |
|
|
Line 5363 sub handler {
|
Line 5254 sub handler {
|
my $toolsflag=0; |
my $toolsflag=0; |
if ($env{'form.tools'}) { $toolsflag=1; } |
if ($env{'form.tools'}) { $toolsflag=1; } |
|
|
if ($env{'form.folderpath'} ne '') { |
|
my @items = split(/\&/,$env{'form.folderpath'}); |
|
my $badpath; |
|
for (my $i=0; $i<@items; $i++) { |
|
my $odd = $i%2; |
|
if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) { |
|
$badpath = 1; |
|
} elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) { |
|
$badpath = 1; |
|
} |
|
last if ($badpath); |
|
} |
|
if ($badpath) { |
|
delete($env{'form.folderpath'}); |
|
} |
|
} |
|
|
|
if ($env{'form.supppath'} ne '') { |
|
my @items = split(/\&/,$env{'form.supppath'}); |
|
my $badpath; |
|
for (my $i=0; $i<@items; $i++) { |
|
my $odd = $i%2; |
|
if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) { |
|
$badpath = 1; |
|
} |
|
last if ($badpath); |
|
} |
|
if ($badpath) { |
|
delete($env{'form.supppath'}); |
|
} |
|
} |
|
|
|
my $script=''; |
my $script=''; |
my $showdoc=0; |
my $showdoc=0; |
my $addentries = {}; |
my $addentries = {}; |
Line 5444 sub handler {
|
Line 5303 sub handler {
|
|
|
if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) { |
if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) { |
if ($supplementalflag) { |
if ($supplementalflag) { |
undef($env{'form.folderpath'}) if ($1 eq 'default'); |
undef($env{'form.folderpath'}) if ($1 eq 'default'); |
} else { |
} else { |
undef($env{'form.folderpath'}) if ($1 eq 'supplemental'); |
undef($env{'form.folderpath'}) if ($1 eq 'supplemental'); |
} |
} |
Line 5465 sub handler {
|
Line 5324 sub handler {
|
.'&'. |
.'&'. |
$env{'form.folderpath'}; |
$env{'form.folderpath'}; |
} |
} |
# If allowed and user's role is not advanced check folderpath is not hidden |
# If allowed and user's role is not advanced check folderpath is not hidden |
if (($allowed) && (!$env{'request.role.adv'}) && |
if (($allowed) && (!$env{'request.role.adv'}) && |
($env{'form.folderpath'} ne '') && (!$supplementalflag)) { |
($env{'form.folderpath'} ne '') && (!$supplementalflag)) { |
my $folderurl; |
my $folderurl; |
my @pathitems = split(/\&/,$env{'form.folderpath'}); |
my @pathitems = split(/\&/,$env{'form.folderpath'}); |
Line 5475 sub handler {
|
Line 5334 sub handler {
|
undef($env{'form.folderpath'}); |
undef($env{'form.folderpath'}); |
} else { |
} else { |
$folderurl = "uploaded/$coursedom/$coursenum/$folder"; |
$folderurl = "uploaded/$coursedom/$coursenum/$folder"; |
if ((split(/\:/,$pathitems[-1]))[5]) { |
if ((split(/\:/,$pathitems[-1]))[4]) { |
$folderurl .= '.page'; |
$folderurl .= '.page'; |
} else { |
} else { |
$folderurl .= '.sequence'; |
$folderurl .= '.sequence'; |
Line 5582 sub handler {
|
Line 5441 sub handler {
|
%ltitools = &Apache::lonnet::get_domain_ltitools($coursedom); |
%ltitools = &Apache::lonnet::get_domain_ltitools($coursedom); |
my $posslti = keys(%ltitools); |
my $posslti = keys(%ltitools); |
my $hostname = $r->hostname(); |
my $hostname = $r->hostname(); |
$script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti, |
$script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti, |
$canedit,$hostname,\$navmap). |
$londocroot,$canedit,$hostname,\$navmap). |
&history_tab_js(). |
&history_tab_js(). |
&inject_data_js(). |
&inject_data_js(). |
&Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid). |
&Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid). |
Line 5604 sub handler {
|
Line 5463 sub handler {
|
.$script."\n" |
.$script."\n" |
.'// ]]>'."\n" |
.'// ]]>'."\n" |
.'</script>'."\n" |
.'</script>'."\n" |
.'<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>'."\n"; |
.'<script type="text/javascript" |
|
src="/res/adm/includes/file_upload.js"></script>'."\n"; |
|
|
# Breadcrumbs |
# Breadcrumbs |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
Line 5666 sub handler {
|
Line 5526 sub handler {
|
undef($hadchanges); |
undef($hadchanges); |
$uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom, |
$uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom, |
\%allfiles,\%codebase,$context,$crstype); |
\%allfiles,\%codebase,$context,$crstype); |
undef($navmap); |
|
if ($hadchanges) { |
if ($hadchanges) { |
&mark_hash_old(); |
&mark_hash_old(); |
} |
} |
Line 5723 sub handler {
|
Line 5582 sub handler {
|
'impo' => 'Import', |
'impo' => 'Import', |
'lnks' => 'Import from Stored Links', |
'lnks' => 'Import from Stored Links', |
'impm' => 'Import from Assembled Map', |
'impm' => 'Import from Assembled Map', |
|
'imcr' => 'Import from Course Resources', |
'extr' => 'External Resource', |
'extr' => 'External Resource', |
'extt' => 'External Tool', |
'extt' => 'External Tool', |
'selm' => 'Select Map', |
'selm' => 'Select Map', |
'load' => 'Load Map', |
'load' => 'Load Map', |
'newf' => 'New Folder', |
'newf' => 'New Folder', |
Line 5733 sub handler {
|
Line 5593 sub handler {
|
'navc' => 'Table of Contents', |
'navc' => 'Table of Contents', |
'sipa' => 'Simple Course Page', |
'sipa' => 'Simple Course Page', |
'sipr' => 'Simple Problem', |
'sipr' => 'Simple Problem', |
'webp' => 'Blank Web Page (editable)', |
'webp' => 'Blank Web Page (editable)', |
|
'stpr' => 'Standard Problem', |
|
'news' => 'New sub-directory', |
|
'crpr' => 'Create Problem', |
'drbx' => 'Drop Box', |
'drbx' => 'Drop Box', |
'scuf' => 'External Scores (handgrade, upload, clicker)', |
'scuf' => 'External Scores (handgrade, upload, clicker)', |
'bull' => 'Discussion Board', |
'bull' => 'Discussion Board', |
Line 5747 sub handler {
|
Line 5610 sub handler {
|
'se' => 'Select', |
'se' => 'Select', |
'file' => 'File', |
'file' => 'File', |
'title' => 'Title', |
'title' => 'Title', |
|
'addp' => 'Add Placeholder to course?', |
|
'uste' => 'Use Template?', |
|
'fnam' => 'File Name:', |
|
'loca' => 'Location:', |
|
'dire' => 'Directory:', |
|
'cate' => 'Category:', |
|
'tmpl' => 'Template:', |
'comment' => 'Comment', |
'comment' => 'Comment', |
'parse' => 'Upload embedded images/multimedia files if HTML file', |
'parse' => 'Upload embedded images/multimedia files if HTML file', |
'bb5' => 'Blackboard 5', |
'bb5' => 'Blackboard 5', |
'bb6' => 'Blackboard 6', |
'bb6' => 'Blackboard 6', |
'angel5' => 'ANGEL 5.5', |
'angel5' => 'ANGEL 5.5', |
'webctce4' => 'WebCT 4 Campus Edition', |
'webctce4' => 'WebCT 4 Campus Edition', |
|
'yes' => 'Yes', |
|
'no' => 'No', |
'er' => 'Editing rights unavailable for your current role.', |
'er' => 'Editing rights unavailable for your current role.', |
); |
); |
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
|
|
# Calculate free quota space for a user or course. A javascript function checks |
# Calculate free quota space for a user or course. A javascript function checks |
# file size to determine if upload should be allowed. |
# file size to determine if upload should be allowed. |
my $quotatype = 'unofficial'; |
my $quotatype = 'unofficial'; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$quotatype = 'community'; |
$quotatype = 'community'; |
|
} elsif ($crstype eq 'Placement') { |
|
$quotatype = 'placement'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) { |
$quotatype = 'official'; |
$quotatype = 'official'; |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) { |
Line 5791 sub handler {
|
Line 5666 sub handler {
|
my $fileupload=(<<FIUP); |
my $fileupload=(<<FIUP); |
$quotainfo |
$quotainfo |
$lt{'file'}:<br /> |
$lt{'file'}:<br /> |
<input type="file" name="uploaddoc" class="LC_flUpload" size="40" $disabled /> |
<input type="file" name="uploaddoc" class="flUpload" size="40" $disabled /> |
<input type="hidden" id="LC_free_space" value="$free_space" /> |
<input type="hidden" id="free_space" value="$free_space" /> |
FIUP |
FIUP |
|
|
my $checkbox=(<<CHBO); |
my $checkbox=(<<CHBO); |
Line 5839 IMSFORM
|
Line 5714 IMSFORM
|
<fieldset id="uploaddocform" style="display: none;"> |
<fieldset id="uploaddocform" style="display: none;"> |
<legend>$lt{'upfi'}</legend> |
<legend>$lt{'upfi'}</legend> |
<input type="hidden" name="active" value="aa" /> |
<input type="hidden" name="active" value="aa" /> |
$fileupload |
$fileupload |
<br /> |
<br /> |
$lt{'title'}:<br /> |
$lt{'title'}:<br /> |
<input type="text" size="60" name="comment" $disabled /> |
<input type="text" size="60" name="comment" $disabled /> |
Line 5857 FUFORM
|
Line 5732 FUFORM
|
|
|
my $mapimportjs; |
my $mapimportjs; |
if ($canedit) { |
if ($canedit) { |
$mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');"; |
$mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');"; |
} else { |
} else { |
$mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');"; |
$mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');"; |
} |
} |
Line 5878 FUFORM
|
Line 5753 FUFORM
|
</form> |
</form> |
|
|
SEDFFORM |
SEDFFORM |
|
my $importcrsresform; |
|
my ($numdirs,$pickfile) = |
|
&Apache::loncommon::import_crsauthor_form('crsresimportform','coursepath','coursefile', |
|
"resize_scrollbox('contentscroll','1','0');", |
|
undef,'res'); |
|
if ($pickfile) { |
|
$importcrsresform=(<<CRSFORM); |
|
<a class="LC_menubuttons_link" href="javascript:toggleImportCrsres('res','$numdirs');"> |
|
$lt{'imcr'}</a>$help{'Course_Resources'} |
|
<form action="/adm/coursedocs" method="post" name="crsresimportform" onsubmit="return validImportCrsRes();"> |
|
<fieldset id="importcrsresform" style="display: none;"> |
|
<legend>$lt{'imcr'}</legend> |
|
<input type="hidden" name="active" value="bb" /> |
|
$pickfile |
|
<p> |
|
$lt{'title'}: <input type="textbox" name="crsrestitle" value="" $disabled /> |
|
</p> |
|
<input type="hidden" name="importdetail" value="" /> |
|
<input type="submit" name="crsres" value="$lt{'impo'}" $disabled /> |
|
</fieldset> |
|
</form> |
|
CRSFORM |
|
} |
|
|
my $fromstoredjs; |
my $fromstoredjs; |
if ($canedit) { |
if ($canedit) { |
$fromstoredjs = 'open_StoredLinks_Import()'; |
$fromstoredjs = 'open_StoredLinks_Import()'; |
} else { |
} else { |
$fromstoredjs = "alert('".&js_escape($lt{'er'})."')"; |
$fromstoredjs = "alert('".&js_escape($lt{'er'})."')"; |
} |
} |
Line 5890 SEDFFORM
|
Line 5788 SEDFFORM
|
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => $pathitem."<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => $pathitem."<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:'.$fromstoredjs.';" />' => '<a class="LC_menubuttons_link" href="javascript:'.$fromstoredjs.';">'.$lt{'lnks'}.'</a>' }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:'.$fromstoredjs.';" />' => '<a class="LC_menubuttons_link" href="javascript:'.$fromstoredjs.';">'.$lt{'lnks'}.'</a>' }, |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform } |
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }, |
); |
); |
|
if ($pickfile) { |
|
push(@importpubforma,{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{imcr}.'" onclick="javascript:toggleImportCrsres(\'res\','."'$numdirs'".');"/>' => $importcrsresform}); |
|
} |
$importpubform = &create_form_ul(&create_list_elements(@importpubforma)); |
$importpubform = &create_form_ul(&create_list_elements(@importpubforma)); |
my $extresourcesform = |
my $extresourcesform = |
&Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem, |
&Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem, |
Line 5943 HIDDENFORM
|
Line 5844 HIDDENFORM
|
} |
} |
|
|
# |
# |
|
|
my $savefolderpath; |
|
my $hostname = $r->hostname(); |
my $hostname = $r->hostname(); |
|
my $savefolderpath; |
|
|
if ($allowed) { |
if ($allowed) { |
my $folder=$env{'form.folder'}; |
my $folder=$env{'form.folder'}; |
Line 6082 NROSTFORM
|
Line 5982 NROSTFORM
|
$help{'Web_Page'} |
$help{'Web_Page'} |
</form> |
</form> |
NWEBFORM |
NWEBFORM |
|
|
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
my %select_menus; |
|
my $numauthor = 0; |
|
my $numcrsdirs = 0; |
|
my $toppath = "/priv/$env{'user.domain'}/$env{'user.name'}"; |
|
if ($env{'user.author'}) { |
|
$numauthor ++; |
|
$select_menus{'author'}->{'text'} = &Apache::lonnet::plaintext('au'); |
|
if (grep(/^\Q$env{'user.home'}\E$/,@ids)) { |
|
my $is_home = 1; |
|
my %subdirs; |
|
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
|
$select_menus{'author'}->{'default'} = '/'; |
|
$select_menus{'author'}->{'select2'}->{'/'} = '/'; |
|
my @ordered = ('/'); |
|
foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
|
$select_menus{'author'}->{'select2'}->{$relpath} = $relpath; |
|
push(@ordered,$relpath); |
|
} |
|
$select_menus{'author'}->{'order'} = \@ordered; |
|
} else { |
|
$select_menus{'author'}->{'select2'}->{'switch'} = &mt('Switch server required'); |
|
$select_menus{'author'}->{'default'} = 'switch'; |
|
$select_menus{'author'}->{'order'} = ['switch']; |
|
} |
|
} |
|
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
|
['active'],['ca','aa']); |
|
my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
|
my %by_roletype; |
|
if (keys(%roleshash)) { |
|
foreach my $entry (keys(%roleshash)) { |
|
my ($auname,$audom,$roletype) = split(/:/,$entry); |
|
my $key = $entry; |
|
$key =~ s/:/___/g; |
|
$by_roletype{$roletype}{$auname.'___'.$audom} = 1; |
|
$select_menus{$key}->{'text'} = &Apache::lonnet::plaintext($roletype)." ($audom/$auname)"; |
|
my $rolehome = &Apache::lonnet::homeserver($auname,$audom); |
|
if (grep(/^\Q$rolehome\E$/,@ids)) { |
|
my $is_home = 1; |
|
my (%subdirs,@ordered); |
|
my $toppath="/priv/$audom/$auname"; |
|
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
|
$select_menus{$key}->{'default'} = '/'; |
|
$select_menus{$key}->{'select2'}->{'/'} = '/'; |
|
my @ordered = ('/'); |
|
foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
|
$select_menus{$key}->{'select2'}->{$relpath} = $relpath; |
|
push(@ordered,$relpath); |
|
} |
|
$select_menus{$key}->{'order'} = \@ordered; |
|
} else { |
|
$select_menus{$key}->{'select2'}->{'switch'} = &mt('Switch server required'); |
|
$select_menus{$key}->{'default'} = 'switch'; |
|
$select_menus{$key}->{'order'} = ['switch']; |
|
} |
|
$numauthor ++; |
|
} |
|
} |
|
my ($pickdir,$showtitle);; |
|
if ($numauthor) { |
|
my @order; |
|
my $defrole; |
|
if ($env{'user.author'}) { |
|
push(@order,'author'); |
|
$defrole = 'author'; |
|
} |
|
if (keys(%by_roletype)) { |
|
foreach my $possrole ('ca','aa') { |
|
if (ref($by_roletype{$possrole}) eq 'HASH') { |
|
foreach my $author (sort { lc($a) cmp lc($b) } (keys(%{$by_roletype{$possrole}}))) { |
|
unless ($defrole) { |
|
$defrole = $author; |
|
} |
|
push(@order,$author.'___'.$possrole); |
|
} |
|
} |
|
} |
|
} |
|
$select_menus{'course'}->{'text'} = &mt('Course Resource'); |
|
if (grep(/^\Q$crshome\E$/,@ids)) { |
|
my $is_home = 1; |
|
my %subdirs; |
|
my $toppath="/priv/$coursedom/$coursenum"; |
|
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
|
$numcrsdirs = keys(%subdirs); |
|
$select_menus{'course'}->{'default'} = '/'; |
|
$select_menus{'course'}->{'select2'}->{'/'} = '/'; |
|
my @ordered = ('/'); |
|
foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
|
$select_menus{'course'}->{'select2'}->{$relpath} = $relpath; |
|
push(@ordered,$relpath); |
|
} |
|
$select_menus{'course'}->{'order'} = \@ordered; |
|
} else { |
|
$select_menus{'course'}->{'select2'}->{'switch'} = &mt('Switch server required'); |
|
$select_menus{'course'}->{'default'} = 'switch'; |
|
$select_menus{'course'}->{'order'} = ['switch']; |
|
} |
|
push(@order,'course'); |
|
$pickdir = $lt{'loca'}. |
|
&Apache::loncommon::linked_select_forms('courseresform','<br />'.$lt{'dire'}, |
|
$defrole,'authorrole','authorpath', |
|
\%select_menus,\@order,'toggleCrsResTitle();', |
|
'','priv').'<br />'; |
|
$showtitle = 'none'; |
|
} else { |
|
my $is_home; |
|
$showtitle = 'inline'; |
|
if (grep(/^\Q$crshome\E$/,@ids)) { |
|
$is_home = 1; |
|
$pickdir .= '<input type="hidden" name="authorrole" value="course" />'; |
|
my $toppath="/priv/$coursedom/$coursenum'}"; |
|
my %subdirs; |
|
&Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs); |
|
$numcrsdirs = keys(%subdirs); |
|
if ($numcrsdirs) { |
|
$pickdir .= &mt('Directory: ').'<select name="authorpath">'."\n". |
|
'<option value="/">/</option>'."\n"; |
|
foreach my $key (sort { lc($a) cmp lc($b) } (keys(%subdirs))) { |
|
$pickdir .= '<option value="'.$key.'">'.$key.'</option>'."\n"; |
|
} |
|
$pickdir .= '</select>'; |
|
} else { |
|
$pickdir .= '<input type="hidden" name="authorpath" value="/" />'."\n"; |
|
} |
|
} |
|
} |
|
|
|
my %seltemplate_menus; |
|
my @files = &Apache::lonhomework::get_template_list('problem'); |
|
my @noexamplelink = ('blank.problem','blank.library','script.library'); |
|
my $currentcategory = ''; |
|
my @ordered = (''); |
|
my %templatehelp; |
|
my $defcategory = ''; |
|
my @catorder = ($defcategory); |
|
$seltemplate_menus{$defcategory}->{'order'} = ['']; |
|
$seltemplate_menus{$defcategory}->{'text'} = ''; |
|
foreach my $file (@files) { |
|
if (ref($file) eq 'ARRAY') { |
|
my ($path,$title,$category,$help) = @{$file}; |
|
next if ($title !~ /\S/); |
|
if (&js_escape($category) ne $currentcategory) { |
|
$currentcategory = &js_escape($category); |
|
push(@catorder,&js_escape($currentcategory)); |
|
$seltemplate_menus{$currentcategory}->{'text'} = $category; |
|
$seltemplate_menus{$currentcategory}->{'default'} = ''; |
|
$seltemplate_menus{$currentcategory}->{'select2'}->{''} = ''; |
|
push(@{$seltemplate_menus{$currentcategory}->{'order'}},''); |
|
} |
|
if ($path) { |
|
$seltemplate_menus{$currentcategory}->{'select2'}->{&js_escape($path)} = $title; |
|
push(@{$seltemplate_menus{$currentcategory}->{'order'}},&js_escape($path)); |
|
if ($help) { |
|
$templatehelp{$path} = $help; |
|
} |
|
} |
|
} |
|
} |
|
|
|
my $templates = $lt{'cate'}.' '. |
|
&Apache::loncommon::linked_select_forms('courseresform','<br />'.$lt{'tmpl'}.' ', |
|
$defcategory,'tempcategory','template', |
|
\%seltemplate_menus,\@catorder, |
|
"resize_scrollbox('contentscroll','1','0');", |
|
"toggleExampleText();",'template').'<br />'; |
|
my $templatepreview = '<a href="#" target="sample" onclick="javascript:getExample(600,420,\'yes\',true); return false;">'. |
|
'<span id="newresexample">'.&mt('Example').'<span></a>'; |
|
my $crsresform=(<<RESFORM); |
|
<a class="LC_menubuttons_link" href="javascript:toggleCrsRes('res','$numauthor','$numcrsdirs');"> |
|
$lt{'stpr'}</a>$help{'Course_Resource'} |
|
<form action="/adm/coursedocs" method="post" name="courseresform"> |
|
<fieldset id="crsresform" style="display:none;"> |
|
<legend>$lt{'stpr'}</legend> |
|
<input type="hidden" name="active" value="ee" /> |
|
<p> |
|
$pickdir |
|
<span class="LC_nobreak">$lt{'news'}? |
|
<label><input type="radio" name="newsubdir" value="0" onclick="toggleNewsubdir(this.form);" checked="checked" $disabled />No</label> |
|
|
|
<label><input type="radio" name="newsubdir" value="1" onclick="toggleNewsubdir(this.form);" $disabled />Yes</label> |
|
</span><span id="newsubdir"></span> |
|
<input type="hidden" name="newsubdirname" id="newsubdirname" value="" autocomplete="off" /> |
|
</p> |
|
$lt{'fnam'} |
|
<input type="text" size="20" name="newresourcename" autocomplete="off" $disabled /> |
|
<p> |
|
<div id="newresource" style="display:$showtitle"> |
|
$lt{'addp'} |
|
<label><input type="radio" name="newresourceadd" value="0" checked="checked" onclick="toggleNewInCourse(this.form);" $disabled /> |
|
$lt{'no'}</label> |
|
<label><input type="radio" name="newresourceadd" value="1" onclick="toggleNewInCourse(this.form);" $disabled /> |
|
$lt{'yes'}</label> |
|
<span id="newrestitle"></span> |
|
<input type="hidden" size="20" name="newresourcetitle" id="newresourcetitle" autocomplete="off" $disabled /> |
|
</div> |
|
</p> |
|
<p> |
|
$lt{'uste'} |
|
<label><input type="radio" name="newresusetemp" value="0" checked="checked" onclick="toggleWithTemplate(this.form);" $disabled /> |
|
$lt{'no'}</label> |
|
<label><input type="radio" name="newresusetemp" value="1" onclick="toggleWithTemplate(this.form);" $disabled /> |
|
$lt{'yes'}</label> |
|
<div id="newrestemplate" style="display:none"> |
|
$templates |
|
$templatepreview |
|
</div> |
|
</p> |
|
<span class="LC_nobreak"> |
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
|
<input type="submit" name="newcrs" value="$lt{'crpr'}" $disabled /> |
|
</span> |
|
</fieldset> |
|
</form> |
|
|
|
RESFORM |
|
|
my $specialdocumentsform; |
my $specialdocumentsform; |
my @specialdocumentsforma; |
my @specialdocumentsforma; |
Line 6169 NGFFORM
|
Line 6286 NGFFORM
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform}, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform}, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{stpr}.'" onclick="javascript:toggleCrsRes(\'res\','."'$numauthor','$numcrsdirs'".');" />'=>$crsresform}, |
); |
); |
$gradingform = &create_form_ul(&create_list_elements(@gradingforma)); |
$gradingform = &create_form_ul(&create_list_elements(@gradingforma)); |
|
|
Line 6203 unless ($container eq 'page') {
|
Line 6320 unless ($container eq 'page') {
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
} |
} |
if ($hadchanges) { |
if ($hadchanges) { |
unless (&is_hash_old()) { |
&mark_hash_old(); |
&mark_hash_old(); |
|
} |
|
} |
} |
|
|
&changewarning($r,''); |
&changewarning($r,''); |
Line 6266 SNFFORM
|
Line 6381 SNFFORM
|
my $supextform = |
my $supextform = |
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
$help{'Adding_External_Resource'}, |
$help{'Adding_External_Resource'}, |
undef,undef,$disabled); |
undef,undef,undef,undef,undef,undef, |
|
$disabled); |
|
|
my $supexttoolform = |
my $supexttoolform = |
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, |
$help{'Adding_External_Tool'}, |
$help{'Adding_External_Tool'}, |
Line 6332 my @supimportdoc = (
|
Line 6449 my @supimportdoc = (
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />' |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />' |
=>$supexttoolform}); |
=>$supexttoolform}); |
} |
} |
push(@supimportdoc, |
push(@supimportdoc, |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />' |
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />' |
=>$supupdocform}, |
=>$supupdocform}, |
); |
); |
|
|
Line 6361 my %suporderhash = (
|
Line 6478 my %suporderhash = (
|
} |
} |
&Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); |
&Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); |
undef($suppchanges); |
undef($suppchanges); |
} |
} |
} |
} |
} |
} |
} elsif ($supplementalflag) { |
} elsif ($supplementalflag) { |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
$supplementalflag,'',$iconpath,$pathitem,'',$hostname); |
$supplementalflag,'',$iconpath,$pathitem,'','',$hostname); |
if ($error) { |
if ($error) { |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
} |
} |
Line 6393 my %suporderhash = (
|
Line 6510 my %suporderhash = (
|
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>'); |
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>'); |
} |
} |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
unless ($noendpage) { |
|
$r->print(&Apache::loncommon::end_page()); |
|
} |
return OK; |
return OK; |
} |
} |
|
|
sub embedded_form_elems { |
sub embedded_form_elems { |
my ($phase,$primaryurl,$newidx) = @_; |
my ($phase,$primaryurl,$newidx) = @_; |
my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
$newidx =~s /\D+//g; |
|
return <<STATE; |
return <<STATE; |
<input type="hidden" name="folderpath" value="$folderpath" /> |
<input type="hidden" name="folderpath" value="$folderpath" /> |
<input type="hidden" name="cmd" value="upload_embedded" /> |
<input type="hidden" name="cmd" value="upload_embedded" /> |
Line 6421 sub embedded_destination {
|
Line 6539 sub embedded_destination {
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
$destination .= $2.'/'; |
$destination .= $2.'/'; |
} |
} |
my $newidx = $env{'form.newidx'}; |
$destination .= $env{'form.newidx'}; |
$newidx =~s /\D+//g; |
|
if ($newidx) { |
|
$destination .= $newidx; |
|
} |
|
my $dir_root = '/userfiles'; |
my $dir_root = '/userfiles'; |
return ($destination,$dir_root); |
return ($destination,$dir_root); |
} |
} |
Line 6451 sub decompression_info {
|
Line 6565 sub decompression_info {
|
} |
} |
unshift(@hiddens,$pathitem); |
unshift(@hiddens,$pathitem); |
foreach my $item (@hiddens) { |
foreach my $item (@hiddens) { |
if ($item eq 'newidx') { |
|
next if ($env{'form.'.$item} =~ /\D/); |
|
} |
|
if ($env{'form.'.$item}) { |
if ($env{'form.'.$item}) { |
$hiddenelem .= '<input type="hidden" name="'.$item.'" value="'. |
$hiddenelem .= '<input type="hidden" name="'.$item.'" value="'. |
&HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n"; |
&HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n"; |
Line 6566 sub generate_admin_menu {
|
Line 6677 sub generate_admin_menu {
|
'vc' => 'Verify Content', |
'vc' => 'Verify Content', |
'cv' => 'Check/Set Resource Versions', |
'cv' => 'Check/Set Resource Versions', |
'ls' => 'List Resource Identifiers', |
'ls' => 'List Resource Identifiers', |
'ct' => 'Display/Set Shortened URLs for Deep-linking', |
|
'imse' => 'Export contents to IMS Archive', |
'imse' => 'Export contents to IMS Archive', |
'dcd' => "Copy $crstype Content to Authoring Space", |
'dcd' => "Copy $crstype Content to Authoring Space", |
); |
); |
Line 6617 sub generate_admin_menu {
|
Line 6727 sub generate_admin_menu {
|
icon => 'symbs.png', |
icon => 'symbs.png', |
linktitle => "List the unique identifier used for each resource instance in your $lc_crstype" |
linktitle => "List the unique identifier used for each resource instance in your $lc_crstype" |
}, |
}, |
{ linktext => $lt{'ct'}, |
|
url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')", |
|
permission => 'F', |
|
help => 'Docs_Short_URLs', |
|
icon => 'shorturls.png', |
|
linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking" |
|
}, |
|
] |
] |
}); |
}); |
if ($canedit) { |
if ($canedit) { |
Line 6755 END
|
Line 6858 END
|
|
|
sub editing_js { |
sub editing_js { |
my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti, |
my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti, |
$canedit,$hostname,$navmapref) = @_; |
$londocroot,$canedit,$hostname,$navmapref) = @_; |
my %js_lt = &Apache::lonlocal::texthash( |
my %js_lt = &Apache::lonlocal::texthash( |
p_mnf => 'Name of New Folder', |
p_mnf => 'Name of New Folder', |
t_mnf => 'New Folder', |
t_mnf => 'New Folder', |
Line 6767 sub editing_js {
|
Line 6870 sub editing_js {
|
p_mdb => 'Title for the Drop Box', |
p_mdb => 'Title for the Drop Box', |
p_mbb => 'Title for the Discussion Board', |
p_mbb => 'Title for the Discussion Board', |
p_mwp => 'Title for Web Page', |
p_mwp => 'Title for Web Page', |
|
p_mnr => 'Title for the Resource', |
p_mab => "Enter user:domain for User's Personal Information Page", |
p_mab => "Enter user:domain for User's Personal Information Page", |
p_mab2 => 'Personal Information Page of ', |
p_mab2 => 'Personal Information Page of ', |
p_mab_alrt1 => 'Not a valid user:domain', |
p_mab_alrt1 => 'Not a valid user:domain', |
Line 6795 sub editing_js {
|
Line 6899 sub editing_js {
|
noor => 'No actions selected or changes to settings specified.', |
noor => 'No actions selected or changes to settings specified.', |
noch => 'No changes to settings specified.', |
noch => 'No changes to settings specified.', |
noac => 'No actions selected.', |
noac => 'No actions selected.', |
|
nofi => 'No file selected', |
|
tinc => 'Title in course', |
|
sunm => 'Sub-directory name', |
edri => 'Editing rights unavailable for your current role.', |
edri => 'Editing rights unavailable for your current role.', |
); |
); |
|
|
&js_escape(\%js_lt); |
&js_escape(\%js_lt); |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); |
my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); |
Line 6827 sub editing_js {
|
Line 6933 sub editing_js {
|
} else { |
} else { |
$url = $res; |
$url = $res; |
} |
} |
$backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"'); |
$backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='. |
if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) { |
&HTML::Entities::encode($caller,'<>&"'); |
$backtourl .= '?navmap=1'; |
|
} else { |
|
$backtourl .= '?symb='. |
|
&HTML::Entities::encode($caller,'<>&"'); |
|
} |
|
if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) { |
if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) { |
if (($ENV{'SERVER_PORT'} == 443) && |
if (($ENV{'SERVER_PORT'} == 443) && |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { |
unless (&Apache::lonnet::uses_sts()) { |
if ($hostname ne '') { |
if ($hostname ne '') { |
$backtourl = 'http://'.$hostname.$backtourl; |
$backtourl = 'http://'.$hostname.$backtourl; |
|
} |
|
$backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1'; |
|
} |
} |
|
$backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1'; |
} |
} |
} elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) { |
} elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) { |
if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) { |
if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) { |
unless (&Apache::lonnet::uses_sts()) { |
$backtourl = 'http://'.$hostname.$backtourl; |
if ($hostname ne '') { |
|
$backtourl = 'http://'.$hostname.$backtourl; |
|
} |
|
$backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1'; |
|
} |
|
} |
} |
} |
} |
if ($anchor ne '') { |
if ($anchor ne '') { |
$backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"'); |
$backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"'); |
} |
} |
$backtourl = &Apache::loncommon::escape_single($backtourl); |
$backtourl = &Apache::loncommon::escape_single($backtourl); |
} else { |
} else { |
$backtourl = '/adm/navmaps'; |
$backtourl = '/adm/navmaps'; |
} |
} |
Line 6883 sub editing_js {
|
Line 6977 sub editing_js {
|
$fieldsets .= ",'supptool'"; |
$fieldsets .= ",'supptool'"; |
} |
} |
} |
} |
|
|
my $jsmakefunctions; |
my $jsmakefunctions; |
if ($canedit) { |
if ($canedit) { |
$jsmakefunctions = <<ENDNEWSCRIPT; |
$jsmakefunctions = <<ENDNEWSCRIPT; |
Line 6930 function makewebpage(type) {
|
Line 7024 function makewebpage(type) {
|
formname = this.document.forms.newwebpage; |
formname = this.document.forms.newwebpage; |
} |
} |
if (title) { |
if (title) { |
var webpage = formname.importdetail.value; |
var webpage = formname.importdetail.value; |
formname.importdetail.value = escape(title)+'='+webpage; |
formname.importdetail.value = escape(title)+'='+webpage; |
formname.submit(); |
formname.submit(); |
} |
} |
Line 7080 function toggleUpload(caller) {
|
Line 7174 function toggleUpload(caller) {
|
document.getElementById('upload'+blocks[i]+'form').style.display=disp; |
document.getElementById('upload'+blocks[i]+'form').style.display=disp; |
if ((caller == 'tool') || (caller == 'supptool')) { |
if ((caller == 'tool') || (caller == 'supptool')) { |
if (disp == 'block') { |
if (disp == 'block') { |
if (document.getElementById('LC_exttoolid')) { |
if (document.getElementById('LC_exttoolid')) { |
var toolselector = document.getElementById('LC_exttoolid'); |
var toolselector = document.getElementById('LC_exttoolid'); |
var suppflag = 0; |
var suppflag = 0; |
if (caller == 'supptool') { |
if (caller == 'supptool') { |
suppflag = 1; |
suppflag = 1; |
} |
} |
currForm = document.getElementById('new'+caller); |
currForm = document.getElementById('new'+caller); |
updateExttool(toolselector,currForm,suppflag); |
updateExttool(toolselector,currForm,suppflag); |
} |
} |
} |
} |
} |
} |
Line 7111 function toggleMap(caller) {
|
Line 7205 function toggleMap(caller) {
|
return; |
return; |
} |
} |
|
|
|
function toggleCrsRes(caller,numauthorrole,numcrsdirs) { |
|
var disp = 'none'; |
|
if (document.getElementById('crsresform')) { |
|
if (caller == 'res') { |
|
var curr = document.getElementById('crsresform').style.display; |
|
if (curr == 'none') { |
|
disp='block'; |
|
numauthor = parseInt(numauthorrole); |
|
if (numauthor > 0) { |
|
document.courseresform.authorrole.selectedIndex = 0; |
|
select1priv_changed(); |
|
document.courseresform.authorpath.selectedIndex = 0; |
|
document.courseresform.newresourceadd.selectedIndex = 0; |
|
toggleNewInCourse(document.courseresform); |
|
if (document.getElementById('newresource')) { |
|
document.getElementById('newresource').style.display = 'none'; |
|
} |
|
} else { |
|
if (numcrsdirs) { |
|
document.courseresform.authorpath.selectedIndex = 0; |
|
} |
|
} |
|
if (document.courseresform.newresusetemp.length) { |
|
document.courseresform.newresusetemp[0].checked = true; |
|
toggleWithTemplate(document.courseresform); |
|
} |
|
document.courseresform.newresourcename.value = ''; |
|
} |
|
} |
|
if (document.courseresform.newsubdir.length) { |
|
for (var j=0; j<document.courseresform.newsubdir.length; j++) { |
|
if (document.courseresform.newsubdir[j].value == 0) { |
|
document.courseresform.newsubdir[j].checked = true; |
|
} |
|
break; |
|
} |
|
if (document.getElementById('newsubdirname')) { |
|
document.getElementById('newsubdirname').type = "hidden"; |
|
document.getElementById('newsubdirname').value = ""; |
|
} |
|
if (document.getElementById('newsubdir')) { |
|
document.getElementById('newsubdir').innerHTML = ""; |
|
} |
|
} |
|
document.getElementById('crsresform').style.display=disp; |
|
resize_scrollbox('contentscroll','1','0'); |
|
} |
|
return; |
|
} |
|
|
|
function toggleNewsubdir(form) { |
|
if (form.newsubdir.length) { |
|
for (var j=0; j<form.newsubdir.length; j++) { |
|
if (form.newsubdir[j].checked) { |
|
if (document.getElementById('newsubdirname')) { |
|
if (form.newsubdir[j].value == '1') { |
|
document.getElementById('newsubdirname').type = "text"; |
|
if (document.getElementById('newsubdir')) { |
|
document.getElementById('newsubdir').innerHTML = '<br />$js_lt{'sunm'}'; |
|
} |
|
} else { |
|
document.getElementById('newsubdirname').type = "hidden"; |
|
document.getElementById('newsubdirname').value = ""; |
|
document.getElementById('newsubdir').innerHTML = ""; |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function toggleCrsResTitle() { |
|
if (document.getElementById('newresource')) { |
|
if (document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value == 'course') { |
|
document.getElementById('newresource').style.display = 'inline'; |
|
document.courseresform.newresourceadd[0].checked = true; |
|
toggleNewInCourse(document.courseresform); |
|
} else { |
|
document.getElementById('newresource').style.display = 'none'; |
|
} |
|
} |
|
} |
|
|
|
function toggleNewInCourse(form) { |
|
if (form.newresourceadd.length) { |
|
for (var i=0; i<form.newresourceadd.length; i++) { |
|
if (form.newresourceadd[i].checked) { |
|
if (document.getElementById('newresourcetitle')) { |
|
if (form.newresourceadd[i].value == '1') { |
|
document.getElementById('newresourcetitle').type = 'text'; |
|
if (document.getElementById('newrestitle')) { |
|
document.getElementById('newrestitle').innerHTML = "<br />$js_lt{'tinc'}"; |
|
} |
|
} else { |
|
document.getElementById('newresourcetitle').type = 'hidden'; |
|
document.getElementById('newresourcetitle').value = ''; |
|
if (document.getElementById('newrestitle')) { |
|
document.getElementById('newrestitle').innerHTML = ''; |
|
} |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function toggleWithTemplate(form) { |
|
if (form.newresusetemp.length) { |
|
for (var i=0; i<form.newresusetemp.length; i++) { |
|
if (form.newresusetemp[i].checked) { |
|
if (document.getElementById('newrestemplate')) { |
|
if (form.newresusetemp[i].value == '1') { |
|
document.getElementById('newrestemplate').style.display = 'inline'; |
|
toggleExampleText(); |
|
} else { |
|
form.tempcategory.selectedIndex = 0; |
|
select1template_changed(); |
|
document.getElementById('newrestemplate').style.display = 'none'; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
function toggleExampleText() { |
|
if (document.getElementById('newresexample')) { |
|
var url = document.courseresform.template.options[document.courseresform.template.selectedIndex].value; |
|
if (url == '') { |
|
document.getElementById('newresexample').style.fontWeight = 'normal'; |
|
} else { |
|
document.getElementById('newresexample').style.fontWeight = 'bold'; |
|
} |
|
} |
|
} |
|
|
|
function getExample(width,height,scrolling,transparency) { |
|
var url; |
|
if (document.courseresform.newresusetemp.length) { |
|
for (var i=0; i<document.courseresform.newresusetemp.length; i++) { |
|
if (document.courseresform.newresusetemp[i].checked) { |
|
if (document.courseresform.newresusetemp[i].value == '1') { |
|
var url = document.courseresform.template.options[document.courseresform.template.selectedIndex].value; |
|
if (url == '') { |
|
alert('Pick a category and template'); |
|
} else { |
|
url = url.replace("$londocroot",""); |
|
url += '?inhibitmenu=yes'; |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
if (url != '') { |
|
openMyModal(url,width,height,scrolling,transparency,''); |
|
} |
|
} |
|
|
|
function toggleImportCrsres(caller,dircount) { |
|
var disp = 'none'; |
|
if (document.getElementById('importcrsresform')) { |
|
if (caller == 'res') { |
|
var numdirs = parseInt(dircount); |
|
var curr = document.getElementById('importcrsresform').style.display; |
|
if (curr == 'none') { |
|
disp='block'; |
|
if (numdirs > 1) { |
|
select1res_changed(); |
|
} |
|
} |
|
} |
|
document.getElementById('importcrsresform').style.display=disp; |
|
resize_scrollbox('contentscroll','1','0'); |
|
} |
|
return; |
|
} |
|
|
function makeims(imsform) { |
function makeims(imsform) { |
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { |
if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) { |
alert("$js_lt{'imsfile'}"); |
alert("$js_lt{'imsfile'}"); |
Line 7417 for (i = 0; i < currentLis.length; i++)
|
Line 7691 for (i = 0; i < currentLis.length; i++)
|
|
|
function hideAll(current, nav, data) { |
function hideAll(current, nav, data) { |
unselectInactive(nav); |
unselectInactive(nav); |
if (current) { |
if (current) { |
if (current.className == 'right'){ |
if (current.className == 'right'){ |
current.className = 'right active' |
current.className = 'right active' |
} else { |
} else { |
current.className = 'active'; |
current.className = 'active'; |
} |
} |
} |
} |
currentData = document.getElementById(data); |
currentData = document.getElementById(data); |
Line 7459 function showPage(current, pageId, nav,
|
Line 7733 function showPage(current, pageId, nav,
|
unselectInactive(nav); |
unselectInactive(nav); |
if ((currstate == 'active') || (currstate == 'right active')) { |
if ((currstate == 'active') || (currstate == 'right active')) { |
if (currstate == 'active') { |
if (currstate == 'active') { |
current.className = ''; |
current.className = ''; |
} else { |
} else { |
current.className = 'right'; |
current.className = 'right'; |
} |
} |
activeTab = ''; |
activeTab = ''; |
toggleUpload(); |
toggleUpload(); |
toggleMap(); |
toggleMap(); |
|
toggleCrsRes(); |
|
toggleImportCrsres(); |
resize_scrollbox('contentscroll','1','0'); |
resize_scrollbox('contentscroll','1','0'); |
return; |
return; |
} else { |
} else { |
Line 7476 function showPage(current, pageId, nav,
|
Line 7752 function showPage(current, pageId, nav,
|
activeTab = pageId; |
activeTab = pageId; |
toggleUpload(); |
toggleUpload(); |
toggleMap(); |
toggleMap(); |
|
toggleCrsRes(); |
|
toggleImportCrsres(); |
if (nav == 'mainnav') { |
if (nav == 'mainnav') { |
var storedpath = "$docs_folderpath"; |
var storedpath = "$docs_folderpath"; |
var storedpage = "$main_container_page"; |
var storedpage = "$main_container_page"; |
Line 7839 function setBoxes(value) {
|
Line 8117 function setBoxes(value) {
|
return; |
return; |
} |
} |
|
|
|
function validImportCrsRes() { |
|
var path = document.crsresimportform.coursepath.options[document.crsresimportform.coursepath.selectedIndex].value; |
|
var fname = document.crsresimportform.coursefile.options[document.crsresimportform.coursefile.selectedIndex].value; |
|
if ((fname == '') || (fname == null)) { |
|
alert("$js_lt{'nofi'}"); |
|
return false; |
|
} |
|
var url = '/res/$coursedom/$coursenum/'; |
|
if (path && path != '/') { |
|
url += path+'/'; |
|
} |
|
if (fname != '') { |
|
url += fname; |
|
} |
|
var title = document.crsresimportform.crsrestitle.value; |
|
document.crsresimportform.importdetail.value=escape(title)+'='+escape(url); |
|
return true; |
|
} |
|
|
|
function validateNewRes(caller) { |
|
if (caller == 'single') { |
|
var role = document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value; |
|
var authorpath = document.courseresform.authorpath.options[document.courseresform.authorpath.selectedIndex].value; |
|
var resname = document.courseresform.newresourcename.value; |
|
} |
|
} |
|
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
Line 7969 sub makesimpleeditform {
|
Line 8274 sub makesimpleeditform {
|
SIMPFORM |
SIMPFORM |
} |
} |
|
|
|
sub makenewproblem { |
|
my ($r,$coursedom,$coursenum) = @_; |
|
# Creating a new problem |
|
my ($redirect,$error); |
|
if ($env{'form.authorrole'}) { |
|
my ($newsubdir,$filename); |
|
if ($env{'form.newsubdir'}) { |
|
if ($env{'form.newsubdirname'} ne '') { |
|
$newsubdir = $env{'form.newsubdirname'}; |
|
} |
|
} |
|
if ($env{'form.newresourcename'}) { |
|
$filename = $env{'form.newresourcename'}; |
|
$filename =~ s/\.(\d+)(\.\w+)$/$2/; |
|
$filename =~ s/`//g; |
|
$filename =~ s{/\.\./}{_}g; |
|
$filename =~ s/\.+/./g; |
|
$filename =~ s{/+}{_}g; |
|
if ($filename ne '') { |
|
my ($name,$ext) = ($filename =~ /(.+)\.([^.]+)$/); |
|
if (($ext) && ($ext ne '.problem')) { |
|
$filename = $name.'.problem'; |
|
} elsif ($ext eq '') { |
|
$filename .= '.problem'; |
|
} |
|
my $docroot = $r->dir_config('lonDocRoot'); |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
if ($env{'form.authorrole'} eq 'author') { |
|
if ($env{'user.author'}) { |
|
if ($env{'user.home'} && grep(/^\Q$env{'user.home'}\E$/,@ids)) { |
|
my $url = "/priv/$env{'user.domain'}/$env{'user.name'}"; |
|
my $path = $docroot.$url; |
|
my $subdir = $env{'form.authorpath'}; |
|
$redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename); |
|
} |
|
} |
|
} elsif ($env{'form.authorrole'} eq 'course') { |
|
my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
|
if ($chome && grep(/^\Q$chome\E$/,@ids)) { |
|
my $url = "/priv/$coursedom/$coursenum"; |
|
my $path=$docroot.$url; |
|
my $subdir = $env{'form.authorpath'}; |
|
$redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename); |
|
if ($redirect) { |
|
my $rightsfile = 'default.rights'; |
|
my $sourcerights = "$path/$rightsfile"; |
|
my $targetrights = $docroot."/res/$coursedom/$coursenum/$rightsfile"; |
|
my $now = time; |
|
if (!-e $sourcerights) { |
|
my $cid = $coursedom.'_'.$coursenum; |
|
if (open(my $fh,">$sourcerights")) { |
|
print $fh <<END; |
|
<accessrule effect="deny" realm="" type="course" role="" /> |
|
<accessrule effect="allow" realm="$cid" type="course" role="" /> |
|
END |
|
close($fh); |
|
} |
|
} |
|
if (!-e "$sourcerights.meta") { |
|
if (open(my $fh,">$sourcerights.meta")) { |
|
my $author=$env{'environment.firstname'}.' '. |
|
$env{'environment.middlename'}.' '. |
|
$env{'environment.lastname'}.' '. |
|
$env{'environment.generation'}; |
|
$author =~ s/\s+$//; |
|
print $fh <<"END"; |
|
|
|
<abstract></abstract> |
|
<author>$author</author> |
|
<authorspace>$coursenum:$coursedom</authorspace> |
|
<copyright>private</copyright> |
|
<creationdate>$now</creationdate> |
|
<customdistributionfile></customdistributionfile> |
|
<dependencies></dependencies> |
|
<domain>$coursedom</domain> |
|
<highestgradelevel>0</highestgradelevel> |
|
<keywords></keywords> |
|
<language>notset </language> |
|
<lastrevisiondate>$now</lastrevisiondate> |
|
<lowestgradelevel>0</lowestgradelevel> |
|
<mime>rights</mime> |
|
<modifyinguser>$env{'user.name'}:$env{'user.domain'}</modifyinguser> |
|
<notes></notes> |
|
<obsolete></obsolete> |
|
<obsoletereplacement></obsoletereplacement> |
|
<owner>$coursenum:$coursedom</owner> |
|
<rule>deny:::course,allow:$cid::course</rule> |
|
<sourceavail></sourceavail> |
|
<standards></standards> |
|
<subject></subject> |
|
<title></title> |
|
END |
|
close($fh); |
|
} |
|
if ((-e $sourcerights) && (-e "$sourcerights.meta")) { |
|
if (!-e "$docroot/res/$coursedom") { |
|
mkdir("$docroot/res/$coursedom",0755); |
|
} |
|
if (!-e "$docroot/res/$coursedom/$coursenum") { |
|
mkdir("$docroot/res/$coursedom/$coursenum",0755); |
|
} |
|
if ((-e "$docroot/res/$coursedom/$coursenum") && (!-e $targetrights)) { |
|
my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes')); |
|
my $output = &Apache::lonpublisher::batchpublish($r,$sourcerights,$targetrights,$nokeyref,1); |
|
} |
|
} |
|
} |
|
if ($env{'form.newresourceadd'}) { |
|
my $template = $env{'form.template'}; |
|
my $source = $docroot.$redirect; |
|
my $target = $redirect; |
|
$target =~ s{^/priv/}{/res/}; |
|
$target = $docroot.$target; |
|
if (!-e $source) { |
|
my $copyfrom; |
|
if ($template) { |
|
my %templates; |
|
my @files = &Apache::lonhomework::get_template_list('problem'); |
|
foreach my $poss (@files) { |
|
if (ref($poss) eq 'ARRAY') { |
|
if ($template eq $poss->[0]) { |
|
$templates{$template} = 1; |
|
last; |
|
} |
|
} |
|
} |
|
if ($templates{$template}) { |
|
$copyfrom = $template; |
|
} |
|
} |
|
unless ($copyfrom) { |
|
$copyfrom = $r->dir_config('lonIncludes').'/templates/blank.problem'; |
|
} |
|
&File::Copy::copy($copyfrom,$source); |
|
} |
|
if (!-e "$source.meta") { |
|
my $cid = $coursedom.'_'.$coursenum; |
|
my $now = time; |
|
if (open(my $fh,">$source.meta")) { |
|
my $author=$env{'environment.firstname'}.' '. |
|
$env{'environment.middlename'}.' '. |
|
$env{'environment.lastname'}.' '. |
|
$env{'environment.generation'}; |
|
$author =~ s/\s+$//; |
|
my $title = $env{'form.newresourcetitle'}; |
|
$title =~ s/^\s+|\s+$//g; |
|
print $fh <<END; |
|
|
|
<abstract></abstract> |
|
<author>$author</author> |
|
<authorspace>$coursenum:$coursedom</authorspace> |
|
<copyright>custom</copyright> |
|
<creationdate>$now</creationdate> |
|
<customdistributionfile>/res/$coursedom/$coursenum/default.rights</customdistributionfile> |
|
<dependencies></dependencies> |
|
<domain>$coursedom</domain> |
|
<highestgradelevel>0</highestgradelevel> |
|
<keywords></keywords> |
|
<language>notset </language> |
|
<lastrevisiondate>$now</lastrevisiondate> |
|
<lowestgradelevel>0</lowestgradelevel> |
|
<mime>problem</mime> |
|
<modifyinguser>$coursenum:$coursedom</modifyinguser> |
|
<notes></notes> |
|
<obsolete></obsolete> |
|
<obsoletereplacement></obsoletereplacement> |
|
<owner>$coursenum:$coursedom</owner> |
|
<sourceavail></sourceavail> |
|
<standards></standards> |
|
<subject></subject> |
|
<title>$title</title> |
|
END |
|
close($fh); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} else { |
|
my ($auname,$audom,$role) = split('___',$env{'form.authorrole'}); |
|
my $rolehome = &Apache::lonnet::homeserver($auname,$audom); |
|
if (grep(/^\Q$rolehome\E$/,@ids)) { |
|
my $now = time; |
|
if (exists($env{'user.role.'.$role.'./'.$audom.'/'.$auname})) { |
|
my ($start,$end) = split(/\./,$env{'user.role.'.$role.'./'.$audom.'/'.$auname}); |
|
if (($start <= $now) && (($end == 0) || ($end >= $now))) { |
|
my $url = "/priv/$audom/$auname"; |
|
my $path = $r->dir_config('lonDocRoot').$url; |
|
my $subdir = $env{'form.authorpath'}; |
|
$redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return ($redirect,$error); |
|
} |
|
|
|
sub finishnewprob { |
|
my ($url,$path,$subdir,$newsubdir,$filename) = @_; |
|
unless (-d $path) { |
|
unless (mkdir($path,02770)) { |
|
return; |
|
} |
|
} |
|
my $redirect; |
|
if ($subdir ne '/') { |
|
$subdir = &cleandir($subdir); |
|
if (($subdir ne '') && (-d "$path/$subdir")) { |
|
$path .= "/$subdir"; |
|
$url .= "/$subdir"; |
|
} |
|
} |
|
my $dest; |
|
if ($newsubdir ne '') { |
|
$newsubdir = &cleandir($newsubdir); |
|
} |
|
if ($newsubdir ne '') { |
|
if (-d "$path/$newsubdir") { |
|
$dest = "$path/$newsubdir/$filename"; |
|
} else { |
|
my $dirok; |
|
unless (-e "$path/$newsubdir") { |
|
if (mkdir("$path/$newsubdir",02770)) { |
|
if (chmod(02770,"$path/$newsubdir")) { |
|
$dirok = 1; |
|
} |
|
} |
|
} |
|
if ($dirok) { |
|
$dest = "$path/$newsubdir/$filename"; |
|
} |
|
} |
|
if (($dest ne '') && (!-e $dest)) { |
|
$redirect = "$url/$newsubdir/$filename"; |
|
} |
|
} else { |
|
$dest = "$path/$filename"; |
|
if (($dest ne '') && (!-e $dest)) { |
|
$redirect = "$url/$filename"; |
|
} |
|
} |
|
return $redirect; |
|
} |
|
|
|
sub cleandir { |
|
my ($dir) = @_; |
|
$dir =~ s/^\s+//; |
|
$dir =~ s/\s+$//; |
|
$dir =~ s/\.+//g; |
|
$dir =~ s/[\#\?&%\":]//g; |
|
return $dir; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|
Line 8068 check on this
|
Line 8629 check on this
|
|
|
Verify Content |
Verify Content |
|
|
=item devalidateversioncache() |
=item devalidateversioncache() & checkversions() |
|
|
=item checkversions() |
|
|
|
Check Versions |
Check Versions |
|
|