--- loncom/interface/lonuserutils.pm 2010/11/14 22:47:37 1.97.2.24
+++ loncom/interface/lonuserutils.pm 2010/09/20 00:26:44 1.109.2.5
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.97.2.24 2010/11/14 22:47:37 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.109.2.5 2010/09/20 00:26:44 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,6 +36,7 @@ use Apache::loncommon();
use Apache::lonhtmlcommon;
use Apache::lonlocal;
use Apache::longroup;
+use Apache::lonnavmaps;
use LONCAPA qw(:DEFAULT :match);
###############################################################
@@ -47,8 +48,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);
@@ -296,7 +296,7 @@ sub hidden_input {
}
sub print_upload_manager_header {
- my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype,
+ my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype,$formname,
$can_assign)=@_;
my $javascript;
#
@@ -327,9 +327,32 @@ sub print_upload_manager_header {
$password_choice = 'int';
}
#
- my $groupslist;
+ my ($sectionjs,$groupslist);
if ($context eq 'course') {
$groupslist = &get_groupslist();
+ if ($env{'form.caller'} eq 'requestcrs') {
+ $sectionjs = <<"ENDJS";
+
+function toggleSectionsDefault() {
+ var usingsecs;
+ if (document.$formname.usesection.length > 1) {
+ for (var i=0; i '
.&mt('Change authentication for existing users in domain "[_1]" to these settings?'
@@ -858,12 +871,17 @@ sub print_upload_manager_footer {
.' '."\n".
- &mt('This will not take effect if the user already exists.').
- &Apache::loncommon::help_open_topic('Auth_Options').
- " \n".$date_table." \n".$date_table."'.
&mt('Identify fields in uploaded list')."
\n");
- $r->print(&mt('Enter as many fields as you can.
The system will inform you and bring you back to this page,
if the data selected are insufficient to add users.')."
\n");
+ $r->print(&mt('Enter as many fields as you can.').'
'.
+ &mt('The system will inform you and bring you back to this page,').
+ '
'.&mt('if the data selected are insufficient to add users.')."
\n");
$r->print(&hidden_input('action','upload').
&hidden_input('state','got_file').
&hidden_input('associate','').
&hidden_input('datatoken',$datatoken).
&hidden_input('fileupload',$env{'form.fileupload'}).
&hidden_input('upfiletype',$env{'form.upfiletype'}).
- &hidden_input('upfile_associate',$env{'form.upfile_associate'}));
+ &hidden_input('upfile_associate',$env{'form.upfile_associate'}).
+ &hidden_input('caller',$env{'form.caller'}));
$r->print('
');
$r->print('
print("
\n".
'');
}
@@ -389,9 +415,13 @@ sub javascript_validations {
if ($context eq 'course') {
if ($env{'request.course.sec'} eq '') {
$setsection_call = 'setSections(document.'.$param{'formname'}.",'$crstype'".');';
- $setsections_js =
- &setsections_javascript($param{'formname'},$groupslist,
- $mode,'',$crstype);
+ if ($env{'form.caller'} eq 'requestcrs') {
+ $setsections_js = &newsections_javascript($param{'formname'});
+ } else {
+ $setsections_js =
+ &setsections_javascript($param{'formname'},$groupslist,
+ $mode,'',$crstype);
+ }
} else {
$setsection_call = "'ok'";
}
@@ -519,7 +549,9 @@ END
END
} else {
$section_checks = §ion_check_js();
- $optional_checks = (<
'.
+ &mt('Will you be using sections?').' '.
+ ''.
+ ' '.&mt('Yes').''.
+ ' ';
+ } else {
+ $Str .= &Apache::lonhtmlcommon::row_title(
&mt('Default role and section'))
- .&mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file.');
+ .&mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file.');
+ }
} else {
$Str .= &Apache::lonhtmlcommon::row_title(
&mt('Default role and/or section(s)'))
@@ -932,11 +963,22 @@ sub print_upload_manager_footer {
}
} else {
my ($cnum,$cdom) = &get_course_identity();
- my $rowtitle = &mt('section');
+ my ($rowtitle,$closure);
+ if ($env{'form.caller'} eq 'requestcrs') {
+ $closure = 1;
+ $rowtitle = &mt('default section name (letters/numbers only)');
+ } else {
+ $rowtitle = &mt('section');
+ }
my $secbox = §ion_picker($cdom,$cnum,'Any',$rowtitle,
- $permission,$context,'upload',$crstype);
- $Str .= $secbox
- .&Apache::lonhtmlcommon::row_closure();
+ $permission,$context,'upload',$crstype,
+ $env{'form.caller'}).
+ &Apache::lonhtmlcommon::row_closure($closure);
+ if ($env{'form.caller'} eq 'requestcrs') {
+ $Str .= ''.$secbox.'
'
- .$lt{'stus'}
- .&Apache::lonhtmlcommon::row_closure();
+ unless ($env{'form.caller'} eq 'requestcrs') {
+ $Str .= &Apache::lonhtmlcommon::row_title(&mt('Full Update'))
+ .'
'
+ .$lt{'stus'}
+ .&Apache::lonhtmlcommon::row_closure();
+ }
}
if ($context eq 'course' || $context eq 'domain') {
- $Str .= &forceid_change($context);
+ unless ($env{'form.caller'} eq 'requestcrs') {
+ $Str .= &forceid_change($context);
+ }
}
$Str .= &Apache::lonhtmlcommon::end_pick_box();
@@ -1001,7 +1047,7 @@ sub forceid_change {
###############################################################
###############################################################
sub print_upload_manager_form {
- my ($r,$context,$permission,$crstype) = @_;
+ my ($r,$context,$permission,$crstype,$formname) = @_;
my $firstLine;
my $datatoken;
if (!$env{'form.datatoken'}) {
@@ -1049,12 +1095,13 @@ sub print_upload_manager_form {
#
my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($defdom);
&print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context,
- $permission,$crstype,\%can_assign);
+ $permission,$crstype,$formname,\%can_assign);
my $i;
my $keyfields;
if ($total>=0) {
my @field=
(['username',&mt('Username'), $env{'form.username_choice'}],
+ ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
['names',&mt('Last Name, First Names'),$env{'form.names_choice'}],
['fname',&mt('First Name'), $env{'form.fname_choice'}],
['mname',&mt('Middle Names/Initials'),$env{'form.mname_choice'}],
@@ -1062,7 +1109,6 @@ sub print_upload_manager_form {
['gen', &mt('Generation'), $env{'form.gen_choice'}],
['id', &mt('Student/Employee ID'),$env{'form.id_choice'}],
['sec', &mt('Section'), $env{'form.sec_choice'}],
- ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
['email',&mt('E-mail Address'), $env{'form.email_choice'}],
['role',&mt('Role'), $env{'form.role_choice'}],
['domain',&mt('Domain'), $env{'form.domain_choice'}],
@@ -1255,8 +1301,10 @@ sub default_role_selector {
'exs' => "Existing sections",
'new' => "New section",
);
- $options = '
' - .&list_submit_button(&mt('Update Display')) - ."
\n" - ); + (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { + $r->print(' '.&list_submit_button(&mt('Update Display')). + "\n\n"); } my ($indexhash,$keylist) = &make_keylist_array(); my (%userlist,%userinfo,$clearcoursepick); if (($context eq 'domain') && - ($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')) { my ($crstype,$numcodes,$title,$warning); if ($env{'form.roletype'} eq 'course') { @@ -1802,7 +1846,7 @@ sub section_group_filter { } if (@options > 0) { my $currsel; - $markup = '