--- loncom/interface/londocs.pm 2012/12/07 16:48:19 1.522 +++ loncom/interface/londocs.pm 2013/04/01 19:39:13 1.539 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.522 2012/12/07 16:48:19 raeburn Exp $ +# $Id: londocs.pm,v 1.539 2013/04/01 19:39:13 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,7 +40,6 @@ use Apache::lonxml; use Apache::lonclonecourse; use Apache::lonnavmaps; use Apache::lonnavdisplay(); -use Apache::lonuserstate(); use Apache::lonextresedit(); use HTML::Entities; use HTML::TokeParser; @@ -153,7 +152,7 @@ sub dumpcourse { $r->print(&endContentScreen()); return ''; } - my ($ca,$cd)=split(/\@/,$env{'form.authorspace'}); + my ($ca,$cd)=split(/\:/,$env{'form.authorspace'}); $r->print('
'."\n". + &mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n". + '
'.
+ join('
',@{$msgsarray}).
+ '
'. + $lockerror. + '
'; + } + } + my ($errtext,$fatal) = + &storemap($coursenum, $coursedom, $folder.'.'.$container,1); + return ($errtext,$fatal,$fixuperrors); } sub log_docs { @@ -396,7 +490,7 @@ sub docs_change_log { } my $folderpath=$env{'form.folderpath'}; if ($folderpath eq '') { - $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents').':::::'); + $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Content').':::::'); } $pathitem = ''; @@ -561,57 +655,115 @@ sub docs_change_log { sub update_paste_buffer { 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 ($env{'form.markcopy'} < 0); my ($errtext,$fatal) = &mapread($coursenum,$coursedom, $env{'form.copyfolder'}); - return if ($fatal); -# Mark for copying - my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]); - if (&is_supplemental_title($title)) { - &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title}); - ($title) = &Apache::loncommon::parse_supplemental_title($title); - } elsif ($env{'docs.markedcopy_supplemental'}) { - &Apache::lonnet::delenv('docs.markedcopy_supplemental'); - } - $url=~s{http(:|:)//https(:|:)//}{https$2//}; - - (my $cmd,undef)=split('_',$env{'form.cmd'}); - - my %addtoenv = ( - 'docs.markedcopy_title' => $title, - 'docs.markedcopy_url' => $url, - 'docs.markedcopy_cmd' => $cmd, - ); - &Apache::lonnet::delenv('docs.markedcopy_nested'); - &Apache::lonnet::delenv('docs.markedcopy_nestednames'); - if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) { - my $prefix = $1; - my $subdir =$2; - if ($subdir eq '') { - $subdir = $prefix; - } - my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps); - &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'} = $nested; - } - if ($nestednames ne '') { - $addtoenv{'docs.markedcopy_nestednames'} = $nestednames; + my %curr_groups = &Apache::longroup::coursegroups(); + +# Retrieve current paste buffer suffixes. + my @currpaste = split(/,/,$env{'docs.markedcopies'}); + my (%pasteurls,@newpaste); + +# Construct identifiers for current contents of user's paste buffer + if (@currpaste) { + foreach my $suffix (@currpaste) { + my $cid = $env{'docs.markedcopy_crs_'.$suffix}; + my $url = $env{'docs.markedcopy_url_'.$suffix}; + if (($cid =~ /^$match_domain(?:_)$match_courseid$/) && + ($url ne '')) { + $pasteurls{$cid.'_'.$url}; + } + } + } + +# Mark items for copying (skip any items already in user's paste buffer) + my %addtoenv; + + foreach my $item (@possibles) { + my ($orderidx,$cmd) = split(/:/,$item); + next if ($orderidx =~ /\D/); + next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove')); + my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]); + my %denied = &action_restrictions($coursenum,$coursedom, + &LONCAPA::map::qtescape($url), + $env{'form.folderpath'},\%curr_groups); + next if ($denied{'copy'}); + $url=~s{http(:|:)//https(:|:)//}{https$2//}; + next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url})); + my ($suffix,$errortxt,$locknotfreed) = + &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste'); + 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; + } + my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps); + &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); delete($env{'form.markcopy'}); } @@ -643,138 +795,200 @@ sub recurse_uploaded_maps { sub print_paste_buffer { 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); - my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1]; - if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { - $is_external = 1; + unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) { + return if ($env{'docs.markedcopies'} eq ''); } - my ($canpaste,$nopaste,$othercrs,$areachange,$is_uploaded_map); - if ($folder =~ /^supplemental/) { - $canpaste = &supp_pasteable($env{'docs.markedcopy_url'}); - unless ($canpaste) { - $nopaste = &mt('Paste into Supplemental Content unavailable for this type of content.'); - } - } else { - $canpaste = 1; - } + my @currpaste = split(/,/,$env{'docs.markedcopies'}); + my ($pasteitems,@pasteable); - if ($canpaste) { - if ($env{'docs.markedcopy_url'} =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { - my $srcdom = $1; - my $srcnum = $2; - my $rem = $3; - if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) { - $othercourse = 1; - if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { - if ($canpaste) { - $othercrs = ''.
+ join('
',@{$pastemsgarray}).
+ '
'. + $lockerror. + '
'); + } if ($save_error ne '') { return $save_error; } if ($paste_res ne 'ok') { - $r->print(''.$paste_res.'
'); + $r->print(''.$paste_res.'
'); } if (keys(%paste_errors) > 0) { - $r->print(''."\n". + $r->print('
'."\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". '
'.$output.'
'); + } + } $r->print($upload_output); +# Rename, cut, copy or remove a single resource if (&handle_edit_cmd()) { my $contentchg; - if ($env{'form.cmd'} =~ /^(del|cut)_/) { + if ($env{'form.cmd'} =~ m{^(del|cut)_}) { $contentchg = 1; } ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); 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 if ($env{'form.importdetail'}) { my @imports; foreach my $item (split(/\&/,$env{'form.importdetail'})) { if (defined($item)) { my ($name,$url,$residx)= - map {&unescape($_)} split(/\=/,$item); - if ($url=~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) { - my ($suffix,$errortxt,$locknotfreed) = - &newmap_suffix($1,$2,$coursedom,$coursenum); + map { &unescape($_); } split(/\=/,$item); + if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) { + my ($suffix,$errortxt,$locknotfreed) = + &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2); if ($locknotfreed) { $r->print($locknotfreed); } @@ -1782,13 +2472,45 @@ sub editor { } else { return $errortxt; } + } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) { + my $type = $1; + my ($suffix,$errortxt,$locknotfreed) = + &new_timebased_suffix($coursedom,$coursenum,$type); + if ($locknotfreed) { + $r->print($locknotfreed); + } + if ($suffix) { + $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix}; + } else { + return $errortxt; + } + } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) { + if ($supplementalflag) { + next unless ($1 eq 'supplemental'); + if ($folder eq 'supplemental') { + next unless ($2 eq 'default'); + } else { + next unless ($folder eq 'supplemental_'.$2); + } + } else { + next unless ($1 eq 'docs'); + if ($folder eq 'default') { + next unless ($2 eq 'default'); + } else { + next unless ($folder eq 'default_'.$2); + } + } } push(@imports, [$name, $url, $residx]); } } - ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder, - $container,'londocs',@imports); + ($errtext,$fatal,my $fixuperrors) = + &group_import($coursenum, $coursedom, $folder,$container, + 'londocs',@imports); return $errtext if ($fatal); + if ($fixuperrors) { + $r->print($fixuperrors); + } } # Loading a complete map if ($env{'form.loadmap'}) { @@ -1844,8 +2566,13 @@ sub editor { $r->print(''); } - my ($to_show,$output); - + 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 foreach my $res (@LONCAPA::map::order) { my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); @@ -1853,21 +2580,27 @@ sub editor { $url=&LONCAPA::map::qtescape($url); unless ($name) { $name=(split(/\//,$url))[-1]; } unless ($name) { $idx++; next; } + push(@allidx,$res); + if ($url =~ m{/uploaded/.+\.(page|sequence)$}) { + push(@allmapidx,$res); + } $output .= &entryline($idx,$name,$url,$folder,$allowed,$res, $coursenum,$coursedom,$crstype, - $pathitem,$supplementalflag,$container); + $pathitem,$supplementalflag,$container, + \%filters,\%curr_groups); $idx++; $shown++; } &Apache::loncommon::end_data_table_count(); + my $need_save; if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) { my $toolslink = '' .&Apache::loncommon::help_open_menu('Navigation Screen', 'Navigation_Screen',undef,'RAT') .' | '.&mt('Tools:').' | ' .'
|
$form_start + $form_param $form_common $selectbox $form_end @@ -2314,7 +3109,6 @@ $copylink | END - } # Figure out what kind of a resource this is my ($extension)=($url=~/\.(\w+)$/); @@ -2400,21 +3194,26 @@ END if ($rpicknum) { $rpckchk = ' checked="checked"'; } - my $formname = 'edit_rpick_'.$orderidx; + my $formname = 'edit_randompick_'.$orderidx; $rand_pick_text = '$rand_pick_text @@ -2508,26 +3311,122 @@ ENDPARMS return $line; } -sub newmap_suffix { - my ($area,$container,$coursedom,$coursenum) = @_; - my ($prefix,$idtype,$errtext,$locknotfreed); - $prefix = 'docs'; - if ($area eq 'supplemental') { - $prefix = 'supp'; +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 { + my ($dom,$num,$type,$area,$container) = @_; + my ($prefix,$namespace,$idtype,$errtext,$locknotfreed); + if ($type eq 'paste') { + $prefix = $type; + $namespace = 'courseeditor'; + } elsif ($type eq 'map') { + $prefix = 'docs'; + if ($area eq 'supplemental') { + $prefix = 'supp'; + } + $prefix .= $container; + $namespace = 'uploadedmaps'; + } else { + $prefix = $type; + $namespace = 'templated'; } - $prefix .= $container; $idtype = 'concat'; my ($suffix,$freedlock,$error) = - &Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps', - $coursedom,$coursenum); + &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num); if (!$suffix) { - $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.'); + 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.'); + } elsif ($type eq 'smppg') { + $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.'); + } else { + $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new bulletin board.'); + } if ($error) { $errtext .= ' '.$error; } } if ($freedlock ne 'ok') { - $locknotfreed = ' '.&mt('There was a problem removing a lockfile. This will prevent creation of additional folders or composite pages in this course. Please contact the domain coordinator for your LON-CAPA domain.').' ';
+ $locknotfreed =
+ ''.
+ &mt('There was a problem removing a lockfile.').' ';
+ 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.');
+ } elsif ($type eq 'smppg') {
+ $locknotfreed .=
+ &mt('This will prevent creation of additional simple pages in this course.');
+ } else {
+ $locknotfreed .=
+ &mt('This will prevent creation of additional bulletin boards in this course.');
+ }
+ unless ($type eq 'paste') {
+ $locknotfreed .=
+ ' '.&mt('Please contact the domain coordinator for your LON-CAPA domain.');
+ }
+ $locknotfreed .= ' ';
}
return ($suffix,$errtext,$locknotfreed);
}
@@ -3133,8 +4032,9 @@ sub handler {
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
-
-
+ $help{'Course Roster'} = &Apache::loncommon::help_open_topic('Docs_Course_Roster');
+ $help{'Web Page'} = &Apache::loncommon::help_open_topic('Docs_Web_Page');
+
my $allowed;
# URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
unless ($r->uri eq '/adm/supplemental') {
@@ -3190,7 +4090,7 @@ sub handler {
# supplementalflag=0: show standard documents
# toolsflag=1: show utilities
-
+ $env{'form.folderpath'} = &unescape($env{'form.folderpath'});
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) {
$supplementalflag=0;
@@ -3211,23 +4111,32 @@ sub handler {
# Do we directly jump somewhere?
- if ($env{'form.command'} eq 'direct') {
- my ($mapurl,$id,$resurl);
+ if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
if ($env{'form.symb'} ne '') {
$env{'form.folderpath'}=
&Apache::loncommon::symb_to_docspath($env{'form.symb'});
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
+ $env{'form.command'}.'_'.$env{'form.symb'}});
} elsif ($env{'form.supppath'} ne '') {
$env{'form.folderpath'}=$env{'form.supppath'};
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
+ $env{'form.command'}.'_'.$env{'form.supppath'}});
}
} elsif ($env{'form.command'} eq 'editdocs') {
- $env{'form.folderpath'} = 'default&'.
- &Apache::lonhtmlcommon::entity_encode('Main Course Content').
- ':::::';
+ $env{'form.folderpath'} = 'default&'.
+ &escape(&mt('Main '.$crstype.' Content').':::::');
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
} elsif ($env{'form.command'} eq 'editsupp') {
- $env{'form.folderpath'} = 'default&'.
- &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
+ $env{'form.folderpath'} = 'supplemental&'.
+ &escape('Supplemental Content');
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
+ } elsif ($env{'form.command'} eq 'contents') {
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
+ } elsif ($env{'form.command'} eq 'home') {
+ &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
}
+
# Where do we store these for when we come back?
my $stored_folderpath='docs_folderpath';
if ($supplementalflag) {
@@ -3238,6 +4147,9 @@ sub handler {
if ((!$env{'form.folderpath'}) && $allowed) {
&Apache::loncommon::restore_course_settings($stored_folderpath,
{'folderpath' => 'scalar'});
+ unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
+ undef($env{'form.folderpath'});
+ }
}
# If we are not allowed to make changes, all we can see are supplemental docs
@@ -3257,8 +4169,8 @@ sub handler {
if ($supplementalflag) {
$env{'form.folderpath'}=&supplemental_base();
} else {
- $env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Documents')).
- ':::::';
+ $env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Content').
+ ':::::');
}
}
@@ -3283,8 +4195,7 @@ sub handler {
if ($env{'form.folder'} eq '' ||
$env{'form.folder'} eq 'supplemental') {
$folderpath='default&'.
- &escape(&mt('Main '.$crstype.' Documents')).
- ':::::';
+ &escape(&mt('Main '.$crstype.' Content').':::::');
}
}
$containertag = '';
@@ -3341,9 +4252,7 @@ sub handler {
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'.
&mt('Switch server?');
@@ -3369,7 +4278,6 @@ sub handler {
} else {
&Apache::lonhtmlcommon::add_breadcrumb({
href=>"/adm/coursedocs",text=>"$crstype Contents"});
-
$r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
{'add_entries' => $addentries}
)
@@ -3440,9 +4348,6 @@ sub handler {
} elsif ((!$showdoc) && (!$uploadphase)) {
# -----------------------------------------------------------------------------
my %lt=&Apache::lonlocal::texthash(
- 'uplm' => 'Upload a new main '.lc($crstype).' document',
- 'upls' => 'Upload a new supplemental '.lc($crstype).' document',
- 'impp' => 'Import a document',
'copm' => 'All documents out of a published map into this folder',
'upfi' => 'Upload File',
'upld' => 'Import Content',
@@ -3452,21 +4357,20 @@ sub handler {
'impm' => 'Import from Assembled Map',
'selm' => 'Select Map',
'load' => 'Load Map',
- 'reco' => 'Recover Deleted Documents',
'newf' => 'New Folder',
'newp' => 'New Composite Page',
- 'extr' => 'External Resource',
'syll' => 'Syllabus',
'navc' => 'Table of Contents',
'sipa' => 'Simple Course Page',
'sipr' => 'Simple Problem',
+ 'webp' => 'Blank Web Page (editable)',
'drbx' => 'Drop Box',
'scuf' => 'External Scores (handgrade, upload, clicker)',
'bull' => 'Discussion Board',
'mypi' => 'My Personal Information Page',
'grpo' => 'Group Portfolio',
'rost' => 'Course Roster',
- 'abou' => 'Personal Information Page for a User',
+ 'abou' => 'Personal Information Page for a User',
'imsf' => 'IMS Import',
'imsl' => 'Import IMS package',
'cms' => 'Origin of IMS package',
@@ -3474,9 +4378,6 @@ sub handler {
'file' => 'File',
'title' => 'Title',
'comment' => 'Comment',
- 'url' => 'URL',
- 'prev' => 'Preview',
- 'lnk' => 'Add Link',
'parse' => 'Upload embedded images/multimedia files if HTML file',
);
# -----------------------------------------------------------------------------
@@ -3577,7 +4478,10 @@ SEDFFORM
if ($folder eq '') {
$folder='default';
}
- &update_paste_buffer($coursenum,$coursedom,$folder);
+ my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
+ if ($output) {
+ $r->print($output);
+ }
$r->print(<'.
' |