--- loncom/interface/londocs.pm 2005/09/20 07:52:03 1.206
+++ loncom/interface/londocs.pm 2006/02/10 10:16:38 1.217.2.1
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.206 2005/09/20 07:52:03 albertel Exp $
+# $Id: londocs.pm,v 1.217.2.1 2006/02/10 10:16:38 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1215,6 +1215,8 @@ sub editor {
$r->print('
');
foreach (@Apache::lonratedt::order) {
my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
+ $name=&Apache::lonratsrv::qtescape($name);
+ $url=&Apache::lonratsrv::qtescape($url);
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $idx++; next; }
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
@@ -1371,7 +1373,7 @@ sub process_secondary_uploads {
if (($folder eq 'default') || ($folder eq 'supplemental')) {
$destination .= 'default/';
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
- $destination .= $1.'/';
+ $destination .= $2.'/';
}
$destination .= $newidx;
my ($url,$filename);
@@ -1399,6 +1401,7 @@ sub entryline {
$foldertitle;
}
$renametitle=~s/\"\;/\\\"/g;
+ $renametitle=~s/\\/\\\\/g;
my $line='';
# Edit commands
my $container;
@@ -1451,7 +1454,24 @@ sub entryline {
'ct' => 'Cut',
'rn' => 'Rename',
'cp' => 'Copy');
+ my $nocopy=0;
+ if ($url=~/\.(page|sequence)$/) {
+ foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) {
+ my ($title,$url,$ext,$type)=split(/\:/,$_);
+ if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
+ $nocopy=1;
+ last;
+ }
+ }
+ }
+ my $copylink=' ';
if ($env{'form.pagepath'}) {
+ unless ($nocopy) {
+ $copylink=(<
+$lt{'cp'}
+ENDCOPY
+ }
$line.=(<
@@ -1475,10 +1495,15 @@ sub entryline {
$lt{'ct'}
$lt{'rn'}
-
-$lt{'cp'}
+$copylink
END
} else {
+ unless ($nocopy) {
+ $copylink=(<
+$lt{'cp'}
+ENDCOPY
+ }
$line.=(<
@@ -1501,8 +1526,7 @@ END
$lt{'ct'}
$lt{'rn'}
-
-$lt{'cp'}
+$copylink
END
}
}
@@ -1532,7 +1556,7 @@ END
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
}
}
- $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
+ $url=~s-^http(\&colon\;|:)//-/adm/wrapper/ext/-;
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
my $symb=&Apache::lonnet::symbclean(
&Apache::lonnet::declutter('uploaded/'.
@@ -1565,7 +1589,7 @@ END
}
}
my $parameterset=' ';
- if ($isfolder) {
+ if ($isfolder || $extension eq 'sequence') {
my $foldername=&Apache::lonnet::escape($foldertitle);
my $folderpath=$env{'form.folderpath'};
if ($folderpath) { $folderpath.='&' };
@@ -1599,7 +1623,7 @@ END
}
$line.=' | '.
- "$title | ";
+ "$title | ";
if (($allowed) && ($folder!~/^supplemental/)) {
my %lt=&Apache::lonlocal::texthash(
'hd' => 'Hidden',
@@ -1643,6 +1667,7 @@ sub tiehash {
sub untiehash {
if ($hashtied) { untie %hash; }
$hashtied=0;
+ return OK;
}
# --------------------------------------------------------------- check on this
@@ -1719,6 +1744,24 @@ sub checkonthis {
#
+# ----------------------------------------------------------------- List Symbs
+#
+sub list_symbs {
+ my $r=shift;
+ my $html=&Apache::lonxml::xmlbegin();
+ $r->print($html.'Symb List'.
+ &Apache::loncommon::bodytag('Symb List'));
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ $r->print("\n");
+ foreach my $res ($navmap->retrieveResources()) {
+ $r->print($res->compTitle()."\t".$res->symb()."\n");
+ }
+ $r->print("\n
\n");
+ $r->print(''.&mt('Return to DOCS').'');
+}
+
+
+#
# -------------------------------------------------------------- Verify Content
#
sub verifycontent {
@@ -2062,14 +2105,14 @@ sub handler {
return OK if $r->header_only;
# --------------------------------------------- Initialize help topics for this
- foreach ('Adding_Course_Doc','Main_Course_Documents',
- 'Adding_External_Resource','Navigate_Content',
- 'Adding_Folders','Docs_Overview', 'Load_Map',
- 'Supplemental','Score_Upload_Form','Adding_Pages',
- 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
- 'Check_Resource_Versions','Verify_Content') {
- $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
- }
+ foreach ('Adding_Course_Doc','Main_Course_Documents',
+ 'Adding_External_Resource','Navigate_Content',
+ 'Adding_Folders','Docs_Overview', 'Load_Map',
+ 'Supplemental','Score_Upload_Form','Adding_Pages',
+ 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
+ 'Check_Resource_Versions','Verify_Content') {
+ $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
+ }
# Composite help files
$help{'Syllabus'} = &Apache::loncommon::help_open_topic(
'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
@@ -2083,13 +2126,18 @@ sub handler {
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
- if ($env{'form.verify'}) {
+# does this user have privileges to modify docs
+ my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+
+ if ($allowed && $env{'form.verify'}) {
&verifycontent($r);
- } elsif ($env{'form.versions'}) {
+ } elsif ($allowed && $env{'form.listsymbs'}) {
+ &list_symbs($r);
+ } elsif ($allowed && $env{'form.versions'}) {
&checkversions($r);
- } elsif ($env{'form.dumpcourse'}) {
+ } elsif ($allowed && $env{'form.dumpcourse'}) {
&dumpcourse($r);
- } elsif ($env{'form.exportcourse'}) {
+ } elsif ($allowed && $env{'form.exportcourse'}) {
&exportcourse($r);
} else {
# is this a standard course?
@@ -2098,7 +2146,6 @@ sub handler {
my $forcestandard = 0;
my $forcesupplement;
my $script='';
- my $allowed;
my $events='';
my $showdoc=0;
my $containertag;
@@ -2124,13 +2171,11 @@ sub handler {
}
unless ($showdoc) { # got called from remote
if (($env{'form.folder'}=~/^default_/) ||
- ($env{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) {
+ ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
$forcestandard = 1;
}
$forcesupplement=($env{'form.folder'}=~/^supplemental_/);
-# does this user have privileges to post, etc?
- $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
if ($allowed) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
$script=&Apache::lonratedt::editscript('simple');
@@ -2452,6 +2497,7 @@ ENDNEWSCRIPT
my %lt=&Apache::lonlocal::texthash(
'vc' => 'Verify Content',
'cv' => 'Check/Set Resource Versions',
+ 'ls' => 'List Symbs',
);
my $folderpath=$env{'form.folderpath'};
@@ -2486,7 +2532,9 @@ $uploadtag
$help{'Check_Resource_Versions'}
$dumpbut
$exportbut
-
+
ENDCOURSEVERIFY
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
@@ -2588,7 +2636,7 @@ $uploadtag
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
-