--- loncom/interface/loncreateuser.pm 2007/12/05 17:13:34 1.199 +++ loncom/interface/loncreateuser.pm 2007/12/11 02:27:24 1.206 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.199 2007/12/05 17:13:34 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.206 2007/12/11 02:27:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -76,7 +76,7 @@ my $authformfsys; my $authformloc; sub initialize_authen_forms { - my ($dom,$curr_authtype) = @_; + my ($dom,$curr_authtype,$mode) = @_; my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/); $krbdefdom= uc($krbdefdom); my %param = ( formname => 'document.cu', @@ -91,6 +91,9 @@ sub initialize_authen_forms { if ($long_auth =~ /^krb(4|5)$/) { $param{'curr_kerb_ver'} = $1; } + if ($mode eq 'modifyuser') { + $param{'mode'} = $mode; + } } # no longer static due to configurable kerberos defaults # $loginscript = &Apache::loncommon::authform_header(%param); @@ -627,7 +630,7 @@ sub print_user_modification_page { } ENDSCRIPT } else { - $nondc_setsection_code = + $nondc_setsection_code = &Apache::lonuserutils::setsections_javascript('cu',$groupslist); } my $js = &user_modification_js($pjump_def,$dc_setcourse_code, @@ -704,9 +707,11 @@ $loginscript

$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain

ENDTITLE - $r->print('
'. - &personal_data_display($ccuname,$ccdomain,$newuser, - %inst_results)); + $r->print('
'); + my $personal_table = + &personal_data_display($ccuname,$ccdomain,$newuser, + $context,%inst_results); + $r->print($personal_table); my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($ccdomain,'hserver', 'default','hide'); @@ -783,11 +788,13 @@ $crumbs $forminfo

$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"

ENDCHANGEUSER - $r->print('
'. - &personal_data_display($ccuname,$ccdomain,$newuser, - %inst_results)); - if ($context eq 'domain') { - $r->print(&Apache::lonuserutils::forceid_change()); + $r->print('
'); + my ($personal_table,$showforceid) = + &personal_data_display($ccuname,$ccdomain,$newuser, + $context,%inst_results); + $r->print($personal_table); + if ($showforceid) { + $r->print(&Apache::lonuserutils::forceid_change($context)); } $r->print('
'); my $user_auth_text = @@ -1197,8 +1204,8 @@ $lt{'uuas'} ($currentauth). $lt{'adcs'}. ENDBADAUTH } } else { # Authentication type is valid - &initialize_authen_forms($ccdomain,$currentauth); - my ($authformcurrent,$authform_other,$can_modify) = + &initialize_authen_forms($ccdomain,$currentauth,'modifyuser'); + my ($authformcurrent,$can_modify,@authform_others) = &modify_login_block($ccdomain,$currentauth); if (&Apache::lonnet::allowed('mau',$ccdomain)) { # Current user has login modification privileges @@ -1222,13 +1229,15 @@ ENDBADAUTH ''.$authformcurrent.''. &Apache::loncommon::end_data_table_row()."\n"; } else { - $outcome .= ' ('.$authformcurrent.')'; + $outcome .= ' ('.$authformcurrent.')'. + &Apache::loncommon::end_data_table_row()."\n"; } - if ($authform_other ne '') { - $outcome .= $authform_other; + foreach my $item (@authform_others) { + $outcome .= &Apache::loncommon::start_data_table_row(). + ''.$item.''. + &Apache::loncommon::end_data_table_row()."\n"; } - $outcome .= &Apache::loncommon::end_data_table_row(). - &Apache::loncommon::end_data_table(); + $outcome .= &Apache::loncommon::end_data_table(); } else { if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { my %lt=&Apache::lonlocal::texthash( @@ -1251,18 +1260,14 @@ sub modify_login_block { my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($dom); - my ($authformcurrent,$authform_other,$show_override_msg); + my ($authformcurrent,@authform_others,$show_override_msg); if ($currentauth=~/^krb(4|5):/) { $authformcurrent=$authformkrb; if ($can_assign{'int'}) { - $authform_other = &Apache::loncommon::start_data_table_row(). - ''.$authformint.''. - &Apache::loncommon::end_data_table_row()."\n" + push(@authform_others,$authformint); } if ($can_assign{'loc'}) { - $authform_other .= &Apache::loncommon::start_data_table_row(). - ''.$authformloc.''. - &Apache::loncommon::end_data_table_row()."\n"; + push(@authform_others,$authformloc); } if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { $show_override_msg = 1; @@ -1270,14 +1275,10 @@ sub modify_login_block { } elsif ($currentauth=~/^internal:/) { $authformcurrent=$authformint; if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { - $authform_other = &Apache::loncommon::start_data_table_row(). - ''.$authformkrb.''. - &Apache::loncommon::end_data_table_row()."\n"; + push(@authform_others,$authformkrb); } if ($can_assign{'loc'}) { - $authform_other .= &Apache::loncommon::start_data_table_row(). - ''.$authformloc.''. - &Apache::loncommon::end_data_table_row()."\n"; + push(@authform_others,$authformloc); } if ($can_assign{'int'}) { $show_override_msg = 1; @@ -1285,19 +1286,13 @@ sub modify_login_block { } elsif ($currentauth=~/^unix:/) { $authformcurrent=$authformfsys; if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { - $authform_other = &Apache::loncommon::start_data_table_row(). - ''.$authformkrb.''. - &Apache::loncommon::end_data_table_row()."\n"; + push(@authform_others,$authformkrb); } if ($can_assign{'int'}) { - $authform_other .= &Apache::loncommon::start_data_table_row(). - ''.$authformint.''. - &Apache::loncommon::end_data_table_row()."\n" + push(@authform_others,$authformint); } if ($can_assign{'loc'}) { - $authform_other .= &Apache::loncommon::start_data_table_row(). - ''.$authformloc.''. - &Apache::loncommon::end_data_table_row()."\n"; + push(@authform_others,$authformloc); } if ($can_assign{'fsys'}) { $show_override_msg = 1; @@ -1305,35 +1300,38 @@ sub modify_login_block { } elsif ($currentauth=~/^localauth:/) { $authformcurrent=$authformloc; if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { - $authform_other = &Apache::loncommon::start_data_table_row(). - ''.$authformkrb.''. - &Apache::loncommon::end_data_table_row()."\n"; + push(@authform_others,$authformkrb); } if ($can_assign{'int'}) { - $authform_other .= &Apache::loncommon::start_data_table_row(). - ''.$authformint.''. - &Apache::loncommon::end_data_table_row()."\n" + push(@authform_others,$authformint); } if ($can_assign{'loc'}) { $show_override_msg = 1; } } if ($show_override_msg) { - $authformcurrent.= ' '. + $authformcurrent = ''."\n". + ''. + ''. + '
'.$authformcurrent. + '
   '.&mt('Currently in use').''. &mt('will override current values'). - '
'; + '
'; } - return ($authformcurrent,$authform_other,$show_override_msg); + return ($authformcurrent,$show_override_msg,@authform_others); } sub personal_data_display { - my ($ccuname,$ccdomain,$newuser,%inst_results) = @_; - my ($output,%userenv); + my ($ccuname,$ccdomain,$newuser,$context,%inst_results) = @_; + my ($output,$showforceid,%userenv,%domconfig); if (!$newuser) { # Get the users information %userenv = &Apache::lonnet::get('environment', ['firstname','middlename','lastname','generation', 'permanentemail','id'],$ccdomain,$ccuname); + %domconfig = + &Apache::lonnet::get_dom('configuration',['usermodification'], + $ccdomain); } my %lt=&Apache::lonlocal::texthash( 'pd' => "Personal Data", @@ -1371,21 +1369,47 @@ sub personal_data_display { $output .= ''; } } else { + my $canmodify = 0; if (&Apache::lonnet::allowed('mau',$ccdomain)) { + $canmodify = 1; + } else { + if (ref($domconfig{'usermodification'}) eq 'HASH') { + if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { + foreach my $key (keys(%{$domconfig{'usermodification'}{$context}})) { + if (ref($domconfig{'usermodification'}{$context}{$key}) eq 'HASH') { + if ($domconfig{'usermodification'}{$context}{$key}{$item}) { + $canmodify = 1; + last; + } + } + } + } + } elsif ($context eq 'course') { + $canmodify = 1; + } + } + if ($canmodify) { $output .= ''; } else { $output .= $userenv{$item}; } + if ($item eq 'id') { + $showforceid = $canmodify; + } } $output .= &Apache::lonhtmlcommon::row_closure(1); } $output .= &Apache::lonhtmlcommon::end_pick_box(); - return $output; + if (wantarray) { + return ($output,$showforceid); + } else { + return $output; + } } # ================================================================= Phase Three sub update_user_data { - my ($r) = @_; + my ($r,$context) = @_; my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'}, $env{'form.ccdomain'}); # Error messages @@ -1583,20 +1607,131 @@ sub update_user_data { if ($tmp =~ /^(con_lost|error)/i) { %userenv = (); } - # Check to see if we need to change user information + my $no_forceid_alert; + # Check to see if user information can be changed + my %domconfig = + &Apache::lonnet::get_dom('configuration',['usermodification'], + $env{'form.ccdomain'}); + my @roletypes = ('active','future'); + my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@roletypes,undef,$env{'request.role.domain'}); + my @userroles; + my ($cnum,$cdom,$auname,$audom); + if ($context eq 'course') { + $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'}; + $audom = $env{'user.domain'}; + } + foreach my $item (keys(%roles)) { + my ($rolenum,$roledom,$role) = split(/:/,$item); + if ($context eq 'course') { + if ($cnum ne '' && $cdom ne '') { + if ($rolenum eq $cnum && $roledom eq $cdom) { + if (!grep(/^\Q$role\E$/,@userroles)) { + push(@userroles,$role); + } + } + } + } elsif ($context eq 'author') { + if ($rolenum eq $auname && $roledom eq $audom) { + if (!grep(/^\Q$role\E$/,@userroles)) { + push(@userroles,$role); + } + } + } + } + # Check for course or co-author roles being activated or re-enabled + if ($context eq 'author' || $context eq 'course') { + foreach my $key (keys(%env)) { + if ($context eq 'author') { + if ($key=~/^form\.act_\Q$audom\E_\Q$auname\E_([^_]+)/) { + if (!grep(/^\Q$1\E$/,@userroles)) { + push(@userroles,$1); + } + } elsif ($key =~/^form\.ren\:\Q$audom\E\/\Q$auname\E_([^_]+)/) { + if (!grep(/^\Q$1\E$/,@userroles)) { + push(@userroles,$1); + } + } + } elsif ($context eq 'course') { + if ($key=~/^form\.act_\Q$cdom\E_\Q$cnum\E_([^_]+)/) { + 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); + } + } + } + } + } + #Check to see if we can change personal data for the user + my (@mod_disallowed,@longroles); + foreach my $role (@userroles) { + if ($role eq 'cr') { + push(@longroles,'Custom'); + } else { + push(@longroles,&Apache::lonnet::plaintext($role)); + } + } foreach my $item ('firstname','middlename','lastname','generation','permanentemail','id') { + my $canmodify = 0; + if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) { + $canmodify = 1; + } else { + if ($context eq 'course' || $context eq 'author') { + if (ref($domconfig{'usermodification'}) eq 'HASH') { + if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { + foreach my $role (@userroles) { + if (ref($domconfig{'usermodification'}{$context}{$role}) eq 'HASH') { + if ($domconfig{'usermodification'}{$context}{$role}{$item}) { + $canmodify = 1; + last; + } + } + } + } + } + } elsif ($context eq 'course') { + if (grep(/^st$/,@userroles)) { + $canmodify = 1; + } + } + } # Strip leading and trailing whitespace - $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; + $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; + if (!$canmodify) { + if ($env{'form.c'.$item} ne $userenv{$item}) { + push(@mod_disallowed,$item); + } + $env{'form.c'.$item} = $userenv{$item}; + } } # Check to see if we can change the ID/student number my $forceid = $env{'form.forceid'}; my $recurseid = $env{'form.recurseid'}; my $newuser = 0; - my $disallowed_id = 0; my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules); - if (!$forceid) { - $env{'form.cid'} = $userenv{'id'}; - } elsif ($env{'form.cid'} ne $userenv{'id'}) { + my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'}, + $env{'form.ccuname'}); + if (($uidhash{$env{'form.ccuname'}}) && + ($uidhash{$env{'form.ccuname'}}!~/error\:/) && + (!$forceid)) { + if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) { + $env{'form.cid'} = $userenv{'id'}; + $no_forceid_alert = &mt('New student/employeeID does not match existing ID for this user.').'
'.&mt('Change is not permitted without checking the \'Force ID change\' checkbox on the previous page.').'
'."\n"; + } + } + if ($env{'form.cid'} ne $userenv{'id'}) { my $checkhash; my $checks = { 'id' => 1 }; $checkhash->{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}} = @@ -1607,15 +1742,17 @@ sub update_user_data { \%alerts,\%rulematch,\%idinst_results,\%curr_rules,\%got_rules); if (ref($alerts{'id'}) eq 'HASH') { if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') { - $disallowed_id = 1; + $env{'form.cid'} = $userenv{'id'}; } } } my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota, - $inststatus,$isdefault,$defquotatext); + $inststatus,$oldisdefault,$newisdefault,$olddefquotatext, + $newdefquotatext); my ($defquota,$settingstatus) = &Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); my %changeHash; + $changeHash{'portfolioquota'} = $userenv{'portfolioquota'}; if ($userenv{'portfolioquota'} ne '') { $oldportfolioquota = $userenv{'portfolioquota'}; if ($env{'form.customquota'} == 1) { @@ -1625,15 +1762,16 @@ sub update_user_data { $newportfolioquota = $env{'form.portfolioquota'}; $newportfolioquota =~ s/[^\d\.]//g; } - if ($newportfolioquota != $userenv{'portfolioquota'}) { + if ($newportfolioquota != $oldportfolioquota) { $quotachanged = "a_admin($newportfolioquota,\%changeHash); } } else { $quotachanged = "a_admin('',\%changeHash); $newportfolioquota = $defquota; - $isdefault = 1; + $newisdefault = 1; } } else { + $oldisdefault = 1; $oldportfolioquota = $defquota; if ($env{'form.customquota'} == 1) { if ($env{'form.portfolioquota'} eq '') { @@ -1645,43 +1783,47 @@ sub update_user_data { $quotachanged = "a_admin($newportfolioquota,\%changeHash); } else { $newportfolioquota = $defquota; - $isdefault = 1; + $newisdefault = 1; } } - if ($isdefault) { - if ($settingstatus eq '') { - $defquotatext = &mt('(default)'); - } else { - my ($usertypes,$order) = - &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'}); - if ($usertypes->{$settingstatus} eq '') { - $defquotatext = &mt('(default)'); - } else { - $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus}); - } - } + if ($oldisdefault) { + $olddefquotatext = &get_defaultquota_text($settingstatus); + } + if ($newisdefault) { + $newdefquotatext = &get_defaultquota_text($settingstatus); } - if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) && - ($env{'form.cfirstname'} ne $userenv{'firstname'} || - $env{'form.cmiddlename'} ne $userenv{'middlename'} || - $env{'form.clastname'} ne $userenv{'lastname'} || - $env{'form.cgeneration'} ne $userenv{'generation'} || - $env{'form.cid'} ne $userenv{'id'} || - $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} )) { + if ($env{'form.cfirstname'} ne $userenv{'firstname'} || + $env{'form.cmiddlename'} ne $userenv{'middlename'} || + $env{'form.clastname'} ne $userenv{'lastname'} || + $env{'form.cgeneration'} ne $userenv{'generation'} || + $env{'form.cid'} ne $userenv{'id'} || + $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) { $namechanged = 1; } - if ($namechanged) { - # Make the change + if ($namechanged || $quotachanged) { $changeHash{'firstname'} = $env{'form.cfirstname'}; $changeHash{'middlename'} = $env{'form.cmiddlename'}; $changeHash{'lastname'} = $env{'form.clastname'}; $changeHash{'generation'} = $env{'form.cgeneration'}; $changeHash{'id'} = $env{'form.cid'}; $changeHash{'permanentemail'} = $env{'form.cpermanentemail'}; - my $putresult = &Apache::lonnet::put - ('environment',\%changeHash, - $env{'form.ccdomain'},$env{'form.ccuname'}); - if ($putresult eq 'ok') { + my ($quotachgresult,$namechgresult); + if ($quotachanged) { + $quotachgresult = + &Apache::lonnet::put('environment',\%changeHash, + $env{'form.ccdomain'},$env{'form.ccuname'}); + } + if ($namechanged) { + # Make the change + $namechgresult = + &Apache::lonnet::modifyuser($env{'form.ccdomain'}, + $env{'form.ccuname'},$changeHash{'id'},undef,undef, + $changeHash{'firstname'},$changeHash{'middlename'}, + $changeHash{'lastname'},$changeHash{'generation'}, + $changeHash{'id'},undef,$changeHash{'permanentemail'}); + } + if (($namechanged && $namechgresult eq 'ok') || + ($quotachanged && $quotachgresult eq 'ok')) { # Tell the user we changed the name my %lt=&Apache::lonlocal::texthash( 'uic' => "User Information Changed", @@ -1695,48 +1837,63 @@ sub update_user_data { 'prvs' => "Previous", 'chto' => "Changed To" ); + $r->print('

'.$lt{'uic'}.'

'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row()); $r->print(<<"END"); - - - + - - + +END + $r->print(&Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row()); + $r->print(<<"END"); + - - - + +END + $r->print(&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::start_data_table_row()); + $r->print(<<"END"); + - -
$lt{'uic'}
   $lt{'frst'} $lt{'mddl'} $lt{'lst'} $lt{'gen'} $lt{'id'} $lt{'mail'}$lt{'disk'}
$lt{'prvs'}$lt{'disk'}$lt{'prvs'} $userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'} $userenv{'id'} $userenv{'permanentemail'} $oldportfolioquota Mb
$lt{'chto'}$oldportfolioquota Mb $olddefquotatext $lt{'chto'} $env{'form.cfirstname'} $env{'form.cmiddlename'} $env{'form.clastname'} $env{'form.cgeneration'} $env{'form.cid'} $env{'form.cpermanentemail'} $newportfolioquota Mb $defquotatext
+ $newportfolioquota Mb $newdefquotatext END - if (($forceid) && ($recurseid) && (!$disallowed_id) && - (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { - my %userupdate = ( + $r->print(&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table().'
'); + if ($env{'form.cid'} ne $userenv{'id'}) { + &Apache::lonnet::idput($env{'form.ccdomain'}, + ($env{'form.ccuname'} => $env{'form.cid'})); + if (($recurseid) && + (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { + my %userupdate = ( lastname => $env{'form.clasaname'}, middlename => $env{'form.cmiddlename'}, firstname => $env{'form.cfirstname'}, generation => $env{'fora.cgeneration'}, id => $env{'form.cid'}, ); - my $idresult = &propagate_id_change($env{'form.ccname'}, - $env{'form.ccdomain'},\%userupdate); - $r->print('
'.$idresult.'
'); + my $idresult = + &Apache::lonuserutils::propagate_id_change( + $env{'form.ccuname'},$env{'form.ccdomain'}, + \%userupdate); + $r->print('
'.$idresult.'
'); + } } if (($env{'form.ccdomain'} eq $env{'user.domain'}) && ($env{'form.ccuname'} eq $env{'user.name'})) { @@ -1749,17 +1906,11 @@ END } else { # error occurred $r->print(''.&mt('Unable to successfully change environment for').' '. $env{'form.ccuname'}.' '.&mt('in domain').' '. - $env{'form.ccdomain'}.''); + $env{'form.ccdomain'}.'

'); } } else { # End of if ($env ... ) logic - my $putresult; - if ($quotachanged) { - $putresult = &Apache::lonnet::put - ('environment',\%changeHash, - $env{'form.ccdomain'},$env{'form.ccuname'}); - } - # They did not want to change the users name but we can - # still tell them what the name is + # They did not want to change the users name or quota but we can + # still tell them what the name and quota are my %lt=&Apache::lonlocal::texthash( 'id' => "ID/Student number", 'mail' => "Permanent e-mail", @@ -1768,20 +1919,34 @@ END $r->print(<<"END");

$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'} END - if ($userenv{'permanentemail'} eq '') { - $r->print('

'); + if ($userenv{'permanentemail'} ne '') { + $r->print('
['.$lt{'mail'}.': '. + $userenv{'permanentemail'}.']'); + } + $r->print('
['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '. + $olddefquotatext.']'); + } + if (@mod_disallowed) { + my ($rolestr,$contextname); + if (@longroles > 0) { + $rolestr = join(', ',@longroles); } else { - $r->print('  ('.$lt{'mail'}.': '. - $userenv{'permanentemail'}.')'); + $rolestr = &mt('No roles'); } - if ($putresult eq 'ok') { - if ($oldportfolioquota != $newportfolioquota) { - $r->print('

'.$lt{'disk'}.': '.$newportfolioquota.' Mb '. - $defquotatext.'

'); - &Apache::lonnet::appenv('environment.portfolioquota' => $changeHash{'portfolioquota'}); - } + if ($context eq 'course') { + $contextname = &mt('course'); + } elsif ($context eq 'author') { + $contextname = &mt('co-author'); + } + $r->print(&mt('The following fields were not updated: ').'
    '); + my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); + foreach my $field (@mod_disallowed) { + $r->print('
  • '.$fieldtitles{$field}.'
  • '."\n"); } + $r->print('
'.&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles: [_2].",$contextname,$rolestr).'
'.&mt('Contact your helpdesk for more information.',"javascript:helpMenu('display')").'
'); } + $r->print($no_forceid_alert. + &Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules)); } ## my $now=time; @@ -1802,10 +1967,10 @@ END $r->print(&mt('Revoking [_1] in [_2]: [_3]', $role,$scope,''.$result.'').'
'); if ($role eq 'st') { - my $result = + my $result = &Apache::lonuserutils::classlist_drop($scope, $env{'form.ccuname'},$env{'form.ccdomain'}, - $now); + $now); $r->print($result); } } @@ -1829,10 +1994,10 @@ END $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope, ''.$result.'').'
'); if ($role eq 'st') { - my $result = + my $result = &Apache::lonuserutils::classlist_drop($scope, $env{'form.ccuname'},$env{'form.ccdomain'}, - $now); + $now); $r->print($result); } } @@ -2009,6 +2174,23 @@ END $r->print(&Apache::loncommon::end_page()); } +sub get_defaultquota_text { + my ($settingstatus) = @_; + my $defquotatext; + if ($settingstatus eq '') { + $defquotatext = &mt('(default)'); + } else { + my ($usertypes,$order) = + &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'}); + if ($usertypes->{$settingstatus} eq '') { + $defquotatext = &mt('(default)'); + } else { + $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus}); + } + } + return $defquotatext; +} + sub update_result_form { my ($uhome) = @_; my $outcome = @@ -2374,16 +2556,18 @@ sub handler { if ($env{'request.course.id'}) { $context = 'course'; } elsif ($env{'request.role'} =~ /^au\./) { - $context = 'construction_space'; + $context = 'author'; } else { $context = 'domain'; } &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['action','state']); + ['action','state','callingform','roletype','showrole','bulkaction']); &Apache::lonhtmlcommon::clear_breadcrumbs(); - &Apache::lonhtmlcommon::add_breadcrumb - ({href=>"/adm/createuser", - text=>"User Management"}); + if ($env{'form.action'} ne 'dateselect') { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>"/adm/createuser", + text=>"User Management"}); + } my ($permission,$allowed) = &get_permission($context); if (!$allowed) { $env{'user.error.msg'}= @@ -2433,7 +2617,7 @@ sub handler { if (! exists($env{'form.state'})) { &Apache::lonuserutils::print_expire_menu($r,$context); } elsif ($env{'form.state'} eq 'done') { - &Apache::lonuserutils::expire_user_list($r); + &Apache::lonuserutils::expire_user_list($r,$context); } else { &Apache::lonuserutils::print_expire_menu($r,$context); } @@ -2487,7 +2671,7 @@ sub handler { $context); } } elsif ($env{'form.phase'} eq 'update_user_data') { - &update_user_data($r); + &update_user_data($r,$context); } else { &print_username_entry_form($r,undef,$srch); } @@ -2498,31 +2682,46 @@ sub handler { &custom_role_editor($r); } } elsif ($env{'form.action'} eq 'listusers' && $permission->{'view'}) { - my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles); - my $formname = 'studentform'; - if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { - ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) = - &Apache::lonuserutils::courses_selector($env{'request.role.domain'}, - $formname); - my $js = &add_script($jscript).$cb_jscript; - my $loadcode = - &Apache::lonuserutils::course_selector_loadcode($formname); - if ($loadcode ne '') { - $r->print(&header($js,{'onload' => $loadcode,})); + if ($env{'form.phase'} eq 'bulkchange') { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'backPage(document.studentform)', + text=>"List Users"}); + my $setting = $env{'form.roletype'}; + my $choice = $env{'form.bulkaction'}; + $r->print(&header()); + $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users", + 'User_Management_List')); + if ($permission->{'cusr'}) { + &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice); + } + } else { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'/adm/createuser?action=listusers', + text=>"List Users"}); + my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles); + my $formname = 'studentform'; + if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { + ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) = + &Apache::lonuserutils::courses_selector($env{'request.role.domain'}, + $formname); + $jscript .= &verify_user_display(); + my $js = &add_script($jscript).$cb_jscript; + my $loadcode = + &Apache::lonuserutils::course_selector_loadcode($formname); + if ($loadcode ne '') { + $r->print(&header($js,{'onload' => $loadcode,})); + } else { + $r->print(&header($js)); + } } else { - $r->print(&header($js)); + $r->print(&header(&add_script(&verify_user_display()))); } - } else { - $r->print(&header()); + $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users", + 'User_Management_List')); + &Apache::lonuserutils::print_userlist($r,undef,$permission,$context, + $formname,$totcodes,$codetitles,$idlist,$idlist_titles); + $r->print(&Apache::loncommon::end_page()); } - &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/createuser?action=listusers', - text=>"List Users"}); - $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users", - 'User_Management_List')); - &Apache::lonuserutils::print_userlist($r,undef,$permission,$context, - $formname,$totcodes,$codetitles,$idlist,$idlist_titles); - $r->print(&Apache::loncommon::end_page()); } elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) { $r->print(&header()); &Apache::lonhtmlcommon::add_breadcrumb @@ -2533,26 +2732,37 @@ sub handler { if (! exists($env{'form.state'})) { &Apache::lonuserutils::print_expire_menu($r,$context); } elsif ($env{'form.state'} eq 'done') { - &Apache::lonuserutiles::expire_user_list($r); + &Apache::lonuserutiles::expire_user_list($r,$context); } else { &print_expire_menu($r,$context); } $r->print(&Apache::loncommon::end_page()); + } elsif ($env{'form.action'} eq 'dateselect') { + if ($permission->{'cusr'}) { + $r->print(&header(undef,undef,{'no_nav_bar' => 1}). + &Apache::lonuserutils::date_section_selector($context). + &Apache::loncommon::end_page()); + } else { + $r->print(&header(). + ''.&mt('You do not have permission to modify dates or sections for users').''. + &Apache::loncommon::end_page()); + } } else { $r->print(&header()); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); $r->print(&print_main_menu($permission)); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); + $r->print(&print_main_menu($permission)); $r->print(&Apache::loncommon::end_page()); } return OK; } sub header { - my ($jscript,$loaditems) = @_; + my ($jscript,$loaditems,$args) = @_; my $start_page; if (ref($loaditems) eq 'HASH') { - $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems,}); + $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems}); } else { - $start_page=&Apache::loncommon::start_page('User Management',$jscript); + $start_page=&Apache::loncommon::start_page('User Management',$jscript,$args); } return $start_page; } @@ -2562,6 +2772,20 @@ sub add_script { return ''; } +sub verify_user_display { + my $output = <<"END"; + +function display_update() { + document.studentform.action.value = 'listusers'; + document.studentform.phase.value = 'display'; + document.studentform.submit(); +} + +END + return $output; + +} + ############################################################### ############################################################### # Menu Phase One @@ -2643,7 +2867,7 @@ sub get_permission { } } } - } elsif ($context eq 'construction_space') { + } elsif ($context eq 'author') { $permission{'cusr'} = &authorpriv($env{'user.name'},$env{'request.role.domain'}); $permission{'view'} = $permission{'cusr'}; } else { @@ -3136,9 +3360,9 @@ sub course_level_table { '.$area.'
Domain: '.$domain.''."\n"; if ($role ne 'cc') { if (%sections_count) { - my $currsec = + my $currsec = &Apache::lonuserutils::course_sections(\%sections_count, - $protectedcourse.'_'.$role); + $protectedcourse.'_'.$role); $table .= ''. ' @@ -3178,7 +3402,7 @@ ENDTIMEENTRY '."\n"; if (%sections_count) { - my $currsec = + my $currsec = &Apache::lonuserutils::course_sections(\%sections_count, $customrole); $table.=
'.$plrole.' '.$area.'