--- loncom/interface/loncommon.pm 2023/12/31 23:03:40 1.1425
+++ loncom/interface/loncommon.pm 2025/01/06 00:22:57 1.1445
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1425 2023/12/31 23:03:40 raeburn Exp $
+# $Id: loncommon.pm,v 1.1445 2025/01/06 00:22:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2437,6 +2437,66 @@ sub show_crsfiles_js {
END
}
+sub crsauthor_rights {
+ my ($rightsfile,$path,$docroot,$cnum,$cdom) = @_;
+ my $sourcerights = "$path/$rightsfile";
+ my $now = time;
+ if (!-e $sourcerights) {
+ my $cid = $cdom.'_'.$cnum;
+ if (!-e "$docroot/priv/$cdom") {
+ mkdir("$docroot/priv/$cdom",0755);
+ }
+ if (!-e "$docroot/priv/$cdom/$cnum") {
+ mkdir("$docroot/priv/$cdom/$cnum",0755);
+ }
+ if (open(my $fh,">$sourcerights")) {
+ print $fh <
+
+END
+ close($fh);
+ }
+ }
+ if (!-e "$sourcerights.meta") {
+ if (open(my $fh,">$sourcerights.meta")) {
+ my $author=$env{'environment.firstname'}.' '.
+ $env{'environment.middlename'}.' '.
+ $env{'environment.lastname'}.' '.
+ $env{'environment.generation'};
+ $author =~ s/\s+$//;
+ print $fh <<"END";
+
+
+$author
+$cnum:$cdom
+private
+$now
+
+
+$cdom
+0
+
+notset
+$now
+0
+rights
+$env{'user.name'}:$env{'user.domain'}
+
+
+
+$cnum:$cdom
+deny:::course,allow:$cid::course
+
+
+
+
Course Authoring Rights
+END
+ close($fh);
+ }
+ }
+ return;
+}
+
=pod
=item * &iframe_wrapper_headjs()
@@ -3890,6 +3950,21 @@ sub passwd_validation_js {
} else {
$alertmsg = &mt('A secret did not satisfy requirement(s):').'\n\n';
}
+ } elsif ($context eq 'ltitools') {
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['toolsec'],$domain);
+ if (ref($domconfig{'toolsec'}) eq 'HASH') {
+ if (ref($domconfig{'toolsec'}{'rules'}) eq 'HASH') {
+ %passwdconf = %{$domconfig{'toolsec'}{'rules'}};
+ }
+ }
+ if ($id eq 'add') {
+ $alertmsg = &mt('Secret for added external tool did not satisfy requirement(s):').'\n\n';
+ } elsif ($id =~ /^\d+$/) {
+ my $pos = $id+1;
+ $alertmsg = &mt('Secret for external tool [_1] did not satisfy requirement(s):','#'.$pos).'\n\n';
+ } else {
+ $alertmsg = &mt('A secret did not satisfy requirement(s):').'\n\n';
+ }
} else {
%passwdconf = &Apache::lonnet::get_passwdconf($domain);
$alertmsg = &mt('Initial password did not satisfy requirement(s):').'\n\n';
@@ -5616,7 +5691,8 @@ sub blockcheck {
}
unless ($has_evb) {
if (($activity eq 'printout') || ($activity eq 'grades') || ($activity eq 'search') ||
- ($activity eq 'boards') || ($activity eq 'groups') || ($activity eq 'chat')) {
+ ($activity eq 'index') || ($activity eq 'boards') || ($activity eq 'groups') ||
+ ($activity eq 'chat')) {
if ($udom eq $cdom) {
$check_ipaccess = 1;
}
@@ -5707,8 +5783,8 @@ sub blockcheck {
if (($activity eq 'boards' || $activity eq 'chat' ||
$activity eq 'groups' || $activity eq 'printout' ||
- $activity eq 'search' || $activity eq 'reinit' ||
- $activity eq 'alert') &&
+ $activity eq 'search' || $activity eq 'index' ||
+ $activity eq 'reinit' || $activity eq 'alert') &&
($env{'request.course.id'})) {
foreach my $key (keys(%live_courses)) {
if ($key ne $env{'request.course.id'}) {
@@ -6043,6 +6119,8 @@ END_MYBLOCK
$text = &mt('Gradebook Blocked');
} elsif ($activity eq 'search') {
$text = &mt('Search Blocked');
+ } elsif ($activity eq 'index') {
+ $text = &mt('Content Index Blocked');
} elsif ($activity eq 'alert') {
$text = &mt('Checking Critical Messages Blocked');
} elsif ($activity eq 'reinit') {
@@ -6476,7 +6554,7 @@ Input: (optional) filename from which br
If page header is being requested for use in a frameset, then
the second (option) argument -- frameset will be true, and
the target attribute set for links should be target="_parent".
- If $title is supplied as the thitd arg, that will be used to
+ If $title is supplied as the third arg, that will be used to
the left of the breadcrumbs tail for the current path.
Returns: HTML div with CSTR path and recent box
@@ -6596,20 +6674,32 @@ sub nocodemirror {
Input: $uri (optional)
Returns: %editors hash in which keys are editors
- permitted in current Authoring Space.
+ permitted in current Authoring Space,
+ or in current course for web pages
+ created in a course.
+
Value for each key is 1. Possible keys
- are: edit, xml, and daxe. If no specific
+ are: edit, xml, and daxe.
+
+ For a regular Authoring Space, if no specific
set of editors has been set for the Author
who owns the Authoring Space, then the
domain default will be used. If no domain
default has been set, then the keys will be
edit and xml.
+ For a course author, or for web pages created
+ in a course, if no specific set of editors has
+ been set for the course, then the domain
+ course default will be used. If no domain
+ course default has been set, then the keys
+ will be edit and xml.
+
=cut
sub permitted_editors {
my ($uri) = @_;
- my ($is_author,$is_coauthor,$auname,$audom,%editors);
+ my ($is_author,$is_coauthor,$is_course,$auname,$audom,%editors);
if ($env{'request.role'} =~ m{^au\./}) {
$is_author = 1;
} elsif ($env{'request.role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)}) {
@@ -6623,20 +6713,33 @@ sub permitted_editors {
}
}
} elsif ($env{'request.course.id'}) {
- if ($env{'request.editurl'} =~ m{^/priv/($match_domain)/($match_username)/}) {
+ my ($cdom,$cnum);
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ if (($env{'request.editurl'} =~ m{^/priv/\Q$cdom/$cnum\E/}) ||
+ ($env{'request.editurl'} =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/}) ||
+ ($uri =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/})) {
+ $is_course = 1;
+ } elsif ($env{'request.editurl'} =~ m{^/priv/($match_domain)/($match_username)/}) {
($audom,$auname) = ($1,$2);
} elsif ($env{'request.uri'} =~ m{^/priv/($match_domain)/($match_username)/}) {
($audom,$auname) = ($1,$2);
} elsif (($uri eq '/daxesave') &&
+ (($env{'form.path'} =~ m{^/daxeopen/priv/\Q$cdom/$cnum\E/}) ||
+ ($env{'form.path'} =~ m{^/daxeopen/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/}))) {
+ $is_course = 1;
+ } elsif (($uri eq '/daxesave') &&
($env{'form.path'} =~ m{^/daxeopen/priv/($match_domain)/($match_username)/})) {
($audom,$auname) = ($1,$2);
}
- if (($audom ne '') && ($auname ne '')) {
- if (($env{'user.domain'} eq $audom) &&
- ($env{'user.name'} eq $auname)) {
- $is_author = 1;
- } else {
- $is_coauthor = 1;
+ unless ($is_course) {
+ if (($audom ne '') && ($auname ne '')) {
+ if (($env{'user.domain'} eq $audom) &&
+ ($env{'user.name'} eq $auname)) {
+ $is_author = 1;
+ } else {
+ $is_coauthor = 1;
+ }
}
}
}
@@ -6656,6 +6759,19 @@ sub permitted_editors {
xml => 1,
);
}
+ } elsif ($is_course) {
+ if (exists($env{'course.'.$env{'request.course.id'}.'.internal.crseditors'})) {
+ map { $editors{$_} = 1; } split(/,/,$env{'course.'.$env{'request.course.id'}.'.internal.crseditors'});
+ } else {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
+ if (exists($domdefaults{'crseditors'})) {
+ map { $editors{$_} = 1; } split(/,/,$domdefaults{'crseditors'});
+ } else {
+ %editors = ( edit => 1,
+ xml => 1,
+ );
+ }
+ }
} else {
%editors = ( edit => 1,
xml => 1,
@@ -6764,7 +6880,6 @@ sub bodytag {
my $hostname = $args->{'hostname'};
$function = &get_users_function() if (!$function);
- my $img = &designparm($function.'.img',$domain);
my $font = &designparm($function.'.font',$domain);
my $pgbg = $bgcolor || &designparm($function.'.pgbg',$domain);
@@ -6887,24 +7002,40 @@ sub bodytag {
# $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
# }
- $bodytag .= Apache::lonhtmlcommon::scripttag(
- Apache::lonmenu::utilityfunctions($httphost), 'start');
+ my $need_endlcint;
+ unless ($args->{'switchserver'}) {
+ $bodytag .= Apache::lonhtmlcommon::scripttag(
+ Apache::lonmenu::utilityfunctions($httphost), 'start');
+ $need_endlcint = 1;
+ }
+ my $collapsible;
if ($args->{'collapsible_header'} ne '') {
- my $alttext = &mt('menu state: collapsed');
- my $tooltip = &mt('display standard menus');
+ $collapsible = 1;
+ my ($menustate,$tiptext,$divclass);
+ if ($args->{'start_collapsed'}) {
+ $menustate = 'collapsed';
+ $tiptext = 'display';
+ $divclass = 'hidden';
+ } else {
+ $menustate = 'expanded';
+ $tiptext = 'hide';
+ $divclass = 'shown';
+ }
+ my $alttext = &mt('menu state: '.$menustate);
+ my $tooltip = &mt($tiptext.' standard menus');
$bodytag .= <<"END";
-
-
+