[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /homework lonhomework.pm structuretags.pm /interface loncommon.pm loncreateuser.pm /lonnet/perl lonnet.pm /publisher lonpubdir.pm
raeburn
raeburn at source.lon-capa.org
Fri Nov 17 12:02:22 EST 2023
raeburn Fri Nov 17 17:02:22 2023 EDT
Modified files:
/loncom/interface loncommon.pm loncreateuser.pm
/loncom/homework lonhomework.pm structuretags.pm
/loncom/auth lonroles.pm
/loncom/publisher lonpubdir.pm
/loncom/lonnet/perl lonnet.pm
Log:
- Available editors in Authoring Space: value set for specific author can
override domain default.
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1417 loncom/interface/loncommon.pm:1.1418
--- loncom/interface/loncommon.pm:1.1417 Sat Nov 11 23:09:23 2023
+++ loncom/interface/loncommon.pm Fri Nov 17 17:02:20 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1417 2023/11/11 23:09:23 raeburn Exp $
+# $Id: loncommon.pm,v 1.1418 2023/11/17 17:02:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6475,6 +6475,59 @@
return;
}
+sub permitted_editors {
+ my ($is_author,$is_coauthor,$auname,$audom,%editors);
+ if ($env{'request.role'} =~ m{^au\./}) {
+ $is_author = 1;
+ } elsif ($env{'request.role'} =~ m{^(?:ca|aa)\./($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;
+ }
+ }
+ } elsif ($env{'request.course.id'}) {
+ if ($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);
+ }
+ if (($audom ne '') && ($auname ne '')) {
+ if (($env{'user.domain'} eq $audom) &&
+ ($env{'user.name'} eq $auname)) {
+ $is_author = 1;
+ } else {
+ $is_coauthor = 1;
+ }
+ }
+ }
+ if ($is_author) {
+ if (exists($env{'environment.editors'})) {
+ map { $editors{$_} = 1; } split(/,/,$env{'environment.editors'});
+ } else {
+ %editors = ( edit => 1,
+ xml => 1,
+ );
+ }
+ } elsif ($is_coauthor) {
+ if (exists($env{"environment.internal.editors./$audom/$auname"})) {
+ map { $editors{$_} = 1; } split(/,/,$env{"environment.internal.editors./$audom/$auname"});
+ } else {
+ %editors = ( edit => 1,
+ xml => 1,
+ );
+ }
+ } else {
+ %editors = ( edit => 1,
+ xml => 1,
+ );
+ }
+ return %editors;
+}
+
###############################################
###############################################
@@ -17735,6 +17788,17 @@
\%userenv,\%domdef,\%is_adv);
}
+ if ((ref($userroles) eq 'HASH') && ($userroles->{'user.author'}) &&
+ (exists($userroles->{"user.role.au./$domain/"}))) {
+ if ($userenv{'authoreditors'}) {
+ $userenv{'editors'} = $userenv{'authoreditors'};
+ } elsif ($domdef{'editors'} ne '') {
+ $userenv{'editors'} = $domdef{'editors'};
+ } else {
+ $userenv{'editors'} = 'edit,xml';
+ }
+ }
+
$userenv{'canrequest.author'} =
&Apache::lonnet::usertools_access($username,$domain,'requestauthor',
'reload','requestauthor',
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.473 loncom/interface/loncreateuser.pm:1.474
--- loncom/interface/loncreateuser.pm:1.473 Sun Nov 5 20:06:04 2023
+++ loncom/interface/loncreateuser.pm Fri Nov 17 17:02:20 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.473 2023/11/05 20:06:04 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.474 2023/11/17 17:02:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -340,10 +340,12 @@
$currdisp,$custdisp,$custradio,$onclick);
$cust_off = 'checked="checked" ';
$tool_on = 'checked="checked" ';
- $curr_access =
- &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
- $context,\%userenv,'',
- {'is_adv' => $isadv});
+ unless (($context eq 'authordefaults') && ($item ne 'webdav')) {
+ $curr_access =
+ &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
+ $context,\%userenv,'',
+ {'is_adv' => $isadv});
+ }
if ($context eq 'requestauthor') {
if ($userenv{$context} ne '') {
$cust_on = ' checked="checked" ';
@@ -3781,7 +3783,10 @@
}
if (($env{'user.name'} eq $env{'form.ccuname'}) &&
($env{'user.domain'} eq $env{'form.ccdomain'})) {
- my %newenvhash;
+ my (%newenvhash,$got_domdefs,%domdefaults,$got_userenv,
+ %userenv);
+ my @fromenv = keys(%changed);
+ push(@fromenv,'inststatus');
foreach my $key (keys(%changed)) {
if (($key eq 'official') || ($key eq 'unofficial') ||
($key eq 'community') || ($key eq 'textbook') ||
@@ -3791,28 +3796,55 @@
if ($changeHash{'requestcourses.'.$key}) {
$newenvhash{'environment.canrequest.'.$key} = 1;
} else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ unless ($got_userenv) {
+ %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'}, at fromenv);
+ $got_userenv = 1;
+ }
$newenvhash{'environment.canrequest.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','requestcourses');
+ $key,'reload','requestcourses',\%userenv,\%domdefaults);
}
} elsif ($key eq 'requestauthor') {
$newenvhash{'environment.'.$key} = $changeHash{$key};
if ($changeHash{$key}) {
$newenvhash{'environment.canrequest.author'} = 1;
} else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ unless ($got_userenv) {
+ %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'}, at fromenv);
+ $got_userenv = 1;
+ }
$newenvhash{'environment.canrequest.author'} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','requestauthor');
+ $key,'reload','requestauthor',\%userenv,\%domdefaults);
}
} elsif ($key eq 'editors') {
$newenvhash{'environment.author'.$key} = $changeHash{'author'.$key};
- if ($key eq 'editors') {
- if ($env{'form.customeditors'}) {
- $newenvhash{'environment.editors'} = $changeHash{'author'.$key};
+ if ($env{'form.customeditors'}) {
+ $newenvhash{'environment.editors'} = $changeHash{'author'.$key};
+ } else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ if ($domdefaults{'editors'} ne '') {
+ $newenvhash{'environment.editors'} = $domdefaults{'editors'};
} else {
- $newenvhash{'environment.editors'} =
- &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','authordefaults');
+ $newenvhash{'environment.editors'} = 'edit,xml';
}
}
} elsif ($key ne 'quota') {
@@ -3822,9 +3854,20 @@
$newenvhash{'environment.availabletools.'.$key} =
$changeHash{'tools.'.$key};
} else {
+ unless ($got_domdefs) {
+ %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ $got_domdefs = 1;
+ }
+ unless ($got_userenv) {
+ %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'}, at fromenv);
+ $got_userenv = 1;
+ }
$newenvhash{'environment.availabletools.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','tools');
+ $key,'reload','tools',\%userenv,\%domdefaults);
}
}
}
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.379 loncom/homework/lonhomework.pm:1.380
--- loncom/homework/lonhomework.pm:1.379 Tue Nov 7 12:26:00 2023
+++ loncom/homework/lonhomework.pm Fri Nov 17 17:02:21 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.379 2023/11/07 12:26:00 raeburn Exp $
+# $Id: lonhomework.pm,v 1.380 2023/11/17 17:02:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -163,9 +163,19 @@
return ('web','answer');
} elsif (($env{'form.problemmode'} eq 'saveedit') ||
($env{'form.problemmode'} eq 'undo')) {
- return ('modified','no_output_web','edit');
+ my %editors = &Apache::loncommon::permitted_editors();
+ if ($editors{'edit'}) {
+ return ('modified','no_output_web','edit');
+ } else {
+ return ('web');
+ }
} elsif ($env{'form.problemmode'} eq 'edit') {
- return ('no_output_web','edit');
+ my %editors = &Apache::loncommon::permitted_editors();
+ if ($editors{'edit'}) {
+ return ('no_output_web','edit');
+ } else {
+ return ('web');
+ }
} else {
return ('web');
}
@@ -964,18 +974,26 @@
{'bread_crumbs' => $brcrum,})
.&Apache::loncommon::head_subbox(
&Apache::loncommon::CSTR_pageheader());
+ my %lt = &Apache::lonlocal::texthash(
+ edit => 'Edit',
+ editxml => 'EditXML',
+ );
$result .=
'<form name="lonhomework" method="post" action="'.
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'.
'<input type="hidden" name="problemmode" value="'.
$env{'form.problemmode'}.'" />'.
&Apache::structuretags::remember_problem_state().'
- <div class="LC_edit_problem_analyze_header">
- <input type="button" name="submitmode" value="'.&mt("EditXML").'" '.
- 'onclick="javascript:setmode(this.form,'."'editxml'".')" />
- <input type="button" name="submitmode" value="'.&mt('Edit').'" '.
- 'onclick="javascript:setmode(this.form,'."'edit'".')" />
- <hr />
+ <div class="LC_edit_problem_analyze_header">';
+ my %editors = &Apache::loncommon::permitted_editors();
+ foreach my $item ('editxml','edit') {
+ next unless ($editors{$item});
+ $result .= '<input type="button" name="submitmode" value="'.$lt{$item}.'" '.
+ 'onclick="javascript:setmode(this.form,'."'$item'".')" />'.
+ "\n";
+ }
+ $result .=
+ '<hr />
<input type="button" name="submitmode" value="'.&mt("View").'" '.
'onclick="javascript:setmode(this.form,'."'view'".')" />
<hr />
@@ -1708,7 +1726,13 @@
($env{'form.problemmode'} eq 'saveeditxml') ||
($env{'form.problemmode'} eq 'saveviewxml') ||
($env{'form.problemmode'} eq 'undoxml')) {
- &editxmlmode($request,$file);
+ my %editors = &Apache::loncommon::permitted_editors();
+ if (($editors{'xml'}) || ($env{'form.problemmode'} eq 'saveviewxml') || ($env{'form.problemmode'} eq 'undoxml')) {
+ &editxmlmode($request,$file);
+ } else {
+ &update_construct_style();
+ &renderpage($request,$file);
+ }
} elsif ($env{'form.problemmode'} eq 'calcanswers') {
&analyze($request,$file);
} else {
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.579 loncom/homework/structuretags.pm:1.580
--- loncom/homework/structuretags.pm:1.579 Tue Nov 7 12:26:00 2023
+++ loncom/homework/structuretags.pm Fri Nov 17 17:02:21 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.579 2023/11/07 12:26:00 raeburn Exp $
+# $Id: structuretags.pm,v 1.580 2023/11/17 17:02:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -835,13 +835,18 @@
sub problem_edit_buttons {
my ($mode)=@_;
+ my %editors = &Apache::loncommon::permitted_editors();
# Buttons that save
my $result = '<div style="float:right">';
if ($mode eq 'editxml') {
- $result.=&problem_edit_action_button('subsaveedit','saveeditxml','s','Save and EditXML');
+ if ($editors{'xml'}) {
+ $result.=&problem_edit_action_button('subsaveedit','saveeditxml','s','Save and EditXML');
+ }
$result.=&problem_edit_action_button('subsaveview','saveviewxml','v','Save and View');
} else {
- $result.=&problem_edit_action_button('subsaveedit','saveedit','s','Save and Edit');
+ if ($editors{'edit'}) {
+ $result.=&problem_edit_action_button('subsaveedit','saveedit','s','Save and Edit');
+ }
$result.=&problem_edit_action_button('subsaveview','saveview','v','Save and View');
}
$result.="\n</div>\n";
@@ -849,13 +854,17 @@
$result .= '<div>'.
&problem_edit_action_button('subdiscview','discard','d','Discard Edits and View',1);
if ($mode eq 'editxml') {
- $result.=&problem_edit_action_button('subedit','edit','e','Edit',1);
+ if ($editors{'edit'}) {
+ $result.=&problem_edit_action_button('subedit','edit','e','Edit',1);
+ }
$result.=&problem_edit_action_button('subundo','undoxml','u','Undo',1);
if (&Apache::loncommon::nocodemirror()) {
$result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1);
}
} else {
- $result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1);
+ if ($editors{'xml'}) {
+ $result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1);
+ }
$result.=&problem_edit_action_button('subundo','undo','u','Undo',1);
}
$result.="\n</div>";
@@ -927,6 +936,7 @@
sub problem_web_to_edit_header {
my ($rndseed)=@_;
+ my %editors = &Apache::loncommon::permitted_editors();
my $result .= '<div class="LC_edit_problem_header">';
if (!$Apache::lonhomework::parsing_a_task) {
@@ -1056,11 +1066,16 @@
<hr />
<div>';
$result.='<input type="hidden" name="problemmode" value="view" />';
- $result .= '<input type="button" name="submitmode" accesskey="e" value="'.&mt('Edit').'" '.
- 'onclick="javascript:setmode(this.form,'."'edit'".')" />';
- $result .= '<input type="button" name="submitmode" accesskey="x" value="'.&mt('EditXML').'" '.
- 'onclick="javascript:setmode(this.form,'."'editxml'".')" />';
- if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) {
+ if ($editors{'edit'}) {
+ $result .= '<input type="button" name="submitmode" accesskey="e" value="'.&mt('Edit').'" '.
+ 'onclick="javascript:setmode(this.form,'."'edit'".')" />';
+ }
+ if ($editors{'xml'}) {
+ $result .= '<input type="button" name="submitmode" accesskey="x" value="'.&mt('EditXML').'" '.
+ 'onclick="javascript:setmode(this.form,'."'editxml'".')" />';
+ }
+ if (($editors{'daxe'}) &&
+ ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9)) {
my $uri = $env{'request.uri'};
my $daxeurl = '/daxepage'.$uri;
$result .= '<input type="button" value="'.&mt('Edit with Daxe').'" '.
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.371 loncom/auth/lonroles.pm:1.372
--- loncom/auth/lonroles.pm:1.371 Tue Oct 17 14:43:03 2023
+++ loncom/auth/lonroles.pm Fri Nov 17 17:02:21 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.371 2023/10/17 14:43:03 raeburn Exp $
+# $Id: lonroles.pm,v 1.372 2023/11/17 17:02:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2704,6 +2704,22 @@
}
} else {
$newrole{$rolekey} = $status_in_db;
+ if ($role eq 'au') {
+ my %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'},'authoreditors');
+ if ($userenv{'authoreditors'}) {
+ $userenv{'editors'} = $userenv{'authoreditors'};
+ } else {
+ my %domdef = &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ if ($domdef{'editors'} ne '') {
+ $userenv{'editors'} = $domdef{'editors'};
+ } else {
+ $userenv{'editors'} = 'edit,xml';
+ }
+ }
+ &Apache::lonnet::appenv(\%userenv);
+ }
}
}
}
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.180 loncom/publisher/lonpubdir.pm:1.181
--- loncom/publisher/lonpubdir.pm:1.180 Fri Jul 14 18:01:23 2023
+++ loncom/publisher/lonpubdir.pm Fri Nov 17 17:02:22 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Authoring Space Directory Lister
#
-# $Id: lonpubdir.pm,v 1.180 2023/07/14 18:01:23 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.181 2023/11/17 17:02:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -315,6 +315,7 @@
}
# Print the sorted resources
+ my %editors = &Apache::loncommon::permitted_editors();
foreach my $filename (@sorted_files) {
if ($filehash->{$filename}->{"cmode"}&$dirptr) { # Directories
&putdirectory($r, $thisdisfn, $linkdir, $filename,
@@ -328,7 +329,8 @@
$filehash->{$filename}->{"linkfilename"},
$filehash->{$filename}->{"fulltitle"},
$filehash->{$filename}->{"status"},
- $filehash->{$filename}->{"pubstatus"});
+ $filehash->{$filename}->{"pubstatus"},
+ \%editors);
}
}
@@ -923,7 +925,8 @@
sub putresource {
my ($r, $udom, $uname, $filename, $thisdisfn, $resdir,
$targetdir, $linkdir, $crsauthor, $cmtime, $size,
- $numres, $linkfilename, $title, $status, $pubstatus) = @_;
+ $numres, $linkfilename, $title, $status, $pubstatus,
+ $editors) = @_;
&Apache::lonnet::devalidate_cache_new('meta',$targetdir.'/'.$filename);
my $editlink='';
@@ -932,13 +935,18 @@
$editlink=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
}
if ($filename=~/$LONCAPA::assess_re/) {
- $editlink=' (<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=editxml">'.&mt('EditXML').'</a>)';
- $editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
+ if ($editors->{'xml'}) {
+ $editlink=' (<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=editxml">'.&mt('EditXML').'</a>)';
+ }
+ if ($editors->{'edit'}) {
+ $editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
+ }
}
if ($filename=~/\.(xml|html|htm|xhtml|xhtm)$/ || $filename=~/$LONCAPA::assess_re/) {
- if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) {
+ if (($editors->{'daxe'}) &&
+ ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9)) {
my $daxeurl = '/daxepage'.$linkdir.'/'.$filename;
- $editlink .= ' (<a href="'.$daxeurl.'" target="_blank">Daxe</a>)';
+ $editlink .= ' (<a href="'.$daxeurl.'">Daxe</a>)';
}
}
if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1517 loncom/lonnet/perl/lonnet.pm:1.1518
--- loncom/lonnet/perl/lonnet.pm:1.1517 Fri Nov 3 01:12:17 2023
+++ loncom/lonnet/perl/lonnet.pm Fri Nov 17 17:02:22 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1517 2023/11/03 01:12:17 raeburn Exp $
+# $Id: lonnet.pm,v 1.1518 2023/11/17 17:02:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -8240,7 +8240,6 @@
} elsif ($context eq 'authordefaults') {
%tools = (
webdav => 1,
- editors => 1,
);
} else {
%tools = (
@@ -8267,8 +8266,6 @@
} elsif ($context eq 'authordefaults') {
if ($tool eq 'webdav') {
return $env{'environment.availabletools.'.$tool};
- } elsif ($tool eq 'editors') {
- return $env{'environment.authoreditors'};
}
} else {
return $env{'environment.availabletools.'.$tool};
@@ -8282,8 +8279,6 @@
} elsif ($context eq 'authordefaults') {
if ($tool eq 'webdav') {
$envkey = 'tools.'.$tool;
- } elsif ($tool eq 'editors') {
- $envkey = 'author'.$tool;
}
} else {
$envkey = $context.'.'.$tool;
More information about the LON-CAPA-cvs
mailing list