');
}
- if (keys(%paste_errors) > 0) {
- $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".
- '
'."\n");
- foreach my $key (sort(keys(%paste_errors))) {
- $r->print('
'.$key.'
'."\n");
- }
- $r->print('
'."\n");
- }
}
$r->print($upload_output);
if (&handle_edit_cmd()) {
- my $contentchg;
- if ($env{'form.cmd'} =~ /^(del|cut)_/) {
- $contentchg = 1;
- }
- ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
+ ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
return $errtext if ($fatal);
}
# Group import/search
@@ -1828,18 +905,6 @@ sub editor {
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);
- if ($locknotfreed) {
- $r->print($locknotfreed);
- }
- if ($suffix) {
- $url =~ s/_new\./_$suffix./;
- } else {
- return $errortxt;
- }
- }
push(@imports, [$name, $url, $residx]);
}
}
@@ -1857,7 +922,7 @@ sub editor {
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
}
($errtext,$fatal)=&storemap($coursenum,$coursedom,
- $folder.'.'.$container,1);
+ $folder.'.'.$container);
return $errtext if ($fatal);
} else {
$r->print('
'.&mt('No map selected.').'
');
@@ -1911,8 +976,7 @@ sub editor {
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $idx++; next; }
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
- $coursenum,$coursedom,$crstype,
- $uploadtag,$supplementalflag);
+ $coursenum,$crstype);
$idx++;
$shown++;
}
@@ -1950,7 +1014,7 @@ sub editor {
my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
$r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto,
$readfile));
- &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
+ &print_paste_buffer($r,$container);
} else {
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
#Function Box for Supplemental Content for users with mdc priv.
@@ -1961,7 +1025,7 @@ sub editor {
&Apache::lonhtmlcommon::add_item_funclist(
''.
- ''.
+ ''.
''.$funcname.'').
&Apache::lonhtmlcommon::end_funclist()));
}
@@ -2038,7 +1102,7 @@ sub process_file_upload {
$comment.':'.$url.':'.$ext.':normal:res';
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
($errtext,$fatal)=&storemap($coursenum,$coursedom,
- $folder.'.'.$container,1);
+ $folder.'.'.$container);
if ($fatal) {
$$upload_output = '
'.$errtext.'
';
return;
@@ -2126,14 +1190,36 @@ sub is_supplemental_title {
return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
}
+sub parse_supplemental_title {
+ my ($title) = @_;
+
+ my ($foldertitle,$renametitle);
+ if ($title =~ /&&&/) {
+ $title = &HTML::Entites::decode($title);
+ }
+ if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
+ $renametitle=$4;
+ my ($time,$uname,$udom) = ($1,$2,$3);
+ $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
+ my $name = &Apache::loncommon::plainname($uname,$udom);
+ $name = &HTML::Entities::encode($name,'"<>&\'');
+ $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');
+ $title=''.&Apache::lonlocal::locallocaltime($time).' '.
+ $name.': '.$foldertitle;
+ }
+ if (wantarray) {
+ return ($title,$foldertitle,$renametitle);
+ }
+ return $title;
+}
+
# --------------------------------------------------------------- An entry line
sub entryline {
- my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
- $crstype,$uploadtag,$supplementalflag)=@_;
+ my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
my ($foldertitle,$pagetitle,$renametitle);
if (&is_supplemental_title($title)) {
- ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
+ ($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
$pagetitle = $foldertitle;
} else {
$title=&HTML::Entities::encode($title,'"<>&\'');
@@ -2144,6 +1230,7 @@ sub entryline {
my $orderidx=$LONCAPA::map::order[$index];
+
$renametitle=~s/\\/\\\\/g;
$renametitle=~s/\"\;/\\\"/g;
$renametitle=~s/ /%20/g;
@@ -2162,22 +1249,9 @@ sub entryline {
$type = $container = 'page';
$esc_path=&escape($env{'form.pagepath'});
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
+ $symb=&escape($env{'form.pagesymb'});
}
- my $isexternal;
- if (!$supplementalflag && $residx) {
- my $currurl = $url;
- $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
- if ($currurl =~ m{^/adm/wrapper/ext/}) {
- $isexternal = 1;
- }
- my $path = 'uploaded/'.
- $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
- $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
- $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
- $residx,
- &Apache::lonnet::declutter($currurl));
- }
- my %lt;
+ my $cpinfo='';
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
@@ -2200,81 +1274,35 @@ sub entryline {
}
$selectbox.='';
}
- %lt=&Apache::lonlocal::texthash(
+ my %lt=&Apache::lonlocal::texthash(
'up' => 'Move Up',
'dw' => 'Move Down',
'rm' => 'Remove',
'ct' => 'Cut',
'rn' => 'Rename',
- 'cp' => 'Copy',
- 'ex' => 'External Resource',
- 'ed' => 'Edit',
- 'pr' => 'Preview',
- 'sv' => 'Save',
- 'ul' => 'URL',
- 'ti' => 'Title',
- );
+ 'cp' => 'Copy');
my $nocopy=0;
my $nocut=0;
- my $noremove=0;
- if ($url=~ m{^/res/.+\.(page|sequence)$}) {
- # no copy for published maps
- $nocopy=1;
- }
+ if ($url=~/\.(page|sequence)$/) {
+ if ($url =~ m{/res/}) {
+ # no copy for published maps
+ $nocopy = 1;
+ } else {
+ foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
+ my ($title,$url,$ext,$type)=split(/\:/,$item);
+ if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
+ $nocopy=1;
+ last;
+ }
+ }
+ }
+ }
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,$renamelink);
+ my $copylink=' ';
+ my $cutlink=' ';
my $skip_confirm = 0;
if ( $folder =~ /^supplemental/
@@ -2283,40 +1311,21 @@ sub entryline {
|/aboutme$
|/navmaps$
|/bulletinboard$
- |\.html$)}x)
- || $isexternal) {
+ |\.html$
+ |^/adm/wrapper/ext)}x)) {
$skip_confirm = 1;
}
- if ($nocopy) {
- $copylink=(<$lt{'cp'}
-ENDCOPY
- } else {
- $copylink=(<$lt{'cp'}
ENDCOPY
}
- if ($nocut) {
- $cutlink=(<$lt{'ct'}
-ENDCUT
- } else {
- $cutlink=(<$lt{'ct'}
ENDCUT
}
- if ($noremove) {
- $removelink=(<$lt{'rm'}
-ENDREM
- } else {
- $removelink=(<$lt{'rm'}
-ENDREM
- }
- $renamelink=(<$lt{'rn'}
-ENDREN
$form_start = '
@@ -2346,12 +1355,11 @@ END
$selectbox
$form_end
-
END
@@ -2388,38 +1396,44 @@ END
}
}
- my $editlink;
my $orig_url = $url;
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
- if (!$supplementalflag && $residx && $symb) {
- if ($container eq 'page') {
- $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
- $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
- }
- if ((!$isfolder) && (!$ispage)) {
- (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
- $url=&Apache::lonnet::clutter($url);
- if ($url=~/^\/*uploaded\//) {
- $url=~/\.(\w+)$/;
- my $embstyle=&Apache::loncommon::fileembstyle($1);
- if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
- $url='/adm/wrapper'.$url;
- } elsif ($embstyle eq 'ssi') {
- #do nothing with these
- } elsif ($url!~/\.(sequence|page)$/) {
- $url='/adm/coursedocs/showdoc'.$url;
- }
- } elsif ($url=~m|^/ext/|) {
- $url='/adm/wrapper'.$url;
- $external = 1;
- }
- if (&Apache::lonnet::symbverify($symb,$url)) {
- $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
- } else {
- $url='';
- }
+ if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
+ my $symb=&Apache::lonnet::symbclean(
+ &Apache::lonnet::declutter('uploaded/'.
+ $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
+ $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
+ '.sequence').
+ '___'.$residx.'___'.
+ &Apache::lonnet::declutter($url));
+ (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
+ $url=&Apache::lonnet::clutter($url);
+ if ($url=~/^\/*uploaded\//) {
+ $url=~/\.(\w+)$/;
+ my $embstyle=&Apache::loncommon::fileembstyle($1);
+ if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
+ $url='/adm/wrapper'.$url;
+ } elsif ($embstyle eq 'ssi') {
+ #do nothing with these
+ } elsif ($url!~/\.(sequence|page)$/) {
+ $url='/adm/coursedocs/showdoc'.$url;
+ }
+ } elsif ($url=~m|^/ext/|) {
+ $url='/adm/wrapper'.$url;
+ $external = 1;
+ }
+ if (&Apache::lonnet::symbverify($symb,$url)) {
+ $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
+ } else {
+ $url='';
}
+ if ($container eq 'page') {
+ my $symb=$env{'form.pagesymb'};
+
+ $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
+ $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
+ }
}
my ($rand_pick_text,$rand_order_text);
if ($isfolder || $extension eq 'sequence') {
@@ -2436,7 +1450,7 @@ END
'parameter_encrypturl'))[0]=~/^yes$/i)
.':'.((&LONCAPA::map::getparameter($orderidx,
'parameter_randomorder'))[0]=~/^yes$/i);
- $url.='folderpath='.&escape($folderpath);
+ $url.='folderpath='.&escape($folderpath).$cpinfo;
my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
'parameter_randompick'))[0];
my $rpckchk;
@@ -2465,51 +1479,23 @@ $form_common.'
my $folderpath=$env{'form.folderpath'};
if ($folderpath) { $pagepath = $folderpath.'&' };
$pagepath.=$pagearg.'&'.$pagename;
+ my $symb=$env{'form.pagesymb'};
+ if (!$symb) {
+ my $path='uploaded/'.
+ $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
+ $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
+ $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
+ $residx,
+ $path.$pagearg.'.page');
+ }
$url.='pagepath='.&escape($pagepath).
- '&pagesymb='.&escape($symb);
+ '&pagesymb='.&escape($symb).$cpinfo;
}
- if ($allowed) {
- my $fileloc =
- &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
-
- if ($external) {
- $editlink = <<"EXTLNK";
-
-
- $lt{'ed'}
-
-EXTLNK
- } else {
- my ($cfile,$home,$switchserver,$forceedit,$forceview) =
- &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
- if (($cfile ne '') && ($symb ne '')) {
- my $jscall =
- &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
- $switchserver,
- $forceedit,
- undef,$symb);
- if ($jscall) {
- $editlink = ' '.&mt('Edit').'';
- }
- }
- }
+ if (($external) && ($allowed)) {
+ my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
+ $external = ' '.&mt('Edit').'';
+ } else {
+ undef($external);
}
my $reinit;
if ($crstype eq 'Community') {
@@ -2535,7 +1521,7 @@ EXTLNK
} else {
$line.=$title.' '.$reinit.'';
}
- $line.=$editlink."";
+ $line.=$external."";
$rand_pick_text = ' ' if ($rand_pick_text eq '');
$rand_order_text = ' ' if ($rand_order_text eq '');
if (($allowed) && ($folder!~/^supplemental/)) {
@@ -2566,30 +1552,6 @@ ENDPARMS
return $line;
}
-sub newmap_suffix {
- my ($area,$container,$coursedom,$coursenum) = @_;
- my ($prefix,$idtype,$errtext,$locknotfreed);
- $prefix = 'docs';
- if ($area eq 'supplemental') {
- $prefix = 'supp';
- }
- $prefix .= $container;
- $idtype = 'concat';
- my ($suffix,$freedlock,$error) =
- &Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps',
- $coursedom,$coursenum);
- if (!$suffix) {
- $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
- 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.').'