\n".
'');
@@ -382,12 +405,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 = <<"END";
$setsections_js
-function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) {
+function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain) {
END
my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($domain);
my $auth_checks;
@@ -502,6 +526,18 @@ END
}
message+='$alert{'email'}';
}
+ if (foundrole==0) {
+ if (message!='') {
+ message+='\\n';
+ }
+ message+='$alert{'role'}';
+ }
+ if (founddomain==0) {
+ if (message!='') {
+ message+='\\n';
+ }
+ message+='$alert{'domain'}';
+ }
if (message!='') {
message+= '\\n$alert{'continue'}';
if (confirm(message)) {
@@ -531,6 +567,7 @@ function verify(vf,sec_caller) {
var foundsec=0;
var foundemail=0;
var foundrole=0;
+ var founddomain=0;
var tw;
for (i=0;i<=vf.nfields.value;i++) {
tw=eval('vf.f'+i+'.selectedIndex');
@@ -541,8 +578,9 @@ function verify(vf,sec_caller) {
if (tw==9) { foundpwd=1; }
if (tw==10) { foundemail=1; }
if (tw==11) { foundrole=1; }
+ if (tw==12) { founddomain=1; }
}
- verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole);
+ verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain);
}
//
@@ -563,6 +601,7 @@ function verify(vf,sec_caller) {
// 9 = ipwd (password)
// 10 = email address
// 11 = role
+// 12 = domain
function flip(vf,tf) {
var nw=eval('vf.f'+tf+'.selectedIndex');
@@ -626,6 +665,7 @@ function verify(vf,sec_caller) {
var foundid=0;
var foundsec=0;
var foundrole=0;
+ var founddomain=0;
var tw;
for (i=0;i<=vf.nfields.value;i++) {
tw=eval('vf.f'+i+'.selectedIndex');
@@ -635,8 +675,9 @@ function verify(vf,sec_caller) {
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; }
}
- verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundrole);
+ verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundrole,founddomain);
}
function flip(vf,tf) {
@@ -699,10 +740,10 @@ sub print_upload_manager_footer {
$Str .= &hidden_input('keyfields',$keyfields);
$Str .= "
".&mt('Login Type')."
\n";
if ($context eq 'domain') {
- $Str .= '
'.&mt('Change authentication for existing users to these settings?').'
';
+ $Str .= '
'.&mt('Change authentication for existing users in domain "[_1]" to these settings?',$defdom).'
';
} else {
$Str .= "
\n".
- &mt('Note: this will not take effect if the user already exists').
+ &mt('Note: This will not take effect if the user already exists.').
&Apache::loncommon::help_open_topic('Auth_Options').
"
';
+ $Str .= '';
$r->print($Str);
return;
}
@@ -769,15 +815,15 @@ sub print_upload_manager_footer {
sub forceid_change {
my ($context) = @_;
my $output =
- "
".&mt('ID/Student Number')."
\n".
+ "
".&mt('Student/Employee ID')."
\n".
"
\n".' '."\n".
+ &mt('Disable Student/Employee ID Safeguard and force change of conflicting IDs').
+ ' '."\n".
&mt('(only do if you know what you are doing.)')."\n";
if ($context eq 'domain') {
$output .= ' '."\n";
}
$output .= '
';
@@ -817,6 +863,7 @@ sub print_upload_manager_form {
'ipwd_choice' => 'scalar',
'email_choice' => 'scalar',
'role_choice' => 'scalar',
+ 'domain_choice' => 'scalar',
};
my $defdom = $env{'request.role.domain'};
if ($context eq 'course') {
@@ -843,11 +890,12 @@ sub print_upload_manager_form {
['mname',&mt('Middle Names/Initials'),$env{'form.mname_choice'}],
['lname',&mt('Last Name'), $env{'form.lname_choice'}],
['gen', &mt('Generation'), $env{'form.gen_choice'}],
- ['id', &mt('ID/Student Number'),$env{'form.id_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'}]);
+ ['role',&mt('Role'), $env{'form.role_choice'}],
+ ['domain',&mt('Domain'), $env{'form.domain_choice'}]);
if ($env{'form.upfile_associate'} eq 'reverse') {
&Apache::loncommon::csv_print_samples($r,\@records);
$i=&Apache::loncommon::csv_print_select_table($r,\@records,
@@ -924,8 +972,15 @@ sub setup_date_selectors {
sub get_dates_from_form {
- my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
- my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate');
+ my ($startname,$endname) = @_;
+ if ($startname eq '') {
+ $startname = 'startdate';
+ }
+ if ($endname eq '') {
+ $endname = 'enddate';
+ }
+ my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname);
+ my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname);
if ($env{'form.no_end_date'}) {
$enddate = 0;
}
@@ -958,7 +1013,7 @@ sub date_setting_table {
}
my $perpetual = '';
if ($mode eq 'create_enrolldates') {
@@ -1244,41 +1299,22 @@ sub print_userlist {
$output_selector .= "\n".$option;
}
$output_selector .= '';
- $r->print(''.(' 'x3));
- }
- $r->print(''.(' 'x3)."\n");
+ $r->print(''.(' 'x3));
+ }
+ $r->print(''.(' 'x3)."\n");
my $roleselected = '';
if ($env{'form.showrole'} eq 'Any') {
$roleselected = ' selected="selected" ';
}
- my ($role_select,$cnum,$cdom);
- if ($context eq 'domain') {
- $role_select = &domain_roles_select();
- $r->print('');
- } else {
- $role_select = '';
- $r->print('');
- if ($context eq 'course') {
- ($cnum,$cdom) = &get_course_identity();
- $r->print(§ion_group_filter($cnum,$cdom));
- }
+ my ($cnum,$cdom);
+ $r->print(&role_filter($context));
+ if ($context eq 'course') {
+ ($cnum,$cdom) = &get_course_identity();
+ $r->print(§ion_group_filter($cnum,$cdom));
}
if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
$r->print(' '.&list_submit_button(&mt('Update Display')).
@@ -1309,7 +1345,9 @@ sub print_userlist {
if ($context eq 'course') {
if (($env{'form.showrole'} eq 'st') || ($env{'form.showrole'} eq 'Any')) {
my $classlist = &Apache::loncoursedata::get_classlist();
- %userlist = %{$classlist};
+ if (ref($classlist) eq 'HASH') {
+ %userlist = %{$classlist};
+ }
}
if ($env{'form.showrole'} ne 'st') {
my $showroles;
@@ -1443,13 +1481,55 @@ sub print_userlist {
$permission,$env{'form.Status'},\%userlist,$keylist);
}
if (!$usercount) {
- $r->print(' '.&mt('There are no users matching the search criteria.'));
+ $r->print(' '
+ .&mt('There are no users matching the search criteria.')
+ .''
+ );
}
}
$r->print('');
}
+sub role_filter {
+ my ($context) = @_;
+ my $output;
+ my $roleselected = '';
+ if ($env{'form.showrole'} eq 'Any') {
+ $roleselected = ' selected="selected" ';
+ }
+ my ($role_select);
+ if ($context eq 'domain') {
+ $role_select = &domain_roles_select();
+ $output = '';
+ } else {
+ $role_select = '';
+ $output = '';
+ }
+ return $output;
+}
+
sub section_group_filter {
my ($cnum,$cdom) = @_;
my @filters;
@@ -1513,6 +1593,10 @@ sub list_submit_button {
sub gather_userinfo {
my ($context,$format,$userlist,$indexhash,$userinfo,$rolehash,$permission) = @_;
+ my $viewablesec;
+ if ($context eq 'course') {
+ $viewablesec = &viewable_section($permission);
+ }
foreach my $item (keys(%{$rolehash})) {
my %userdata;
if ($context eq 'author') {
@@ -1522,7 +1606,6 @@ sub gather_userinfo {
&build_user_record($context,\%userdata,$userinfo,$indexhash,
$item,$userlist);
} elsif ($context eq 'course') {
- my $viewablesec = &viewable_section($permission);
($userdata{'username'},$userdata{'domain'},$userdata{'role'},
$userdata{'section'}) = split(/:/,$item,-1);
($userdata{'start'},$userdata{'end'})=split(/:/,$rolehash->{$item});
@@ -1825,22 +1908,25 @@ sub aggregate_user_info {
sub process_date_info {
my ($userdata) = @_;
my $now = time;
- $userdata->{'status'} = 'Active';
+ $userdata->{'status'} = &mt('Active');
if ($userdata->{'start'} > 0) {
if ($now < $userdata->{'start'}) {
- $userdata->{'status'} = 'Future';
+ $userdata->{'status'} = &mt('Future');
}
}
if ($userdata->{'end'} > 0) {
if ($now > $userdata->{'end'}) {
- $userdata->{'status'} = 'Expired';
+ $userdata->{'status'} = &mt('Expired');
}
}
return;
}
sub show_users_list {
- my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist)=@_;
+ my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist,$formname)=@_;
+ if ($formname eq '') {
+ $formname = 'studentform';
+ }
#
# Variables for excel output
my ($excel_workbook, $excel_sheet, $excel_filename,$row,$format);
@@ -1855,6 +1941,9 @@ sub show_users_list {
} else {
push(@sortable,'extent');
}
+ if ($mode eq 'pickauthor') {
+ @sortable = ('username','fullname','email','status');
+ }
if (!grep(/^\Q$sortby\E$/,@sortable)) {
$sortby = 'username';
}
@@ -1895,121 +1984,41 @@ function photowindow(photolink) {
END
}
}
- if ($mode ne 'autoenroll') {
+ if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();
- my $alert = &mt("You must select at least one user by checking a user's 'Select' checkbox");
- my $singconfirm = &mt(' for a single user?');
- my $multconfirm = &mt(' for multiple users?');
my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode);
- my %lt = &Apache::lonlocal::texthash(
- acwi => 'Access will be set to start immediately',
- asyo => 'as you did not select an end date in the pop-up window',
- accw => 'Access will be set to continue indefinitely',
- asyd => 'as you did not select an end date in the pop-up window',
- sewi => "Sections will be switched to 'No section'",
- ayes => "as you either selected the 'No section' option",
- oryo => 'or you did not select a section in the pop-up window',
- arol => 'A role with no section will be added',
- swbs => 'Sections will be switched to:',
- rwba => 'Roles will be added for section(s):',
- );
+ my $verify_action_js = &bulkaction_javascript($formname);
$r->print(<
$check_uncheck_js
-function verify_action (field) {
- var numchecked = 0;
- var singconf = '$singconfirm';
- var multconf = '$multconfirm';
- if (field.length > 0) {
- for (i = 0; i < field.length; i++) {
- if (field[i].checked == true) {
- numchecked ++;
- }
- }
- } else {
- if (field.checked == true) {
- numchecked ++;
- }
- }
- if (numchecked == 0) {
- alert("$alert");
- }
- else {
- var message = document.studentform.bulkaction[document.studentform.bulkaction.selectedIndex].text;
- var choice = document.studentform.bulkaction[document.studentform.bulkaction.selectedIndex].value;
- if (numchecked == 1) {
- message += singconf;
- }
- else {
- message += multconf;
- }
- if (choice == 'chgdates' || choice == 'reenable' || choice == 'activate') {
- var datemsg = '';
- if ((document.studentform.startdate_month.value == '') &&
- (document.studentform.startdate_day.value == '') &&
- (document.studentform.startdate_year.value == '')) {
- datemsg = "\\n$lt{'acwi'},\\n$lt{'asyo'}.\\n";
- }
- if ((document.studentform.enddate_month.value == '') &&
- (document.studentform.enddate_day.value == '') &&
- (document.studentform.enddate_year.value == '')) {
- datemsg += "\\n$lt{'accw'},\\n$lt{'asyd'}.\\n";
- }
- if (datemsg != '') {
- message += "\\n"+datemsg;
- }
- }
- if (choice == 'chgsec') {
- var rolefilter = document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value;
- var retained = document.studentform.retainsec.value;
- var secshow = document.studentform.newsecs.value;
- if (secshow == '') {
- if (rolefilter == 'st' || retained == 0 || retained == "") {
- message += "\\n\\n$lt{'sewi'},\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n";
- } else {
- message += "\\n\\n$lt{'arol'}\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n";
- }
- } else {
- if (rolefilter == 'st' || retained == 0 || retained == "") {
- message += "\\n\\n$lt{'swbs'} "+secshow+".\\n";
- } else {
- message += "\\n\\n$lt{'rwba'} "+secshow+".\\n";
- }
- }
- }
- if (confirm(message)) {
- document.studentform.phase.value = 'bulkchange';
- document.studentform.submit();
- }
- }
-}
+$verify_action_js
function username_display_launch(username,domain) {
var target;
- for (var i=0; i "role",
'type' => "enroll type/action",
'email' => "email address",
- 'clicker' => "clicker id",
'photo' => "photo",
'extent' => "extent",
- 'go' => "go",
'pr' => "Proceed",
'ca' => "check all",
'ua' => "uncheck all",
'ac' => "Action to take for selected users",
- 'link' => "Behavior of username links",
+ 'link' => "Behavior of clickable username link for each user",
'aboutme' => "Display a user's personal page",
'owin' => "Open in a new window",
'modify' => "Modify a user's information",
+ 'clicker' => "Clicker-ID",
);
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
$lt{'extent'} = &mt('Course(s): description, section(s), status');
} elsif ($context eq 'author') {
$lt{'extent'} = &mt('Author');
}
- my @cols = ('username','domain','id','fullname');
- if ($context eq 'course') {
- push(@cols,'section');
- }
- if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {
- push(@cols,('start','end'));
- }
- if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
- push(@cols,'role');
- }
- if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||
- $env{'form.roletype'} eq 'course')) {
- push (@cols,'extent');
- }
- if (($statusmode eq 'Any') &&
- (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {
- push(@cols,'status');
- }
- if ($context eq 'course') {
- push(@cols,'groups');
+ my @cols;
+ if ($mode eq 'pickauthor') {
+ @cols = ('username','fullname','status','email');
+ } else {
+ @cols = ('username','domain','id','fullname');
+ if ($context eq 'course') {
+ push(@cols,'section');
+ }
+ if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {
+ push(@cols,('start','end'));
+ }
+ if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
+ push(@cols,'role');
+ }
+ if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||
+ $env{'form.roletype'} eq 'course')) {
+ push (@cols,'extent');
+ }
+ if (($statusmode eq 'Any') &&
+ (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {
+ push(@cols,'status');
+ }
+ if ($context eq 'course') {
+ push(@cols,'groups');
+ }
+ push(@cols,'email');
}
- push(@cols,'email');
my $rolefilter = $env{'form.showrole'};
if ($env{'form.showrole'} eq 'cr') {
@@ -2093,13 +2106,13 @@ END
if ($mode ne 'autoenroll') {
$results_description = &results_header_row($rolefilter,$statusmode,
$context,$permission,$mode);
- $r->print(''.$results_description.' ');
+ $r->print(''.$results_description.'
');
}
my ($output,$actionselect,%canchange,%canchangesec);
- if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll') {
- if ($mode ne 'autoenroll') {
+ if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
+ if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
if ($permission->{'cusr'}) {
- $actionselect = &select_actions($context,$setting,$statusmode);
+ $actionselect = &select_actions($context,$setting,$statusmode,$formname);
}
$r->print(<
@@ -2108,33 +2121,12 @@ END
END
- $output = '
';
- my @linkdests = ('aboutme');
- if ($permission->{'cusr'}) {
- unshift (@linkdests,'modify');
- }
- $output .= ''.$lt{'link'}.': ';
- my $usernamelink = $env{'form.usernamelink'};
- if ($usernamelink eq '') {
- $usernamelink = 'aboutme';
- }
- foreach my $item (@linkdests) {
- my $checkedstr = '';
- if ($item eq $usernamelink) {
- $checkedstr = ' checked="checked" ';
- }
- $output .= ' ';
- }
- my $checkwin;
- if ($env{'form.userwin'}) {
- $checkwin = 'checked = "checked"';
- }
- $output .= ' '.$lt{'owin'}.' ';
if ($actionselect) {
$output .= <<"END";
-$lt{'ac'}: $actionselect
-
-
+
END
my @allroles;
if ($env{'form.showrole'} eq 'Any') {
@@ -2176,40 +2168,68 @@ END
}
}
}
+ $output .= '';
}
- $output .= "\n
';
$str .= &Apache::loncommon::help_open_topic("Course_Create_Class_List",
&mt("How do I create a users list from a spreadsheet")).
" \n";
$str .= &Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
- &mt("How do I create a CSV file from a spreadsheet")).
- " \n";
+ &mt("How do I create a CSV file from a spreadsheet"));
+ $str .= "
\n";
+ $str .= "
\n";
+ $str .= '
\n";
+ $str .= ''." \n";
$str .= &Apache::loncommon::end_page();
$r->print($str);
return;
@@ -3272,7 +3415,7 @@ sub upfile_drop_add {
#
# Store the field choices away
foreach my $field (qw/username names
- fname mname lname gen id sec ipwd email role/) {
+ fname mname lname gen id sec ipwd email role domain/) {
$env{'form.'.$field.'_choice'}=$fields{$field};
}
&Apache::loncommon::store_course_settings('enrollment_upload',
@@ -3286,19 +3429,26 @@ sub upfile_drop_add {
'sec_choice' => 'scalar',
'ipwd_choice' => 'scalar',
'email_choice' => 'scalar',
- 'role_choice' => 'scalar' });
+ 'role_choice' => 'scalar',
+ 'domain_choice' => 'scalar'});
#
my ($startdate,$enddate) = &get_dates_from_form();
if ($env{'form.makedatesdefault'}) {
$r->print(&make_dates_default($startdate,$enddate,$context));
}
# Determine domain and desired host (home server)
- my $domain=$env{'request.role.domain'};
+ my $defdom=$env{'request.role.domain'};
+ my $domain;
+ if ($env{'form.defaultdomain'} ne '') {
+ $domain = $env{'form.defaultdomain'};
+ } else {
+ $domain = $defdom;
+ }
my $desiredhost = $env{'form.lcserver'};
if (lc($desiredhost) eq 'default') {
$desiredhost = undef;
} else {
- my %home_servers = &Apache::lonnet::get_servers($domain,'library');
+ my %home_servers = &Apache::lonnet::get_servers($defdom,'library');
if (! exists($home_servers{$desiredhost})) {
$r->print(''.&mt('Error').
&mt('Invalid home server specified').'');
@@ -3383,7 +3533,9 @@ sub upfile_drop_add {
if ($context eq 'course') {
my ($cnum,$cdom) = &get_course_identity();
my $roster = &Apache::loncoursedata::get_classlist();
- %userlist = %{$roster};
+ if (ref($roster) eq 'HASH') {
+ %userlist = %{$roster};
+ }
my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
\@statuses,\@poss_roles);
&gather_userinfo($context,'view',\%userlist,$indexhash,\%info,
@@ -3485,11 +3637,20 @@ sub upfile_drop_add {
ne &LONCAPA::clean_username($entries{$fields{'username'}})) {
$r->print(' '.
&mt('[_1]: Unacceptable username for user [_2] [_3] [_4] [_5]',
- $entries{$fields{'username'}},$fname,$mname,$lname,$gen).
- '');
+ $entries{$fields{'username'}},$fname,$mname,$lname,$gen));
next;
} else {
+ if ($entries{$fields{'domain'}}
+ ne &LONCAPA::clean_domain($entries{$fields{'domain'}})) {
+ $r->print(' '. ''.$entries{$fields{'domain'}}.
+ ': '.&mt('Unacceptable domain for user [_2] [_3] [_4] [_5]',$fname,$mname,$lname,$gen));
+ next;
+ }
my $username = $entries{$fields{'username'}};
+ my $userdomain = $entries{$fields{'domain'}};
+ if ($userdomain eq '') {
+ $userdomain = $domain;
+ }
if (defined($fields{'sec'})) {
if (defined($entries{$fields{'sec'}})) {
$entries{$fields{'sec'}} =~ s/\W//g;
@@ -3507,8 +3668,8 @@ sub upfile_drop_add {
}
if ($env{'request.course.sec'} ne '') {
@secs = ($env{'request.course.sec'});
- if (ref($userlist{$username.':'.$domain}) eq 'ARRAY') {
- my $currsec = $userlist{$username.':'.$domain}[$secidx];
+ if (ref($userlist{$username.':'.$userdomain}) eq 'ARRAY') {
+ my $currsec = $userlist{$username.':'.$userdomain}[$secidx];
if ($currsec ne $env{'request.course.sec'}) {
$r->print(' '.&mt('[_1]: Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]".',$username,$fname,$mname,$lname,$gen,$secs[0]).' ');
if ($currsec eq '') {
@@ -3570,16 +3731,16 @@ sub upfile_drop_add {
$role = $defaultrole;
}
# Clean up whitespace
- foreach (\$domain,\$username,\$id,\$fname,\$mname,
- \$lname,\$gen) {
+ foreach (\$id,\$fname,\$mname,\$lname,\$gen) {
$$_ =~ s/(\s+$|^\s+)//g;
}
# check against rules
my $checkid = 0;
my $newuser = 0;
my (%rulematch,%inst_results,%idinst_results);
- my $uhome=&Apache::lonnet::homeserver($username,$domain);
+ my $uhome=&Apache::lonnet::homeserver($username,$userdomain);
if ($uhome eq 'no_host') {
+ next if ($userdomain ne $domain);
$checkid = 1;
$newuser = 1;
my $checkhash;
@@ -3595,38 +3756,40 @@ sub upfile_drop_add {
}
} else {
if ($context eq 'course' || $context eq 'author') {
- if ($role eq '') {
- my @checkroles;
- foreach my $role (@poss_roles) {
- my $endkey;
- if ($role ne 'st') {
- $endkey = ':'.$role;
- }
- if (exists($userlist{$username.':'.$domain.$endkey})) {
- if (!grep(/^\Q$role\E$/,@checkroles)) {
- push(@checkroles,$role);
+ if ($userdomain eq $domain ) {
+ if ($role eq '') {
+ my @checkroles;
+ foreach my $role (@poss_roles) {
+ my $endkey;
+ if ($role ne 'st') {
+ $endkey = ':'.$role;
+ }
+ if (exists($userlist{$username.':'.$userdomain.$endkey})) {
+ if (!grep(/^\Q$role\E$/,@checkroles)) {
+ push(@checkroles,$role);
+ }
}
}
+ if (@checkroles > 0) {
+ %canmodify = &can_modify_userinfo($context,$domain,\@userinfo,\@checkroles);
+ }
+ } elsif (ref($modifiable_fields{$role}) eq 'HASH') {
+ %canmodify = %{$modifiable_fields{$role}};
}
- if (@checkroles > 0) {
- %canmodify = &can_modify_userinfo($context,$domain,\@userinfo,\@checkroles);
- }
- } elsif (ref($modifiable_fields{$role}) eq 'HASH') {
- %canmodify = %{$modifiable_fields{$role}};
}
- }
- my @newinfo = (\$fname,\$mname,\$lname,\$gen,\$email,\$id);
- for (my $i=0; $i<@userinfo; $i++) {
- if (${$newinfo[$i]} ne '') {
- if (!$canmodify{$userinfo[$i]}) {
- ${$newinfo[$i]} = '';
+ my @newinfo = (\$fname,\$mname,\$lname,\$gen,\$email,\$id);
+ for (my $i=0; $i<@userinfo; $i++) {
+ if (${$newinfo[$i]} ne '') {
+ if (!$canmodify{$userinfo[$i]}) {
+ ${$newinfo[$i]} = '';
+ }
}
}
}
}
if ($id ne '') {
if (!$newuser) {
- my %idhash = &Apache::lonnet::idrget($domain,($username));
+ my %idhash = &Apache::lonnet::idrget($userdomain,($username));
if ($idhash{$username} ne $id) {
$checkid = 1;
}
@@ -3634,14 +3797,14 @@ sub upfile_drop_add {
if ($checkid) {
my $checkhash;
my $checks = { 'id' => 1 };
- $checkhash->{$username.':'.$domain} = { 'newuser' => $newuser,
+ $checkhash->{$username.':'.$userdomain} = { 'newuser' => $newuser,
'id' => $id };
&Apache::loncommon::user_rule_check($checkhash,$checks,
\%alerts,\%rulematch,\%idinst_results,\%curr_rules,
\%got_rules);
if (ref($alerts{'id'}) eq 'HASH') {
- if (ref($alerts{'id'}{$domain}) eq 'HASH') {
- next if ($alerts{'id'}{$domain}{$id});
+ if (ref($alerts{'id'}{$userdomain}) eq 'HASH') {
+ next if ($alerts{'id'}{$userdomain}{$id});
}
}
}
@@ -3656,14 +3819,15 @@ sub upfile_drop_add {
if (@secs > 0) {
$sec = $secs[0];
}
- &modifystudent($domain,$username,$cid,$sec,
- $desiredhost);
+ &modifystudent($userdomain,$username,$cid,$sec,
+ $desiredhost,$context);
$roleresult =
&Apache::lonnet::modifystudent
- ($domain,$username,$id,$amode,$password,
+ ($userdomain,$username,$id,$amode,$password,
$fname,$mname,$lname,$gen,$sec,$enddate,
$startdate,$env{'form.forceid'},
- $desiredhost,$email,'manual','',$cid);
+ $desiredhost,$email,'manual','',$cid,
+ '',$context);
$userresult = $roleresult;
} else {
if ($role ne '') {
@@ -3678,7 +3842,7 @@ sub upfile_drop_add {
foreach my $sec (@secs) {
($userres{$sec},$authres{$sec},$roleres{$sec},$idres{$sec}) =
&modifyuserrole($context,$setting,
- $changeauth,$cid,$domain,$username,
+ $changeauth,$cid,$userdomain,$username,
$id,$amode,$password,$fname,
$mname,$lname,$gen,$sec,
$env{'form.forceid'},$desiredhost,
@@ -3694,7 +3858,7 @@ sub upfile_drop_add {
if (!$multiple) {
($userresult,$authresult,$roleresult,$idresult) =
&modifyuserrole($context,$setting,
- $changeauth,$cid,$domain,$username,
+ $changeauth,$cid,$userdomain,$username,
$id,$amode,$password,$fname,
$mname,$lname,$gen,$singlesec,
$env{'form.forceid'},$desiredhost,
@@ -3706,14 +3870,14 @@ sub upfile_drop_add {
$flushc =
&user_change_result($r,$userres{$sec},$authres{$sec},
$roleres{$sec},$idres{$sec},\%counts,$flushc,
- $username,\%userchg);
+ $username,$userdomain,\%userchg);
}
} else {
$flushc =
&user_change_result($r,$userresult,$authresult,
$roleresult,$idresult,\%counts,$flushc,
- $username,\%userchg);
+ $username,$userdomain,\%userchg);
}
} else {
if ($context eq 'course') {
@@ -3761,7 +3925,7 @@ sub upfile_drop_add {
''.
&mt('There are no students with current/future access to the course.').
''."\n");
- } else {
+ } elsif (ref($classlist) eq 'HASH') {
# Remove the students we just added from the list of students.
foreach my $line (@userdata) {
my %entries=&Apache::loncommon::record_sep($line);
@@ -3823,13 +3987,13 @@ sub print_namespacing_alerts {
sub user_change_result {
my ($r,$userresult,$authresult,$roleresult,$idresult,$counts,$flushc,
- $username,$userchg) = @_;
+ $username,$userdomain,$userchg) = @_;
my $okresult = 0;
if ($userresult ne 'ok') {
if ($userresult =~ /^error:(.+)$/) {
my $error = $1;
$r->print(' '.
- &mt('[_1]: Unable to add/modify: [_2]',$username,$error));
+ &mt('[_1]: Unable to add/modify: [_2]',$username.':'.$userdomain,$error));
}
} else {
$counts->{'user'} ++;
@@ -3839,7 +4003,7 @@ sub user_change_result {
if ($authresult =~ /^error:(.+)$/) {
my $error = $1;
$r->print(' '.
- &mt('[_1]: Unable to modify authentication: [_2]',$username,$error));
+ &mt('[_1]: Unable to modify authentication: [_2]',$username.':'.$userdomain,$error));
}
} else {
$counts->{'auth'} ++;
@@ -3849,7 +4013,7 @@ sub user_change_result {
if ($roleresult =~ /^error:(.+)$/) {
my $error = $1;
$r->print(' '.
- &mt('[_1]: Unable to add role: [_2]',$username,$error));
+ &mt('[_1]: Unable to add role: [_2]',$username.':'.$userdomain,$error));
}
} else {
$counts->{'role'} ++;
@@ -3857,7 +4021,7 @@ sub user_change_result {
}
if ($okresult) {
$flushc++;
- $userchg->{$username}=1;
+ $userchg->{$username.':'.$userdomain}=1;
$r->print('. ');
if ($flushc>15) {
$r->rflush;
@@ -3969,24 +4133,25 @@ sub update_user_list {
$end = $now;
$type = 'manual';
$result =
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} elsif ($choice eq 'revoke') {
# revoke or delete user role
$end = $now;
if ($role eq 'st') {
$result =
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
$result =
- &Apache::lonnet::revokerole($udom,$uname,$scope,$role);
+ &Apache::lonnet::revokerole($udom,$uname,$scope,$role,
+ '','',$context);
}
} elsif ($choice eq 'delete') {
if ($role eq 'st') {
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$now,$start,$type,$locktype,$cid);
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$now,$start,$type,$locktype,$cid,'',$context);
}
$result =
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now,
- $start,1);
+ $start,1,'',$context);
} else {
#reenable, activate, change access dates or change section
if ($choice ne 'chgsec') {
@@ -3995,25 +4160,25 @@ sub update_user_list {
}
if ($choice eq 'reenable') {
if ($role eq 'st') {
- $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
$result =
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end,
- $now);
+ $now,'','',$context);
}
} elsif ($choice eq 'activate') {
if ($role eq 'st') {
- $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
$result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end,
- $now);
+ $now,'','',$context);
}
} elsif ($choice eq 'chgdates') {
if ($role eq 'st') {
- $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+ $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
$result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end,
- $start);
+ $start,'','',$context);
}
} elsif ($choice eq 'chgsec') {
my (@newsecs,$revresult,$nochg,@retained);
@@ -4029,7 +4194,8 @@ sub update_user_list {
} else {
$revresult =
&Apache::lonnet::revokerole($udom,$uname,
- $scope,$role);
+ $scope,$role,
+ '','',$context);
}
} else {
if (@newsecs > 0) {
@@ -4038,12 +4204,14 @@ sub update_user_list {
} else {
$revresult =
&Apache::lonnet::revokerole($udom,$uname,
- $scope,$role);
+ $scope,$role,
+ '','',$context);
}
} else {
$revresult =
&Apache::lonnet::revokerole($udom,$uname,
- $scope,$role);
+ $scope,$role,
+ '','',$context);
}
}
} else {
@@ -4058,17 +4226,17 @@ sub update_user_list {
if (!$nochg) {
if ($role eq 'st') {
$result =
- &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid);
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid,'',$context);
} else {
my $newscope = $scopestem;
- $result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start);
+ $result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start,'','',$context);
}
}
} else {
foreach my $newsec (@newsecs) {
if (!grep(/^\Q$newsec\E$/,@retained)) {
if ($role eq 'st') {
- $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid);
+ $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid,'',$context);
} else {
my $newscope = $scopestem;
if ($newsec ne '') {
@@ -4136,11 +4304,9 @@ sub classlist_drop {
my ($scope,$uname,$udom,$now) = @_;
my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)});
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 },$cdom,$cnum);
+ my %user;
+ my $result = &update_classlist($cdom,$cnum,$udom,$uname,\%user,$now);
return &mt('Drop from classlist: [_1]',
''.$result.'').' ';
}
@@ -4207,17 +4373,29 @@ sub set_login {
}
sub course_sections {
- my ($sections_count,$role) = @_;
+ my ($sections_count,$role,$current_sec) = @_;
my $output = '';
my @sections = (sort {$a <=> $b} keys %{$sections_count});
my $numsec = scalar(@sections);
+ my $is_selected = ' selected="selected" ';
if ($numsec <= 1) {
$output = '