--- loncom/interface/londocs.pm 2004/04/07 20:36:54 1.114
+++ loncom/interface/londocs.pm 2025/01/07 21:01:37 1.722
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.114 2004/04/07 20:36:54 albertel Exp $
+# $Id: londocs.pm,v 1.722 2025/01/07 21:01:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -30,15 +30,32 @@ package Apache::londocs;
use strict;
use Apache::Constants qw(:common :http);
+use Apache::imsexport;
use Apache::lonnet;
use Apache::loncommon;
-use Apache::lonratedt;
-use Apache::lonratsrv;
+use Apache::lonhtmlcommon;
+use LONCAPA::map();
+use Apache::lonratedt();
use Apache::lonxml;
-use Apache::loncreatecourse;
+use Apache::lonclonecourse;
+use Apache::lonnavmaps;
+use Apache::lonnavdisplay();
+use Apache::lonextresedit();
+use Apache::lontemplate();
+use Apache::lonsimplepage();
+use Apache::lonhomework();
+use Apache::lonpublisher();
+use Apache::loncourserespicker();
use HTML::Entities;
+use HTML::TokeParser;
+use HTML::LCParser;
use GDBM_File;
+use File::MMagic;
+use File::Copy;
use Apache::lonlocal;
+use Cwd;
+use UUID::Tiny ':std';
+use LONCAPA qw(:DEFAULT :match);
my $iconpath;
@@ -48,529 +65,6189 @@ my $hashtied;
my %alreadyseen=();
my $hadchanges;
+my $suppchanges;
-# Available help topics
my %help=();
-# Mapread read maps into lonratedt::global arrays
-# @order and @resources, determines status
-# sets @order - pointer to resources in right order
-# sets @resources - array with the resources with correct idx
-#
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 ($coursenum,$coursedom,$map,$contentchg)=@_;
+ my $report;
+ if (($contentchg) && ($map =~ /^default/)) {
+ $report = 1;
+ }
my ($outtext,$errtext)=
- &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
- $map,1);
+ &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
+ $map,1,$report);
if ($errtext) { return ($errtext,2); }
-
- $hadchanges=1;
+
+ if ($map =~ /^default/) {
+ $hadchanges=1;
+ } elsif ($contentchg) {
+ $suppchanges=1;
+ }
return ($errtext,0);
}
-# ----------------------------------------- Return hash with valid author names
+
sub authorhosts {
my %outhash=();
my $home=0;
my $other=0;
- foreach (keys %ENV) {
- if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
+ my @ids=&Apache::lonnet::current_machine_ids();
+ foreach my $key (keys(%env)) {
+ if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
my $role=$1;
my $realm=$2;
- my ($start,$end)=split(/\./,$ENV{$_});
+ my ($start,$end)=split(/\./,$env{$key});
if (($start) && ($start>time)) { next; }
if (($end) && (time>$end)) { next; }
- my $ca; my $cd;
+ my ($ca,$cd);
if ($1 eq 'au') {
- $ca=$ENV{'user.name'};
- $cd=$ENV{'user.domain'};
+ $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);
- my @ids=&Apache::lonnet::current_machine_ids();
- foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
+ foreach my $id (@ids) {
+ if ($id eq $myhome) {
+ $allowed=1;
+ last;
+ }
+ }
if ($allowed) {
$home++;
- $outhash{'home_'.$ca.'@'.$cd}=1;
+ $outhash{'home_'.$ca.':'.$cd}=1;
} else {
- $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
+ $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
$other++;
}
}
}
return ($home,$other,%outhash);
}
-# ------------------------------------------------------ Generate "dump" button
-sub dumpbutton {
- my ($home,$other,%outhash)=&authorhosts();
- if ($home+$other==0) { return ''; }
- my $output='
';
- if ($home) {
- return ' | '.
- '';
+
+sub clean {
+ my ($title)=@_;
+ $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
+ return $title;
+}
+
+sub default_folderpath {
+ my ($coursenum,$coursedom,$navmapref) = @_;
+ return unless ($coursenum && $coursedom && ref($navmapref));
+# Check if entire course is hidden and/or encrypted
+ my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
+ my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
+ unless (ref($$navmapref)) {
+ $$navmapref = Apache::lonnavmaps::navmap->new();
+ }
+ if (ref($$navmapref)) {
+ if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
+ my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
+ my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
+ unless (@resources) {
+ $hiddenmap = 1;
+ unless ($env{'request.role.adv'}) {
+ $hiddentop = 1;
+ if ($env{'form.folder'}) {
+ undef($env{'form.folder'});
+ }
+ }
+ }
+ }
+ if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
+ $encryptmap = 1;
+ }
+ }
+ unless ($hiddentop) {
+ $folderpath='default&'.&escape(&mt('Main Content')).
+ '::'.$hiddenmap.':'.$encryptmap.'::';
+ }
+ if (wantarray) {
+ return ($folderpath,$hiddentop);
} else {
- return' | '.
- &mt('Dump Course DOCS to Construction Space: available on other servers');
+ return $folderpath;
}
}
-# -------------------------------------------------------- Actually dump course
+sub validate_supppath {
+ my ($coursenum,$coursedom) = @_;
+ my $backto;
+ if ($env{'form.supppath'} ne '') {
+ my @items = split(/\&/,$env{'form.supppath'});
+ my ($badpath,$got_supp,$supppath,%supphidden,%suppids);
+ for (my $i=0; $i<@items; $i++) {
+ my $odd = $i%2;
+ if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
+ $badpath = 1;
+ last;
+ } elsif ($odd) {
+ my $suffix;
+ my $idx = $i-1;
+ if ($items[$i] =~ /^([^:]*)::(|1):::$/) {
+ $backto .= '&'.$1;
+ } elsif ($items[$idx] eq 'supplemental') {
+ $backto .= '&'.$items[$i];
+ } else {
+ $backto .= '&'.$items[$i];
+ my $is_hidden;
+ unless ($got_supp) {
+ my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
+ if (ref($supplemental) eq 'HASH') {
+ if (ref($supplemental->{'hidden'}) eq 'HASH') {
+ %supphidden = %{$supplemental->{'hidden'}};
+ }
+ if (ref($supplemental->{'ids'}) eq 'HASH') {
+ %suppids = %{$supplemental->{'ids'}};
+ }
+ }
+ $got_supp = 1;
+ }
+ if (ref($suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}) eq 'ARRAY') {
+ my $mapid = $suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}->[0];
+ if ($supphidden{$mapid}) {
+ $is_hidden = 1;
+ }
+ }
+ $suffix = '::'.$is_hidden.':::';
+ }
+ $supppath .= '&'.$items[$i].$suffix;
+ } else {
+ $supppath .= '&'.$items[$i];
+ $backto .= '&'.$items[$i];
+ }
+ }
+ if ($badpath) {
+ delete($env{'form.supppath'});
+ } else {
+ $supppath =~ s/^\&//;
+ $backto =~ s/^\&//;
+ $env{'form.supppath'} = $supppath;
+ }
+ }
+ return $backto;
+}
sub dumpcourse {
- my $r=shift;
- $r->print('Dump DOCS'.
- &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
- ' | ');
- }
-# ----------------------------------------------------- Supplemental documents
- if (!$forcestandard) {
- $r->print(
- ''.&mt('Supplemental Course Documents').
- ($allowed?' '.$help{'Supplemental'}:'').'');
- my $folder=$ENV{'form.folder'};
- unless ($folder=~/supplemental/) { $folder='supplemental'; }
- &editor($r,$coursenum,$coursedom,$folder,$allowed);
- if ($allowed) {
- my $folderseq=
- '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
- '.sequence';
-
- $r->print(<
-$lt{'upls'} |
-$lt{'spec'} |
-
-
-
- |
-
-
-
-
-
- |
- |
-ENDSUPFORM
- }
+ } else {
+ $jsmakefunctions = <print('');
+ return <print('');
- } else {
-# -------------------------------------------------------- This is showdoc mode
- $r->print("".&mt('Uploaded Document').'
'.
-&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."
".
- &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'
');
- }
- }
- $r->print('');
- return OK;
+ resize_scrollbox('contentscroll','1','1');
+ return;
+}
+
+function toggleExternal(caller) {
+ var blocks = Array($extfieldsets);
+ for (var i=0; i$js_lt{'sunm'}';
+ }
+ } else {
+ document.getElementById('newsubdirname').type = "hidden";
+ document.getElementById('newsubdirname').value = "";
+ document.getElementById('newsubdir').innerHTML = "";
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+function toggleCrsResTitle() {
+ if (document.getElementById('newresource')) {
+ var selloc = document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value;
+ if (selloc == 'course') {
+ document.getElementById('newresource').style.display = 'inline';
+ document.courseresform.newresourceadd[0].checked = true;
+ toggleNewInCourse(document.courseresform);
+ } else {
+ document.getElementById('newresource').style.display = 'none';
+ }
+ }
+ if (document.getElementById('newstdproblem')) {
+ if (document.courseresform.authorpath.options[document.courseresform.authorpath.selectedIndex].value == 'switch') {
+ document.getElementById('newstdproblem').style.display = 'none';
+ if (document.getElementById('stdprobswitch')) {
+ document.getElementById('stdprobswitch').style.display = 'block';
+ }
+ } else {
+ document.getElementById('newstdproblem').style.display = 'block';
+ if (document.getElementById('stdprobswitch')) {
+ document.getElementById('stdprobswitch').style.display = 'none';
+ }
+ }
+ }
+}
+
+function toggleNewInCourse(form) {
+ if (form.newresourceadd.length) {
+ for (var i=0; i$js_lt{'tinc'}";
+ }
+ } else {
+ document.getElementById('newresourcetitle').type = 'hidden';
+ document.getElementById('newresourcetitle').value = '';
+ if (document.getElementById('newrestitle')) {
+ document.getElementById('newrestitle').innerHTML = '';
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+function toggleWithTemplate(form) {
+ if (form.newresusetemp.length) {
+ for (var i=0; i=0) {
+ for (i = numfiles; i >= 0; i--) {
+ selelem.remove(i);
+ }
+ }
+ if ((location == '') || (location == null) || (location == 'undefined')) {
+ if (selelem.options.length == 0) {
+ selelem.options[selelem.options.length] = new Option('','');
+ selelem.selectedIndex = 0;
+ }
+ if (document.getElementById('newstdproblem')) {
+ document.getElementById('newstdproblem').style.display = 'none';
+ }
+ return;
+ }
+ var machineIds = new Array($machines_str);
+ var athome = 0;
+ var role = location;
+ if ((location == 'author') || (location == 'course')) {
+ if (document.getElementById('rolehome_'+location)) {
+ var currhome = document.getElementById('rolehome_'+location).value;
+ if ((currhome != '') && (currhome != null) && (currhome != 'undefined')) {
+ if (machineIds.includes(currhome)) {
+ athome = 1;
+ }
+ }
+ }
+ } else {
+ const roleinfo = location.split('___');
+ role = encodeURIComponent(roleinfo[0]+'./'+roleinfo[1]);
+ if (document.getElementById('rolehome_coauthor_'+roleinfo[1]+'_'+roleinfo[0])) {
+ var currhome = document.getElementById('rolehome_coauthor_'+roleinfo[1]+'_'+roleinfo[0]).value;
+ if ((currhome != '') && (currhome != null) && (currhome != 'undefined')) {
+ if (machineIds.includes(currhome)) {
+ athome = 1;
+ }
+ }
+ }
+ }
+ var templateradio = document.courseresform.elements['newresusetemp'];
+ if (athome) {
+ if (document.getElementById('stdprobswitch')) {
+ document.getElementById('stdprobswitch').style.display = 'none';
+ }
+ if (document.getElementById('newstdproblem')) {
+ document.getElementById('newstdproblem').style.display = 'none';
+ }
+ var canedit = '$canedit';
+ if (canedit) {
+ if (templateradio.length > 1) {
+ for (var i=0; i 1) {
+ selelem.options[selelem.options.length] = new Option('$js_lt{sele}','');
+ }
+ }
+ if (len) {
+ var j;
+ for (j = 0; j < len; j++) {
+ selelem.options[selelem.options.length] = new Option(data.dirs[j],data.dirs[j]);
+ }
+ selelem.selectedIndex = 0;
+ if (len == 1) {
+ toggleCrsResTitle();
+ }
+ }
+ }
+ }
+ }
+ http.send(params);
+ } else {
+ selelem.options[selelem.options.length] = new Option('$js_lt{swit}','switch');
+ selelem.selectedIndex = 0;
+ if (document.getElementById('stdprobswitch')) {
+ document.getElementById('stdprobswitch').style.display = 'block';
+ }
+ if (document.getElementById('newstdproblem')) {
+ document.getElementById('newstdproblem').style.display = 'none';
+ }
+ if (templateradio.length > 1) {
+ for (var i=0; i'+picknum+'';
+ if (caller == 'link') {
+ propagateState(targetform,'rpicknum');
+ }
+ } else {
+ picknumtext.innerHTML = ' '+picknum+'';
+ checkForSubmit(targetform,'randompick','settings');
+ }
+ } else {
+ if (caller == 'check') {
+ if (index == 'all') {
+ picknumtext.innerHTML = '';
+ if (caller == 'link') {
+ propagateState(targetform,'rpicknum');
+ }
+ } else {
+ pickitem.checked=false;
+ checkForSubmit(targetform,'randompick','settings');
+ }
+ }
+ return;
+ }
+ }
+ } else {
+ picknumitem.value = '';
+ picknumtext.innerHTML = '';
+ if (index == 'all') {
+ if (caller == 'link') {
+ propagateState(targetform,'rpicknum');
+ }
+ } else {
+ checkForSubmit(targetform,'randompick','settings');
+ }
+ }
+}
+
+function propagateState(form,param) {
+ if (document.getElementById(param+'all')) {
+ var setcheck = 0;
+ var rpick = 0;
+ if (param == 'rpicknum') {
+ if (document.getElementById('randompickall')) {
+ if (document.getElementById('randompickall').checked) {
+ if (document.getElementById('rpicknumall')) {
+ rpick = document.getElementById('rpicknumall').value;
+ }
+ }
+ }
+ } else {
+ if (document.getElementById(param+'all').checked) {
+ 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 1) {
+ for (var i=0; i 0) {
+ document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': '+rpick+'';
+ } else {
+ document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
+ }
+ }
+ }
+ } else {
+ if (setcheck == 1) {
+ document.getElementById(param+'_'+allidxs[i]).checked = true;
+ } else {
+ document.getElementById(param+'_'+allidxs[i]).checked = false;
+ if (param == 'randompick') {
+ document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
+ }
+ }
+ }
+ }
+ }
+ if (setcheck == 1) {
+ if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
+ var actions = new Array('copy','cut','remove');
+ for (var i=0; i 1) {
+ for (var j=0; j 2 ){
+ currentNav = document.getElementById(tabnav[1].id);
+ currentLis = currentNav.getElementsByTagName('LI');
+ for(i = 0; i< currentLis.length; i++){
+ if(currentLis[i].className == 'active') {
+ funcString = currentLis[i].onclick.toString();
+ tab = funcString.split('"');
+ if(tab.length < 2) {
+ tab = funcString.split("'");
+ }
+ currentData = document.getElementById(tab[1]);
+ currentData.style.display = 'block';
+ }
+ }
+ }
+}
+
+function showPage(current, pageId, nav, data) {
+ currstate = current.className;
+ hideAll(current, nav, data);
+ openTabs(pageId);
+ unselectInactive(nav);
+ if ((currstate == 'active') || (currstate == 'right active')) {
+ if (currstate == 'active') {
+ current.className = '';
+ } else {
+ current.className = 'right';
+ }
+ activeTab = '';
+ toggleExternal();
+ toggleUpload();
+ toggleMap();
+ toggleCrsRes();
+ toggleImportCrsres();
+ resize_scrollbox('contentscroll','1','0');
+ return;
+ } else {
+ current.className = 'active';
+ }
+ currentData = document.getElementById(pageId);
+ currentData.style.display = 'block';
+ activeTab = pageId;
+ toggleExternal();
+ toggleUpload();
+ toggleMap();
+ toggleCrsRes();
+ toggleImportCrsres();
+ if (nav == 'mainnav') {
+ var storedpath = "$docs_folderpath";
+ var storedpage = "$main_container_page";
+ var reg = new RegExp("^supplemental");
+ if (pageId == 'mainCourseDocuments') {
+ if (storedpage == 1) {
+ document.simpleedit.folderpath.value = '';
+ document.uploaddocument.folderpath.value = '';
+ } else {
+ if (reg.test(storedpath)) {
+ document.simpleedit.folderpath.value = '$toplevelmain';
+ document.uploaddocument.folderpath.value = '$toplevelmain';
+ document.newext.folderpath.value = '$toplevelmain';
+ } else {
+ document.simpleedit.folderpath.value = storedpath;
+ document.uploaddocument.folderpath.value = storedpath;
+ document.newext.folderpath.value = storedpath;
+ }
+ }
+ } else {
+ if (reg.test(storedpath)) {
+ document.simpleedit.folderpath.value = storedpath;
+ document.supuploaddocument.folderpath.value = storedpath;
+ document.supnewext.folderpath.value = storedpath;
+ } else {
+ document.simpleedit.folderpath.value = '$toplevelsupp';
+ document.supuploaddocument.folderpath.value = '$toplevelsupp';
+ document.supnewext.folderpath.value = '$toplevelsupp';
+ }
+ }
+ }
+ resize_scrollbox('contentscroll','1','0');
+ return false;
+}
+
+function toContents(jumpto) {
+ var newurl = '$backtourl';
+ if ((newurl == '/adm/navmaps') && (jumpto != '')) {
+ newurl = newurl+'?postdata='+jumpto;
+ }
+ location.href=newurl;
+}
+
+function togglePick(caller,value) {
+ var disp = 'none';
+ if (document.getElementById('multi'+caller)) {
+ var curr = document.getElementById('multi'+caller).style.display;
+ if (value == 1) {
+ disp='block';
+ }
+ if (curr == disp) {
+ return;
+ }
+ document.getElementById('multi'+caller).style.display=disp;
+ if (value == 1) {
+ document.getElementById('more'+caller).innerHTML = ' $js_lt{'more'}';
+ } 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 = ' $js_lt{'less'}';
+ document.getElementById('allfields'+caller).style.display='block';
+ } else {
+ document.getElementById('more'+caller).innerHTML = ' $js_lt{'more'}';
+ 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 1) {
+ for (var i=0; i 0) {
+ form.multichange.value = numchanges;
+ }
+ }
+ var dosettings = multiSettings();
+ var haschanges = 0;
+ if (dosettings == 1) {
+ form.allencrypturl.value = '';
+ form.allhiddenresource.value = '';
+ form.changeparms.value = 'all';
+ var patt=new RegExp(",\$");
+ var allidxlist = document.cumulativesettings.allidx.value;
+ if ((allidxlist != '') && (allidxlist != null)) {
+ var allidxs = allidxlist.split(',');
+ if (allidxs.length > 1) {
+ for (var i=0; i 0) {
+ if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
+ if (remwarnings > 0) {
+ if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
+ return false;
+ }
+ }
+ if (removalinfo > 0) {
+ if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
+ return false;
+ }
+ }
+ if (cutwarnings > 0) {
+ if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) {
+ return false;
+ }
+ }
+ }
+ form.submit();
+ return true;
+ }
+ }
+ if (dosettings == 1) {
+ if (haschanges == 1) {
+ form.submit();
+ return true;
+ }
+ }
+ if ((dosettings == 1) && (doactions == 1)) {
+ alert("$js_lt{'noor'}");
+ } else {
+ if (dosettings == 1) {
+ alert("$js_lt{'noch'}");
+ } else {
+ alert("$js_lt{'noac'}");
+ }
+ }
+ 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 'Copying content to Authoring Space requires switching server.',
+ swit => 'Switch server?',
+ );
+ my %html_js_lt = &Apache::lonlocal::texthash(
+ swit => 'Switch server?',
+ duco => 'Copying uploaded content to Authoring Space',
+ yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
+ chos => 'Choose server',
+ );
+ &js_escape(\%js_lt);
+ &html_escape(\%html_js_lt);
+ &js_escape(\%html_js_lt);
+ my $role = $env{'request.role'};
+ my $js = <<"ENDSWJS";
+
+
+ENDSWJS
+
+ my $startpage = &Apache::loncommon::start_page('Choose server',$js,
+ {'only_body' => 1,
+ 'js_ready' => 1,});
+ my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
+
+ my $hostpicker;
+ my $count = 0;
+ foreach my $host (sort(@hosts)) {
+ my $checked;
+ if ($count == 0) {
+ $checked = ' checked="checked"';
+ }
+ $hostpicker .= ' ';
+ $count++;
+ }
+
+ return <<"ENDSWITCHJS";
+
+function dump_needs_switchserver(url) {
+ if (url!='' && url!= null) {
+ if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
+ go(url);
+ }
+ }
+ return;
+}
+
+function choose_switchserver_window() {
+ newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
+ newWindow.document.open();
+ newWindow.document.writeln('$startpage');
+ newWindow.document.write('$html_js_lt{'duco'}<\\/h3>\\n'+
+ '
$html_js_lt{'yone'}<\\/p>\\n'+
+ '