--- loncom/interface/lonuserutils.pm 2007/12/22 00:47:25 1.23
+++ loncom/interface/lonuserutils.pm 2008/07/12 23:56:13 1.60
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.23 2007/12/22 00:47:25 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.60 2008/07/12 23:56:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,7 +42,7 @@ use LONCAPA qw(:DEFAULT :match);
###############################################################
# Drop student from all sections of a course, except optional $csec
sub modifystudent {
- my ($udom,$unam,$courseid,$csec,$desiredhost)=@_;
+ my ($udom,$unam,$courseid,$csec,$desiredhost,$context)=@_;
# if $csec is undefined, drop the student from all the courses matching
# this one. If $csec is defined, drop them from all other sections of
# this course and add them to section $csec
@@ -69,14 +69,14 @@ sub modifystudent {
# dom name id mode pass f m l g
($udom,$unam,'', '', '',undef,undef,undef,undef,
$section,time,undef,undef,$desiredhost,'','manual',
- '',$courseid);
+ '',$courseid,'',$context);
$result .= $reply.':';
}
}
}
}
if ($result eq '') {
- $result = 'Unable to find section for this student';
+ $result = &mt('Unable to find section for this student');
} else {
$result =~ s/(ok:)+/ok/g;
}
@@ -129,7 +129,8 @@ sub modifyuserrole {
if ($role ne '') {
$role =~ s/_/\//g;
$roleresult = &Apache::lonnet::assignrole($udom,$uname,$scope,
- $role,$end,$start);
+ $role,$end,$start,'',
+ '',$context);
}
}
return ($userresult,$authresult,$roleresult,$idresult);
@@ -304,7 +305,7 @@ sub print_upload_manager_header {
my $javascript_validations =
&javascript_validations('upload',$krbdefdom,$password_choice,undef,
$env{'request.role.domain'},$context,
- $permission,$groupslist);
+ $groupslist);
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':'');
$r->print(&mt('Total number of records found in file: [_1].',$distotal).
" '.&mt('Change authentication for existing users to these settings?').' '.&mt('Change authentication for existing users in domain "[_1]" to these settings?',$defdom).' \n".
&mt('Note: this will not take effect if the user already exists').
@@ -729,6 +736,8 @@ sub print_upload_manager_footer {
} else {
$Str .= $home_server_pick;
}
+ $Str .= ' \n".$date_table."
\n");
@@ -318,8 +319,8 @@ sub print_upload_manager_header {
&hidden_input('fileupload',$env{'form.fileupload'}).
&hidden_input('upfiletype',$env{'form.upfiletype'}).
&hidden_input('upfile_associate',$env{'form.upfile_associate'}));
- $r->print('
print('
');
$r->print('');
@@ -332,18 +333,13 @@ sub print_upload_manager_header {
###############################################################
sub javascript_validations {
my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain,
- $context,$permission,$groupslist)=@_;
-
+ $context,$groupslist)=@_;
my %param = (
kerb_def_dom => $krbdefdom,
curr_authtype => $curr_authtype,
);
- if ($mode eq 'createuser') {
- $param{'formname'} = 'cu';
- } elsif ($mode eq 'upload') {
+ if ($mode eq 'upload') {
$param{'formname'} = 'studentform';
- } elsif ($mode eq 'singlestudent') {
- $param{'formname'} = 'cu';
} elsif ($mode eq 'createcourse') {
$param{'formname'} = 'ccrs';
} elsif ($mode eq 'modifycourse') {
@@ -367,7 +363,7 @@ sub javascript_validations {
}
} elsif ($context eq 'domain') {
$setsection_call = 'setCourse()';
- $setsections_js = &dc_setcourse_js($param{'formname'},$mode);
+ $setsections_js = &dc_setcourse_js($param{'formname'},$mode,$context);
}
$finish = " var checkSec = $setsection_call\n".
" if (checkSec == 'ok') {\n".
@@ -387,13 +383,13 @@ sub javascript_validations {
section => 'The optional section field was not specified.',
email => 'The optional email address field was not specified.',
role => 'The optional role field was not specified.',
+ domain => 'The optional domain field was not specified.',
continue => 'Continue adding users?',
);
-
- my $function_name =(<'.&mt('Default domain').'
'."\n".
+ &Apache::loncommon::select_dom_form($defdom,'defaultdomain',undef,1);
$Str .= ''.&mt('Starting and Ending Dates').
"
\n";
$Str .= "'.&mt('Default role')."
\n".
- &mt('Choose the role to assign to users without one specified in the uploaded file');
+ &mt('Choose the role to assign to users without a value specified in the uploaded file');
} elsif ($context eq 'course') {
$Str .= ''.&mt('Default role and section')."
\n".
- &mt('Choose the role and/or section to assign to users without one 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 .= '
'.&mt('Default role and/or section')."
\n".
- &mt('Role and/or section for users without one in the uploaded file.');
+ $Str .= '
'.&mt('Default role and/or section(s)')."
\n".
+ &mt('Role and/or section(s) for users without values specified in the uploaded file.');
}
$Str .= '
';
if (($context eq 'domain') || ($context eq 'author')) {
@@ -761,15 +770,14 @@ sub print_upload_manager_footer {
$permission,$context,'upload');
$Str .= $secbox."".&mt('Full Update')."
\n".
'\n";
+ ' '.&mt('Display students with current/future access who are not in the uploaded file.').'
'.&mt('Students selected from this list can be dropped.').'
\n".'
'."\n".
- &mt('(only do if you know what you are doing.)')."
\n";
+ &mt('(only do if you know what you are doing.)')."\n";
if ($context eq 'domain') {
- $output .= '
'.&list_submit_button(&mt('Update Display')). - "\n
\n"); + "\n".''.&mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.').''."\n"); if ($env{'form.coursepick'}) { $r->print(''; + if ($actionselect) { + $output .= <<"END"; +
+END + my @allroles; + if ($env{'form.showrole'} eq 'Any') { + my $custom = 1; + if ($context eq 'domain') { + @allroles = &roles_by_context($setting,$custom); + } else { + @allroles = &roles_by_context($context,$custom); + } + } else { + @allroles = ($env{'form.showrole'}); + } + foreach my $role (@allroles) { + if ($context eq 'domain') { + if ($setting eq 'domain') { + if (&Apache::lonnet::allowed('c'.$role, + $env{'request.role.domain'})) { + $canchange{$role} = 1; + } + } elsif ($setting eq 'author') { + if (&Apache::lonnet::allowed('c'.$role, + $env{'request.role.domain'})) { + $canchange{$role} = 1; + } + } + } elsif ($context eq 'author') { + if (&Apache::lonnet::allowed('c'.$role, + $env{'user.domain'}.'/'.$env{'user.name'})) { + $canchange{$role} = 1; + } + } elsif ($context eq 'course') { + if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) { + $canchange{$role} = 1; + } elsif ($env{'request.course.sec'} ne '') { + if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { + $canchangesec{$role} = $env{'request.course.sec'}; + } + } + } + } + } + $output .= ''; } - $output .= "\n\n". + $output .= "\n".'
'.$lt{'fors'}.'
'; - } elsif ($env{'form.shorole'} eq 'Any') { + } elsif ($env{'form.showrole'} eq 'Any') { $output .= ''.$lt{'fors'}.'
'. ''.$lt{'forn'}.' '; $info = $lt{'reta'}; @@ -2590,14 +2950,12 @@ END } else { $info = ''; } - my $sections_select .= &course_sections(\%sections_count,$env{'form.showrole'}); my $rowtitle = &mt('New section to assign'); my $secbox = §ion_picker($cdom,$cnum,$env{'form.showrole'},$rowtitle,$permission,$context); $output .= $info.$secbox; } $output .= '
'.
-&mt('Use "Save" to update the main window with your selections.').'
'.
-'
'.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,users].",$count).'
'); + $r->print(''."\n"); } sub classlist_drop { - my ($scope,$uname,$udom,$now,$action) = @_; + my ($scope,$uname,$udom,$now) = @_; my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)}); - my $cid=$cdom.'_'.$cnum; - my $user = $uname.':'.$udom; - if ($action eq 'drop') { + if (&Apache::lonnet::is_course($cdom,$cnum)) { + my $user = $uname.':'.$udom; if (!&active_student_roles($cnum,$cdom,$uname,$udom)) { my $result = &Apache::lonnet::cput('classlist', - { $user => $now }, - $env{'course.'.$cid.'.domain'}, - $env{'course.'.$cid.'.num'}); + { $user => $now },$cdom,$cnum); return &mt('Drop from classlist: [_1]', ''.$result.'').'