--- loncom/interface/lonuserutils.pm 2010/01/20 20:35:28 1.97.2.8
+++ loncom/interface/lonuserutils.pm 2010/11/14 21:19:08 1.97.2.22
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.97.2.8 2010/01/20 20:35:28 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.97.2.22 2010/11/14 21:19:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,7 +47,8 @@ sub modifystudent {
# this one. If $csec is defined, drop them from all other sections of
# this course and add them to section $csec
my ($cnum,$cdom) = &get_course_identity($courseid);
- my %roles = &Apache::lonnet::dump('roles',$udom,$unam);
+ my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1});
+ my %roles = &Apache::lonnet::dump('roles',$udom,$unam,'.',undef,$extra);
my ($tmp) = keys(%roles);
# Bail out if we were unable to get the students roles
return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i);
@@ -295,7 +296,8 @@ sub hidden_input {
}
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'})) {
@@ -309,9 +311,9 @@ sub print_upload_manager_header {
}
}
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
@@ -386,8 +388,7 @@ sub javascript_validations {
if (($context eq 'course') || ($context eq 'domain')) {
if ($context eq 'course') {
if ($env{'request.course.sec'} eq '') {
- $setsection_call = 'setSections(document.'.$param{'formname'}."'$crstype'".');';
-
+ $setsection_call = 'setSections(document.'.$param{'formname'}.",'$crstype'".');';
$setsections_js =
&setsections_javascript($param{'formname'},$groupslist,
$mode,'',$crstype);
@@ -533,6 +534,7 @@ END
if (message!='') {
message+='\\n';
}
+ message+='$alert{'section'}';
}
if (foundemail==0) {
if (message!='') {
@@ -586,6 +588,46 @@ END
###############################################################
###############################################################
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(<
' + .&list_submit_button(&mt('Update Display')) + ."
\n" + ); } my ($indexhash,$keylist) = &make_keylist_array(); my (%userlist,%userinfo,$clearcoursepick); @@ -1559,7 +1640,8 @@ sub print_userlist { } } } - } elsif ($env{'form.roletype'} eq 'course') { + } elsif (($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'community')) { if (($env{'form.coursepick'}) && (!$clearcoursepick)) { my %courses = &process_coursepick(); my %allusers; @@ -1728,7 +1810,7 @@ sub section_group_filter { } if (@options > 0) { my $currsel; - $markup = ''."\n"; + $markup = ''."\n"; - $output .= (' 'x3).''; + $output .= (' 'x3).'' + .'' + .' '; } } return $output; @@ -2297,7 +2381,7 @@ END if ($env{'form.showrole'} eq 'cr') { $rolefilter = &mt('custom'); } elsif ($env{'form.showrole'} ne 'Any') { - $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'}); + $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'},$crstype); } my $results_description; if ($mode ne 'autoenroll') { @@ -2397,7 +2481,7 @@ END if ($env{'form.userwin'}) { $checkwin = ' checked="checked"'; } - $output .= '' + .&mt('Problems occurred in writing the CSV file.') + .' '.&mt('This error has been logged.') + .' '.&mt('Please alert your LON-CAPA administrator.') + .'
' + ); $CSVfile = undef; } # @@ -2933,7 +3021,7 @@ sub print_username_link { $output = $in->{'username'}; } else { $output = '{'username'}','$in->{'domain'}'".')" />'. + "'$in->{'username'}','$in->{'domain'}'".')">'. $in->{'username'}.''; } return $output; @@ -2945,7 +3033,6 @@ sub role_type_names { 'author' => 'Co-Author Roles', 'course' => 'Course Roles', 'community' => 'Community Roles', - ); return %lt; } @@ -3164,8 +3251,8 @@ ENDJS my %lt = &Apache::lonlocal::texthash ( chac => 'Access dates to apply for selected users', chse => 'Changes in section affiliation to apply to selected users', - fors => 'For student roles changing the section, will result in a section switch as students may only be in one section of a course at a time.', - forn => 'For a role in a course that is not a student role, a user may have roles in more than one section of a course at a time.', + fors => 'For student roles, changing the section will result in a section switch as students may only be in one section of a course at a time.', + forn => 'For a course role that is not "student", users may have roles in more than one section at a time.', reta => "Retain each user's current section affiliations?", dnap => '(Does not apply to student roles).', ); @@ -3184,14 +3271,13 @@ ENDJS $permission,$crstype); } $output .= '