[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncommon.pm
raeburn
raeburn at source.lon-capa.org
Sat Oct 22 15:10:13 EDT 2016
raeburn Sat Oct 22 19:10:13 2016 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface loncommon.pm
Log:
- For 2.11
- Backport 1.1254, 1.1255, 1.1256, 1.1257
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1075.2.114 loncom/interface/loncommon.pm:1.1075.2.115
--- loncom/interface/loncommon.pm:1.1075.2.114 Sun Sep 18 20:56:04 2016
+++ loncom/interface/loncommon.pm Sat Oct 22 19:10:11 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1075.2.114 2016/09/18 20:56:04 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.115 2016/10/22 19:10:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -936,8 +936,8 @@
}
sub select_timezone {
- my ($name,$selected,$onchange,$includeempty)=@_;
- my $output='<select name="'.$name.'" '.$onchange.'>'."\n";
+ my ($name,$selected,$onchange,$includeempty,$disabled)=@_;
+ my $output='<select name="'.$name.'" '.$onchange.$disabled.'>'."\n";
if ($includeempty) {
$output .= '<option value=""';
if (($selected eq '') || ($selected eq 'local')) {
@@ -958,8 +958,8 @@
}
sub select_datelocale {
- my ($name,$selected,$onchange,$includeempty)=@_;
- my $output='<select name="'.$name.'" '.$onchange.'>'."\n";
+ my ($name,$selected,$onchange,$includeempty,$disabled)=@_;
+ my $output='<select name="'.$name.'" '.$onchange.$disabled.'>'."\n";
if ($includeempty) {
$output .= '<option value=""';
if ($selected eq '') {
@@ -1011,7 +1011,7 @@
}
sub select_language {
- my ($name,$selected,$includeempty) = @_;
+ my ($name,$selected,$includeempty,$noedit) = @_;
my %langchoices;
if ($includeempty) {
%langchoices = ('' => 'No language preference');
@@ -1023,7 +1023,7 @@
}
}
%langchoices = &Apache::lonlocal::texthash(%langchoices);
- return &select_form($selected,$name,\%langchoices);
+ return &select_form($selected,$name,\%langchoices,undef,$noedit);
}
=pod
@@ -2239,12 +2239,15 @@
=pod
-=item * &select_form($defdom,$name,$hashref,$onchange)
+=item * &select_form($defdom,$name,$hashref,$onchange,$readonly)
Returns a string containing a <select name='$name' size='1'> form to
allow a user to select options from a ref to a hash containing:
option_name => displayed text. An optional $onchange can include
-a javascript onchange item, e.g., onchange="this.form.submit();"
+a javascript onchange item, e.g., onchange="this.form.submit();".
+An optional arg -- $readonly -- if true will cause the select form
+to be disabled, e.g., for the case where an instructor has a section-
+specific role, and is viewing/modifying parameters.
See lonrights.pm for an example invocation and use.
@@ -2252,7 +2255,7 @@
#-------------------------------------------
sub select_form {
- my ($def,$name,$hashref,$onchange) = @_;
+ my ($def,$name,$hashref,$onchange,$readonly) = @_;
return unless (ref($hashref) eq 'HASH');
if ($onchange) {
$onchange = ' onchange="'.$onchange.'"';
@@ -2426,7 +2429,7 @@
=pod
-=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms)
+=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled)
Returns a string containing a <select name='$name' size='1'> form to
allow a user to select the domain to preform an operation in.
@@ -2441,16 +2444,21 @@
The optional $incdoms is a reference to an array of domains which will be the only available options.
-The optional $excdoms is a reference to an array of domains which will be excluded from the available options.
+The optional $excdoms is a reference to an array of domains which will be excluded from the available options.
+
+The optional $disabled argument, if true, adds the disabled attribute to the select tag.
=cut
#-------------------------------------------
sub select_dom_form {
- my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms) = @_;
+ my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled) = @_;
if ($onchange) {
$onchange = ' onchange="'.$onchange.'"';
}
+ if ($disabled) {
+ $disabled = ' disabled="disabled"';
+ }
my (@domains,%exclude);
if (ref($incdoms) eq 'ARRAY') {
@domains = sort {lc($a) cmp lc($b)} (@{$incdoms});
@@ -2461,7 +2469,7 @@
if (ref($excdoms) eq 'ARRAY') {
map { $exclude{$_} = 1; } @{$excdoms};
}
- my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n";
+ my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange$disabled>\n";
foreach my $dom (@domains) {
next if ($exclude{$dom});
$selectdomain.="<option value=\"$dom\" ".
@@ -5420,6 +5428,10 @@
if ($env{'request.course.id'}) {
if ($env{'request.role'} !~ /^cr/) {
$role = &Apache::lonnet::plaintext($role,&course_type());
+ } elsif ($role =~ m{^cr/($match_domain)/\1-domainconfig/(\w+)$}) {
+ $role = &mt('Helpdesk[_1]',' '.$2);
+ } else {
+ $role = (split(/\//,$role,4))[-1];
}
if ($env{'request.course.sec'}) {
$role .= (' 'x2).'- '.&mt('section:').' '.$env{'request.course.sec'};
@@ -9504,7 +9516,7 @@
}
sub user_picker {
- my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context) = @_;
+ my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context,$fixeddom) = @_;
my $currdom = $dom;
my @alldoms = &Apache::lonnet::all_domains();
if (@alldoms == 1) {
@@ -9568,7 +9580,12 @@
);
&html_escape(\%html_lt);
&js_escape(\%js_lt);
- my $domform = &select_dom_form($currdom,'srchdomain',1,1);
+ my $domform;
+ if ($fixeddom) {
+ $domform = &select_dom_form($currdom,'srchdomain',1,1,undef,[$currdom]);
+ } else {
+ $domform = &select_dom_form($currdom,'srchdomain',1,1);
+ }
my $srchinsel = ' <select name="srchin">';
my @srchins = ('crs','dom','alc','instd');
More information about the LON-CAPA-cvs
mailing list