--- loncom/interface/lonuserutils.pm 2010/11/14 21:13:20 1.97.2.21
+++ loncom/interface/lonuserutils.pm 2009/10/31 14:27:48 1.102
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.97.2.21 2010/11/14 21:13:20 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.102 2009/10/31 14:27:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,8 +47,7 @@ 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 $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1});
- my %roles = &Apache::lonnet::dump('roles',$udom,$unam,'.',undef,$extra);
+ my %roles = &Apache::lonnet::dump('roles',$udom,$unam);
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);
@@ -92,7 +91,7 @@ sub modifyuserrole {
if ($setting eq 'course' || $context eq 'course') {
$scope = '/'.$cid;
$scope =~ s/\_/\//g;
- if (($role ne 'cc') && ($role ne 'co') && ($sec ne '')) {
+ if ($role ne 'cc' && $sec ne '') {
$scope .='/'.$sec;
}
} elsif ($context eq 'domain') {
@@ -296,8 +295,7 @@ sub hidden_input {
}
sub print_upload_manager_header {
- my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype,
- $can_assign)=@_;
+ my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission)=@_;
my $javascript;
#
if (! exists($env{'form.upfile_associate'})) {
@@ -311,9 +309,9 @@ sub print_upload_manager_header {
}
}
if ($env{'form.upfile_associate'} eq 'reverse') {
- $javascript=&upload_manager_javascript_reverse_associate($can_assign);
+ $javascript=&upload_manager_javascript_reverse_associate();
} else {
- $javascript=&upload_manager_javascript_forward_associate($can_assign);
+ $javascript=&upload_manager_javascript_forward_associate();
}
#
# Deal with restored settings
@@ -334,7 +332,7 @@ sub print_upload_manager_header {
my $javascript_validations =
&javascript_validations('upload',$krbdefdom,$password_choice,undef,
$env{'request.role.domain'},$context,
- $groupslist,$crstype);
+ $groupslist);
my $checked=(($env{'form.noFirstLine'})?' checked="checked"':'');
$r->print('
'
.&mt('Total number of records found in file: [_1]'
@@ -367,7 +365,7 @@ sub print_upload_manager_header {
###############################################################
sub javascript_validations {
my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain,
- $context,$groupslist,$crstype)=@_;
+ $context,$groupslist)=@_;
my %param = (
kerb_def_dom => $krbdefdom,
curr_authtype => $curr_authtype,
@@ -388,10 +386,10 @@ 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'}.');';
$setsections_js =
&setsections_javascript($param{'formname'},$groupslist,
- $mode,'',$crstype);
+ $mode);
} else {
$setsection_call = "'ok'";
}
@@ -534,7 +532,6 @@ END
if (message!='') {
message+='\\n';
}
- message+='$alert{'section'}';
}
if (foundemail==0) {
if (message!='') {
@@ -588,46 +585,6 @@ 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(<{'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(<'
.' '
+ .' '.&mt('Add a course role').''
.'';
} elsif ($context eq 'author') {
$Str .= &Apache::lonhtmlcommon::row_title(
@@ -976,7 +899,7 @@ sub print_upload_manager_footer {
.'';
if ($context eq 'course') {
$Str .= '
'
- .&mt('Note: This operation may be time consuming when adding several users.')
+ .&mt('Note: For large courses, this operation may be time consuming.')
.'
';
}
$Str .= '
=0) {
@@ -1254,7 +1176,7 @@ sub default_role_selector {
my %customroles;
my ($options,$coursepick,$cb_jscript);
if ($context ne 'author') {
- %customroles = &my_custom_roles($crstype);
+ %customroles = &my_custom_roles();
}
my %lt=&Apache::lonlocal::texthash(
@@ -1280,16 +1202,16 @@ sub default_role_selector {
$options .= ' ';
}
my $courseform = &Apache::loncommon::selectcourse_link
- ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course/Community');
+ ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course');
$cb_jscript =
- &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform','courserole','Course/Community');
+ &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform');
$coursepick = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
'