version 1.537, 2013/03/17 14:27:34
|
version 1.538, 2013/03/31 22:36:01
|
Line 323 sub group_import {
|
Line 323 sub group_import {
|
} |
} |
my $ext = 'false'; |
my $ext = 'false'; |
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } |
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } |
$url = &LONCAPA::map::qtunescape($url); |
|
$name = &LONCAPA::map::qtunescape($name); |
$name = &LONCAPA::map::qtunescape($name); |
if ($name eq '') { |
if ($name eq '') { |
$name = &mt('Web Page'); |
$name = &LONCAPA::map::qtunescape(&mt('Web Page')); |
} |
} |
if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) { |
if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) { |
my $filepath = $1; |
my $filepath = $1; |
Line 367 END
|
Line 366 END
|
return (&mt('Failed to save new web page.'),1); |
return (&mt('Failed to save new web page.'),1); |
} |
} |
} |
} |
|
$url = &LONCAPA::map::qtunescape($url); |
$LONCAPA::map::resources[$residx] = |
$LONCAPA::map::resources[$residx] = |
join(':', ($name, $url, $ext, 'normal', 'res')); |
join(':', ($name, $url, $ext, 'normal', 'res')); |
} |
} |
Line 490 sub docs_change_log {
|
Line 490 sub docs_change_log {
|
} |
} |
my $folderpath=$env{'form.folderpath'}; |
my $folderpath=$env{'form.folderpath'}; |
if ($folderpath eq '') { |
if ($folderpath eq '') { |
$folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents').':::::'); |
$folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Content').':::::'); |
} |
} |
$pathitem = '<input type="hidden" name="folderpath" value="'. |
$pathitem = '<input type="hidden" name="folderpath" value="'. |
&HTML::Entities::encode($folderpath,'<>&"').'" />'; |
&HTML::Entities::encode($folderpath,'<>&"').'" />'; |
Line 655 sub docs_change_log {
|
Line 655 sub docs_change_log {
|
|
|
sub update_paste_buffer { |
sub update_paste_buffer { |
my ($coursenum,$coursedom,$folder) = @_; |
my ($coursenum,$coursedom,$folder) = @_; |
|
my (@possibles,%removals,%cuts); |
|
if ($env{'form.multiremove'}) { |
|
$env{'form.multiremove'} =~ s/,$//; |
|
map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'}); |
|
} |
|
if (($env{'form.multicopy'}) || ($env{'form.multicut'})) { |
|
if ($env{'form.multicut'}) { |
|
$env{'form.multicut'} =~ s/,$//; |
|
foreach my $item (split(/,/,$env{'form.multicut'})) { |
|
unless ($removals{$item}) { |
|
$cuts{$item} = 1; |
|
push(@possibles,$item.':cut'); |
|
} |
|
} |
|
} |
|
if ($env{'form.multicopy'}) { |
|
$env{'form.multicopy'} =~ s/,$//; |
|
foreach my $item (split(/,/,$env{'form.multicopy'})) { |
|
unless ($removals{$item} || $cuts{$item}) { |
|
push(@possibles,$item.':copy'); |
|
} |
|
} |
|
} |
|
} elsif ($env{'form.markcopy'}) { |
|
@possibles = split(/,/,$env{'form.markcopy'}); |
|
} |
|
|
return if (!defined($env{'form.markcopy'})); |
return if (@possibles == 0); |
return if (!defined($env{'form.copyfolder'})); |
return if (!defined($env{'form.copyfolder'})); |
return if ($env{'form.markcopy'} < 0); |
|
|
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
$env{'form.copyfolder'}); |
$env{'form.copyfolder'}); |
|
|
return if ($fatal); |
return if ($fatal); |
|
|
# Mark for copying |
my %curr_groups = &Apache::longroup::coursegroups(); |
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]); |
|
if (&is_supplemental_title($title)) { |
# Retrieve current paste buffer suffixes. |
&Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title}); |
my @currpaste = split(/,/,$env{'docs.markedcopies'}); |
($title) = &Apache::loncommon::parse_supplemental_title($title); |
my (%pasteurls,@newpaste); |
} elsif ($env{'docs.markedcopy_supplemental'}) { |
|
&Apache::lonnet::delenv('docs.markedcopy_supplemental'); |
# Construct identifiers for current contents of user's paste buffer |
} |
if (@currpaste) { |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
foreach my $suffix (@currpaste) { |
|
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
(my $cmd,undef)=split('_',$env{'form.cmd'}); |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
|
if (($cid =~ /^$match_domain(?:_)$match_courseid$/) && |
my %addtoenv = ( |
($url ne '')) { |
'docs.markedcopy_title' => $title, |
$pasteurls{$cid.'_'.$url}; |
'docs.markedcopy_url' => $url, |
} |
'docs.markedcopy_cmd' => $cmd, |
} |
); |
} |
&Apache::lonnet::delenv('docs.markedcopy_nested'); |
|
&Apache::lonnet::delenv('docs.markedcopy_nestednames'); |
# Mark items for copying (skip any items already in user's paste buffer) |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) { |
my %addtoenv; |
my $prefix = $1; |
|
my $subdir =$2; |
foreach my $item (@possibles) { |
if ($subdir eq '') { |
my ($orderidx,$cmd) = split(/:/,$item); |
$subdir = $prefix; |
next if ($orderidx =~ /\D/); |
} |
next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove')); |
my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps); |
my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]); |
&contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps, |
my %denied = &action_restrictions($coursenum,$coursedom, |
\%hierarchy,\%titles,\%allmaps); |
&LONCAPA::map::qtescape($url), |
if (ref($hierarchy{$url}) eq 'HASH') { |
$env{'form.folderpath'},\%curr_groups); |
my ($nested,$nestednames); |
next if ($denied{'copy'}); |
&recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames); |
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
$nested =~ s/\&$//; |
next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url})); |
$nestednames =~ s/\Q___&&&___\E$//; |
my ($suffix,$errortxt,$locknotfreed) = |
if ($nested ne '') { |
&new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste'); |
$addtoenv{'docs.markedcopy_nested'} = $nested; |
push(@newpaste,$suffix); |
|
if ($locknotfreed) { |
|
return $locknotfreed; |
|
last; |
|
} |
|
if (&is_supplemental_title($title)) { |
|
&Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title}); |
|
($title) = &Apache::loncommon::parse_supplemental_title($title); |
|
} |
|
|
|
$addtoenv{'docs.markedcopy_title_'.$suffix} = $title, |
|
$addtoenv{'docs.markedcopy_url_'.$suffix} = $url, |
|
$addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd, |
|
$addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'}; |
|
|
|
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) { |
|
my $prefix = $1; |
|
my $subdir =$2; |
|
if ($subdir eq '') { |
|
$subdir = $prefix; |
} |
} |
if ($nestednames ne '') { |
my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps); |
$addtoenv{'docs.markedcopy_nestednames'} = $nestednames; |
&contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps, |
|
\%hierarchy,\%titles,\%allmaps); |
|
if (ref($hierarchy{$url}) eq 'HASH') { |
|
my ($nested,$nestednames); |
|
&recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames); |
|
$nested =~ s/\&$//; |
|
$nestednames =~ s/\Q___&&&___\E$//; |
|
if ($nested ne '') { |
|
$addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested; |
|
} |
|
if ($nestednames ne '') { |
|
$addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames; |
|
} |
} |
} |
} |
} |
} |
} |
|
if (@newpaste) { |
|
$addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste)); |
|
} |
&Apache::lonnet::appenv(\%addtoenv); |
&Apache::lonnet::appenv(\%addtoenv); |
delete($env{'form.markcopy'}); |
delete($env{'form.markcopy'}); |
} |
} |
Line 737 sub recurse_uploaded_maps {
|
Line 795 sub recurse_uploaded_maps {
|
|
|
sub print_paste_buffer { |
sub print_paste_buffer { |
my ($r,$container,$folder,$coursedom,$coursenum) = @_; |
my ($r,$container,$folder,$coursedom,$coursenum) = @_; |
return if (!defined($env{'docs.markedcopy_url'})); |
return if (!defined($env{'docs.markedcopies'})); |
|
|
my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent); |
unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) { |
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1]; |
return if ($env{'docs.markedcopies'} eq ''); |
if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
|
$is_external = 1; |
|
} |
} |
|
|
my ($canpaste,$nopaste,$othercrs,$areachange); |
my @currpaste = split(/,/,$env{'docs.markedcopies'}); |
if ($folder =~ /^supplemental/) { |
my ($pasteitems,@pasteable); |
$canpaste = &supp_pasteable($env{'docs.markedcopy_url'}); |
|
unless ($canpaste) { |
|
$nopaste = &mt('Paste into Supplemental Content unavailable for this type of content.'); |
|
} |
|
} else { |
|
$canpaste = 1; |
|
} |
|
|
|
if ($canpaste) { |
# Construct identifiers for current contents of user's paste buffer |
if ($env{'docs.markedcopy_url'} =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
foreach my $suffix (@currpaste) { |
my $srcdom = $1; |
next if ($suffix =~ /\D/); |
my $srcnum = $2; |
my $cid = $env{'docs.markedcopy_crs_'.$suffix}; |
my $rem = $3; |
my $url = $env{'docs.markedcopy_url_'.$suffix}; |
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) { |
if (($cid =~ /^$match_domain\_$match_courseid$/) && |
$othercourse = 1; |
($url ne '')) { |
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent, |
if ($canpaste) { |
$canpaste,$nopaste,$othercrs,$areachange); |
$othercrs = '<br />'.&mt('(from another course).'); |
my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1]; |
} |
if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
} else { |
$is_external = 1; |
$canpaste = 0; |
|
$nopaste = &mt('Paste from another course unavailable.') |
|
} |
|
} |
} |
if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) { |
if ($folder =~ /^supplemental/) { |
my $prefix = $1; |
$canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix}); |
$parent = $2; |
unless ($canpaste) { |
if ($folder !~ /^\Q$prefix\E/) { |
$nopaste = &mt('Paste into Supplemental Content unavailable.'); |
$areachange = 1; |
|
} |
} |
$is_uploaded_map = 1; |
} else { |
|
$canpaste = 1; |
} |
} |
} |
if ($canpaste) { |
} |
if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { |
|
my $srcdom = $1; |
$r->print('<fieldset>' |
my $srcnum = $2; |
.'<legend>'.&mt('Clipboard').'</legend>'); |
my $rem = $3; |
my ($type,$buffer); |
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) { |
if ($is_external) { |
$othercourse = 1; |
$type = &mt('External Resource'); |
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
$buffer = $type.': '. |
if ($canpaste) { |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('. |
$othercrs = '<br />'.&mt('(from another course).'); |
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')'; |
} |
} else { |
} else { |
my $icon = &Apache::loncommon::icon($extension); |
$canpaste = 0; |
if ($extension eq 'sequence' && |
$nopaste = &mt('Paste from another course unavailable.'); |
$env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) { |
|
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); |
|
$icon .= '/navmap.folder.closed.gif'; |
|
} |
|
$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />'; |
|
$buffer = $icon.$type.': '. &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})); |
|
} |
|
if ($canpaste) { |
|
$r->print('<form name="pasteform" action="/adm/coursedocs" method="post">'.$buffer); |
|
if ((!$areachange) && (!$othercourse) && |
|
($env{'docs.markedcopy_cmd'} eq 'cut')) { |
|
if (($is_uploaded_map) || |
|
($env{'docs.markedcopy_url'} =~ /(bulletinboard|smppg)$/) || |
|
($env{'docs.markedcopy_url'} =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) { |
|
my ($copytext,$movetext); |
|
if ($is_uploaded_map) { |
|
$copytext = &mt('Copy to new folder'); |
|
$movetext = &mt('Move old folder'); |
|
} elsif ($env{'docs.markedcopy_url'} =~ /bulletinboard$/) { |
|
$copytext = &mt('Copy to new bulletin board (not posts)'); |
|
$movetext = &mt('Move old bulletin board (not posts)'); |
|
} elsif ($env{'docs.markedcopy_url'} =~ /smppg$/) { |
|
$copytext = &mt('Copy to new simple page'); |
|
$movetext = &mt('Move old simple page'); |
|
} else { |
|
$copytext = &mt('Copy to new uploaded document'); |
|
$movetext = &mt('Move old uploaded document'); |
|
} |
|
$r->print((' 'x 4).'<span id="pasteoptionstext">'. |
|
'<a href="javascript:showPasteOptions();" class="LC_menubuttons_link">'. |
|
&mt('Show Paste Options').'</a></span><br />'. |
|
'<div id="pasteoptions" class="LC_dccid">'.(' 'x 4). |
|
'<label>'. |
|
'<input type="radio" name="docs.markedcopy_options" value="new" checked="checked" />'. |
|
$copytext.'</label>'.(' ' x2). |
|
'<label>'. |
|
'<input type="radio" name="docs.markedcopy_options" value="move" />'. |
|
$movetext.'</label><br />'); |
|
if (($is_uploaded_map) && ($env{'docs.markedcopy_nested'})) { |
|
$r->print('<br />'.&mt('Folder to paste contains sub-folders'). |
|
'<br /><table border="0">'); |
|
my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested'}); |
|
my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames'}); |
|
my $lastdir = $parent; |
|
my %depths = ( |
|
$lastdir => 0, |
|
); |
|
my (%display,%deps); |
|
for (my $i=0; $i<@pastemaps; $i++) { |
|
($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]); |
|
my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]); |
|
my @subfolders = split(/,/,$subfolderstr); |
|
$deps{$lastdir} = \@subfolders; |
|
my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr); |
|
my $depth = $depths{$lastdir} + 1; |
|
my $offset = int($depth * 4); |
|
my $indent = (' ' x $offset); |
|
for (my $j=0; $j<@subfolders; $j++) { |
|
$depths{$subfolders[$j]} = $depth; |
|
$display{$subfolders[$j]} = |
|
'<tr><td>'.$indent.$subfoldertitles[$j].' </td>'. |
|
'<td><label>'. |
|
'<input type="radio" name="docs.markedcopy_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2). |
|
'<label>'. |
|
'<input type="radio" name="docs.markedcopy_'.$subfolders[$j].'" value="move" />'. |
|
&mt('Move old').'</label>'. |
|
'</td></tr>'; |
|
} |
} |
} |
} |
&recurse_print($r,$parent,\%deps,\%display); |
if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) { |
$r->print('</table>'); |
my $prefix = $1; |
|
$parent = $2; |
|
if ($folder !~ /^\Q$prefix\E/) { |
|
$areachange = 1; |
|
} |
|
$is_uploaded_map = 1; |
|
} |
|
} |
|
} |
|
if ($canpaste) { |
|
push(@pasteable,$suffix); |
|
} |
|
my $buffer; |
|
if ($is_external) { |
|
$buffer = &mt('External Resource').': '. |
|
&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('. |
|
&LONCAPA::map::qtescape($url).')'; |
|
} else { |
|
my $icon = &Apache::loncommon::icon($extension); |
|
if ($extension eq 'sequence' && |
|
$url =~ m{/default_\d+\.sequence$}x) { |
|
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); |
|
$icon .= '/navmap.folder.closed.gif'; |
|
} |
|
$buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'. |
|
': '. |
|
&Apache::loncommon::parse_supplemental_title( |
|
&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix})); |
|
} |
|
$pasteitems .= '<div class="LC_left_float">'; |
|
my ($options,$onclick); |
|
if (($canpaste) && (!$areachange) && (!$othercourse) && |
|
($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) { |
|
if (($is_uploaded_map) || |
|
($url =~ /(bulletinboard|smppg)$/) || |
|
($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) { |
|
$options = &paste_options($suffix,$is_uploaded_map,$parent); |
|
$onclick= 'onclick="showOptions(this,'."'$suffix'".');" '; |
|
} |
|
} |
|
$pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>'; |
|
if ($nopaste) { |
|
$pasteitems .= $nopaste; |
|
} else { |
|
if ($othercrs) { |
|
$pasteitems .= $othercrs; |
|
} |
|
if ($options) { |
|
$pasteitems .= $options; |
} |
} |
$r->print('</div>'); |
|
} |
} |
|
$pasteitems .= '</div>'; |
} |
} |
$r->print('<br /><input type="submit" name="pastemarked" value="'.&mt('Paste').'" />'.$othercrs); |
} |
$r->print(' |
if ($pasteitems eq '') { |
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /> |
&Apache::lonnet::delenv('docs.markedcopies'); |
'); |
} |
$r->print('</form>'); |
my ($pasteform,$form_start,$buttons,$form_end); |
|
if ($pasteitems) { |
|
$pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>'; |
|
$form_start = '<form name="pasteform" action="/adm/coursedocs" method="post">'; |
|
if (@pasteable) { |
|
$buttons = '<input type="submit" name="pastemarked" value="'.&mt('Paste selected').'" />'.(' 'x2); |
|
} |
|
$buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Clear selected').'" />'. |
|
'<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'; |
|
$form_end = '</form>'; |
} else { |
} else { |
$r->print(&mt('Paste buffer contains:').' '.$buffer. |
$pasteitems = &mt('Clipboard is empty'); |
'<br /><p class="LC_info">'.$nopaste.'</p>'); |
|
} |
} |
$r->print('</fieldset>'); |
$r->print($form_start |
|
.'<fieldset>' |
|
.'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>' |
|
.$pasteitems |
|
.'</fieldset>' |
|
.$form_end); |
|
} |
|
|
|
sub paste_options { |
|
my ($suffix,$is_uploaded_map,$parent) = @_; |
|
my ($copytext,$movetext); |
|
if ($is_uploaded_map) { |
|
$copytext = &mt('Copy to new folder'); |
|
$movetext = &mt('Move old'); |
|
} elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) { |
|
$copytext = &mt('Copy to new board'); |
|
$movetext = &mt('Move (not posts)'); |
|
} elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) { |
|
$copytext = &mt('Copy to new page'); |
|
$movetext = &mt('Move'); |
|
} else { |
|
$copytext = &mt('Copy to new file'); |
|
$movetext = &mt('Move'); |
|
} |
|
my $output = '<br />'. |
|
'<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'. |
|
'<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4). |
|
'<label>'. |
|
'<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'. |
|
$copytext.'</label></span>'.(' 'x2).' '. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'. |
|
$movetext.'</label></span>'; |
|
if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) { |
|
$output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders'). |
|
'</legend><table border="0">'; |
|
my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix}); |
|
my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix}); |
|
my $lastdir = $parent; |
|
my %depths = ( |
|
$lastdir => 0, |
|
); |
|
my (%display,%deps); |
|
for (my $i=0; $i<@pastemaps; $i++) { |
|
($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]); |
|
my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]); |
|
my @subfolders = split(/,/,$subfolderstr); |
|
$deps{$lastdir} = \@subfolders; |
|
my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr); |
|
my $depth = $depths{$lastdir} + 1; |
|
my $offset = int($depth * 4); |
|
my $indent = (' ' x $offset); |
|
for (my $j=0; $j<@subfolders; $j++) { |
|
$depths{$subfolders[$j]} = $depth; |
|
$display{$subfolders[$j]} = |
|
'<tr><td>'.$indent.$subfoldertitles[$j].' </td>'. |
|
'<td><label>'. |
|
'<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2). |
|
'<label>'. |
|
'<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'. |
|
&mt('Move old').'</label>'. |
|
'</td></tr>'; |
|
} |
|
} |
|
&recurse_print(\$output,$parent,\%deps,\%display); |
|
$output .= '</table></fieldset>'; |
|
} |
|
$output .= '</div>'; |
|
return $output; |
} |
} |
|
|
sub recurse_print { |
sub recurse_print { |
my ($r,$dir,$deps,$display) = @_; |
my ($outputref,$dir,$deps,$display) = @_; |
$r->print($display->{$dir}."\n"); |
$$outputref .= $display->{$dir}."\n"; |
if (ref($deps->{$dir}) eq 'ARRAY') { |
if (ref($deps->{$dir}) eq 'ARRAY') { |
foreach my $subdir (@{$deps->{$dir}}) { |
foreach my $subdir (@{$deps->{$dir}}) { |
&recurse_print($r,$subdir,$deps,$display); |
&recurse_print($outputref,$subdir,$deps,$display); |
} |
} |
} |
} |
} |
} |
Line 904 sub supp_pasteable {
|
Line 1007 sub supp_pasteable {
|
|
|
sub paste_popup_js { |
sub paste_popup_js { |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
show => 'Show Paste Options', |
show => 'Show Options', |
hide => 'Hide Paste Options', |
hide => 'Hide Options', |
); |
); |
return <<"END"; |
return <<"END"; |
|
|
function showPasteOptions() { |
function showPasteOptions(suffix) { |
document.getElementById('pasteoptions').style.display='block'; |
document.getElementById('pasteoptions_'+suffix).style.display='block'; |
document.getElementById('pasteoptions').style.textAlign='left'; |
document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$lt{'hide'}</a>'; |
document.getElementById('pasteoptions').style.textFace='normal'; |
|
document.getElementById('pasteoptionstext').innerHTML ='<a href="javascript:hidePasteOptions();" class="LC_menubuttons_link">$lt{'hide'}</a><br />'; |
|
return; |
return; |
} |
} |
|
|
function hidePasteOptions() { |
function hidePasteOptions(suffix) { |
document.getElementById('pasteoptions').style.display='none'; |
document.getElementById('pasteoptions_'+suffix).style.display='none'; |
document.getElementById('pasteoptionstext').innerHTML ='<a href="javascript:showPasteOptions()" class="LC_menubuttons_link">$lt{'show'}</a>'; |
document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$lt{'show'}</a>'; |
|
return; |
|
} |
|
|
|
function showOptions(caller,suffix) { |
|
if (document.getElementById('pasteoptionstext_'+suffix)) { |
|
if (caller.checked) { |
|
document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$lt{'show'}</a>'; |
|
} else { |
|
document.getElementById('pasteoptionstext_'+suffix).innerHTML =''; |
|
} |
|
if (document.getElementById('pasteoptions_'+suffix)) { |
|
document.getElementById('pasteoptions_'+suffix).style.display='none'; |
|
} |
|
} |
return; |
return; |
} |
} |
|
|
Line 931 END
|
Line 1046 END
|
sub do_paste_from_buffer { |
sub do_paste_from_buffer { |
my ($coursenum,$coursedom,$folder,$container,$errors) = @_; |
my ($coursenum,$coursedom,$folder,$container,$errors) = @_; |
|
|
|
# Array of items in paste buffer |
|
my (@currpaste,%pastebuffer,%allerrors); |
|
@currpaste = split(/,/,$env{'docs.markedcopies'}); |
|
|
# Early out if paste buffer is empty |
# Early out if paste buffer is empty |
if (!$env{'form.pastemarked'}) { |
if (@currpaste == 0) { |
return (); |
return (); |
|
} |
|
map { $pastebuffer{$_} = 1; } @currpaste; |
|
|
|
# Array of items selected items to paste |
|
my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting'); |
|
|
|
# Early out if nothing selected to paste |
|
if (@reqpaste == 0) { |
|
return(); |
|
} |
|
my @topaste; |
|
foreach my $suffix (@reqpaste) { |
|
next if ($suffix =~ /\D/); |
|
next unless (exists($pastebuffer{$suffix})); |
|
push(@topaste,$suffix); |
} |
} |
|
|
# Supplemental content may only include certain types of content |
# Early out if nothing available to paste |
# Early out if pasted content is not supported in Supplemental area |
if (@topaste == 0) { |
if ($folder =~ /^supplemental/) { |
return(); |
unless (&supp_pasteable($env{'docs.markedcopy_url'})) { |
|
return (&mt('Paste failed: content type is not supported within Supplemental Content')); |
|
} |
|
} |
} |
|
|
# Prepare to paste resource at end of list |
my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate, |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); |
%prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult, |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}); |
%msgs); |
|
|
my ($is_map,$srcdom,$srcnum,$prefixchg,%before,%after,%mapchanges,%tomove); |
foreach my $suffix (@topaste) { |
if ($url=~/\.(page|sequence)$/) { |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
$is_map = 1; |
# Supplemental content may only include certain types of content |
} |
# Early out if pasted content is not supported in Supplemental area |
if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/([^/]+)}) { |
if ($folder =~ /^supplemental/) { |
$srcdom = $1; |
unless (&supp_pasteable($url)) { |
$srcnum = $2; |
$notinsupp{$suffix} = 1; |
my $oldprefix = $3; |
next; |
|
} |
|
} |
|
if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) { |
|
my $srcd = $1; |
|
my $srcn = $2; |
# 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 |
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) { |
if (($srcd ne $coursedom) || ($srcn ne $coursenum)) { |
unless ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) { |
return (&mt('Paste failed: Item is from a different course which you do not have rights to edit.')); |
$notincrs{$suffix} = 1; |
|
next; |
|
} |
} |
} |
|
$srcdom{$suffix} = $srcd; |
|
$srcnum{$suffix} = $srcn; |
} |
} |
|
|
|
push(@dopaste,$suffix); |
|
if ($url=~/\.(page|sequence)$/) { |
|
$is_map{$suffix} = 1; |
|
} |
|
|
|
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) { |
|
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 = 1; |
$prefixchg{$suffix} = 'docstosupp'; |
%before = ( map => 'default', |
} elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) { |
doc => 'docs'); |
$prefixchg{$suffix} = 'supptodocs'; |
%after = ( map => 'supplemental', |
} |
doc => 'supplemental' ); |
|
} elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) { |
|
$prefixchg = 1; |
|
%before = ( map => 'supplemental', |
|
doc => 'supplemental'); |
|
%after = ( map => 'default', |
|
doc => 'docs'); |
|
} |
|
|
|
# If pasting an uploaded map, get list of contained uploaded maps. |
# If pasting an uploaded map, get list of contained uploaded maps. |
my @nested; |
if ($env{'docs.markedcopy_nested_'.$suffix}) { |
if ($env{'docs.markedcopy_nested'}) { |
my @nested; |
my ($type) = ($oldprefix =~ /^(default|supplemental)/); |
my ($type) = ($oldprefix =~ /^(default|supplemental)/); |
my @items = split(/\&/,$env{'docs.markedcopy_nested'}); |
my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix}); |
my @deps = map { /\d+:([\d,]+$)/ } @items; |
my @deps = map { /\d+:([\d,]+$)/ } @items; |
foreach my $dep (@deps) { |
foreach my $dep (@deps) { |
if ($dep =~ /,/) { |
if ($dep =~ /,/) { |
push(@nested,split(/,/,$dep)); |
push(@nested,split(/,/,$dep)); |
} else { |
} else { |
push(@nested,$dep); |
push(@nested,$dep); |
|
} |
} |
} |
} |
foreach my $item (@nested) { |
foreach my $item (@nested) { |
if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') { |
if ($env{'form.docs.markedcopy_'.$item} eq 'move') { |
push(@{$marktomove{$suffix}},$type.'_'.$item); |
$tomove{$type.'_'.$item} = 1; |
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
|
# Early out if nothing available to paste |
|
if (@dopaste == 0) { |
|
return (); |
|
} |
|
|
|
# Populate message hash and hashes used for main content <=> supplemental content |
|
# changes |
|
|
|
%msgs = &Apache::lonlocal::texthash ( |
|
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.', |
|
duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.', |
|
); |
|
|
|
%before = ( |
|
docstosupp => { |
|
map => 'default', |
|
doc => 'docs', |
|
}, |
|
supptodocs => { |
|
map => 'supplemental', |
|
doc => 'supplemental', |
|
}, |
|
); |
|
|
|
%after = ( |
|
docstosupp => { |
|
map => 'supplemental', |
|
doc => 'supplemental' |
|
}, |
|
supptodocs => { |
|
map => 'default', |
|
doc => 'docs', |
|
}, |
|
); |
|
|
|
# Retrieve information about all course maps in main content area |
|
|
|
my $allmaps = {}; |
|
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 |
|
foreach my $suffix (@dopaste) { |
# Maps need to be copied first |
# Maps need to be copied first |
my ($oldurl,%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies, |
my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies, |
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls); |
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir, |
$oldurl = $url; |
%newurls,%tomove); |
if ($is_map) { |
if (ref($marktomove{$suffix}) eq 'ARRAY') { |
|
map { $tomove{$_} = 1; } @{$marktomove{$suffix}}; |
|
} |
|
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); |
|
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}); |
|
my $oldurl = $url; |
|
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 ($allmaps,%hierarchy,%titles); |
my (%hierarchy,%titles); |
$allmaps = {}; |
&contained_map_check($url,$folder,\%removefrommap,\%removeparam, |
if ($folder =~ /^default/) { |
\%addedmaps,\%hierarchy,\%titles,$allmaps); |
$allmaps = |
if ($url=~ m{^/uploaded/}) { |
&Apache::loncommon::allmaps_incourse($coursedom,$coursenum, |
my $newurl; |
$env{"course.$env{'request.course.id'}.home"}, |
unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') { |
$env{'request.course.id'}); |
($newurl,my $error) = |
} |
&get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom, |
&contained_map_check($url,$folder,\%removefrommap,\%removeparam, |
$coursenum,$srcdom{$suffix},$srcnum{$suffix}, |
\%addedmaps,\%hierarchy,\%titles,$allmaps); |
\$title,$allmaps,\%newurls); |
if ($url=~ m{^/uploaded/}) { |
if ($error) { |
my $newurl; |
$allerrors{$suffix} = $error; |
unless ($env{'form.docs.markedcopy_options'} eq 'move') { |
next; |
($newurl,my $error) = |
} |
&get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum, |
if ($newurl ne '') { |
$srcdom,$srcnum,\$title,$allmaps,\%newurls); |
if ($newurl ne $url) { |
if ($error) { |
if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) { |
return ($error); |
$newsubdir{$url} = $1; |
} |
} |
if ($newurl ne '') { |
$mapchanges{$url} = 1; |
if ($newurl ne $url) { |
|
if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) { |
|
$newsubdir{$url} = $1; |
|
} |
} |
$mapchanges{$url} = 1; |
|
} |
} |
} |
} |
} |
if (($srcdom{$suffix} ne $coursedom) || |
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) || |
($srcnum{$suffix} ne $coursenum) || |
(($newurl ne '') && ($newurl ne $url))) { |
($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) { |
unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom, |
unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix}, |
$coursenum,$srcdom,$srcnum,$allmaps, |
$coursedom,$coursenum,$srcdom{$suffix}, |
\%rewrites,\%retitles,\%copies,\%dbcopies, |
$srcnum{$suffix},$allmaps,\%rewrites, |
\%zombies,\%params,\%mapmoves,\%mapchanges,\%tomove, |
\%retitles,\%copies,\%dbcopies, |
\%newsubdir,\%newurls)) { |
\%zombies,\%params,\%mapmoves, |
$mapmoves{$url} = 1; |
\%mapchanges,\%tomove,\%newsubdir, |
} |
\%newurls)) { |
$url = $newurl; |
$mapmoves{$url} = 1; |
} elsif ($env{'docs.markedcopy_nested'}) { |
} |
&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum, |
$url = $newurl; |
$srcdom,$srcnum,$allmaps,\%rewrites, |
} elsif ($env{'docs.markedcopy_nested_'.$suffix}) { |
\%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves, |
&url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom, |
\%mapchanges,\%tomove,\%newsubdir,\%newurls); |
$coursenum,$srcdom{$suffix},$srcnum{$suffix}, |
} |
$allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
} elsif ($url=~m {^/res/}) { |
\%zombies,\%params,\%mapmoves,\%mapchanges, |
# published maps can only exists once, so remove it from paste buffer when done |
\%tomove,\%newsubdir,\%newurls); |
&Apache::lonnet::delenv('docs.markedcopy'); |
} |
# if pasting published map (main content are only) check map is not already in course |
} elsif ($url=~m {^/res/}) { |
if ($folder =~ /^default/) { |
# published map can only exists once, so remove from paste buffer when done |
if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) { |
push(@toclear,$suffix); |
return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.')); |
# if pasting published map (main content area only) check map not already in course |
|
if ($folder =~ /^default/) { |
|
if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) { |
|
$duplicate{$suffix} = 1; |
|
next; |
|
} |
} |
} |
} |
} |
} |
} |
} |
if ($url=~ m{/(bulletinboard|smppg)$}) { |
my $lockerrors; |
my $prefix = $1; |
if ($url=~ m{/(bulletinboard|smppg)$}) { |
#need to copy the db contents to a new one, unless this is a move. |
my $prefix = $1; |
my %info = ( |
#need to copy the db contents to a new one, unless this is a move. |
src => $url, |
my %info = ( |
cdom => $coursedom, |
src => $url, |
cnum => $coursenum, |
cdom => $coursedom, |
); |
cnum => $coursenum, |
unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') { |
); |
my (%lockerr,$msg); |
my (%lockerr,$msg); |
my ($newurl,$result,$errtext) = |
unless ($env{'form.docs.markedcopy_options'} eq 'move') { |
&dbcopy(\%info,$coursedom,$coursenum,\%lockerr); |
my ($newurl,$result,$errtext) = |
if ($result eq 'ok') { |
&dbcopy(\%info,$coursedom,$coursenum,\%lockerr); |
$url = $newurl; |
if ($result eq 'ok') { |
$title=&mt('Copy of').' '.$title; |
$url = $newurl; |
} else { |
$title=&mt('Copy of').' '.$title; |
if ($prefix eq 'smppg') { |
} else { |
$msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext; |
if ($prefix eq 'smppg') { |
} elsif ($prefix eq 'bulletinboard') { |
$msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext; |
$msg = &mt('Paste failed: An error occurred when copying the bulletin board.').' '.$errtext; |
} elsif ($prefix eq 'bulletinboard') { |
} |
$msg = &mt('Paste failed: An error occurred when copying the bulletin board.').' '.$errtext; |
$results{$suffix} = $result; |
|
$msgerrs{$suffix} = $msg; |
|
$lockerrs{$suffix} = $lockerr{$prefix}; |
|
next; |
|
} |
|
if ($lockerr{$prefix}) { |
|
$lockerrs{$suffix} = $lockerr{$prefix}; |
} |
} |
return ($result,undef,[$msg],$lockerr{$prefix}); |
|
} |
|
if ($lockerr{$prefix}) { |
|
$lockerrors = $lockerr{$prefix}; |
|
} |
} |
} |
} |
} |
$title = &LONCAPA::map::qtunescape($title); |
$title = &LONCAPA::map::qtunescape($title); |
my $ext='false'; |
my $ext='false'; |
if ($url=~m{^http(|s)://}) { $ext='true'; } |
if ($url=~m{^http(|s)://}) { $ext='true'; } |
if ($env{'docs.markedcopy_supplemental_'.$suffix}) { |
$url = &LONCAPA::map::qtunescape($url); |
if ($folder !~ /^supplemental/) { |
|
(undef,undef,$title) = |
|
&Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix}); |
|
} |
|
} else { |
|
if ($folder=~/^supplemental/) { |
|
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
|
$env{'user.domain'}.'___&&&___'.$title; |
|
} |
|
} |
|
|
# For uploaded files (excluding pages/sequences) path in copied file is changed |
# For uploaded files (excluding pages/sequences) path in copied file is changed |
# if paste is from Main to Supplemental (or vice versa), or if pasting between |
# if paste is from Main to Supplemental (or vice versa), or if pasting between |
# courses. |
# courses. |
|
|
my $newidx; |
unless ($is_map{$suffix}) { |
unless ($is_map) { |
my $newidx; |
# Now insert the URL at the bottom |
# Now insert the URL at the bottom |
$newidx = &LONCAPA::map::getresidx($url); |
$newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url)); |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) { |
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) { |
my $relpath = $1; |
my $relpath = $1; |
if ($relpath ne '') { |
if ($relpath ne '') { |
my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$}); |
my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$}); |
my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/); |
my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/); |
my $newprefix = $newloc; |
my $newprefix = $newloc; |
if ($newloc eq 'default') { |
if ($newloc eq 'default') { |
$newprefix = 'docs'; |
$newprefix = 'docs'; |
} |
} |
if ($newdocsdir eq '') { |
if ($newdocsdir eq '') { |
$newdocsdir = 'default'; |
$newdocsdir = 'default'; |
} |
} |
if (($prefixchg) || |
if (($prefixchg{$suffix}) || |
($srcdom ne $coursedom) || ($srcnum ne $coursenum) || |
($srcdom{$suffix} ne $coursedom) || |
($env{'form.docs.markedcopy_options'} ne 'move')) { |
($srcnum{$suffix} ne $coursenum) || |
my $newpath = "$newprefix/$newdocsdir/$newidx/$rem"; |
($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) { |
$url = |
my $newpath = "$newprefix/$newdocsdir/$newidx/$rem"; |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath, |
$url = |
&Apache::lonnet::getfile($oldurl)); |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath, |
if ($url eq '/adm/notfound.html') { |
&Apache::lonnet::getfile($oldurl)); |
return (&mt('Paste failed: an error occurred saving the file.')); |
if ($url eq '/adm/notfound.html') { |
} else { |
$msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.'); |
my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$}); |
next; |
$newsubpath =~ s{/+$}{/}; |
} else { |
$docmoves{$oldurl} = $newsubpath; |
my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$}); |
|
$newsubpath =~ s{/+$}{/}; |
|
$docmoves{$oldurl} = $newsubpath; |
|
} |
} |
} |
} |
} |
} |
} |
} |
$LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url). |
} |
':'.$ext.':normal:res'; |
# Apply any changes to maps, or copy dependencies for uploaded HTML pages |
push(@LONCAPA::map::order,$newidx); |
my ($result,$save_err); |
# Store the result |
my %updated = ( |
my ($errtext,$fatal) = |
rewrites => \%rewrites, |
&storemap($coursenum,$coursedom,$folder.'.'.$container,1); |
zombies => \%zombies, |
if ($fatal) { |
removefrommap => \%removefrommap, |
$save_err .= $errtext; |
removeparam => \%removeparam, |
$allresult = 'fail'; |
dbcopies => \%dbcopies, |
|
retitles => \%retitles, |
|
); |
|
my %info = ( |
|
newsubdir => \%newsubdir, |
|
params => \%params, |
|
before => \%before, |
|
after => \%after, |
|
); |
|
my %moves = ( |
|
copies => \%copies, |
|
docmoves => \%docmoves, |
|
mapmoves => \%mapmoves, |
|
); |
|
($result,my $msgsarray,my $lockerror) = |
|
&apply_fixups($folder,$is_map,$coursedom,$coursenum,$errors, |
|
\%updated,\%info,\%moves,$prefixchg,$oldurl,$url,'paste'); |
|
$lockerrors .= $lockerror; |
|
if ($result eq 'ok') { |
|
if ($is_map) { |
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
|
$folder.'.'.$container); |
|
return ($errtext,$save_err,$msgsarray,$lockerrors) if ($fatal); |
|
|
|
if ($#LONCAPA::map::order<1) { |
|
my $idx=&LONCAPA::map::getresidx(); |
|
if ($idx<=0) { $idx=1; } |
|
$LONCAPA::map::order[0]=$idx; |
|
$LONCAPA::map::resources[$idx]=''; |
|
} |
|
$newidx = &LONCAPA::map::getresidx($url); |
|
} |
|
if ($env{'docs.markedcopy_supplemental'}) { |
|
if ($folder !~ /^supplemental/) { |
|
(undef,undef,$title) = |
|
&Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental'}); |
|
} |
|
} else { |
|
if ($folder=~/^supplemental/) { |
|
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
|
$env{'user.domain'}.'___&&&___'.$title; |
|
} |
} |
} |
} |
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res'; |
|
push(@LONCAPA::map::order, $newidx); |
# Apply any changes to maps, or copy dependencies for uploaded HTML pages |
|
unless ($allresult eq 'fail') { |
|
my %updated = ( |
|
rewrites => \%rewrites, |
|
zombies => \%zombies, |
|
removefrommap => \%removefrommap, |
|
removeparam => \%removeparam, |
|
dbcopies => \%dbcopies, |
|
retitles => \%retitles, |
|
); |
|
my %info = ( |
|
newsubdir => \%newsubdir, |
|
params => \%params, |
|
); |
|
if ($prefixchg{$suffix}) { |
|
$info{'before'} = $before{$prefixchg{$suffix}}; |
|
$info{'after'} = $after{$prefixchg{$suffix}}; |
|
} |
|
my %moves = ( |
|
copies => \%copies, |
|
docmoves => \%docmoves, |
|
mapmoves => \%mapmoves, |
|
); |
|
(my $result,$msgs{$suffix},my $lockerror) = |
|
&apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors, |
|
\%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl, |
|
$url,'paste'); |
|
$lockerrors .= $lockerror; |
|
if ($result eq 'ok') { |
|
if ($is_map{$suffix}) { |
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
|
$folder.'.'.$container); |
|
if ($fatal) { |
|
$allresult = 'failread'; |
|
} else { |
|
if ($#LONCAPA::map::order<1) { |
|
my $idx=&LONCAPA::map::getresidx(); |
|
if ($idx<=0) { $idx=1; } |
|
$LONCAPA::map::order[0]=$idx; |
|
$LONCAPA::map::resources[$idx]=''; |
|
} |
|
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); |
|
|
# Store the result |
# Store the result |
my ($errtext,$fatal) = |
my ($errtext,$fatal) = |
&storemap($coursenum,$coursedom,$folder.'.'.$container,1); |
&storemap($coursenum,$coursedom,$folder.'.'.$container,1); |
if ($fatal) { |
if ($fatal) { |
$save_err = $errtext; |
$save_err .= $errtext; |
|
$allresult = 'failstore'; |
|
} |
|
} |
|
} |
|
if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') { |
|
push(@toclear,$suffix); |
|
} |
|
} |
} |
} |
} |
} |
|
&clear_from_buffer(\@toclear,\@currpaste); |
|
my $msgsarray; |
|
foreach my $suffix (keys(%msgs)) { |
|
if (ref($msgs{$suffix}) eq 'ARRAY') { |
|
$msgsarray .= join(',',@{$msgs{$suffix}}); |
|
} |
|
} |
|
return ($allresult,$save_err,$msgsarray,$lockerrors); |
|
} |
|
|
if ($env{'form.docs.markedcopy_options'} eq 'move') { |
sub do_buffer_empty { |
&Apache::lonnet::delenv('docs.markedcopy'); |
my @currpaste = split(/,/,$env{'docs.markedcopies'}); |
&Apache::lonnet::delenv('docs.markedcopy_nested'); |
if (@currpaste == 0) { |
&Apache::lonnet::delenv('docs.markedcopy_nestednames'); |
return &mt('Clipboard is already empty'); |
|
} |
|
my @toclear = &Apache::loncommon::get_env_multiple('form.pasting'); |
|
if (@toclear == 0) { |
|
return &mt('Nothing selected to clear from clipboard'); |
|
} |
|
my $numdel = &clear_from_buffer(\@toclear,\@currpaste); |
|
if ($numdel) { |
|
return &mt('[quant,_1,item] cleared from clipboard',$numdel); |
|
} else { |
|
return &mt('Clipboard unchanged'); |
} |
} |
return ($result,$save_err,$msgsarray,$lockerrors); |
return; |
|
} |
|
|
|
sub clear_from_buffer { |
|
my ($toclear,$currpaste) = @_; |
|
return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY')); |
|
my %pastebuffer; |
|
map { $pastebuffer{$_} = 1; } @{$currpaste}; |
|
my $numdel = 0; |
|
foreach my $suffix (@{$toclear}) { |
|
next if ($suffix =~ /\D/); |
|
next unless (exists($pastebuffer{$suffix})); |
|
my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix; |
|
if (&Apache::lonnet::delenv($regexp,1) eq 'ok') { |
|
delete($pastebuffer{$suffix}); |
|
$numdel ++; |
|
} |
|
} |
|
my $newbuffer = join(',',sort(keys(%pastebuffer))); |
|
&Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer}); |
|
return $numdel; |
} |
} |
|
|
sub get_newmap_url { |
sub get_newmap_url { |
Line 1744 sub apply_fixups {
|
Line 2006 sub apply_fixups {
|
if (defined($LONCAPA::map::resources[$idx])) { |
if (defined($LONCAPA::map::resources[$idx])) { |
my $changed; |
my $changed; |
my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]); |
my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]); |
if ((exists($toremove{$idx})) && ($toremove{$idx} eq $src)) { |
if ((exists($toremove{$idx})) && |
|
($toremove{$idx} eq &LONCAPA::map::qtescape($src))) { |
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}}) { |
Line 1783 sub apply_fixups {
|
Line 2046 sub apply_fixups {
|
$changed = 1; |
$changed = 1; |
} |
} |
if ($changed) { |
if ($changed) { |
$LONCAPA::map::resources[$idx] = join(':',($title,$src,$ext,$type)); |
$LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type)); |
} |
} |
} |
} |
} |
} |
Line 1981 sub update_parameter {
|
Line 2244 sub update_parameter {
|
|
|
sub handle_edit_cmd { |
sub handle_edit_cmd { |
my ($coursenum,$coursedom) =@_; |
my ($coursenum,$coursedom) =@_; |
|
return if ($env{'form.cmd'} eq ''); |
my ($cmd,$idx)=split('_',$env{'form.cmd'}); |
my ($cmd,$idx)=split('_',$env{'form.cmd'}); |
|
|
my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; |
my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; |
my ($title, $url, @rrest) = split(':', $ratstr); |
my ($title, $url, @rrest) = split(':', $ratstr); |
|
|
if ($cmd eq 'del') { |
if ($cmd eq 'remove') { |
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && |
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && |
($url!~/$LONCAPA::assess_page_seq_re/)) { |
($url!~/$LONCAPA::assess_page_seq_re/)) { |
&Apache::lonnet::removeuploadedurl($url); |
&Apache::lonnet::removeuploadedurl($url); |
Line 2008 sub handle_edit_cmd {
|
Line 2272 sub handle_edit_cmd {
|
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1]; |
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1]; |
|
|
} elsif ($cmd eq 'rename') { |
} elsif ($cmd eq 'rename') { |
|
|
my $comment = &LONCAPA::map::qtunescape($env{'form.title'}); |
my $comment = &LONCAPA::map::qtunescape($env{'form.title'}); |
if ($comment=~/\S/) { |
if ($comment=~/\S/) { |
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]= |
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]= |
Line 2017 sub handle_edit_cmd {
|
Line 2280 sub handle_edit_cmd {
|
# Devalidate title cache |
# Devalidate title cache |
my $renamed_url=&LONCAPA::map::qtescape($url); |
my $renamed_url=&LONCAPA::map::qtescape($url); |
&Apache::lonnet::devalidate_title_cache($renamed_url); |
&Apache::lonnet::devalidate_title_cache($renamed_url); |
|
|
} else { |
} else { |
return 0; |
return 0; |
} |
} |
Line 2102 sub editor {
|
Line 2366 sub editor {
|
return $save_error; |
return $save_error; |
} |
} |
if ($paste_res ne 'ok') { |
if ($paste_res ne 'ok') { |
$r->print('<p><span class="LC_error">'.$paste_res.'</span></p>'); |
$r->print('<p class="LC_error">'.$paste_res.'</p>'); |
} |
} |
if (keys(%paste_errors) > 0) { |
if (keys(%paste_errors) > 0) { |
$r->print('<p span class="LC_warning">'."\n". |
$r->print('<p class="LC_warning">'."\n". |
&mt('The following files are either dependencies of a web page or references within a folder and/or composite page which could not be copied during the paste operation:')."\n". |
&mt('The following files are either dependencies of a web page or references within a folder and/or composite page which could not be copied during the paste operation:')."\n". |
'<ul>'."\n"); |
'<ul>'."\n"); |
foreach my $key (sort(keys(%paste_errors))) { |
foreach my $key (sort(keys(%paste_errors))) { |
Line 2113 sub editor {
|
Line 2377 sub editor {
|
} |
} |
$r->print('</ul></p>'."\n"); |
$r->print('</ul></p>'."\n"); |
} |
} |
} |
} elsif ($env{'form.clearmarked'}) { |
|
my $output = &do_buffer_empty(); |
|
if ($output) { |
|
$r->print('<p class="LC_info">'.$output.'</p>'); |
|
} |
|
} |
|
|
$r->print($upload_output); |
$r->print($upload_output); |
|
|
|
# Rename, cut, copy or remove a single resource |
if (&handle_edit_cmd()) { |
if (&handle_edit_cmd()) { |
my $contentchg; |
my $contentchg; |
if ($env{'form.cmd'} =~ /^(del|cut)_/) { |
if ($env{'form.cmd'} =~ m{^(del|cut)_}) { |
$contentchg = 1; |
$contentchg = 1; |
} |
} |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); |
return $errtext if ($fatal); |
return $errtext if ($fatal); |
} |
} |
|
|
|
# Cut, copy and/or remove multiple resources |
|
if ($env{'form.multichange'}) { |
|
my %allchecked = ( |
|
cut => {}, |
|
remove => {}, |
|
); |
|
my $needsupdate; |
|
foreach my $which (keys(%allchecked)) { |
|
$env{'form.multi'.$which} =~ s/,$//; |
|
if ($env{'form.multi'.$which}) { |
|
map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which}); |
|
if (ref($allchecked{$which}) eq 'HASH') { |
|
$needsupdate += scalar(keys(%{$allchecked{$which}})); |
|
} |
|
} |
|
} |
|
if ($needsupdate) { |
|
my $haschanges = 0; |
|
my %curr_groups = &Apache::longroup::coursegroups(); |
|
my $total = scalar(@LONCAPA::map::order) - 1; |
|
for (my $i=$total; $i>=0; $i--) { |
|
my $res = $LONCAPA::map::order[$i]; |
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); |
|
$name=&LONCAPA::map::qtescape($name); |
|
$url=&LONCAPA::map::qtescape($url); |
|
next unless ($name && $url); |
|
my %denied = |
|
&action_restrictions($coursenum,$coursedom,$url, |
|
$env{'form.folderpath'},\%curr_groups); |
|
foreach my $which (keys(%allchecked)) { |
|
next if ($denied{$which}); |
|
next unless ($allchecked{$which}{$res}); |
|
if ($which eq 'remove') { |
|
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && |
|
($url!~/$LONCAPA::assess_page_seq_re/)) { |
|
&Apache::lonnet::removeuploadedurl($url); |
|
} else { |
|
&LONCAPA::map::makezombie($res); |
|
} |
|
splice(@LONCAPA::map::order,$i,1); |
|
$haschanges ++; |
|
} elsif ($which eq 'cut') { |
|
&LONCAPA::map::makezombie($res); |
|
splice(@LONCAPA::map::order,$i,1); |
|
$haschanges ++; |
|
} |
|
} |
|
} |
|
if ($haschanges) { |
|
($errtext,$fatal) = |
|
&storemap($coursenum,$coursedom,$folder.'.'.$container,1); |
|
return $errtext if ($fatal); |
|
} |
|
} |
|
} |
|
|
# Group import/search |
# Group import/search |
if ($env{'form.importdetail'}) { |
if ($env{'form.importdetail'}) { |
my @imports; |
my @imports; |
Line 2237 sub editor {
|
Line 2564 sub editor {
|
$r->print('</div>'); |
$r->print('</div>'); |
} |
} |
|
|
my ($to_show,$output,@allidx,@allmapidx); |
my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups); |
|
%filters = ( |
|
canremove => [], |
|
cancut => [], |
|
cancopy => [], |
|
); |
|
%curr_groups = &Apache::longroup::coursegroups(); |
&Apache::loncommon::start_data_table_count(); #setup a row counter |
&Apache::loncommon::start_data_table_count(); #setup a row counter |
foreach my $res (@LONCAPA::map::order) { |
foreach my $res (@LONCAPA::map::order) { |
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); |
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); |
Line 2252 sub editor {
|
Line 2584 sub editor {
|
} |
} |
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
$coursenum,$coursedom,$crstype, |
$coursenum,$coursedom,$crstype, |
$pathitem,$supplementalflag,$container); |
$pathitem,$supplementalflag,$container, |
|
\%filters,\%curr_groups); |
$idx++; |
$idx++; |
$shown++; |
$shown++; |
} |
} |
&Apache::loncommon::end_data_table_count(); |
&Apache::loncommon::end_data_table_count(); |
|
|
|
my $need_save; |
if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) { |
if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) { |
my $toolslink = '<table><tr><td>' |
my $toolslink = '<table><tr><td>' |
.&Apache::loncommon::help_open_menu('Navigation Screen', |
.&Apache::loncommon::help_open_menu('Navigation Screen', |
Line 2275 sub editor {
|
Line 2609 sub editor {
|
.&Apache::loncommon::start_data_table(undef,'contentlist') |
.&Apache::loncommon::start_data_table(undef,'contentlist') |
.&Apache::loncommon::start_data_table_header_row() |
.&Apache::loncommon::start_data_table_header_row() |
.'<th colspan="2">'.&mt('Move').'</th>' |
.'<th colspan="2">'.&mt('Move').'</th>' |
.'<th>'.&mt('Actions').'</th>' |
.'<th colspan="2">'.&mt('Actions').'</th>' |
.'<th colspan="2">'.&mt('Document').'</th>'; |
.'<th>'.&mt('Document').'</th>'; |
if ($folder !~ /^supplemental/) { |
if ($folder !~ /^supplemental/) { |
$to_show .= '<th colspan="4">'.&mt('Settings').'</th>'; |
$to_show .= '<th colspan="4">'.&mt('Settings').'</th>'; |
} |
} |
$to_show .= &Apache::loncommon::end_data_table_header_row(); |
$to_show .= &Apache::loncommon::end_data_table_header_row(); |
if ($folder !~ /^supplemental/) { |
if ($folder !~ /^supplemental/) { |
my $idxlist = join(',',@allidx); |
$lists{'canhide'} = join(',',@allidx); |
my $mapidxlist = join(',',@allmapidx); |
$lists{'canrandomlyorder'} = join(',',@allmapidx); |
|
foreach my $item ('canremove','cancut','cancopy') { |
|
if (ref($filters{$item}) eq 'ARRAY') { |
|
$lists{$item} = join(',',@{$filters{$item}}); |
|
} |
|
} |
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'},'<>&"'); |
} |
} |
$to_show .= |
if (@allidx > 1) { |
&Apache::loncommon::continue_data_table_row(). |
$to_show .= |
'<td colspan="5"> </td>'. |
&Apache::loncommon::continue_data_table_row(). |
'<td colspan="4">'. |
'<td colspan="2"> </td>'. |
'<form action="/adm/coursedocs" method="post" name="togglemultchecks">'. |
'<td>'. |
'<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.&mt('Select:').' '. |
&multiple_check_form('actions',\%lists). |
'<label><input type="radio" name="showmultpick" value="0" onclick="javascript:togglePick();" checked="checked" />'.&mt('single').'</label>'.(' 'x2).'<label><input type="radio" name="showmultpick" value="1" onclick="javascript:togglePick();" />'.&mt('multiple').'</label></span></form>'. |
'</td>'. |
'<div id="multiclick" style="display: none">'. |
'<td> </td>'. |
'<form action="/adm/coursedocs" method="post" name="cumulativechecks" onsubmit="return submitSettings(this);">'."\n". |
'<td> </td>'. |
'<fieldset><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n". |
'<td colspan="4">'. |
'<table><tr><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')" />'.&mt('Hidden').'</span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');" />'.&mt('Randomly Pick').'<span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" /></span></td>'. |
&multiple_check_form('settings',\%lists). |
'</tr>'."\n". |
'</td>'. |
'<tr><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')" />'.&mt('URL hidden').'</span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')" />'.&mt('Random Order').'</span></td></tr></table>'."\n". |
&Apache::loncommon::end_data_table_row(); |
'</fieldset>'. |
$need_save = 1; |
'<input type="hidden" name="folderpath" value="'.$path.'" />'. |
} |
'<input type="hidden" name="symb" value="'.$env{'form.symb'}.'" />'. |
|
'<input type="hidden" name="allhiddenresource" value="" />'. |
|
'<input type="hidden" name="allencrypturl" value="" />'. |
|
'<input type="hidden" name="allrandompick" value="" />'. |
|
'<input type="hidden" name="allrandomorder" value="" />'. |
|
'<input type="hidden" name="allidx" value="'.$idxlist.'" />'. |
|
'<input type="hidden" name="allmapidx" value="'.$mapidxlist.'" />'. |
|
'<input type="hidden" name="changeparms" value="all" />'. |
|
'<input type="submit" name="multiplesettings" value="'.&mt('Save settings below').'" />'. |
|
'</form>'. |
|
'</div>'. |
|
|
|
'</td>'. |
|
&Apache::loncommon::end_data_table_row(); |
|
} |
} |
} |
} |
$to_show .= $output.' ' |
$to_show .= $output.' ' |
Line 2360 sub editor {
|
Line 2685 sub editor {
|
} |
} |
if ($allowed) { |
if ($allowed) { |
my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container"; |
my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container"; |
$r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto, |
$r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath, |
$readfile)); |
$jumpto,$readfile,$need_save,"$folder.$container")); |
&print_paste_buffer($r,$container,$folder,$coursedom,$coursenum); |
&print_paste_buffer($r,$container,$folder,$coursedom,$coursenum); |
} else { |
} else { |
$r->print($to_show); |
$r->print($to_show); |
Line 2369 sub editor {
|
Line 2694 sub editor {
|
return; |
return; |
} |
} |
|
|
|
sub multiple_check_form { |
|
my ($caller,$listsref) = @_; |
|
return unless (ref($listsref) eq 'HASH'); |
|
my $output = |
|
'<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'. |
|
'<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'. |
|
'<label><input type="radio" name="showmultpick" value="0" onclick="javascript:togglePick('."'$caller','0'".');" checked="checked" />'.&mt('one').'</label>'.(' 'x2).'<label><input type="radio" name="showmultpick" value="1" onclick="javascript:togglePick('."'$caller','1'".');" />'.&mt('multiple').'</label></span><span id="more'.$caller.'" class="LC_nobreak LC_docs_ext_edit"></span></form>'. |
|
'<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'. |
|
'<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n". |
|
'<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n"; |
|
if ($caller eq 'settings') { |
|
$output .= |
|
'<table><tr>'. |
|
'<td class="LC_docs_entry_parameter">'. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')" />'.&mt('Hidden'). |
|
'</label></span></td>'. |
|
'<td class="LC_docs_entry_parameter">'. |
|
'<span class="LC_nobreak"><label><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');" />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'. |
|
'</span></td>'. |
|
'</tr>'."\n". |
|
'<tr>'. |
|
'<td class="LC_docs_entry_parameter">'. |
|
'<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')" />'.&mt('URL hidden').'</label></span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><label><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')" />'.&mt('Random Order'). |
|
'</label></span>'. |
|
'</td></tr></table>'."\n"; |
|
} else { |
|
$output .= |
|
'<table><tr>'. |
|
'<td class="LC_docs_entry_parameter">'. |
|
'<span class="LC_nobreak LC_docs_remove">'. |
|
'<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')" />'.&mt('Remove'). |
|
'</label></span></td>'. |
|
'<td class="LC_docs_entry_parameter">'. |
|
'<span class="LC_nobreak LC_docs_cut">'. |
|
'<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');" />'.&mt('Cut'). |
|
'</label></span></td>'."\n". |
|
'<td class="LC_docs_entry_parameter">'. |
|
'<span class="LC_nobreak LC_docs_copy">'. |
|
'<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')" />'.&mt('Copy'). |
|
'</label></span></td>'. |
|
'</tr></table>'."\n"; |
|
} |
|
$output .= |
|
'</fieldset>'. |
|
'<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />'; |
|
if ($caller eq 'settings') { |
|
$output .= |
|
'<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'; |
|
} elsif ($caller eq 'actions') { |
|
$output .= |
|
'<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'. |
|
'<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'. |
|
'<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />'; |
|
} |
|
$output .= |
|
'</form>'. |
|
'</div>'; |
|
return $output; |
|
} |
|
|
sub process_file_upload { |
sub process_file_upload { |
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; |
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; |
# upload a file, if present |
# upload a file, if present |
Line 2528 sub is_supplemental_title {
|
Line 2914 sub is_supplemental_title {
|
|
|
sub entryline { |
sub entryline { |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom, |
$crstype,$pathitem,$supplementalflag,$container)=@_; |
$crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups)=@_; |
my ($foldertitle,$renametitle); |
my ($foldertitle,$renametitle); |
if (&is_supplemental_title($title)) { |
if (&is_supplemental_title($title)) { |
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); |
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title); |
Line 2544 sub entryline {
|
Line 2930 sub entryline {
|
$renametitle=~s/\"\;/\\\"/g; |
$renametitle=~s/\"\;/\\\"/g; |
$renametitle=~s/ /%20/g; |
$renametitle=~s/ /%20/g; |
my $line=&Apache::loncommon::start_data_table_row(); |
my $line=&Apache::loncommon::start_data_table_row(); |
my ($form_start,$form_end,$form_common); |
my ($form_start,$form_end,$form_common,$form_param); |
# Edit commands |
# Edit commands |
my ($esc_path, $path, $symb); |
my ($esc_path, $path, $symb); |
if ($env{'form.folderpath'}) { |
if ($env{'form.folderpath'}) { |
Line 2568 sub entryline {
|
Line 2954 sub entryline {
|
&Apache::lonnet::declutter($currurl)); |
&Apache::lonnet::declutter($currurl)); |
} |
} |
} |
} |
my ($renamelink,%lt); |
my ($renamelink,%lt,$ishash); |
|
if (ref($filtersref) eq 'HASH') { |
|
$ishash = 1; |
|
} |
|
|
if ($allowed) { |
if ($allowed) { |
|
$form_start = ' |
|
<form action="/adm/coursedocs" method="post"> |
|
'; |
|
$form_common=(<<END); |
|
<input type="hidden" name="folderpath" value="$path" /> |
|
<input type="hidden" name="symb" value="$symb" /> |
|
END |
|
$form_param=(<<END); |
|
<input type="hidden" name="setparms" value="$orderidx" /> |
|
<input type="hidden" name="changeparms" value="0" /> |
|
END |
|
$form_end = '</form>'; |
|
|
my $incindex=$index+1; |
my $incindex=$index+1; |
my $selectbox=''; |
my $selectbox=''; |
if (($#LONCAPA::map::order>0) && |
if (($#LONCAPA::map::order>0) && |
Line 2605 sub entryline {
|
Line 3008 sub entryline {
|
'ul' => 'URL', |
'ul' => 'URL', |
'ti' => 'Title', |
'ti' => 'Title', |
); |
); |
my $nocopy=0; |
my %denied = &action_restrictions($coursenum,$coursedom,$url, |
my $nocut=0; |
$env{'form.folderpath'}, |
my $noremove=0; |
$currgroups); |
if ($url=~ m{^/res/.+\.(page|sequence)$}) { |
|
# no copy for published maps |
|
$nocopy=1; |
|
} |
|
if ($url=~/^\/res\/lib\/templates\//) { |
|
$nocopy=1; |
|
$nocut=1; |
|
} |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
if ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") { |
|
if ($env{'form.folderpath'} =~ /^default&[^\&]+$/) { |
|
my %curr_groups = &Apache::longroup::coursegroups(); |
|
if (keys(%curr_groups) > 0) { |
|
$noremove=1; |
|
} |
|
$nocut=1; |
|
$nocopy=1; |
|
} |
|
} elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) { |
|
my $group = $1; |
|
if ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) { |
|
my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group); |
|
if (keys(%curr_group) > 0) { |
|
$noremove=1; |
|
} |
|
} |
|
$nocut=1; |
|
$nocopy=1; |
|
} elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) { |
|
my $group = $1; |
|
if ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) { |
|
my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group); |
|
my %groupsettings = &Apache::longroup::get_group_settings($curr_group{$group}); |
|
if (keys(%groupsettings) > 0) { |
|
$noremove=1; |
|
} |
|
$nocut=1; |
|
$nocopy=1; |
|
} |
|
} elsif ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) { |
|
my $group = $1; |
|
my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group); |
|
if ($url =~ /group_boards_\Q$group\E/) { |
|
my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group); |
|
my %groupsettings = &Apache::longroup::get_group_settings($curr_group{$group}); |
|
if (keys(%groupsettings) > 0) { |
|
if (ref($groupsettings{'functions'}) eq 'HASH') { |
|
if ($groupsettings{'functions'}{'discussion'} eq 'on') { |
|
$noremove=1; |
|
} |
|
} |
|
} |
|
$nocut=1; |
|
$nocopy=1; |
|
} |
|
} |
|
my ($copylink,$cutlink,$removelink); |
my ($copylink,$cutlink,$removelink); |
my $skip_confirm = 0; |
my $skip_confirm = 0; |
if ( $folder =~ /^supplemental/ |
if ( $folder =~ /^supplemental/ |
Line 2678 sub entryline {
|
Line 3024 sub entryline {
|
$skip_confirm = 1; |
$skip_confirm = 1; |
} |
} |
|
|
if ($nocopy) { |
if ($denied{'copy'}) { |
$copylink=(<<ENDCOPY); |
$copylink=(<<ENDCOPY); |
<span style="visibility: hidden;">$lt{'cp'}</span> |
<span style="visibility: hidden;">$lt{'cp'}</span> |
ENDCOPY |
ENDCOPY |
} else { |
} else { |
|
my $formname = 'edit_copy_'.$orderidx; |
|
my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');"; |
$copylink=(<<ENDCOPY); |
$copylink=(<<ENDCOPY); |
<a href="javascript:markcopy('$esc_path','$index','$renametitle','$container','$folder');" class="LC_docs_copy">$lt{'cp'}</a> |
<form name="$formname" method="post" action="/adm/coursedocs"> |
|
$form_common |
|
<input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden"><a href="$js" class="LC_docs_copy">$lt{'cp'}</a> |
|
$form_end |
ENDCOPY |
ENDCOPY |
|
if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) { |
|
push(@{$filtersref->{'cancopy'}},$orderidx); |
|
} |
} |
} |
if ($nocut) { |
if ($denied{'cut'}) { |
$cutlink=(<<ENDCUT); |
$cutlink=(<<ENDCUT); |
<span style="visibility: hidden;">$lt{'ct'}</span> |
<span style="visibility: hidden;">$lt{'ct'}</span> |
ENDCUT |
ENDCUT |
} else { |
} else { |
|
my $formname = 'edit_cut_'.$orderidx; |
|
my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');"; |
$cutlink=(<<ENDCUT); |
$cutlink=(<<ENDCUT); |
<a href="javascript:cutres('$esc_path','$index','$renametitle','$container','$folder',$skip_confirm);" class="LC_docs_cut">$lt{'ct'}</a> |
<form name="$formname" method="post" action="/adm/coursedocs"> |
|
$form_common |
|
<input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden"><a href="$js" class="LC_docs_cut">$lt{'ct'}</a> |
|
$form_end |
ENDCUT |
ENDCUT |
|
if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) { |
|
push(@{$filtersref->{'cancut'}},$orderidx); |
|
} |
} |
} |
if ($noremove) { |
if ($denied{'remove'}) { |
$removelink=(<<ENDREM); |
$removelink=(<<ENDREM); |
<span style="visibility: hidden;">$lt{'rm'}</a> |
<span style="visibility: hidden;">$lt{'rm'}</a> |
ENDREM |
ENDREM |
} else { |
} else { |
|
my $formname = 'edit_remove_'.$orderidx; |
|
my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm);"; |
$removelink=(<<ENDREM); |
$removelink=(<<ENDREM); |
<a href='javascript:removeres("$esc_path","$index","$renametitle",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a> |
<form name="$formname" method="post" action="/adm/coursedocs"> |
|
$form_common |
|
<input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden"><a href="$js" class="LC_docs_remove">$lt{'rm'}</a> |
|
$form_end |
ENDREM |
ENDREM |
|
if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) { |
|
push(@{$filtersref->{'canremove'}},$orderidx); |
|
} |
} |
} |
unless ($isexternal) { |
unless ($isexternal) { |
$renamelink=(<<ENDREN); |
$renamelink=(<<ENDREN); |
<a href='javascript:changename("$esc_path","$index","$renametitle");' class="LC_docs_rename">$lt{'rn'}</a> |
<a href='javascript:changename("$esc_path","$index","$renametitle");' class="LC_docs_rename">$lt{'rn'}</a> |
ENDREN |
ENDREN |
} |
} |
$form_start = ' |
|
<form action="/adm/coursedocs" method="post"> |
|
'; |
|
$form_common=(<<END); |
|
<input type="hidden" name="folderpath" value="$path" /> |
|
<input type="hidden" name="symb" value="$symb" /> |
|
<input type="hidden" name="setparms" value="$orderidx" /> |
|
<input type="hidden" name="changeparms" value="0" /> |
|
END |
|
$form_end = '</form>'; |
|
$line.=(<<END); |
$line.=(<<END); |
<td> |
<td> |
<div class="LC_docs_entry_move"> |
<div class="LC_docs_entry_move"> |
Line 2735 END
|
Line 3095 END
|
</td> |
</td> |
<td> |
<td> |
$form_start |
$form_start |
|
$form_param |
$form_common |
$form_common |
$selectbox |
$selectbox |
$form_end |
$form_end |
Line 2746 $copylink
|
Line 3107 $copylink
|
</span> |
</span> |
</td> |
</td> |
END |
END |
|
|
} |
} |
# Figure out what kind of a resource this is |
# Figure out what kind of a resource this is |
my ($extension)=($url=~/\.(\w+)$/); |
my ($extension)=($url=~/\.(\w+)$/); |
Line 2835 END
|
Line 3195 END
|
my $formname = 'edit_randompick_'.$orderidx; |
my $formname = 'edit_randompick_'.$orderidx; |
$rand_pick_text = |
$rand_pick_text = |
'<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n". |
'<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n". |
|
$form_param."\n". |
$form_common."\n". |
$form_common."\n". |
'<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">'; |
'<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">'; |
if ($rpicknum ne '') { |
if ($rpicknum ne '') { |
Line 2847 $form_common."\n".
|
Line 3208 $form_common."\n".
|
my $formname = 'edit_rorder_'.$orderidx; |
my $formname = 'edit_rorder_'.$orderidx; |
$rand_order_text = |
$rand_order_text = |
'<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n". |
'<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\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'".')"; '.$ro_set.' /> '.&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.' /> '.&mt('Random Order').' </label></span>'. |
$form_end; |
$form_end; |
} |
} |
} elsif ($supplementalflag && !$allowed) { |
} elsif ($supplementalflag && !$allowed) { |
Line 2928 $form_end;
|
Line 3290 $form_end;
|
$line.=(<<ENDPARMS); |
$line.=(<<ENDPARMS); |
<td class="LC_docs_entry_parameter"> |
<td class="LC_docs_entry_parameter"> |
<form action="/adm/coursedocs" method="post" name="$formhidden"> |
<form action="/adm/coursedocs" method="post" name="$formhidden"> |
|
$form_param |
$form_common |
$form_common |
<label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'."'hiddenresource'".');" $hidtext /> $lt{'hd'}</label> |
<label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext /> $lt{'hd'}</label> |
$form_end |
$form_end |
<br /> |
<br /> |
<form action="/adm/coursedocs" method="post" name="$formurlhidden"> |
<form action="/adm/coursedocs" method="post" name="$formurlhidden"> |
|
$form_param |
$form_common |
$form_common |
<label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'."'encrypturl'".');" $enctext /> $lt{'ec'}</label> |
<label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext /> $lt{'ec'}</label> |
$form_end |
$form_end |
</td> |
</td> |
<td class="LC_docs_entry_parameter">$rand_pick_text<br /> |
<td class="LC_docs_entry_parameter">$rand_pick_text<br /> |
Line 2945 ENDPARMS
|
Line 3309 ENDPARMS
|
return $line; |
return $line; |
} |
} |
|
|
|
sub action_restrictions { |
|
my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_; |
|
my %denied = ( |
|
cut => 0, |
|
copy => 0, |
|
remove => 0, |
|
); |
|
if ($url=~ m{^/res/.+\.(page|sequence)$}) { |
|
# no copy for published maps |
|
$denied{'copy'} = 1; |
|
} elsif ($url=~m{^/res/lib/templates/}) { |
|
$denied{'copy'} = 1; |
|
$denied{'cut'} = 1; |
|
} elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") { |
|
if ($folderpath =~ /^default&[^\&]+$/) { |
|
if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) { |
|
$denied{'remove'} = 1; |
|
} |
|
$denied{'cut'} = 1; |
|
$denied{'copy'} = 1; |
|
} |
|
} elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) { |
|
my $group = $1; |
|
if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) { |
|
if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) { |
|
$denied{'remove'} = 1; |
|
} |
|
} |
|
$denied{'cut'} = 1; |
|
$denied{'copy'} = 1; |
|
} elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) { |
|
my $group = $1; |
|
if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) { |
|
if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) { |
|
my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group}); |
|
if (keys(%groupsettings) > 0) { |
|
$denied{'remove'} = 1; |
|
} |
|
$denied{'cut'} = 1; |
|
$denied{'copy'} = 1; |
|
} |
|
} |
|
} elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) { |
|
my $group = $1; |
|
if ($url =~ /group_boards_\Q$group\E/) { |
|
if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) { |
|
my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group}); |
|
if (keys(%groupsettings) > 0) { |
|
if (ref($groupsettings{'functions'}) eq 'HASH') { |
|
if ($groupsettings{'functions'}{'discussion'} eq 'on') { |
|
$denied{'remove'} = 1; |
|
} |
|
} |
|
} |
|
$denied{'cut'} = 1; |
|
$denied{'copy'} = 1; |
|
} |
|
} |
|
} |
|
return %denied; |
|
} |
|
|
sub new_timebased_suffix { |
sub new_timebased_suffix { |
my ($coursedom,$coursenum,$type,$area,$container) = @_; |
my ($dom,$num,$type,$area,$container) = @_; |
my ($prefix,$namespace,$idtype,$errtext,$locknotfreed); |
my ($prefix,$namespace,$idtype,$errtext,$locknotfreed); |
if ($type eq 'map') { |
if ($type eq 'paste') { |
|
$prefix = $type; |
|
$namespace = 'courseeditor'; |
|
} elsif ($type eq 'map') { |
$prefix = 'docs'; |
$prefix = 'docs'; |
if ($area eq 'supplemental') { |
if ($area eq 'supplemental') { |
$prefix = 'supp'; |
$prefix = 'supp'; |
Line 2961 sub new_timebased_suffix {
|
Line 3390 sub new_timebased_suffix {
|
} |
} |
$idtype = 'concat'; |
$idtype = 'concat'; |
my ($suffix,$freedlock,$error) = |
my ($suffix,$freedlock,$error) = |
&Apache::lonnet::get_timebased_id($prefix,'num',$namespace, |
&Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num); |
$coursedom,$coursenum); |
|
if (!$suffix) { |
if (!$suffix) { |
if ($type eq 'map') { |
if ($type eq 'paste') { |
|
$errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.'); |
|
} elsif ($type eq 'map') { |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.'); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.'); |
} elsif ($type eq 'smppg') { |
} elsif ($type eq 'smppg') { |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.'); |
$errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.'); |
Line 2979 sub new_timebased_suffix {
|
Line 3409 sub new_timebased_suffix {
|
$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 'map') { |
if ($type eq 'paste') { |
|
&mt('This will prevent use of the paste buffer until th next log-in.'); |
|
} elsif ($type eq 'map') { |
&mt('This will prevent creation of additional folders or composite pages in this course.'); |
&mt('This will prevent creation of additional folders or composite pages in this course.'); |
} elsif ($type eq 'smppg') { |
} elsif ($type eq 'smppg') { |
$locknotfreed .= |
$locknotfreed .= |
Line 2988 sub new_timebased_suffix {
|
Line 3420 sub new_timebased_suffix {
|
$locknotfreed .= |
$locknotfreed .= |
&mt('This will prevent creation of additional bulletin boards in this course.'); |
&mt('This will prevent creation of additional bulletin boards in this course.'); |
} |
} |
$locknotfreed .= |
unless ($type eq 'paste') { |
' '.&mt('Please contact the domain coordinator for your LON-CAPA domain.'). |
$locknotfreed .= |
'</div>'; |
' '.&mt('Please contact the domain coordinator for your LON-CAPA domain.'); |
|
} |
|
$locknotfreed .= '</div>'; |
} |
} |
return ($suffix,$errtext,$locknotfreed); |
return ($suffix,$errtext,$locknotfreed); |
} |
} |
Line 3654 sub handler {
|
Line 4088 sub handler {
|
# supplementalflag=0: show standard documents |
# supplementalflag=0: show standard documents |
# toolsflag=1: show utilities |
# toolsflag=1: show utilities |
|
|
|
$env{'form.folderpath'} = &unescape($env{'form.folderpath'}); |
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); |
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); |
if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) { |
if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) { |
$supplementalflag=0; |
$supplementalflag=0; |
Line 3688 sub handler {
|
Line 4122 sub handler {
|
} |
} |
} elsif ($env{'form.command'} eq 'editdocs') { |
} elsif ($env{'form.command'} eq 'editdocs') { |
$env{'form.folderpath'} = 'default&'. |
$env{'form.folderpath'} = 'default&'. |
&Apache::lonhtmlcommon::entity_encode('Main Course Content'). |
&escape(&mt('Main '.$crstype.' Content').':::::'); |
':::::'; |
|
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}}); |
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}}); |
} elsif ($env{'form.command'} eq 'editsupp') { |
} elsif ($env{'form.command'} eq 'editsupp') { |
$env{'form.folderpath'} = 'supplemental&'. |
$env{'form.folderpath'} = 'supplemental&'. |
&Apache::lonhtmlcommon::entity_encode('Supplemental Content'); |
&escape('Supplemental Content'); |
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'}); |
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'}); |
} elsif ($env{'form.command'} eq 'contents') { |
} elsif ($env{'form.command'} eq 'contents') { |
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'}); |
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'}); |
Line 3734 sub handler {
|
Line 4167 sub handler {
|
if ($supplementalflag) { |
if ($supplementalflag) { |
$env{'form.folderpath'}=&supplemental_base(); |
$env{'form.folderpath'}=&supplemental_base(); |
} else { |
} else { |
$env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Documents')). |
$env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Content'). |
':::::'; |
':::::'); |
} |
} |
} |
} |
|
|
Line 3760 sub handler {
|
Line 4193 sub handler {
|
if ($env{'form.folder'} eq '' || |
if ($env{'form.folder'} eq '' || |
$env{'form.folder'} eq 'supplemental') { |
$env{'form.folder'} eq 'supplemental') { |
$folderpath='default&'. |
$folderpath='default&'. |
&escape(&mt('Main '.$crstype.' Documents')). |
&escape(&mt('Main '.$crstype.' Content').':::::'); |
':::::'; |
|
} |
} |
} |
} |
$containertag = '<input type="hidden" name="folderpath" value="" />'; |
$containertag = '<input type="hidden" name="folderpath" value="" />'; |
Line 3818 sub handler {
|
Line 4250 sub handler {
|
onload => "javascript:resize_scrollbox('contentscroll','1','1');", |
onload => "javascript:resize_scrollbox('contentscroll','1','1');", |
}; |
}; |
} |
} |
if ($env{'docs.markedcopy_url'}) { |
$script .= &paste_popup_js(); |
$script .= &paste_popup_js(); |
|
} |
|
my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. |
my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. |
&mt('Switch server?'); |
&mt('Switch server?'); |
|
|
Line 3846 sub handler {
|
Line 4276 sub handler {
|
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb({ |
&Apache::lonhtmlcommon::add_breadcrumb({ |
href=>"/adm/coursedocs",text=>"$crstype Contents"}); |
href=>"/adm/coursedocs",text=>"$crstype Contents"}); |
|
|
$r->print(&Apache::loncommon::start_page("$crstype Contents", $script, |
$r->print(&Apache::loncommon::start_page("$crstype Contents", $script, |
{'add_entries' => $addentries} |
{'add_entries' => $addentries} |
) |
) |
Line 4047 SEDFFORM
|
Line 4476 SEDFFORM
|
if ($folder eq '') { |
if ($folder eq '') { |
$folder='default'; |
$folder='default'; |
} |
} |
&update_paste_buffer($coursenum,$coursedom,$folder); |
my $output = &update_paste_buffer($coursenum,$coursedom,$folder); |
|
if ($output) { |
|
$r->print($output); |
|
} |
$r->print(<<HIDDENFORM); |
$r->print(<<HIDDENFORM); |
<form name="renameform" method="post" action="/adm/coursedocs"> |
<form name="renameform" method="post" action="/adm/coursedocs"> |
<input type="hidden" name="title" /> |
<input type="hidden" name="title" /> |
Line 4660 sub generate_admin_menu {
|
Line 5092 sub generate_admin_menu {
|
foreach my $aurole (keys(%outhash)) { |
foreach my $aurole (keys(%outhash)) { |
unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) { |
unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) { |
push(@hosts,$outhash{$aurole}); |
push(@hosts,$outhash{$aurole}); |
} |
} |
} |
} |
if (@hosts == 1) { |
if (@hosts == 1) { |
my $switchto = '/adm/switchserver?otherserver='.$hosts[0]. |
my $switchto = '/adm/switchserver?otherserver='.$hosts[0]. |
Line 4724 sub generate_admin_menu {
|
Line 5156 sub generate_admin_menu {
|
} |
} |
|
|
sub generate_edit_table { |
sub generate_edit_table { |
my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile) = @_; |
my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile, |
|
$need_save,$copyfolder) = @_; |
return unless(ref($orderhash_ref) eq 'HASH'); |
return unless(ref($orderhash_ref) eq 'HASH'); |
my %orderhash = %{$orderhash_ref}; |
my %orderhash = %{$orderhash_ref}; |
my $form; |
my $form; |
Line 4773 sub generate_edit_table {
|
Line 5206 sub generate_edit_table {
|
$form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n"; |
$form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n"; |
|
|
if ($to_show ne '') { |
if ($to_show ne '') { |
$form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'."\n"; |
my $saveform; |
|
if ($need_save) { |
|
my $button = &mt('Make changes'); |
|
my $path; |
|
if ($env{'form.folderpath'}) { |
|
$path = |
|
&HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
|
} |
|
$saveform = <<"END"; |
|
<div id="multisave" style="display:none; clear:both;" > |
|
<form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();"> |
|
<input type="hidden" name="folderpath" value="$path" /> |
|
<input type="hidden" name="symb" value="$env{'form.symb'}" /> |
|
<input type="hidden" name="allhiddenresource" value="" /> |
|
<input type="hidden" name="allencrypturl" value="" /> |
|
<input type="hidden" name="allrandompick" value="" /> |
|
<input type="hidden" name="allrandomorder" value="" /> |
|
<input type="hidden" name="changeparms" value="" /> |
|
<input type="hidden" name="multiremove" value="" /> |
|
<input type="hidden" name="multicut" value="" /> |
|
<input type="hidden" name="multicopy" value="" /> |
|
<input type="hidden" name="multichange" value="" /> |
|
<input type="hidden" name="copyfolder" value="$copyfolder" /> |
|
<input type="submit" name="savemultiples" value="$button" /> |
|
</form> |
|
</div> |
|
END |
|
} |
|
$form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n"; |
} |
} |
foreach my $field (keys(%orderhash)){ |
foreach my $field (keys(%orderhash)){ |
if($field ne '00'){ |
if($field ne '00'){ |
Line 4823 sub editing_js {
|
Line 5284 sub editing_js {
|
imscms => 'You must select which Course Management System was the source of the IMS package', |
imscms => 'You must select which Course Management System was the source of the IMS package', |
invurl => 'Invalid URL', |
invurl => 'Invalid URL', |
titbl => 'Title is blank', |
titbl => 'Title is blank', |
|
more => '(More ...)', |
|
less => '(Less ...)', |
); |
); |
|
|
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
Line 4831 sub editing_js {
|
Line 5294 sub editing_js {
|
if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) { |
if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) { |
$main_container_page = 1; |
$main_container_page = 1; |
} |
} |
my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents%3A%3A%3A%3A%3A'; |
my $toplevelmain = |
|
&escape(&mt('Main '.$crstype.' Content').':::::'); |
my $toplevelsupp = &supplemental_base(); |
my $toplevelsupp = &supplemental_base(); |
|
|
my $backtourl; |
my $backtourl; |
Line 5006 function makeims(imsform) {
|
Line 5470 function makeims(imsform) {
|
function changename(folderpath,index,oldtitle) { |
function changename(folderpath,index,oldtitle) { |
var title=prompt('$lt{"p_chn"}',oldtitle); |
var title=prompt('$lt{"p_chn"}',oldtitle); |
if (title) { |
if (title) { |
this.document.forms.renameform.markcopy.value=-1; |
this.document.forms.renameform.markcopy.value=''; |
this.document.forms.renameform.title.value=title; |
this.document.forms.renameform.title.value=title; |
this.document.forms.renameform.cmd.value='rename_'+index; |
this.document.forms.renameform.cmd.value='rename_'+index; |
this.document.forms.renameform.folderpath.value=folderpath; |
this.document.forms.renameform.folderpath.value=folderpath; |
Line 5014 this.document.forms.renameform.submit();
|
Line 5478 this.document.forms.renameform.submit();
|
} |
} |
} |
} |
|
|
function removeres(folderpath,index,oldtitle,skip_confirm) { |
|
if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) { |
|
this.document.forms.renameform.markcopy.value=-1; |
|
this.document.forms.renameform.cmd.value='del_'+index; |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
this.document.forms.renameform.submit(); |
|
} |
|
} |
|
|
|
function cutres(folderpath,index,oldtitle,container,folder,skip_confirm) { |
|
if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) { |
|
this.document.forms.renameform.cmd.value='cut_'+index; |
|
this.document.forms.renameform.markcopy.value=index; |
|
this.document.forms.renameform.copyfolder.value=folder+'.'+container; |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
this.document.forms.renameform.submit(); |
|
} |
|
} |
|
|
|
function markcopy(folderpath,index,oldtitle,container,folder) { |
|
this.document.forms.renameform.markcopy.value=index; |
|
this.document.forms.renameform.copyfolder.value=folder+'.'+container; |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
this.document.forms.renameform.submit(); |
|
} |
|
|
|
function updatePick(targetform,index,caller) { |
function updatePick(targetform,index,caller) { |
var pickitem; |
var pickitem; |
var picknumitem; |
var picknumitem; |
Line 5064 function updatePick(targetform,index,cal
|
Line 5502 function updatePick(targetform,index,cal
|
propagateState(targetform,'rpicknum'); |
propagateState(targetform,'rpicknum'); |
} |
} |
} else { |
} else { |
checkForSubmit(targetform,'randompick'); |
checkForSubmit(targetform,'randompick','settings'); |
} |
} |
} |
} |
} else { |
} else { |
Line 5073 function updatePick(targetform,index,cal
|
Line 5511 function updatePick(targetform,index,cal
|
if (regexdigit.test(picknum)) { |
if (regexdigit.test(picknum)) { |
picknumitem.value = picknum; |
picknumitem.value = picknum; |
if (index == 'all') { |
if (index == 'all') { |
picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativechecks,\\'all\\',\\'link\\');">'+picknum+'</a>'; |
picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>'; |
if (caller == 'link') { |
if (caller == 'link') { |
propagateState(targetform,'rpicknum'); |
propagateState(targetform,'rpicknum'); |
} |
} |
} else { |
} else { |
picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>'; |
picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>'; |
checkForSubmit(targetform,'randompick'); |
checkForSubmit(targetform,'randompick','settings'); |
} |
} |
} else { |
} else { |
if (caller == 'check') { |
if (caller == 'check') { |
Line 5090 function updatePick(targetform,index,cal
|
Line 5528 function updatePick(targetform,index,cal
|
} |
} |
} else { |
} else { |
pickitem.checked=false; |
pickitem.checked=false; |
checkForSubmit(targetform,'randompick'); |
checkForSubmit(targetform,'randompick','settings'); |
} |
} |
} |
} |
return; |
return; |
Line 5104 function updatePick(targetform,index,cal
|
Line 5542 function updatePick(targetform,index,cal
|
propagateState(targetform,'rpicknum'); |
propagateState(targetform,'rpicknum'); |
} |
} |
} else { |
} else { |
checkForSubmit(targetform,'randompick'); |
checkForSubmit(targetform,'randompick','settings'); |
} |
} |
} |
} |
} |
} |
Line 5126 function propagateState(form,param) {
|
Line 5564 function propagateState(form,param) {
|
setcheck = 1; |
setcheck = 1; |
} |
} |
} |
} |
|
var allidxlist; |
|
if ((param == 'remove') || (param == 'cut') || (param == 'copy')) { |
|
if (document.getElementById('all'+param+'idx')) { |
|
allidxlist = document.getElementById('all'+param+'idx').value; |
|
} |
|
var actions = new Array ('remove','cut','copy'); |
|
for (var i=0; i<actions.length; i++) { |
|
if (actions[i] != param) { |
|
if (document.getElementById(actions[i]+'all')) { |
|
document.getElementById(actions[i]+'all').checked = false; |
|
} |
|
} |
|
} |
|
} |
if ((param == 'encrypturl') || (param == 'hiddenresource')) { |
if ((param == 'encrypturl') || (param == 'hiddenresource')) { |
var allidxlist = form.allidx.value; |
allidxlist = form.allidx.value; |
if (allidxlist != '') { |
} |
var allidxs = allidxlist.split(','); |
if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) { |
if (allidxs.length > 1) { |
allidxlist = form.allmapidx.value; |
for (var i=0; i<allidxs.length; i++) { |
} |
if (document.getElementById(param+'_'+allidxs[i])) { |
if ((allidxlist != '') && (allidxlist != null)) { |
|
var allidxs = allidxlist.split(','); |
|
if (allidxs.length > 1) { |
|
for (var i=0; i<allidxs.length; i++) { |
|
if (document.getElementById(param+'_'+allidxs[i])) { |
|
if (param == 'rpicknum') { |
|
if (document.getElementById('randompick_'+allidxs[i])) { |
|
if (document.getElementById('randompick_'+allidxs[i]).checked) { |
|
document.getElementById(param+'_'+allidxs[i]).value = rpick; |
|
if (rpick > 0) { |
|
document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>'; |
|
} else { |
|
document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ''; |
|
} |
|
} |
|
} |
|
} else { |
if (setcheck == 1) { |
if (setcheck == 1) { |
document.getElementById(param+'_'+allidxs[i]).checked = true; |
document.getElementById(param+'_'+allidxs[i]).checked = true; |
} else { |
} else { |
document.getElementById(param+'_'+allidxs[i]).checked = false; |
document.getElementById(param+'_'+allidxs[i]).checked = false; |
|
if (param == 'randompick') { |
|
document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ''; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
if (setcheck == 1) { |
} else { |
if ((param == 'remove') || (param == 'cut') || (param == 'copy')) { |
var allmapidxlist = form.allmapidx.value; |
var actions = new Array('copy','cut','remove'); |
if (allmapidxlist != '') { |
for (var i=0; i<actions.length; i++) { |
var allmapidxs = allmapidxlist.split(','); |
var otheractions; |
if (allmapidxs.length > 1) { |
var otheridxs; |
for (var i=0; i<allmapidxs.length; i++) { |
if (actions[i] === param) { |
var item = param+'_'+allmapidxs[i]; |
continue; |
if (document.getElementById(item)) { |
} else { |
if (param == 'rpicknum') { |
if (document.getElementById('all'+actions[i]+'idx')) { |
if (document.getElementById('randompick_'+allmapidxs[i])) { |
otheractions = document.getElementById('all'+actions[i]+'idx').value; |
if (document.getElementById('randompick_'+allmapidxs[i]).checked) { |
otheridxs = otheractions.split(','); |
document.getElementById(param+'_'+allmapidxs[i]).value = rpick; |
if (otheridxs.length > 1) { |
if (rpick > 0) { |
for (var j=0; j<otheridxs.length; j++) { |
document.getElementById('randompicknum_'+allmapidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allmapidxs[i]+',\\''+allmapidxs[i]+'\\',\\'link\\')">'+rpick+'</a>'; |
if (document.getElementById(actions[i]+'_'+otheridxs[j])) { |
} else { |
document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false; |
document.getElementById('randompicknum_'+allmapidxs[i]).innerHTML = ''; |
} |
} |
} |
} |
} |
} |
} |
} else { |
} |
if (setcheck == 1) { |
} |
document.getElementById(param+'_'+allmapidxs[i]).checked = true; |
} |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder) { |
|
var control = document.togglemultsettings; |
|
if (context == 'actions') { |
|
control = document.togglemultactions; |
|
} |
|
if (control.showmultpick.length) { |
|
for (var i=0; i<control.showmultpick.length; i++) { |
|
if (control.showmultpick[i].checked) { |
|
if (control.showmultpick[i].value == 0) { |
|
if (context == 'settings') { |
|
targetform.changeparms.value=param; |
|
targetform.submit(); |
|
} else { |
|
targetform.cmd.value=param+'_'+index; |
|
targetform.folderpath.value=folderpath; |
|
targetform.markcopy.value=idx+':'+param; |
|
targetform.copyfolder.value=folder+'.'+container; |
|
if (param == 'remove') { |
|
if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) { |
|
targetform.markcopy.value=''; |
|
targetform.copyfolder.value=''; |
|
targetform.submit(); |
|
} |
|
} |
|
if (param == 'cut') { |
|
if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) { |
|
targetform.submit(); |
|
} |
|
} |
|
if (param == 'copy') { |
|
targetform.submit(); |
|
} |
|
targetform.markcopy.value=''; |
|
targetform.copyfolder.value=''; |
|
targetform.cmd.value=''; |
|
targetform.folderpath.value=''; |
|
} |
|
} else { |
|
if (context == 'actions') { |
|
if (document.getElementById(param+'_'+idx)) { |
|
item = document.getElementById(param+'_'+idx); |
|
if (item.type == 'checkbox') { |
|
if (item.checked) { |
|
item.checked = false; |
} else { |
} else { |
document.getElementById(param+'_'+allmapidxs[i]).checked = false; |
item.checked = true; |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
} else { |
|
if (document.getElementById(param+'_'+idx)) { |
|
checkbox = document.getElementById(param+'_'+idx); |
|
singleCheck(checkbox,idx,param); |
|
} |
} |
} |
} |
} |
|
} else { |
|
if (context == 'settings') { |
|
targetform.changeparms.value=param; |
|
targetform.submit(); |
|
} |
} |
} |
return; |
return; |
} |
} |
|
|
function checkForSubmit(targetform,param) { |
function singleCheck(caller,idx,action) { |
if (document.togglemultchecks.showmultpick.length) { |
actions = new Array('cut','copy','remove'); |
for (var i=0; i<document.togglemultchecks.showmultpick.length; i++) { |
if (caller.checked) { |
if (document.togglemultchecks.showmultpick[i].checked) { |
for (var i=0; i<actions.length; i++) { |
if (document.togglemultchecks.showmultpick[i].value == 0) { |
if (actions[i] != action) { |
targetform.changeparms.value=param; |
if (document.getElementById(actions[i]+'_'+idx)) { |
targetform.submit(); |
if (document.getElementById(actions[i]+'_'+idx).checked) { |
|
document.getElementById(actions[i]+'_'+idx).checked = false; |
|
} |
} |
} |
} |
} |
} |
} |
Line 5295 function toContents(jumpto) {
|
Line 5829 function toContents(jumpto) {
|
location.href=newurl; |
location.href=newurl; |
} |
} |
|
|
function submitSettings(form) { |
function togglePick(caller,value) { |
var allidxlist = form.allidx.value; |
var disp = 'none'; |
form.allencrypturl.value = ''; |
if (document.getElementById('multi'+caller)) { |
form.allhiddenresource.value = ''; |
var curr = document.getElementById('multi'+caller).style.display; |
if (allidxlist != '') { |
if (value == 1) { |
var allidxs = allidxlist.split(','); |
disp='block'; |
if (allidxs.length > 1) { |
} |
for (var i=0; i<allidxs.length; i++) { |
if (curr == disp) { |
if (document.getElementById('hiddenresource_'+allidxs[i])) { |
return; |
if (document.getElementById('hiddenresource_'+allidxs[i]).checked) { |
} |
form.allhiddenresource.value += allidxs[i]+','; |
document.getElementById('multi'+caller).style.display=disp; |
|
if (value == 1) { |
|
document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>'; |
|
} else { |
|
document.getElementById('more'+caller).innerHTML = ''; |
|
} |
|
if (caller == 'actions') { |
|
setClass(value); |
|
setBoxes(value); |
|
} |
|
} |
|
var showButton = multiSettings(); |
|
if (showButton != 1) { |
|
showButton = multiActions(); |
|
} |
|
if (document.getElementById('multisave')) { |
|
if (showButton == 1) { |
|
document.getElementById('multisave').style.display='block'; |
|
} else { |
|
document.getElementById('multisave').style.display='none'; |
|
} |
|
} |
|
resize_scrollbox('contentscroll','1','1'); |
|
return; |
|
} |
|
|
|
function toggleCheckUncheck(caller,more) { |
|
if (more == 1) { |
|
document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$lt{'less'}</a>'; |
|
document.getElementById('allfields'+caller).style.display='block'; |
|
} else { |
|
document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>'; |
|
document.getElementById('allfields'+caller).style.display='none'; |
|
} |
|
resize_scrollbox('contentscroll','1','1'); |
|
} |
|
|
|
function multiSettings() { |
|
var inuse = 0; |
|
var settingsform = document.togglemultsettings; |
|
if (settingsform.showmultpick.length > 1) { |
|
for (var i=0; i<settingsform.showmultpick.length; i++) { |
|
if (settingsform.showmultpick[i].checked) { |
|
if (settingsform.showmultpick[i].value == 1) { |
|
inuse = 1; |
|
} |
|
} |
|
} |
|
} |
|
return inuse; |
|
} |
|
|
|
function multiActions() { |
|
var inuse = 0; |
|
var actionsform = document.togglemultactions; |
|
if (actionsform.showmultpick.length > 1) { |
|
for (var i=0; i<actionsform.showmultpick.length; i++) { |
|
if (actionsform.showmultpick[i].checked) { |
|
if (actionsform.showmultpick[i].value == 1) { |
|
inuse = 1; |
|
} |
|
} |
|
} |
|
} |
|
return inuse; |
|
} |
|
|
|
function checkSubmits() { |
|
var numchanges = 0; |
|
var form = document.saveactions; |
|
var doactions = multiActions(); |
|
if (doactions == 1) { |
|
var remidxlist = document.cumulativeactions.allremoveidx.value; |
|
if ((remidxlist != '') && (remidxlist != null)) { |
|
var remidxs = remidxlist.split(','); |
|
for (var i=0; i<remidxs.length; i++) { |
|
if (document.getElementById('remove_'+remidxs[i])) { |
|
if (document.getElementById('remove_'+remidxs[i]).checked) { |
|
form.multiremove.value += remidxs[i]+','; |
|
numchanges ++; |
} |
} |
} |
} |
if (document.getElementById('encrypturl_'+allidxs[i])) { |
} |
if (document.getElementById('encrypturl_'+allidxs[i]).checked) { |
} |
form.allencrypturl.value += allidxs[i]+','; |
var cutidxlist = document.cumulativeactions.allcutidx.value; |
|
if ((cutidxlist != '') && (cutidxlist != null)) { |
|
var cutidxs = cutidxlist.split(','); |
|
for (var i=0; i<cutidxs.length; i++) { |
|
if (document.getElementById('cut_'+cutidxs[i])) { |
|
if (document.getElementById('cut_'+cutidxs[i]).checked == true) { |
|
form.multicut.value += cutidxs[i]+','; |
|
numchanges ++; |
} |
} |
} |
} |
} |
} |
} |
} |
|
var copyidxlist = document.cumulativeactions.allcopyidx.value; |
|
if ((copyidxlist != '') && (copyidxlist != null)) { |
|
var copyidxs = copyidxlist.split(','); |
|
for (var i=0; i<copyidxs.length; i++) { |
|
if (document.getElementById('copy_'+copyidxs[i])) { |
|
if (document.getElementById('copy_'+copyidxs[i]).checked) { |
|
form.multicopy.value += copyidxs[i]+','; |
|
numchanges ++; |
|
} |
|
} |
|
} |
|
} |
|
if (numchanges > 0) { |
|
form.multichange.value = numchanges; |
|
} |
} |
} |
var allmapidxlist = form.allmapidx.value; |
var dosettings = multiSettings(); |
form.allrandompick.value = ''; |
if (dosettings == 1) { |
form.allrandomorder.value = ''; |
form.allencrypturl.value = ''; |
if (allmapidxlist != '') { |
form.allhiddenresource.value = ''; |
var allmapidxs = allmapidxlist.split(','); |
form.changeparams.value = 'all'; |
for (var i=0; i<allmapidxs.length; i++) { |
var allidxlist = document.cumulativesettings.allidx.value; |
var randompick = document.getElementById('randompick_'+allmapidxs[i]); |
if ((allidxlist != '') && (allidxlist != null)) { |
var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]); |
var allidxs = allidxlist.split(','); |
var randorder = document.getElementById('randomorder_'+allmapidxs[i]); |
if (allidxs.length > 1) { |
if ((randompick.checked) && (rpicknum.value != '')) { |
for (var i=0; i<allidxs.length; i++) { |
form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+','; |
if (document.getElementById('hiddenresource_'+allidxs[i])) { |
|
if (document.getElementById('hiddenresource_'+allidxs[i]).checked) { |
|
form.allhiddenresource.value += allidxs[i]+','; |
|
} |
|
} |
|
if (document.getElementById('encrypturl_'+allidxs[i])) { |
|
if (document.getElementById('encrypturl_'+allidxs[i]).checked) { |
|
form.allencrypturl.value += allidxs[i]+','; |
|
} |
|
} |
|
} |
} |
} |
if (randorder.checked) { |
} |
form.allrandomorder.value += allmapidxs[i]+','; |
form.allrandompick.value = ''; |
|
form.allrandomorder.value = ''; |
|
var allmapidxlist = document.cumulativesettings.allmapidx.value; |
|
if ((allmapidxlist != '') && (allmapidxlist != null)) { |
|
var allmapidxs = allmapidxlist.split(','); |
|
for (var i=0; i<allmapidxs.length; i++) { |
|
var randompick = document.getElementById('randompick_'+allmapidxs[i]); |
|
var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]); |
|
var randorder = document.getElementById('randomorder_'+allmapidxs[i]); |
|
if ((randompick.checked) && (rpicknum.value != '')) { |
|
form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+','; |
|
} |
|
if (randorder.checked) { |
|
form.allrandomorder.value += allmapidxs[i]+','; |
|
} |
} |
} |
} |
} |
} |
} |
form.submit(); |
if ((numchanges > 0) || (dosettings == 1)) { |
return true; |
form.submit(); |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
function setClass(value) { |
|
var cutclass = 'LC_docs_cut'; |
|
var copyclass = 'LC_docs_copy'; |
|
var removeclass = 'LC_docs_remove'; |
|
var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b"); |
|
var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b"); |
|
var removereg = new RegExp("\\\\"+removeclass+"\\\\b"); |
|
var links = document.getElementsByTagName('a'); |
|
for (var i=0; i<links.length; i++) { |
|
var classes = links[i].className; |
|
if (cutreg.test(classes)) { |
|
links[i].className = cutclass; |
|
if (value == 1) { |
|
links[i].className += " LC_menubuttons_link"; |
|
} |
|
} else { |
|
if (copyreg.test(classes)) { |
|
links[i].className = copyclass; |
|
if (value == 1) { |
|
links[i].className += " LC_menubuttons_link"; |
|
} |
|
} else { |
|
if (removereg.test(classes)) { |
|
links[i].className = removeclass; |
|
if (value == 1) { |
|
links[i].className += " LC_menubuttons_link"; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return; |
} |
} |
|
|
function togglePick() { |
function setBoxes(value) { |
var disp = 'none'; |
var remidxlist = document.cumulativeactions.allremoveidx.value; |
if (document.getElementById('multiclick')) { |
if ((remidxlist != '') && (remidxlist != null)) { |
var curr = document.getElementById('multiclick').style.display; |
var remidxs = remidxlist.split(','); |
if (curr == 'none') { |
for (var i=0; i<remidxs.length; i++) { |
disp='block'; |
if (document.getElementById('remove_'+remidxs[i])) { |
|
var item = document.getElementById('remove_'+remidxs[i]); |
|
if (value == 1) { |
|
item.className = 'LC_docs_remove'; |
|
} else { |
|
item.className = 'LC_hidden'; |
|
} |
|
} |
} |
} |
document.getElementById('multiclick').style.display=disp; |
|
} |
} |
if (document.getElementById('savemulti')) { |
var cutidxlist = document.cumulativeactions.allcutidx.value; |
var curr = document.getElementById('save.multi').style.display; |
if ((cutidxlist != '') && (cutidxlist != null)) { |
if (curr == 'none') { |
var cutidxs = cutidxlist.split(','); |
disp='inline'; |
for (var i=0; i<cutidxs.length; i++) { |
|
if (document.getElementById('cut_'+cutidxs[i])) { |
|
var item = document.getElementById('cut_'+cutidxs[i]); |
|
if (value == 1) { |
|
item.className = 'LC_docs_cut'; |
|
} else { |
|
item.className = 'LC_hidden'; |
|
} |
|
} |
|
} |
|
} |
|
var copyidxlist = document.cumulativeactions.allcopyidx.value; |
|
if ((copyidxlist != '') && (copyidxlist != null)) { |
|
var copyidxs = copyidxlist.split(','); |
|
for (var i=0; i<copyidxs.length; i++) { |
|
if (document.getElementById('copy_'+copyidxs[i])) { |
|
var item = document.getElementById('copy_'+copyidxs[i]); |
|
if (value == 1) { |
|
item.className = 'LC_docs_copy'; |
|
} else { |
|
item.className = 'LC_hidden'; |
|
} |
|
} |
} |
} |
document.getElementById('savemulti').style.display=disp; |
|
} |
} |
resize_scrollbox('contentscroll','1','1'); |
|
return; |
return; |
} |
} |
|
|
Line 5536 Return hash with valid author names
|
Line 6258 Return hash with valid author names
|
|
|
=item do_paste_from_buffer() |
=item do_paste_from_buffer() |
|
|
|
=item do_buffer_empty() |
|
|
|
=item clear_from_buffer() |
|
|
=item get_newmap_url() |
=item get_newmap_url() |
|
|
=item dbcopy() |
=item dbcopy() |