version 1.171, 2015/08/05 18:47:21
|
version 1.174, 2016/07/24 14:34:59
|
Line 36 use Apache::loncommon();
|
Line 36 use Apache::loncommon();
|
use Apache::lonhtmlcommon; |
use Apache::lonhtmlcommon; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::longroup; |
use Apache::longroup; |
|
use HTML::Entities; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
|
############################################################### |
############################################################### |
Line 2413 sub make_keylist_array {
|
Line 2414 sub make_keylist_array {
|
$index->{'photo'} = &Apache::loncoursedata::CL_PHOTO(); |
$index->{'photo'} = &Apache::loncoursedata::CL_PHOTO(); |
$index->{'thumbnail'} = &Apache::loncoursedata::CL_THUMBNAIL(); |
$index->{'thumbnail'} = &Apache::loncoursedata::CL_THUMBNAIL(); |
$index->{'credits'} = &Apache::loncoursedata::CL_CREDITS(); |
$index->{'credits'} = &Apache::loncoursedata::CL_CREDITS(); |
|
$index->{'instsec'} = &Apache::loncoursedata::CL_INSTSEC(); |
$index->{'authorquota'} = &Apache::loncoursedata::CL_AUTHORQUOTA(); |
$index->{'authorquota'} = &Apache::loncoursedata::CL_AUTHORQUOTA(); |
$index->{'authorusage'} = &Apache::loncoursedata::CL_AUTHORUSAGE(); |
$index->{'authorusage'} = &Apache::loncoursedata::CL_AUTHORUSAGE(); |
foreach my $key (keys(%{$index})) { |
foreach my $key (keys(%{$index})) { |
Line 3056 END
|
Line 3058 END
|
if ($role eq 'st') { |
if ($role eq 'st') { |
$checkval .= ':'.$in{'type'}.':'. |
$checkval .= ':'.$in{'type'}.':'. |
$in{'lockedtype'}.':'. |
$in{'lockedtype'}.':'. |
$in{'credits'}; |
$in{'credits'}.':'. |
|
&escape($in{'instsec'}); |
} |
} |
} |
} |
} |
} |
if ($showcheckbox) { |
if ($showcheckbox) { |
$r->print('<td><input type="checkbox" name="'. |
$r->print('<td><input type="checkbox" name="'. |
'actionlist" value="'.$checkval.'" /></td>'); |
'actionlist" value="'.&HTML::Entities::encode($checkval,'&<>"').'" /></td>'); |
} else { |
} else { |
$r->print('<td> </td>'); |
$r->print('<td> </td>'); |
} |
} |
Line 3077 END
|
Line 3080 END
|
if ($item eq 'username') { |
if ($item eq 'username') { |
$r->print('<td>'.&print_username_link($mode,\%in).'</td>'); |
$r->print('<td>'.&print_username_link($mode,\%in).'</td>'); |
} elsif (($item eq 'start' || $item eq 'end') && ($actionselect)) { |
} elsif (($item eq 'start' || $item eq 'end') && ($actionselect)) { |
$r->print('<td>'.$in{$item}.'<input type="hidden" name="'.$checkval.'_'.$item.'" value="'.$sdata->[$index{$item}].'" /></td>'."\n"); |
$r->print('<td>'.$in{$item}.'<input type="hidden" name="'.&HTML::Entities::encode($checkval.'_'.$item.'" value="'.$sdata->[$index{$item}],'&<>"').'" /></td>'."\n"); |
} elsif ($item eq 'status') { |
} elsif ($item eq 'status') { |
my $showitem = $in{$item}; |
my $showitem = $in{$item}; |
if (defined($ltstatus{$in{$item}})) { |
if (defined($ltstatus{$in{$item}})) { |
Line 4297 sub upfile_drop_add {
|
Line 4300 sub upfile_drop_add {
|
my $newuserdom = $env{'request.role.domain'}; |
my $newuserdom = $env{'request.role.domain'}; |
map { $cancreate{$_} = &can_create_user($newuserdom,$context,$_); } keys(%longtypes); |
map { $cancreate{$_} = &can_create_user($newuserdom,$context,$_); } keys(%longtypes); |
# Get new users list |
# Get new users list |
my (%existinguser,%userinfo,%disallow,%rulematch,%inst_results,%idinst_results,%alerts,%checkuname); |
my (%existinguser,%userinfo,%disallow,%rulematch,%inst_results,%alerts,%checkuname); |
my $counter = -1; |
my $counter = -1; |
foreach my $line (@userdata) { |
foreach my $line (@userdata) { |
$counter ++; |
$counter ++; |
Line 4507 sub upfile_drop_add {
|
Line 4510 sub upfile_drop_add {
|
} |
} |
$checkid = 1; |
$checkid = 1; |
$newuser = 1; |
$newuser = 1; |
$checkuname{$username.':'.$newuserdom} = { 'newuser' => 1, 'id' => 1 }; |
$checkuname{$username.':'.$newuserdom} = { 'newuser' => $newuser, 'id' => $id }; |
} else { |
} else { |
if ($context eq 'course' || $context eq 'author') { |
if ($context eq 'course' || $context eq 'author') { |
if ($userdomain eq $domain ) { |
if ($userdomain eq $domain ) { |
Line 4566 sub upfile_drop_add {
|
Line 4569 sub upfile_drop_add {
|
} # end of foreach (@userdata) |
} # end of foreach (@userdata) |
if ($counter > -1) { |
if ($counter > -1) { |
my $total = $counter + 1; |
my $total = $counter + 1; |
my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,$total); |
|
my %checkids; |
my %checkids; |
if (keys(%existinguser)) { |
if ((keys(%existinguser)) || (keys(%checkuname))) { |
foreach my $dom (keys(%existinguser)) { |
$r->print(&mt('Please be patient -- checking for institutional data ...')); |
if (ref($existinguser{$dom}) eq 'HASH') { |
$r->rflush(); |
my %idhash = &Apache::lonnet::idrget($dom,keys(%{$existinguser{$dom}})); |
if (keys(%existinguser)) { |
foreach my $username (keys(%{$existinguser{$dom}})) { |
foreach my $dom (keys(%existinguser)) { |
if ($idhash{$username} ne $existinguser{$dom}{$username}) { |
if (ref($existinguser{$dom}) eq 'HASH') { |
$checkids{$username.':'.$dom} = { 'id' => $existinguser{$dom}{$username} }; |
my %idhash = &Apache::lonnet::idrget($dom,keys(%{$existinguser{$dom}})); |
|
foreach my $username (keys(%{$existinguser{$dom}})) { |
|
if ($idhash{$username} ne $existinguser{$dom}{$username}) { |
|
$checkids{$username.':'.$dom} = { |
|
'id' => $existinguser{$dom}{$username}, |
|
}; |
|
} |
|
} |
|
if (keys(%checkids)) { |
|
&Apache::loncommon::user_rule_check(\%checkids,{ 'id' => 1 }, |
|
\%alerts,\%rulematch, |
|
\%inst_results,\%curr_rules, |
|
\%got_rules); |
} |
} |
} |
|
if (keys(%checkids)) { |
|
&Apache::loncommon::user_rule_check(\%checkids,{ 'id' => 1 }, |
|
\%alerts,\%rulematch, |
|
\%idinst_results,\%curr_rules, |
|
\%got_rules); |
|
} |
} |
} |
} |
} |
} |
|
if (keys(%checkuname)) { |
|
&Apache::loncommon::user_rule_check(\%checkuname,{ 'username' => 1, 'id' => 1, }, |
|
\%alerts,\%rulematch,\%inst_results, |
|
\%curr_rules,\%got_rules); |
|
} |
|
$r->print(' '.&mt('done').'<br /><br />'); |
|
$r->rflush(); |
} |
} |
if (keys(%checkuname)) { |
my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,$total); |
&Apache::loncommon::user_rule_check(\%checkuname,{ 'username' => 1 }, |
|
\%alerts,\%rulematch,\%inst_results, |
|
\%curr_rules,\%got_rules); |
|
} |
|
$r->print('<ul>'); |
$r->print('<ul>'); |
for (my $i=0; $i<=$counter; $i++) { |
for (my $i=0; $i<=$counter; $i++) { |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state); |
|
if ($disallow{$i}) { |
if ($disallow{$i}) { |
$r->print('<li>'.$disallow{$i}.'</li>'); |
$r->print('<li>'.$disallow{$i}.'</li>'); |
} elsif (ref($userinfo{$i}) eq 'HASH') { |
} elsif (ref($userinfo{$i}) eq 'HASH') { |
Line 4627 sub upfile_drop_add {
|
Line 4637 sub upfile_drop_add {
|
} |
} |
} |
} |
} |
} |
|
if (ref($inst_results{$user}) eq 'HASH') { |
|
if ($inst_results{$user}{'firstname'} ne '') { |
|
$fname = $inst_results{$user}{'firstname'}; |
|
} |
|
if ($inst_results{$user}{'middlename'} ne '') { |
|
$mname = $inst_results{$user}{'middlename'}; |
|
} |
|
if ($inst_results{$user}{'lasttname'} ne '') { |
|
$lname = $inst_results{$user}{'lastname'}; |
|
} |
|
if ($inst_results{$user}{'permanentemail'} ne '') { |
|
$email = $inst_results{$user}{'permanentemail'}; |
|
} |
|
if ($inst_results{$user}{'id'} ne '') { |
|
$id = $inst_results{$user}{'id'}; |
|
$checkid = 0; |
|
} |
|
if (ref($inst_results{$user}{'inststatus'}) eq 'ARRAY') { |
|
$inststatus = join(':',@{$inst_results{$user}{'inststatus'}}); |
|
} |
|
} |
|
if (($checkid) && ($id ne '')) { |
|
if (ref($alerts{'id'}) eq 'HASH') { |
|
if (ref($alerts{'id'}{$userdomain}) eq 'HASH') { |
|
if ($alerts{'id'}{$userdomain}{$username}) { |
|
$r->print('<li>'. |
|
&mt('[_1]: has a student/employee ID matching the format at your institution, but the ID is not found by your directory service.', |
|
'<b>'.$username.'</b>').'<br />'. |
|
&mt('Consequently, the user was not created.').'</li>'); |
|
next; |
|
} |
|
} |
|
} |
|
} |
my $usertype = 'unofficial'; |
my $usertype = 'unofficial'; |
if (ref($rulematch{$user}) eq 'HASH') { |
if (ref($rulematch{$user}) eq 'HASH') { |
if ($rulematch{$user}{'username'}) { |
if ($rulematch{$user}{'username'}) { |
Line 4639 sub upfile_drop_add {
|
Line 4683 sub upfile_drop_add {
|
&mt('[_1]: The user does not exist, and you are not permitted to create users of type: [_2].','<b>'.$username.'</b>',$showtype).'</li>'); |
&mt('[_1]: The user does not exist, and you are not permitted to create users of type: [_2].','<b>'.$username.'</b>',$showtype).'</li>'); |
next; |
next; |
} |
} |
} |
} elsif ($id ne '') { |
if ($id ne '') { |
|
if (exists($checkids{$user})) { |
if (exists($checkids{$user})) { |
$checkid = 1; |
$checkid = 1; |
if (ref($alerts{'id'}) eq 'HASH') { |
if (ref($alerts{'id'}) eq 'HASH') { |
if (ref($alerts{'id'}{$userdomain}) eq 'HASH') { |
if (ref($alerts{'id'}{$userdomain}) eq 'HASH') { |
if ($alerts{'id'}{$userdomain}{$id}) { |
if ($alerts{'id'}{$userdomain}{$username}) { |
$r->print('<li>'. |
$r->print('<li>'. |
&mt('[_1]: has a student/employee ID matching the format at your institution, but the ID is found by your directory service.', |
&mt('[_1]: has a student/employee ID matching the format at your institution, but the ID is not found by your directory service.', |
'<b>'.$username.'</b>').'<br />'. |
'<b>'.$username.'</b>').'<br />'. |
&mt('Consequently, the user was not created.').'</li>'); |
&mt('Consequently, the ID was not changed.').'</li>'); |
next; |
$id = ''; |
} |
} |
} |
} |
} |
} |
Line 4729 sub upfile_drop_add {
|
Line 4772 sub upfile_drop_add {
|
$username,$userdomain,\%userchg); |
$username,$userdomain,\%userchg); |
} |
} |
} |
} |
$r->print('</ul>'); |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last user'); |
} # end of loop |
} # end of loop |
|
$r->print('</ul>'); |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
} |
} |
# Flush the course logs so reverse user roles immediately updated |
# Flush the course logs so reverse user roles immediately updated |
Line 4939 sub update_user_list {
|
Line 4983 sub update_user_list {
|
foreach my $item (@changelist) { |
foreach my $item (@changelist) { |
my ($role,$uname,$udom,$cid,$sec,$scope,$result,$type,$locktype, |
my ($role,$uname,$udom,$cid,$sec,$scope,$result,$type,$locktype, |
@sections,$scopestem,$singlesec,$showsecs,$warn_singlesec, |
@sections,$scopestem,$singlesec,$showsecs,$warn_singlesec, |
$nothingtodo,$keepnosection,$credits); |
$nothingtodo,$keepnosection,$credits,$instsec); |
if ($choice eq 'drop') { |
if ($choice eq 'drop') { |
($uname,$udom,$sec) = split(/:/,$item,-1); |
($uname,$udom,$sec) = split(/:/,$item,-1); |
$role = 'st'; |
$role = 'st'; |
Line 4952 sub update_user_list {
|
Line 4996 sub update_user_list {
|
$scope = $scopestem.'/'.$sec; |
$scope = $scopestem.'/'.$sec; |
} |
} |
} elsif ($context eq 'course') { |
} elsif ($context eq 'course') { |
($uname,$udom,$role,$sec,$type,$locktype,$credits) = |
($uname,$udom,$role,$sec,$type,$locktype,$credits,$instsec) = |
split(/\:/,$item); |
split(/\:/,$item,8); |
|
$instsec = &unescape($instsec); |
$cid = $env{'request.course.id'}; |
$cid = $env{'request.course.id'}; |
$scopestem = '/'.$cid; |
$scopestem = '/'.$cid; |
$scopestem =~s/\_/\//g; |
$scopestem =~s/\_/\//g; |
Line 4972 sub update_user_list {
|
Line 5017 sub update_user_list {
|
} elsif ($setting eq 'author') { |
} elsif ($setting eq 'author') { |
($uname,$udom,$role,$scope) = split(/\:/,$item); |
($uname,$udom,$role,$scope) = split(/\:/,$item); |
} elsif ($setting eq 'course') { |
} elsif ($setting eq 'course') { |
($uname,$udom,$role,$cid,$sec,$type,$locktype,$credits) = |
($uname,$udom,$role,$cid,$sec,$type,$locktype,$credits,$instsec) = |
split(/\:/,$item); |
split(/\:/,$item,9); |
|
$instsec = &unescape($instsec); |
$scope = '/'.$cid; |
$scope = '/'.$cid; |
$scope =~s/\_/\//g; |
$scope =~s/\_/\//g; |
if ($sec ne '') { |
if ($sec ne '') { |
Line 4995 sub update_user_list {
|
Line 5041 sub update_user_list {
|
$end = $now; |
$end = $now; |
if ($role eq 'st') { |
if ($role eq 'st') { |
$result = |
$result = |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits); |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits,$instsec); |
} else { |
} else { |
$result = |
$result = |
&Apache::lonnet::revokerole($udom,$uname,$scope,$role, |
&Apache::lonnet::revokerole($udom,$uname,$scope,$role, |
Line 5003 sub update_user_list {
|
Line 5049 sub update_user_list {
|
} |
} |
} elsif ($choice eq 'delete') { |
} elsif ($choice eq 'delete') { |
if ($role eq 'st') { |
if ($role eq 'st') { |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$now,$start,$type,$locktype,$cid,'',$context,$credits); |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$now,$start,$type,$locktype,$cid,'',$context,$credits,$instsec); |
} |
} |
$result = |
$result = |
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now, |
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now, |
Line 5016 sub update_user_list {
|
Line 5062 sub update_user_list {
|
} |
} |
if ($choice eq 'reenable') { |
if ($choice eq 'reenable') { |
if ($role eq 'st') { |
if ($role eq 'st') { |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits); |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits,$instsec); |
} else { |
} else { |
$result = |
$result = |
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end, |
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end, |
Line 5024 sub update_user_list {
|
Line 5070 sub update_user_list {
|
} |
} |
} elsif ($choice eq 'activate') { |
} elsif ($choice eq 'activate') { |
if ($role eq 'st') { |
if ($role eq 'st') { |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits); |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits,$instsec); |
} else { |
} else { |
$result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end, |
$result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end, |
$now,'','',$context); |
$now,'','',$context); |
} |
} |
} elsif ($choice eq 'chgdates') { |
} elsif ($choice eq 'chgdates') { |
if ($role eq 'st') { |
if ($role eq 'st') { |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits); |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits,$instsec); |
} else { |
} else { |
$result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end, |
$result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end, |
$start,'','',$context); |
$start,'','',$context); |
Line 5101 sub update_user_list {
|
Line 5147 sub update_user_list {
|
} else { |
} else { |
if ($role eq 'st') { |
if ($role eq 'st') { |
$result = |
$result = |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid,'',$context,$credits); |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid,'',$context,$credits,$instsec); |
} else { |
} else { |
my $newscope = $scopestem; |
my $newscope = $scopestem; |
$result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start,'','',$context); |
$result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start,'','',$context); |
Line 5115 sub update_user_list {
|
Line 5161 sub update_user_list {
|
foreach my $newsec (@newsecs) { |
foreach my $newsec (@newsecs) { |
if (!grep(/^\Q$newsec\E$/,@retained)) { |
if (!grep(/^\Q$newsec\E$/,@retained)) { |
if ($role eq 'st') { |
if ($role eq 'st') { |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid,'',$context,$credits); |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid,'',$context,$credits,$instsec); |
if (@newsecs > 1) { |
if (@newsecs > 1) { |
my $showsingle; |
my $showsingle; |
if ($newsec eq '') { |
if ($newsec eq '') { |
Line 6201 sub get_extended_type {
|
Line 6247 sub get_extended_type {
|
} |
} |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$type = 'community'; |
$type = 'community'; |
|
} elsif ($crstype eq 'Placement') { |
|
$type = 'placement'; |
} elsif ($settings{'internal.coursecode'}) { |
} elsif ($settings{'internal.coursecode'}) { |
$type = 'official'; |
$type = 'official'; |
} elsif ($settings{'internal.textbook'}) { |
} elsif ($settings{'internal.textbook'}) { |