--- loncom/interface/lonhelper.pm 2014/02/17 19:36:34 1.192
+++ loncom/interface/lonhelper.pm 2015/08/15 20:11:57 1.195
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.192 2014/02/17 19:36:34 bisitz Exp $
+# $Id: lonhelper.pm,v 1.195 2015/08/15 20:11:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -64,9 +64,11 @@ messages, resource selections, or date q
The helper tag is required to have one attribute, "title", which is the name
of the helper itself, such as "Parameter helper". The helper tag may optionally
-have a "requiredpriv" attribute, specifying the priviledge a user must have
+have a "requiredpriv" attribute, specifying the privilege a user must have
to use the helper, or get denied access. See loncom/auth/rolesplain.tab for
-useful privs. Default is full access, which is often wrong!
+useful privs. You may add the modifier &S at the end of the three letter priv
+if you want to grant access to users for whom the corresponding privilege is
+section-specific. The default is full access, which is often wrong!
=head2 State tags
@@ -283,7 +285,8 @@ sub real_handler {
my $allowed = $helper->allowedCheck();
if (!$allowed) {
- $env{'user.error.msg'} = $env{'request.uri'}.':'.$helper->{REQUIRED_PRIV}.
+ my ($priv,$modifier) = split(/\&/,$helper->{REQUIRED_PRIV});
+ $env{'user.error.msg'} = $env{'request.uri'}.':'.$priv.
":0:0:Permission denied to access this helper.";
return HTTP_NOT_ACCEPTABLE;
}
@@ -508,8 +511,13 @@ sub allowedCheck {
if (!defined($self->{REQUIRED_PRIV})) {
return 1;
}
-
- return Apache::lonnet::allowed($self->{REQUIRED_PRIV}, $env{'request.course.id'});
+ my ($priv,$modifier) = split(/\&/,$self->{REQUIRED_PRIV});
+ my $allowed = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
+ if ((!$allowed) && ($modifier eq 'S') && ($env{'request.course.sec'} ne '')) {
+ $allowed = &Apache::lonnet::allowed($priv,$env{'request.course.id'}.'/'.
+ $env{'request.course.sec'});
+ }
+ return $allowed;
}
sub changeState {
@@ -651,7 +659,7 @@ sub display {
$result .= $buttons;
- #foreach my $key (keys %{$self->{VARS}}) {
+ #foreach my $key (keys(%{$self->{VARS}})) {
# $result .= "|$key| -> " . $self->{VARS}->{$key} . " ";
#}
@@ -2493,7 +2501,7 @@ BUTTONS
&HTML::Entities::encode(&$valueFunc($resource),"<>&\"'");
if ($addparts && (scalar(@{$resource->parts}) > 1)) {
$col .= "