version 1.219, 2007/12/21 17:27:57
|
version 1.220, 2007/12/21 18:16:39
|
Line 1509 sub update_user_data {
|
Line 1509 sub update_user_data {
|
text=>"Result", |
text=>"Result", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
my %disallowed; |
|
$r->print(&update_result_form($uhome)); |
$r->print(&update_result_form($uhome)); |
# Check Inputs |
# Check Inputs |
if (! $env{'form.ccuname'} ) { |
if (! $env{'form.ccuname'} ) { |
Line 1681 sub update_user_data {
|
Line 1680 sub update_user_data {
|
my @statuses = ('active','future'); |
my @statuses = ('active','future'); |
my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@statuses,undef,$env{'request.role.domain'}); |
my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@statuses,undef,$env{'request.role.domain'}); |
my ($auname,$audom); |
my ($auname,$audom); |
if ($context eq 'course') { |
if ($context eq 'author') { |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
if ($cnum eq '' || $cdom eq '') { |
|
my $cid = $env{'request.course.id'}; |
|
my %coursehash = |
|
&Apache::lonnet::coursedescription($cid,{'one_time' => 1}); |
|
$cdom = $coursehash{'domain'}; |
|
$cnum = $coursehash{'num'}; |
|
} |
|
} elsif ($context eq 'author') { |
|
$auname = $env{'user.name'}; |
$auname = $env{'user.name'}; |
$audom = $env{'user.domain'}; |
$audom = $env{'user.domain'}; |
} |
} |
foreach my $item (keys(%roles)) { |
foreach my $item (keys(%roles)) { |
my ($rolenum,$roledom,$role) = split(/:/,$item); |
my ($rolenum,$roledom,$role) = split(/:/,$item,-1); |
if ($context eq 'course') { |
if ($context eq 'course') { |
if ($cnum ne '' && $cdom ne '') { |
if ($cnum ne '' && $cdom ne '') { |
if ($rolenum eq $cnum && $roledom eq $cdom) { |
if ($rolenum eq $cnum && $roledom eq $cdom) { |
Line 1713 sub update_user_data {
|
Line 1702 sub update_user_data {
|
} |
} |
} |
} |
} |
} |
# Check for course or co-author roles being activated or re-enabled |
if ($env{'form.action'} eq 'singlestudent') { |
if ($context eq 'author' || $context eq 'course') { |
if (!grep(/^st$/,@userroles)) { |
foreach my $key (keys(%env)) { |
push(@userroles,'st'); |
if ($context eq 'author') { |
} |
if ($key=~/^form\.act_\Q$audom\E_\Q$auname\E_([^_]+)/) { |
} else { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
# Check for course or co-author roles being activated or re-enabled |
push(@userroles,$1); |
if ($context eq 'author' || $context eq 'course') { |
} |
foreach my $key (keys(%env)) { |
} elsif ($key =~/^form\.ren\:\Q$audom\E\/\Q$auname\E_([^_]+)/) { |
if ($context eq 'author') { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
if ($key=~/^form\.act_\Q$audom\E_\Q$auname\E_([^_]+)/) { |
push(@userroles,$1); |
if (!grep(/^\Q$1\E$/,@userroles)) { |
} |
push(@userroles,$1); |
} |
} |
} elsif ($context eq 'course') { |
} elsif ($key =~/^form\.ren\:\Q$audom\E\/\Q$auname\E_([^_]+)/) { |
if ($key=~/^form\.act_\Q$cdom\E_\Q$cnum\E_([^_]+)/) { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
push(@userroles,$1); |
push(@userroles,$1); |
} |
} |
} |
} elsif ($key =~/^form\.ren\:\Q$cdom\E\/\Q$cnum\E(\/?\w*)_([^_]+)/) { |
} elsif ($context eq 'course') { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
if ($key=~/^form\.act_\Q$cdom\E_\Q$cnum\E_([^_]+)/) { |
push(@userroles,$1); |
if (!grep(/^\Q$1\E$/,@userroles)) { |
|
push(@userroles,$1); |
|
} |
|
} elsif ($key =~/^form\.ren\:\Q$cdom\E\/\Q$cnum\E(\/?\w*)_([^_]+)/) { |
|
if (!grep(/^\Q$1\E$/,@userroles)) { |
|
push(@userroles,$1); |
|
} |
} |
} |
} |
} |
} |
} |
Line 1765 sub update_user_data {
|
Line 1760 sub update_user_data {
|
# Check to see if we can change the ID/student number |
# Check to see if we can change the ID/student number |
my $forceid = $env{'form.forceid'}; |
my $forceid = $env{'form.forceid'}; |
my $recurseid = $env{'form.recurseid'}; |
my $recurseid = $env{'form.recurseid'}; |
my $newuser = 0; |
|
my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules); |
my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules); |
my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'}, |
my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'}, |
$env{'form.ccuname'}); |
$env{'form.ccuname'}); |
Line 1797 sub update_user_data {
|
Line 1791 sub update_user_data {
|
$newdefquotatext); |
$newdefquotatext); |
my ($defquota,$settingstatus) = |
my ($defquota,$settingstatus) = |
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); |
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); |
|
my $showquota; |
|
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) { |
|
$showquota = 1; |
|
} |
my %changeHash; |
my %changeHash; |
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'}; |
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'}; |
if ($userenv{'portfolioquota'} ne '') { |
if ($userenv{'portfolioquota'} ne '') { |
Line 1867 sub update_user_data {
|
Line 1865 sub update_user_data {
|
$changeHash{'firstname'},$changeHash{'middlename'}, |
$changeHash{'firstname'},$changeHash{'middlename'}, |
$changeHash{'lastname'},$changeHash{'generation'}, |
$changeHash{'lastname'},$changeHash{'generation'}, |
$changeHash{'id'},undef,$changeHash{'permanentemail'}); |
$changeHash{'id'},undef,$changeHash{'permanentemail'}); |
|
%userupdate = ( |
|
lastname => $env{'form.clastname'}, |
|
middlename => $env{'form.cmiddlename'}, |
|
firstname => $env{'form.cfirstname'}, |
|
generation => $env{'form.cgeneration'}, |
|
id => $env{'form.cid'}, |
|
); |
} |
} |
if (($namechanged && $namechgresult eq 'ok') || |
if (($namechanged && $namechgresult eq 'ok') || |
($quotachanged && $quotachgresult eq 'ok')) { |
($quotachanged && $quotachgresult eq 'ok')) { |
Line 1894 sub update_user_data {
|
Line 1899 sub update_user_data {
|
<th>$lt{'gen'}</th> |
<th>$lt{'gen'}</th> |
<th>$lt{'id'}</th> |
<th>$lt{'id'}</th> |
<th>$lt{'mail'}</th> |
<th>$lt{'mail'}</th> |
<th>$lt{'disk'}</th> |
|
END |
END |
|
if ($showquota) { |
|
$r->print(" |
|
<th>$lt{'disk'}</th>\n"); |
|
} |
$r->print(&Apache::loncommon::end_data_table_header_row(). |
$r->print(&Apache::loncommon::end_data_table_header_row(). |
&Apache::loncommon::start_data_table_row()); |
&Apache::loncommon::start_data_table_row()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
Line 1906 END
|
Line 1914 END
|
<td>$userenv{'generation'} </td> |
<td>$userenv{'generation'} </td> |
<td>$userenv{'id'}</td> |
<td>$userenv{'id'}</td> |
<td>$userenv{'permanentemail'} </td> |
<td>$userenv{'permanentemail'} </td> |
<td>$oldportfolioquota Mb $olddefquotatext </td> |
|
END |
END |
|
if ($showquota) { |
|
$r->print(" |
|
<td>$oldportfolioquota Mb $olddefquotatext </td>\n"); |
|
} |
$r->print(&Apache::loncommon::end_data_table_row(). |
$r->print(&Apache::loncommon::end_data_table_row(). |
&Apache::loncommon::start_data_table_row()); |
&Apache::loncommon::start_data_table_row()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
Line 1918 END
|
Line 1929 END
|
<td>$env{'form.cgeneration'} </td> |
<td>$env{'form.cgeneration'} </td> |
<td>$env{'form.cid'} </td> |
<td>$env{'form.cid'} </td> |
<td>$env{'form.cpermanentemail'} </td> |
<td>$env{'form.cpermanentemail'} </td> |
<td>$newportfolioquota Mb $newdefquotatext </td> |
|
END |
END |
|
if ($showquota) { |
|
$r->print(" |
|
<td>$newportfolioquota Mb $newdefquotatext </td>\n"); |
|
} |
$r->print(&Apache::loncommon::end_data_table_row(). |
$r->print(&Apache::loncommon::end_data_table_row(). |
&Apache::loncommon::end_data_table().'<br />'); |
&Apache::loncommon::end_data_table().'<br />'); |
if ($env{'form.cid'} ne $userenv{'id'}) { |
if ($env{'form.cid'} ne $userenv{'id'}) { |
Line 1927 END
|
Line 1941 END
|
($env{'form.ccuname'} => $env{'form.cid'})); |
($env{'form.ccuname'} => $env{'form.cid'})); |
if (($recurseid) && |
if (($recurseid) && |
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { |
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { |
%userupdate = ( |
|
lastname => $env{'form.clasaname'}, |
|
middlename => $env{'form.cmiddlename'}, |
|
firstname => $env{'form.cfirstname'}, |
|
generation => $env{'fora.cgeneration'}, |
|
id => $env{'form.cid'}, |
|
); |
|
my $idresult = |
my $idresult = |
&Apache::lonuserutils::propagate_id_change( |
&Apache::lonuserutils::propagate_id_change( |
$env{'form.ccuname'},$env{'form.ccdomain'}, |
$env{'form.ccuname'},$env{'form.ccdomain'}, |
Line 1969 END
|
Line 1976 END
|
$r->print('<br />['.$lt{'mail'}.': '. |
$r->print('<br />['.$lt{'mail'}.': '. |
$userenv{'permanentemail'}.']'); |
$userenv{'permanentemail'}.']'); |
} |
} |
$r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '. |
if ($showquota) { |
$olddefquotatext.']</h4>'); |
$r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '. |
|
$olddefquotatext.']'); |
|
} |
|
$r->print('</h4>'); |
} |
} |
if (@mod_disallowed) { |
if (@mod_disallowed) { |
my ($rolestr,$contextname); |
my ($rolestr,$contextname); |
Line 2001 END
|
Line 2011 END
|
$r->print($no_forceid_alert. |
$r->print($no_forceid_alert. |
&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules)); |
&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules)); |
} |
} |
## |
if ($env{'form.action'} eq 'singlestudent') { |
|
&enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser); |
|
} else { |
|
my $rolechanges = &update_roles($r); |
|
if (!$rolechanges && $namechanged) { |
|
if ($context eq 'course') { |
|
if (@userroles > 0) { |
|
if (grep(/^st$/,@userroles)) { |
|
my $classlistupdated = |
|
&Apache::lonuserutils::update_classlist($cdom, |
|
$cnum,$env{'form.ccdomain'}, |
|
$env{'form.ccuname'},\%userupdate); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
} |
|
|
|
sub update_roles { |
|
my ($r) = @_; |
my $now=time; |
my $now=time; |
my $rolechanges = 0; |
my $rolechanges = 0; |
|
my %disallowed; |
$r->print('<h3>'.&mt('Modifying Roles').'</h3>'); |
$r->print('<h3>'.&mt('Modifying Roles').'</h3>'); |
foreach my $key (keys (%env)) { |
foreach my $key (keys (%env)) { |
next if (! $env{$key}); |
next if (! $env{$key}); |
Line 2076 END
|
Line 2108 END
|
if ($role eq 'st') { |
if ($role eq 'st') { |
if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) { |
if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) { |
my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3); |
my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3); |
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) { |
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) { |
$output = "Error: $result\n"; |
$output = "Error: $result\n"; |
} else { |
} else { |
$output = &mt('Assigning').' '.$role.' in '.$url. |
$output = &mt('Assigning').' '.$role.' in '.$url. |
Line 2224 END
|
Line 2256 END
|
if (!$rolechanges) { |
if (!$rolechanges) { |
$r->print(&mt('No roles to modify')); |
$r->print(&mt('No roles to modify')); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
return $rolechanges; |
|
} |
|
|
|
sub enroll_single_student { |
|
my ($r,$uhome,$amode,$genpwd,$now,$newuser) = @_; |
|
$r->print('<h3>'.&mt('Enrolling Student').'</h3>'); |
|
|
|
# Remove non alphanumeric values from section |
|
$env{'form.sections'}=~s/\W//g; |
|
|
|
# Clean out any old student roles the user has in this class. |
|
&Apache::lonuserutils::modifystudent($env{'form.ccdomain'}, |
|
$env{'form.ccuname'},$env{'request.course.id'},undef,$uhome); |
|
my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form(); |
|
my $enroll_result = |
|
&Apache::lonnet::modify_student_enrollment($env{'form.ccdomain'}, |
|
$env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'}, |
|
$env{'form.cmiddlename'},$env{'form.clastname'}, |
|
$env{'form.generation'},$env{'form.sections'},$enddate, |
|
$startdate,'manual',undef,$env{'request.course.id'}); |
|
if ($enroll_result =~ /^ok/) { |
|
$r->print(&mt('<b>[_1]</b> enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'})); |
|
if ($env{'form.sections'} ne '') { |
|
$r->print(' '.&mt('in section [_1]',$env{'form.sections'})); |
|
} |
|
my ($showstart,$showend); |
|
if ($startdate <= $now) { |
|
$showstart = &mt('Access starts immediately'); |
|
} else { |
|
$showstart = &mt('Access starts: ').&Apache::lonlocal::locallocaltime($startdate); |
|
} |
|
if ($enddate == 0) { |
|
$showend = &mt('ends: no ending date'); |
|
} else { |
|
$showend = &mt('ends: ').&Apache::lonlocal::locallocaltime($enddate); |
|
} |
|
$r->print('.<br />'.$showstart.'; '.$showend); |
|
if ($startdate <= $now && !$newuser) { |
|
$r->print("<p> ".&mt('If the student is currently logged-in to LON-CAPA, the new role will be available when the student next logs in.')."</p>"); |
|
} |
|
} else { |
|
$r->print(&mt('unable to enroll').": ".$enroll_result); |
|
} |
|
return; |
} |
} |
|
|
sub get_defaultquota_text { |
sub get_defaultquota_text { |
Line 2264 sub update_result_form {
|
Line 2339 sub update_result_form {
|
} |
} |
$outcome .= '<input type="hidden" name="phase" value="" />'."\n". |
$outcome .= '<input type="hidden" name="phase" value="" />'."\n". |
'<input type ="hidden" name="currstate" value="" />'."\n". |
'<input type ="hidden" name="currstate" value="" />'."\n". |
'<input type ="hidden" name="action" value="singleuser" />'."\n". |
'<input type ="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n". |
'</form>'; |
'</form>'; |
return $outcome; |
return $outcome; |
} |
} |