--- loncom/interface/loncommon.pm 2024/02/28 03:23:49 1.1075.2.161.2.22 +++ loncom/interface/loncommon.pm 2024/08/17 23:31:37 1.1075.2.161.2.25 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.161.2.22 2024/02/28 03:23:49 raeburn Exp $ +# $Id: loncommon.pm,v 1.1075.2.161.2.25 2024/08/17 23:31:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -6069,20 +6069,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)}) { @@ -6096,20 +6108,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; + } } } } @@ -6129,6 +6154,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, @@ -6379,21 +6417,33 @@ sub bodytag { $bodytag .= Apache::lonhtmlcommon::scripttag( Apache::lonmenu::utilityfunctions($httphost), 'start'); + 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";