[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface lonuserutils.pm
raeburn
raeburn@source.lon-capa.org
Sun, 14 Nov 2010 21:13:20 -0000
raeburn Sun Nov 14 21:13:20 2010 EDT
Modified files: (Branch: version_2_9_X)
/loncom/interface lonuserutils.pm
Log:
- Backport 1.122, 1.123, 1.126, 1.131, 1.132.
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.97.2.20 loncom/interface/lonuserutils.pm:1.97.2.21
--- loncom/interface/lonuserutils.pm:1.97.2.20 Sat Nov 13 01:29:34 2010
+++ loncom/interface/lonuserutils.pm Sun Nov 14 21:13:20 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.97.2.20 2010/11/13 01:29:34 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.97.2.21 2010/11/14 21:13:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -296,7 +296,8 @@
}
sub print_upload_manager_header {
- my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype)=@_;
+ my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype,
+ $can_assign)=@_;
my $javascript;
#
if (! exists($env{'form.upfile_associate'})) {
@@ -310,9 +311,9 @@
}
}
if ($env{'form.upfile_associate'} eq 'reverse') {
- $javascript=&upload_manager_javascript_reverse_associate();
+ $javascript=&upload_manager_javascript_reverse_associate($can_assign);
} else {
- $javascript=&upload_manager_javascript_forward_associate();
+ $javascript=&upload_manager_javascript_forward_associate($can_assign);
}
#
# Deal with restored settings
@@ -533,6 +534,7 @@
if (message!='') {
message+='\\n';
}
+ message+='$alert{'section'}';
}
if (foundemail==0) {
if (message!='') {
@@ -586,6 +588,46 @@
###############################################################
###############################################################
sub upload_manager_javascript_forward_associate {
+ my ($can_assign) = @_;
+ my ($auth_update,$numbuttons,$argreset);
+ if (ref($can_assign) eq 'HASH') {
+ if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) {
+ $argreset .= " vf.krbarg.value='';\n";
+ $numbuttons ++ ;
+ }
+ if ($can_assign->{'int'}) {
+ $argreset .= " vf.intarg.value='';\n";
+ $numbuttons ++;
+ }
+ if ($can_assign->{'loc'}) {
+ $argreset .= " vf.locarg.value='';\n";
+ $numbuttons ++;
+ }
+ if (!$can_assign->{'int'}) {
+ my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.\n').
+ &mt('Your current role does not have rights to create users with that authentication type.');
+ $auth_update = <<"END";
+ // Currently the initial password field is only supported for internal auth
+ // (see bug 6368).
+ if (nw==9) {
+ eval('vf.f'+tf+'.selectedIndex=0;')
+ alert('$warning');
+ }
+END
+ } elsif ($numbuttons > 1) {
+ $auth_update = <<"END";
+ // If we set the password, make the password form below correspond to
+ // the new value.
+ if (nw==9) {
+ changed_radio('int',document.studentform);
+ set_auth_radio_buttons('int',document.studentform);
+$argreset
+ }
+
+END
+ }
+ }
+
return(<<ENDPICK);
function verify(vf,sec_caller) {
var founduname=0;
@@ -662,15 +704,7 @@
}
}
}
- // If we set the password, make the password form below correspond to
- // the new value.
- if (nw==9) {
- changed_radio('int',document.studentform);
- set_auth_radio_buttons('int',document.studentform);
- vf.intarg.value='';
- vf.krbarg.value='';
- vf.locarg.value='';
- }
+ $auth_update
}
function clearpwd(vf) {
@@ -688,6 +722,45 @@
###############################################################
###############################################################
sub upload_manager_javascript_reverse_associate {
+ my ($can_assign) = @_;
+ my ($auth_update,$numbuttons,$argreset);
+ if (ref($can_assign) eq 'HASH') {
+ if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) {
+ $argreset .= " vf.krbarg.value='';\n";
+ $numbuttons ++ ;
+ }
+ if ($can_assign->{'int'}) {
+ $argreset .= " vf.intarg.value='';\n";
+ $numbuttons ++;
+ }
+ if ($can_assign->{'loc'}) {
+ $argreset .= " vf.locarg.value='';\n";
+ $numbuttons ++;
+ }
+ if (!$can_assign->{'int'}) {
+ my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n').
+ &mt('Your current role does not have rights to create users with that authentication type.');
+ $auth_update = <<"END";
+ // Currently the initial password field is only supported for internal auth
+ // (see bug 6368).
+ if (tf==8 && nw!=0) {
+ eval('vf.f'+tf+'.selectedIndex=0;')
+ alert('$warning');
+ }
+END
+ } elsif ($numbuttons > 1) {
+ $auth_update = <<"END";
+ // initial password specified, pick internal authentication
+ if (tf==8 && nw!=0) {
+ changed_radio('int',document.studentform);
+ set_auth_radio_buttons('int',document.studentform);
+$argreset
+ }
+
+END
+ }
+ }
+
return(<<ENDPICK);
function verify(vf,sec_caller) {
var founduname=0;
@@ -695,6 +768,7 @@
var foundname=0;
var foundid=0;
var foundsec=0;
+ var foundemail=0;
var foundrole=0;
var founddomain=0;
var foundinststatus=0;
@@ -706,11 +780,12 @@
if (i==6 && tw!=0) { foundid=1; }
if (i==7 && tw!=0) { foundsec=1; }
if (i==8 && tw!=0) { foundpwd=1; }
- if (i==9 && tw!=0) { foundrole=1; }
- if (i==10 && tw!=0) { founddomain=1; }
- if (i==13 && tw!=0) { foundinstatus=1; }
+ if (i==9 && tw!=0) { foundemail=1; }
+ if (i==10 && tw!=0) { foundrole=1; }
+ if (i==11 && tw!=0) { founddomain=1; }
+ if (i==12 && tw!=0) { foundinstatus=1; }
}
- verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundrole,founddomain,foundinststatus);
+ verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus);
}
function flip(vf,tf) {
@@ -735,6 +810,7 @@
vf.intarg.value='';
vf.locarg.value='';
}
+ $auth_update
}
function clearpwd(vf) {
@@ -979,8 +1055,9 @@
my ($krbdef,$krbdefdom) =
&Apache::loncommon::get_kerberos_defaults($defdom);
#
+ my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($defdom);
&print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context,
- $permission,$crstype);
+ $permission,$crstype,\%can_assign);
my $i;
my $keyfields;
if ($total>=0) {
@@ -4231,7 +4308,7 @@
}
} # end of foreach (@userdata)
# Flush the course logs so reverse user roles immediately updated
- &Apache::lonnet::flushcourselogs();
+ $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
$r->print("</p>\n<p>\n".&mt('Processed [quant,_1,user].',$counts{'user'}).
"</p>\n");
if ($counts{'role'} > 0) {
@@ -4722,7 +4799,7 @@
$r->print('<p>'.&mt('Re-enabling will re-activate data for the role.').'</p>');
}
# Flush the course logs so reverse user roles immediately updated
- &Apache::lonnet::flushcourselogs();
+ $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
}
if ($env{'form.makedatesdefault'}) {
if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') {