--- loncom/interface/londocs.pm 2023/12/28 19:29:38 1.707
+++ loncom/interface/londocs.pm 2024/06/07 14:37:55 1.710
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.707 2023/12/28 19:29:38 raeburn Exp $
+# $Id: londocs.pm,v 1.710 2024/06/07 14:37:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -102,6 +102,7 @@ sub authorhosts {
my %outhash=();
my $home=0;
my $other=0;
+ my @ids=&Apache::lonnet::current_machine_ids();
foreach my $key (keys(%env)) {
if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
my $role=$1;
@@ -118,7 +119,6 @@ sub authorhosts {
}
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;
@@ -263,8 +263,8 @@ ENDJS
add_entries => {'onload' => "hide_searching();"},
};
}
- $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
- &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
+ $r->print(&Apache::loncommon::start_page('Copy uploaded content to Authoring Space',$js,$starthash)."\n".
+ &Apache::lonhtmlcommon::breadcrumbs('Copy uploaded content to Authoring Space')."\n");
$r->print(&startContentScreen('tools'));
my ($home,$other,%outhash)=&authorhosts();
unless ($home) {
@@ -5965,7 +5965,7 @@ sub handler {
&init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
&checkversions($r,$canedit);
} elsif ($canedit && $env{'form.dumpcourse'}) {
- &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
+ &init_breadcrumbs('dumpcourse','Copy uploaded content to Authoring Space');
&dumpcourse($r);
} elsif ($canedit && $env{'form.exportcourse'}) {
&init_breadcrumbs('exportcourse','IMS Export');
@@ -6503,7 +6503,7 @@ sub handler {
if ($allowed && $toolsflag) {
$r->print(&startContentScreen('tools'));
- $r->print(&generate_admin_menu($crstype,$canedit));
+ $r->print(&generate_admin_menu($crstype,$canedit,$coursenum,$coursedom));
$r->print(&endContentScreen());
} elsif ((!$showdoc) && (!$uploadphase)) {
# -----------------------------------------------------------------------------
@@ -6694,7 +6694,18 @@ SEDFFORM
$checkcrsres = 1;
} elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.crsauthor'} ne '0') {
my %domdefs=&Apache::lonnet::get_domain_defaults($coursedom);
- if ($domdefs{'crsauthor'}) {
+ my $type = lc($env{'course.'.$env{'request.course.id'}.'.type'});
+ unless (($type eq 'community') || ($type eq 'placement')) {
+ $type = 'unofficial';
+ if ($env{'course.'.$env{'request.course.id'}.'internal.coursecode'} ne '') {
+ $type = 'official';
+ } elsif ($env{'course.'.$env{'request.course.id'}.'internal.textbook'} ne '') {
+ $type = 'textbook';
+ } else {
+ $type = 'unofficial';
+ }
+ }
+ if ($domdefs{$type.'crsauthor'}) {
$checkcrsres = 1;
}
}
@@ -7597,7 +7608,7 @@ sub remove_archive {
}
sub generate_admin_menu {
- my ($crstype,$canedit) = @_;
+ my ($crstype,$canedit,$coursenum,$coursedom) = @_;
my $lc_crstype = lc($crstype);
my ($home,$other,%outhash)=&authorhosts();
my %lt= ( # do not translate here
@@ -7605,6 +7616,7 @@ sub generate_admin_menu {
'cv' => 'Check/Set Resource Versions',
'ls' => 'List Resource Identifiers',
'ct' => 'Display/Set Shortened URLs for Deep-linking',
+ 'ca' => "Enter $crstype Authoring Space",
'imse' => 'Export contents to IMS Archive',
'dcd' => "Copy $crstype Content to Authoring Space",
);
@@ -7665,6 +7677,31 @@ sub generate_admin_menu {
]
});
if ($canedit) {
+ my ($crsauname,$crsaudom,$crshome);
+ if (($coursenum ne '') && ($coursedom ne '')) {
+ my $crsauthorurl = "/priv/$coursedom/$coursenum/";
+ ($crsauname,$crsaudom,$crshome) = &Apache::lonnet::constructaccess($crsauthorurl);
+ if (($crsauname eq $coursenum) && ($crsaudom eq $coursedom)) {
+ my @ids=&Apache::lonnet::current_machine_ids();
+ my $linkurl;
+ if (grep(/^\Q$crshome\E$/,@ids)) {
+ $linkurl = $crsauthorurl;
+ } else {
+ $linkurl =
+ &Apache::lonhtmlcommon::jump_to_editres($crsauthorurl,$crshome,1);
+ }
+ if ((ref($menu[0]) eq 'HASH') && (ref($menu[0]->{'items'}) eq 'ARRAY')) {
+ push(@{$menu[0]->{items}},
+ { linktext => $lt{'ca'},
+ url => $linkurl,
+ permission => 'F',
+ help => 'Docs_Course_Authorspace',
+ icon => 'impcrsau.png',
+ linktitle => $lt{'ca'},
+ });
+ }
+ }
+ }
push(@menu,
{ categorytitle=>'Export',
items =>[
@@ -9381,7 +9418,7 @@ sub dump_switchserver_js {
);
my %html_js_lt = &Apache::lonlocal::texthash(
swit => 'Switch server?',
- duco => 'Copying Content to Authoring Space',
+ 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',
);
@@ -9522,55 +9559,8 @@ sub makenewproblem {
if ($redirect) {
my $rightsfile = 'default.rights';
my $sourcerights = "$path/$rightsfile";
+ &Apache::loncommon::crsauthor_rights($rightsfile,$path,$docroot,$coursenum,$coursedom);
my $targetrights = $docroot."/res/$coursedom/$coursenum/$rightsfile";
- my $now = time;
- if (!-e $sourcerights) {
- my $cid = $coursedom.'_'.$coursenum;
- if (open(my $fh,">$sourcerights")) {
- print $fh <