--- loncom/interface/londocs.pm 2006/05/30 20:09:25 1.229
+++ loncom/interface/londocs.pm 2007/06/29 23:25:30 1.281
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.229 2006/05/30 20:09:25 raeburn Exp $
+# $Id: londocs.pm,v 1.281 2007/06/29 23:25:30 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,17 +33,16 @@ use Apache::Constants qw(:common :http);
use Apache::imsexport;
use Apache::lonnet;
use Apache::loncommon;
-use Apache::lonratedt;
-use Apache::lonratsrv;
+use LONCAPA::map();
+use Apache::lonratedt();
use Apache::lonxml;
-use Apache::loncreatecourse;
+use Apache::lonclonecourse;
use Apache::lonnavmaps;
use HTML::Entities;
use GDBM_File;
use Apache::lonlocal;
use Cwd;
-use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
my $iconpath;
@@ -58,7 +57,7 @@ my $hadchanges;
my %help=();
-# Mapread read maps into lonratedt::global arrays
+# Mapread read maps into LONCAPA::map:: global arrays
# @order and @resources, determines status
# sets @order - pointer to resources in right order
# sets @resources - array with the resources with correct idx
@@ -67,15 +66,15 @@ my %help=();
sub mapread {
my ($coursenum,$coursedom,$map)=@_;
return
- &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
- $map);
+ &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
+ $map);
}
sub storemap {
my ($coursenum,$coursedom,$map)=@_;
my ($outtext,$errtext)=
- &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
- $map,1);
+ &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
+ $map,1);
if ($errtext) { return ($errtext,2); }
$hadchanges=1;
@@ -100,7 +99,7 @@ sub authorhosts {
$ca=$env{'user.name'};
$cd=$env{'user.domain'};
} else {
- ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
+ ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
}
my $allowed=0;
my $myhome=&Apache::lonnet::homeserver($ca,$cd);
@@ -121,21 +120,18 @@ sub authorhosts {
sub dumpbutton {
my ($home,$other,%outhash)=&authorhosts();
- my $type = 'Course';
- if (defined($env{'course.'.$env{'request.course.id'}.'.type'})) {
- $type = $env{'course.'.$env{'request.course.id'}.'.type'};
- }
+ my $type = &Apache::loncommon::course_type();
if ($home+$other==0) { return ''; }
my $output='
';
if ($home) {
return '
'.
''.
+ &mt('Dump '.$type.' DOCS to Construction Space').'" />'.
&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
} else {
return'
'.
- &mt('Dump [_1] DOCS to Construction Space: available on other servers',
- $type);
+ &mt('Dump '.$type.
+ ' DOCS to Construction Space: available on other servers');
}
}
@@ -148,12 +144,10 @@ sub clean {
sub dumpcourse {
my ($r) = @_;
- my $type = 'Course';
- if (defined($env{'course.'.$env{'request.course.id'}.'.type'})) {
- $type = $env{'course.'.$env{'request.course.id'}.'.type'};
- }
- $r->print(&Apache::loncommon::start_page('Dump [_1] DOCS to Construction Space',
- $type).'
ENDCOURSEVERIFY
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
- &mt('Editing the Table of Contents for your [_1]',$type)));
+ &mt('Editing the Table of Contents for your '.$type)));
}
# --------------------------------------------------------- Standard documents
$r->print('
');
@@ -2410,7 +2718,7 @@ ENDCOURSEVERIFY
my $folder=$env{'form.folder'};
if ($folder eq '' || $folder eq 'supplemental') {
$folder='default';
- $env{'form.folderpath'}='default&'.&escape(&mt('Main [_1] Documents',$type));
+ $env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
}
my $postexec='';
if ($folder eq 'default') {
@@ -2466,11 +2774,14 @@ $uploadtag
-
+
$help{'My Personal Info'}
@@ -2746,7 +3066,7 @@ sub editing_js {
function makenewfolder(targetform,folderseq) {
var foldername=prompt('Name of New Folder','New Folder');
if (foldername) {
- targetform.importdetail.value=foldername+"="+folderseq;
+ targetform.importdetail.value=escape(foldername)+"="+folderseq;
targetform.submit();
}
}
@@ -2754,7 +3074,7 @@ function makenewfolder(targetform,folder
function makenewpage(targetform,folderseq) {
var pagename=prompt('Name of New Page','New Page');
if (pagename) {
- targetform.importdetail.value=pagename+"="+folderseq;
+ targetform.importdetail.value=escape(pagename)+"="+folderseq;
targetform.submit();
}
}
@@ -2768,7 +3088,7 @@ function makeexamupload() {
var title=prompt('Listed Title for the Uploaded Score');
if (title) {
this.document.forms.newexamupload.importdetail.value=
- title+'=/res/lib/templates/examupload.problem';
+ escape(title)+'=/res/lib/templates/examupload.problem';
this.document.forms.newexamupload.submit();
}
}
@@ -2777,7 +3097,7 @@ function makesmppage() {
var title=prompt('Listed Title for the Page');
if (title) {
this.document.forms.newsmppg.importdetail.value=
- title+'=/adm/$udom/$uname/$now/smppg';
+ escape(title)+'=/adm/$udom/$uname/$now/smppg';
this.document.forms.newsmppg.submit();
}
}
@@ -2786,7 +3106,7 @@ function makesmpproblem() {
var title=prompt('Listed Title for the Problem');
if (title) {
this.document.forms.newsmpproblem.importdetail.value=
- title+'=/res/lib/templates/simpleproblem.problem';
+ escape(title)+'=/res/lib/templates/simpleproblem.problem';
this.document.forms.newsmpproblem.submit();
}
}
@@ -2795,7 +3115,7 @@ function makedropbox() {
var title=prompt('Listed Title for the Drop Box');
if (title) {
this.document.forms.newdropbox.importdetail.value=
- title+'=/res/lib/templates/DropBox.problem';
+ escape(title)+'=/res/lib/templates/DropBox.problem';
this.document.forms.newdropbox.submit();
}
}
@@ -2804,26 +3124,26 @@ function makebulboard() {
var title=prompt('Listed Title for the Bulletin Board');
if (title) {
this.document.forms.newbul.importdetail.value=
- title+'=/adm/$udom/$uname/$now/bulletinboard';
+ escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
this.document.forms.newbul.submit();
}
}
function makeabout() {
- var user=prompt("Enter user\@domain for User's 'About Me' Page");
+ var user=prompt("Enter user:domain for User's 'About Me' Page");
if (user) {
var comp=new Array();
- comp=user.split('\@');
+ comp=user.split(':');
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
if ((comp[0]) && (comp[1])) {
this.document.forms.newaboutsomeone.importdetail.value=
- 'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
+ 'About '+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
this.document.forms.newaboutsomeone.submit();
} else {
- alert("Not a valid user\@domain");
+ alert("Not a valid user:domain");
}
} else {
- alert("Please enter both user and domain in the format user\@domain");
+ alert("Please enter both user and domain in the format user:domain");
}
}
}
@@ -2848,6 +3168,7 @@ function finishpick() {
function changename(folderpath,index,oldtitle,container,pagesymb) {
var title=prompt('New Title',oldtitle);
if (title) {
+ this.document.forms.renameform.markcopy.value=-1;
this.document.forms.renameform.title.value=title;
this.document.forms.renameform.cmd.value='rename_'+index;
if (container == 'sequence') {
@@ -2863,6 +3184,7 @@ function changename(folderpath,index,old
function removeres(folderpath,index,oldtitle,container,pagesymb) {
if (confirm('WARNING: Removing a resource makes associated grades and scores inaccessible!\\nRemove "'+oldtitle+'"?')) {
+ this.document.forms.renameform.markcopy.value=-1;
this.document.forms.renameform.cmd.value='del_'+index;
if (container == 'sequence') {
this.document.forms.renameform.folderpath.value=folderpath;
@@ -2875,10 +3197,11 @@ function removeres(folderpath,index,oldt
}
}
-function cutres(folderpath,index,oldtitle,container,pagesymb) {
+function cutres(folderpath,index,oldtitle,container,pagesymb,folder) {
if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) {
this.document.forms.renameform.cmd.value='cut_'+index;
this.document.forms.renameform.markcopy.value=index;
+ this.document.forms.renameform.copyfolder.value=folder+'.'+container;
if (container == 'sequence') {
this.document.forms.renameform.folderpath.value=folderpath;
}
@@ -2890,8 +3213,9 @@ function cutres(folderpath,index,oldtitl
}
}
-function markcopy(folderpath,index,oldtitle,container,pagesymb) {
+function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
this.document.forms.renameform.markcopy.value=index;
+ this.document.forms.renameform.copyfolder.value=folder+'.'+container;
if (container == 'sequence') {
this.document.forms.renameform.folderpath.value=folderpath;
}