Diff for /loncom/interface/loncreateuser.pm between versions 1.191 and 1.203

version 1.191, 2007/11/06 04:39:19 version 1.203, 2007/12/06 04:03:35
Line 440  sub print_user_query_page { Line 440  sub print_user_query_page {
 }  }
   
 sub print_user_modification_page {  sub print_user_modification_page {
     my ($r,$ccuname,$ccdomain,$srch,$response) = @_;      my ($r,$ccuname,$ccdomain,$srch,$response,$context) = @_;
     if (($ccuname eq '') || ($ccdomain eq '')) {      if (($ccuname eq '') || ($ccdomain eq '')) {
         my $usermsg = &mt('No username and/or domain provided.');           my $usermsg = &mt('No username and/or domain provided.'); 
  &print_username_entry_form($r,$usermsg);   &print_username_entry_form($r,$usermsg);
         return;          return;
     }      }
     my %abv_auth = &auth_abbrev();      my %abv_auth = &auth_abbrev();
     my ($curr_authtype,$instsrch,$rulematch,$rules,%inst_results,      my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser,
         $curr_kerb_ver,$newuser);          %alerts,%curr_rules,%got_rules);
     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);      my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
     if ($uhome eq 'no_host') {      if ($uhome eq 'no_host') {
         $newuser = 1;          $newuser = 1;
         $instsrch =          my $checkhash;
                       {          my $checks = { 'username' => 1 };
                          srchin => 'instd',          $checkhash->{$ccuname.':'.$ccdomain} = { 'newuser' => $newuser };
                          srchby => 'uname',          &Apache::loncommon::user_rule_check($checkhash,$checks,
                          srchtype => 'exact',              \%alerts,\%rulematch,\%inst_results,\%curr_rules,\%got_rules);
                          srchterm => $ccuname,          if (ref($alerts{'username'}) eq 'HASH') {
                          srchdomain => $ccdomain,              if (ref($alerts{'username'}{$ccdomain}) eq 'HASH') {
                        };                  my $domdesc =
         (my $usercheckmsg,$rulematch,$rules,%inst_results) =                       &Apache::lonnet::domain($ccdomain,'description');
             &Apache::loncommon::username_rule_check($instsrch,'new');                  if ($alerts{'username'}{$ccdomain}{$ccuname}) {
         if ($usercheckmsg) {                      my $userchkmsg;
             &print_username_entry_form($r,$usercheckmsg);                      if (ref($curr_rules{$ccdomain}) eq 'HASH') {  
             return;                          $userchkmsg = 
                               &Apache::loncommon::instrule_disallow_msg('username',
                                                                    $domdesc,1).
                           &Apache::loncommon::user_rule_formats($ccdomain,
                               $domdesc,$curr_rules{$ccdomain}{'username'},
                               'username');
                       }
                       &print_username_entry_form($r,$userchkmsg);
                       return;
                   } 
               }
         }          }
     } else {      } else {
         $newuser = 0;          $newuser = 0;
Line 617  sub print_user_modification_page { Line 627  sub print_user_modification_page {
     }      }
 ENDSCRIPT  ENDSCRIPT
     } else {      } else {
         $nondc_setsection_code = <<"ENDSECCODE";          $nondc_setsection_code = 
     function setSections() {              &Apache::lonuserutils::setsections_javascript('cu',$groupslist);
         var re1 = /^currsec_/;  
         var groups = new Array($groupslist);  
         for (var i=0;i<document.cu.elements.length;i++) {  
             var str = document.cu.elements[i].name;  
             var checkcurr = str.match(re1);  
             if (checkcurr != null) {  
                 if (document.cu.elements[i-1].checked == true) {  
     var match = str.split('_');  
                     var role = match[3];  
                     if (role == 'cc') {  
                         alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections.");  
                     }  
                     else {  
                         var sections = '';  
                         var numsec = 0;  
                         var sections;  
                         for (var j=0; j<document.cu.elements[i].length; j++) {  
                             if (document.cu.elements[i].options[j].selected == true ) {  
                                 if (document.cu.elements[i].options[j].value != "") {  
                                     if (numsec == 0) {  
                                         if (document.cu.elements[i].options[j].value != "") {  
                                             sections = document.cu.elements[i].options[j].value;  
                                             numsec ++;  
                                         }  
                                     }  
                                     else {  
                                         sections = sections + "," +  document.cu.elements[i].options[j].value  
                                         numsec ++;  
                                     }  
                                 }  
                             }  
                         }  
                         if (numsec > 0) {  
                             if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) {  
                                 sections = sections + "," +  document.cu.elements[i+1].value;  
                             }  
                         }  
                         else {  
                             sections = document.cu.elements[i+1].value;  
                         }  
                         var newsecs = document.cu.elements[i+1].value;  
  var numsplit;  
                         if (newsecs != null && newsecs != "") {  
                             numsplit = newsecs.split(/,/g);  
                             numsec = numsec + numsplit.length;  
                         }  
   
                         if ((role == 'st') && (numsec > 1)) {  
                             alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.")  
                             return;  
                         }  
                         else if (numsplit != null) {  
                             for (var j=0; j<numsplit.length; j++) {  
                                 if ((numsplit[j] == 'all') ||  
                                     (numsplit[j] == 'none')) {  
                                     alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");  
                                     return;  
                                 }  
                                 for (var k=0; k<groups.length; k++) {  
                                     if (numsplit[j] == groups[k]) {  
                                         alert("'"+numsplit[j]+"' may not be used as a section name, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name.");  
                                         return;  
                                     }  
                                 }  
                             }  
                         }  
                         document.cu.elements[i+2].value = sections;  
                     }  
                 }  
             }  
         }  
         document.cu.submit();  
     }  
 ENDSECCODE  
     }      }
     my $js = &user_modification_js($pjump_def,$dc_setcourse_code,      my $js = &user_modification_js($pjump_def,$dc_setcourse_code,
                                    $nondc_setsection_code,$groupslist);                                     $nondc_setsection_code,$groupslist);
Line 766  $forminfo Line 702  $forminfo
 $loginscript  $loginscript
 </script>  </script>
 <input type='hidden' name='makeuser' value='1' />  <input type='hidden' name='makeuser' value='1' />
 <h3>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h3>  <h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h2>
 ENDTITLE  ENDTITLE
         $r->print('<div class="LC_left_float">'.          $r->print('<div class="LC_left_float">'.
                   &personal_data_display($ccuname,$ccdomain,$newuser,                    &personal_data_display($ccuname,$ccdomain,$newuser,
Line 785  $lt{'hs'}: $home_server_pick Line 721  $lt{'hs'}: $home_server_pick
         $r->print('</div>'."\n".'<div class="LC_left_float"><h3>'.          $r->print('</div>'."\n".'<div class="LC_left_float"><h3>'.
                   $lt{'lg'}.'</h3>');                    $lt{'lg'}.'</h3>');
         my ($fixedauth,$varauth,$authmsg);           my ($fixedauth,$varauth,$authmsg); 
         if ($rulematch) {          if (ref($rulematch{$ccuname.':'.$ccdomain}) eq 'HASH') {
               my $matchedrule = $rulematch{$ccuname.':'.$ccdomain}{'username'};
               my ($rules,$ruleorder) = 
                   &Apache::lonnet::inst_userrules($ccdomain,'username');
             if (ref($rules) eq 'HASH') {              if (ref($rules) eq 'HASH') {
                 if (ref($rules->{$rulematch}) eq 'HASH') {                  if (ref($rules->{$matchedrule}) eq 'HASH') {
                     my $authtype = $rules->{$rulematch}{'authtype'};                      my $authtype = $rules->{$matchedrule}{'authtype'};
                     if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {                      if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {
                         $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));                          $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
                     } else {                       } else { 
                         my $authparm = $rules->{$rulematch}{'authparm'};                          my $authparm = $rules->{$matchedrule}{'authparm'};
                         if ($authtype =~ /^krb(4|5)$/) {                          if ($authtype =~ /^krb(4|5)$/) {
                             my $ver = $1;                              my $ver = $1;
                             if ($authparm ne '') {                              if ($authparm ne '') {
Line 801  $lt{'hs'}: $home_server_pick Line 740  $lt{'hs'}: $home_server_pick
 <input type="hidden" name="krbver" value="$ver" />  <input type="hidden" name="krbver" value="$ver" />
 <input type="hidden" name="krbarg" value="$authparm" />  <input type="hidden" name="krbarg" value="$authparm" />
 KERB  KERB
                                 $authmsg = $rules->{$rulematch}{'authmsg'};                                      $authmsg = $rules->{$matchedrule}{'authmsg'};    
                             }                              }
                         } else {                          } else {
                             $fixedauth =                               $fixedauth = 
 '<input type="hidden" name="login" value="'.$authtype.'" />'."\n";  '<input type="hidden" name="login" value="'.$authtype.'" />'."\n";
                             if ($rules->{$rulematch}{'authparmfixed'}) {                              if ($rules->{$matchedrule}{'authparmfixed'}) {
                                 $fixedauth .=                                      $fixedauth .=    
 '<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n";  '<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n";
                             } else {                              } else {
Line 846  $forminfo Line 785  $forminfo
 ENDCHANGEUSER  ENDCHANGEUSER
         $r->print('<div class="LC_left_float">'.          $r->print('<div class="LC_left_float">'.
                   &personal_data_display($ccuname,$ccdomain,$newuser,                    &personal_data_display($ccuname,$ccdomain,$newuser,
                                          %inst_results).                                           %inst_results));
                   '</div>');          if ($context eq 'domain') {
               $r->print(&Apache::lonuserutils::forceid_change($context));
           }
           $r->print('</div>');
         my $user_auth_text =           my $user_auth_text = 
             &user_authentication($ccuname,$ccdomain,$krbdefdom,\%abv_auth);              &user_authentication($ccuname,$ccdomain,$krbdefdom,\%abv_auth);
         my $user_quota_text;          my $user_quota_text;
Line 1198  ENDNOPORTPRIV Line 1140  ENDNOPORTPRIV
         }          }
     } else {      } else {
         $r->print(&course_level_table(%inccourses));          $r->print(&course_level_table(%inccourses));
         $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setSections()" />'."\n");          $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setSections(this.form)" />'."\n");
     }      }
     $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));      $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));
     $r->print('<input type="hidden" name="currstate" value="" />');      $r->print('<input type="hidden" name="currstate" value="" />');
Line 1255  $lt{'uuas'} ($currentauth). $lt{'adcs'}. Line 1197  $lt{'uuas'} ($currentauth). $lt{'adcs'}.
 ENDBADAUTH  ENDBADAUTH
         }          }
     } else { # Authentication type is valid      } else { # Authentication type is valid
         my $authformcurrent='';  
         my $authform_other='';  
         &initialize_authen_forms($ccdomain,$currentauth);          &initialize_authen_forms($ccdomain,$currentauth);
           my $authformnop_row;      
           if (&Apache::lonnet::allowed('mau',$ccdomain)) {
               $authformnop_row = &Apache::loncommon::start_data_table_row();
           }
         my ($authformcurrent,$authform_other,$can_modify) =          my ($authformcurrent,$authform_other,$can_modify) =
             &modify_login_block($ccdomain,$currentauth);              &modify_login_block($ccdomain,$currentauth);
         if (&Apache::lonnet::allowed('mau',$ccdomain)) {          if (&Apache::lonnet::allowed('mau',$ccdomain)) {
Line 1273  ENDBADAUTH Line 1217  ENDBADAUTH
                        '</script>'."\n".                         '</script>'."\n".
                        '<h3>'.$lt{'ld'}.'</h3>'.                         '<h3>'.$lt{'ld'}.'</h3>'.
                        &Apache::loncommon::start_data_table().                         &Apache::loncommon::start_data_table().
                        &Apache::loncommon::start_data_table_row().                         $authformnop_row.
                        '<td>'.$authformnop;                         '<td>'.$authformnop;
             if ($can_modify) {              if ($can_modify) {
                 $outcome .= '</td>'."\n".                  $outcome .= '</td>'."\n".
Line 1282  ENDBADAUTH Line 1226  ENDBADAUTH
                             '<td>'.$authformcurrent.'</td>'.                              '<td>'.$authformcurrent.'</td>'.
                             &Apache::loncommon::end_data_table_row()."\n";                              &Apache::loncommon::end_data_table_row()."\n";
             } else {              } else {
                 $outcome .= '&nbsp;('.$authformcurrent.')</td>';                  $outcome .= '&nbsp;('.$authformcurrent.')</td>'.
                               &Apache::loncommon::end_data_table_row()."\n";
             }              }
             if ($authform_other ne '') {              if ($authform_other ne '') {
                 $outcome .= $authform_other;                  $outcome .= $authform_other;
Line 1450  sub update_user_data { Line 1395  sub update_user_data {
                                           $env{'form.ccdomain'});                                            $env{'form.ccdomain'});
     # Error messages      # Error messages
     my $error     = '<span class="LC_error">'.&mt('Error').': ';      my $error     = '<span class="LC_error">'.&mt('Error').': ';
     my $end       = '</span><br /><br />'.      my $end       = '</span><br /><br />';
                     '<a href="javascript:backPage(document.userupdate,'.      my $rtnlink   = '<a href="javascript:backPage(document.userupdate,'.
                     "'$env{'form.prevphase'}','modify')".'" />'.                      "'$env{'form.prevphase'}','modify')".'" />'.
                     &mt('Return to previous page').'</a>'.&Apache::loncommon::end_page();                      &mt('Return to previous page').'</a>'.&Apache::loncommon::end_page();
     my $title;      my $title;
Line 1489  sub update_user_data { Line 1434  sub update_user_data {
     $r->print(&update_result_form($uhome));      $r->print(&update_result_form($uhome));
     # Check Inputs      # Check Inputs
     if (! $env{'form.ccuname'} ) {      if (! $env{'form.ccuname'} ) {
  $r->print($error.&mt('No login name specified').'.'.$end);   $r->print($error.&mt('No login name specified').'.'.$end.$rtnlink);
  return;   return;
     }      }
     if (  $env{'form.ccuname'} ne       if (  $env{'form.ccuname'} ne 
   &LONCAPA::clean_username($env{'form.ccuname'}) ) {    &LONCAPA::clean_username($env{'form.ccuname'}) ) {
  $r->print($error.&mt('Invalid login name').'.  '.   $r->print($error.&mt('Invalid login name').'.  '.
   &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'.    &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'.
   $end);    $end.$rtnlink);
  return;   return;
     }      }
     if (! $env{'form.ccdomain'}       ) {      if (! $env{'form.ccdomain'}       ) {
  $r->print($error.&mt('No domain specified').'.'.$end);   $r->print($error.&mt('No domain specified').'.'.$end.$rtnlink);
  return;   return;
     }      }
     if (  $env{'form.ccdomain'} ne      if (  $env{'form.ccdomain'} ne
   &LONCAPA::clean_domain($env{'form.ccdomain'}) ) {    &LONCAPA::clean_domain($env{'form.ccdomain'}) ) {
  $r->print($error.&mt ('Invalid domain name').'.  '.   $r->print($error.&mt ('Invalid domain name').'.  '.
   &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.    &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.
   $end);    $end.$rtnlink);
  return;   return;
     }      }
     if (! exists($env{'form.makeuser'})) {      if (! exists($env{'form.makeuser'})) {
Line 1543  sub update_user_data { Line 1488  sub update_user_data {
         # If they are creating a new user but have not specified login          # If they are creating a new user but have not specified login
         # information this will be caught below.          # information this will be caught below.
     } else {      } else {
     $r->print($error.&mt('Invalid login mode or password').$end);          $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);    
     return;      return;
     }      }
   
   
     $r->print('<h3>'.&mt('User [_1] in domain [_2]',      $r->print('<h3>'.&mt('User [_1] in domain [_2]',
  $env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>');   $env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>');
       my (%alerts,%rulematch,%inst_results,%curr_rules);
     if ($env{'form.makeuser'}) {      if ($env{'form.makeuser'}) {
  $r->print('<h3>'.&mt('Creating new account.').'</h3>');   $r->print('<h3>'.&mt('Creating new account.').'</h3>');
         # Check for the authentication mode and password          # Check for the authentication mode and password
         if (! $amode || ! $genpwd) {          if (! $amode || ! $genpwd) {
     $r->print($error.&mt('Invalid login mode or password').$end);          $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);    
     return;      return;
  }   }
         # Determine desired host          # Determine desired host
Line 1566  sub update_user_data { Line 1511  sub update_user_data {
             my %home_servers =               my %home_servers = 
  &Apache::lonnet::get_servers($env{'form.ccdomain'},'library');   &Apache::lonnet::get_servers($env{'form.ccdomain'},'library');
             if (! exists($home_servers{$desiredhost})) {              if (! exists($home_servers{$desiredhost})) {
                 $r->print($error.&mt('Invalid home server specified'));                  $r->print($error.&mt('Invalid home server specified').$end.$rtnlink);
                 return;                  return;
             }              }
         }          }
           # Check ID format
           my %checkhash;
           my %checks = ('id' => 1);
           %{$checkhash{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}} = (
               'newuser' => 1, 
               'id' => $env{'form.cid'},
           );
           if ($env{'form.cid'} ne '') {
               &Apache::loncommon::user_rule_check(\%checkhash,\%checks,\%alerts,
                                             \%rulematch,\%inst_results,\%curr_rules);
               if (ref($alerts{'id'}) eq 'HASH') {
                   if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') {
                       my $domdesc =
                           &Apache::lonnet::domain($env{'form.ccdomain'},'description');
                       if ($alerts{'id'}{$env{'form.ccdomain'}}{$env{'form.cid'}}) {
                           my $userchkmsg;
                           if (ref($curr_rules{$env{'form.ccdomain'}}) eq 'HASH') {
                               $userchkmsg  = 
                                   &Apache::loncommon::instrule_disallow_msg('id',
                                                                       $domdesc,1).
                                   &Apache::loncommon::user_rule_formats($env{'form.ccdomain'},
                                       $domdesc,$curr_rules{$env{'form.ccdomain'}}{'id'},'id');
                           }
                           $r->print($error.&mt('Invalid ID format').$end.
                                     $userchkmsg.$rtnlink);
                           return;
                       }
                   }
               }
           }
  # Call modifyuser   # Call modifyuser
  my $result = &Apache::lonnet::modifyuser   my $result = &Apache::lonnet::modifyuser
     ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},      ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'},
              $amode,$genpwd,$env{'form.cfirstname'},               $amode,$genpwd,$env{'form.cfirstname'},
              $env{'form.cmiddlename'},$env{'form.clastname'},               $env{'form.cmiddlename'},$env{'form.clastname'},
              $env{'form.cgeneration'},undef,$desiredhost,               $env{'form.cgeneration'},undef,$desiredhost,
Line 1586  sub update_user_data { Line 1561  sub update_user_data {
              ($env{'form.login'} ne ''        )) {               ($env{'form.login'} ne ''        )) {
  # Modify user privileges   # Modify user privileges
         if (! $amode || ! $genpwd) {          if (! $amode || ! $genpwd) {
     $r->print($error.'Invalid login mode or password'.$end);          $r->print($error.'Invalid login mode or password'.$end.$rtnlink);    
     return;      return;
  }   }
  # Only allow authentification modification if the person has authority   # Only allow authentification modification if the person has authority
Line 1599  sub update_user_data { Line 1574  sub update_user_data {
   ($env{'form.ccuname'},$env{'form.ccdomain'}));    ($env{'form.ccuname'},$env{'form.ccdomain'}));
  } else {   } else {
     # Okay, this is a non-fatal error.      # Okay, this is a non-fatal error.
     $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.');          $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);    
  }   }
     }      }
     ##      ##
Line 1607  sub update_user_data { Line 1582  sub update_user_data {
         # Check for need to change          # Check for need to change
         my %userenv = &Apache::lonnet::get          my %userenv = &Apache::lonnet::get
             ('environment',['firstname','middlename','lastname','generation',              ('environment',['firstname','middlename','lastname','generation',
              'permanentemail','portfolioquota','inststatus'],               'id','permanentemail','portfolioquota','inststatus'],
               $env{'form.ccdomain'},$env{'form.ccuname'});                $env{'form.ccdomain'},$env{'form.ccuname'});
         my ($tmp) = keys(%userenv);          my ($tmp) = keys(%userenv);
         if ($tmp =~ /^(con_lost|error)/i) {           if ($tmp =~ /^(con_lost|error)/i) { 
             %userenv = ();              %userenv = ();
         }          }
         # Check to see if we need to change user information          # Check to see if we need to change user information
         foreach my $item ('firstname','middlename','lastname','generation','permanentemail') {          foreach my $item ('firstname','middlename','lastname','generation','permanentemail','id') {
             # Strip leading and trailing whitespace              # Strip leading and trailing whitespace
             $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g;               $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g;
           }
           # 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 (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules);
           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'};
               }
           }
           if ($env{'form.cid'} ne $userenv{'id'}) {
               my $checkhash;
               my $checks = { 'id' => 1 };
               $checkhash->{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}} = 
                      { 'newuser' => $newuser,
                        'id'  => $env{'form.cid'}, 
                      };
               &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'}{$env{'form.ccdomain'}}) eq 'HASH') {
                      $env{'form.cid'} = $userenv{'id'};
                   }
               }
         }          }
         my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota,          my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota,
             $inststatus,$isdefault,$defquotatext);              $inststatus,$isdefault,$defquotatext);
Line 1673  sub update_user_data { Line 1677  sub update_user_data {
              $env{'form.cmiddlename'} ne $userenv{'middlename'} ||               $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
              $env{'form.clastname'}   ne $userenv{'lastname'}   ||               $env{'form.clastname'}   ne $userenv{'lastname'}   ||
              $env{'form.cgeneration'} ne $userenv{'generation'} ||               $env{'form.cgeneration'} ne $userenv{'generation'} ||
                $env{'form.cid'} ne $userenv{'id'}                 ||
              $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} )) {               $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} )) {
             $namechanged = 1;              $namechanged = 1;
         }          }
Line 1682  sub update_user_data { Line 1687  sub update_user_data {
             $changeHash{'middlename'} = $env{'form.cmiddlename'};              $changeHash{'middlename'} = $env{'form.cmiddlename'};
             $changeHash{'lastname'}   = $env{'form.clastname'};              $changeHash{'lastname'}   = $env{'form.clastname'};
             $changeHash{'generation'} = $env{'form.cgeneration'};              $changeHash{'generation'} = $env{'form.cgeneration'};
               $changeHash{'id'}         = $env{'form.cid'};
             $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};              $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
             my $putresult = &Apache::lonnet::put              my $putresult = &Apache::lonnet::put
                 ('environment',\%changeHash,                  ('environment',\%changeHash,
Line 1694  sub update_user_data { Line 1700  sub update_user_data {
                              'mddl' => "middle",                               'mddl' => "middle",
                              'lst'  => "last",                               'lst'  => "last",
      'gen'  => "generation",       'gen'  => "generation",
                                'id'   => "ID/Student number",
                              'mail' => "permanent e-mail",                               'mail' => "permanent e-mail",
                              'disk' => "disk space allocated to portfolio files",                               'disk' => "disk space allocated to portfolio files",
                              'prvs' => "Previous",                               'prvs' => "Previous",
                              'chto' => "Changed To"                               'chto' => "Changed To"
    );     );
                   $r->print('<h4>'.$lt{'uic'}.'</h4>'.
                             &Apache::loncommon::start_data_table().
                             &Apache::loncommon::start_data_table_header_row());
                 $r->print(<<"END");                  $r->print(<<"END");
 <table border="2">      <th>&nbsp;</th>
 <caption>$lt{'uic'}</caption>  
 <tr><th>&nbsp;</th>  
     <th>$lt{'frst'}</th>      <th>$lt{'frst'}</th>
     <th>$lt{'mddl'}</th>      <th>$lt{'mddl'}</th>
     <th>$lt{'lst'}</th>      <th>$lt{'lst'}</th>
     <th>$lt{'gen'}</th>      <th>$lt{'gen'}</th>
       <th>$lt{'id'}</th>
     <th>$lt{'mail'}</th>      <th>$lt{'mail'}</th>
     <th>$lt{'disk'}</th></tr>      <th>$lt{'disk'}</th>
 <tr><td>$lt{'prvs'}</td>  END
                   $r->print(&Apache::loncommon::end_data_table_header_row().
                             &Apache::loncommon::start_data_table_row());
                   $r->print(<<"END");
       <td><b>$lt{'prvs'}</b></td>
     <td>$userenv{'firstname'}  </td>      <td>$userenv{'firstname'}  </td>
     <td>$userenv{'middlename'} </td>      <td>$userenv{'middlename'} </td>
     <td>$userenv{'lastname'}   </td>      <td>$userenv{'lastname'}   </td>
     <td>$userenv{'generation'} </td>      <td>$userenv{'generation'} </td>
       <td>$userenv{'id'}</td>
     <td>$userenv{'permanentemail'} </td>      <td>$userenv{'permanentemail'} </td>
     <td>$oldportfolioquota Mb</td>      <td>$oldportfolioquota Mb</td>
 </tr>  END
 <tr><td>$lt{'chto'}</td>                  $r->print(&Apache::loncommon::end_data_table_row().
                             &Apache::loncommon::start_data_table_row());
                   $r->print(<<"END");
       <td><b>$lt{'chto'}</b></td>
     <td>$env{'form.cfirstname'}  </td>      <td>$env{'form.cfirstname'}  </td>
     <td>$env{'form.cmiddlename'} </td>      <td>$env{'form.cmiddlename'} </td>
     <td>$env{'form.clastname'}   </td>      <td>$env{'form.clastname'}   </td>
     <td>$env{'form.cgeneration'} </td>      <td>$env{'form.cgeneration'} </td>
       <td>$env{'form.cid'} </td>
     <td>$env{'form.cpermanentemail'} </td>      <td>$env{'form.cpermanentemail'} </td>
     <td>$newportfolioquota Mb $defquotatext </td></tr>      <td>$newportfolioquota Mb $defquotatext </td>
 </table>  
 END  END
                   $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 = 
                               &Apache::lonuserutils::propagate_id_change(
                                   $env{'form.ccuname'},$env{'form.ccdomain'},
                                   \%userupdate);
                           $r->print('<br />'.$idresult.'<br />');
                       }
                   }
                 if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&                   if (($env{'form.ccdomain'} eq $env{'user.domain'}) && 
                     ($env{'form.ccuname'} eq $env{'user.name'})) {                      ($env{'form.ccuname'} eq $env{'user.name'})) {
                     my %newenvhash;                      my %newenvhash;
Line 1749  END Line 1787  END
             # They did not want to change the users name but we can              # They did not want to change the users name but we can
             # still tell them what the name is              # still tell them what the name is
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
                              'id'   => "ID/Student number",
                            'mail' => "Permanent e-mail",                             'mail' => "Permanent e-mail",
                            'disk' => "Disk space allocated to user's portfolio files",                             'disk' => "Disk space allocated to user's portfolio files",
        );         );
             $r->print(<<"END");              $r->print(<<"END");
 <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}&nbsp;&nbsp;($lt{'mail'}: $userenv{'permanentemail'})</h4>  <h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
 END  END
               if ($userenv{'permanentemail'} eq '') {
                   $r->print('</h4>');
               } else {
                   $r->print('&nbsp;&nbsp;('.$lt{'mail'}.': '.
                             $userenv{'permanentemail'}.')</h4>');
               }
             if ($putresult eq 'ok') {              if ($putresult eq 'ok') {
                 if ($oldportfolioquota != $newportfolioquota) {                  if ($oldportfolioquota != $newportfolioquota) {
                     $r->print('<h4>'.$lt{'disk'}.': '.$newportfolioquota.' Mb '.                       $r->print('<h4>'.$lt{'disk'}.': '.$newportfolioquota.' Mb '. 
Line 1766  END Line 1811  END
     }      }
     ##      ##
     my $now=time;      my $now=time;
       my $rolechanges = 0;
     $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 1782  END Line 1828  END
         $r->print(&mt('Revoking [_1] in [_2]: [_3]',          $r->print(&mt('Revoking [_1] in [_2]: [_3]',
       $role,$scope,'<b>'.$result.'</b>').'<br />');        $role,$scope,'<b>'.$result.'</b>').'<br />');
  if ($role eq 'st') {   if ($role eq 'st') {
     my $result = &classlist_drop($scope,$env{'form.ccuname'},      my $result = 
  $env{'form.ccdomain'},$now);                          &Apache::lonuserutils::classlist_drop($scope,
                               $env{'form.ccuname'},$env{'form.ccdomain'},
       $now);
     $r->print($result);      $r->print($result);
  }   }
     }       }
     if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$ }s) {      if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}s) {
 # Revoke custom role  # Revoke custom role
  $r->print(&mt('Revoking custom role:').   $r->print(&mt('Revoking custom role:').
                       ' '.$4.' by '.$3.':'.$2.' in '.$1.': <b>'.                        ' '.$4.' by '.$3.':'.$2.' in '.$1.': <b>'.
Line 1795  END Line 1843  END
   $env{'form.ccuname'},$1,$2,$3,$4).    $env{'form.ccuname'},$1,$2,$3,$4).
  '</b><br />');   '</b><br />');
     }      }
               $rolechanges ++;
  } elsif ($key=~/^form\.del/) {   } elsif ($key=~/^form\.del/) {
     if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {      if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
 # Delete standard role  # Delete standard role
Line 1806  END Line 1855  END
         $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,          $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,
       '<b>'.$result.'</b>').'<br />');        '<b>'.$result.'</b>').'<br />');
  if ($role eq 'st') {   if ($role eq 'st') {
     my $result = &classlist_drop($scope,$env{'form.ccuname'},      my $result = 
  $env{'form.ccdomain'},$now);                          &Apache::lonuserutils::classlist_drop($scope,
                               $env{'form.ccuname'},$env{'form.ccdomain'},
       $now);
     $r->print($result);      $r->print($result);
  }   }
             }              }
Line 1820  END Line 1871  END
                          $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,                           $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
                          0,1).'</b><br />');                           0,1).'</b><br />');
             }              }
               $rolechanges ++;
  } elsif ($key=~/^form\.ren/) {   } elsif ($key=~/^form\.ren/) {
             my $udom = $env{'form.ccdomain'};              my $udom = $env{'form.ccdomain'};
             my $uname = $env{'form.ccuname'};              my $uname = $env{'form.ccuname'};
Line 1858  END Line 1910  END
                 $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>',                  $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>',
                           $rolename,$rnam,$rdom,$url,$result).'<br />');                            $rolename,$rnam,$rdom,$url,$result).'<br />');
             }              }
               $rolechanges ++;
  } elsif ($key=~/^form\.act/) {   } elsif ($key=~/^form\.act/) {
             my $udom = $env{'form.ccdomain'};              my $udom = $env{'form.ccdomain'};
             my $uname = $env{'form.ccuname'};              my $uname = $env{'form.ccuname'};
Line 1971  END Line 2024  END
                 }                  }
                 $r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />');                  $r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />');
             }              }
               $rolechanges ++;
  }   }
     } # End of foreach (keys(%env))      } # End of foreach (keys(%env))
 # Flush the course logs so reverse user roles immediately updated  # Flush the course logs so reverse user roles immediately updated
     &Apache::lonnet::flushcourselogs();      &Apache::lonnet::flushcourselogs();
       if (!$rolechanges) {
           $r->print(&mt('No roles to modify'));
       }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
 }  }
   
Line 2000  sub update_result_form { Line 2057  sub update_result_form {
     return $outcome;      return $outcome;
 }  }
   
 sub classlist_drop {  
     my ($scope,$uname,$udom,$now) = @_;  
     my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)});  
     my $cid=$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'});  
  return &mt('Drop from classlist: [_1]',  
    '<b>'.$result.'</b>').'<br />';  
     }  
 }  
   
 sub active_student_roles {  
     my ($cnum,$cdom,$uname,$udom) = @_;  
     my %roles =   
  &Apache::lonnet::get_my_roles($uname,$udom,'userroles',  
       ['future','active'],['st']);  
     return exists($roles{"$cnum:$cdom:st"});  
 }  
   
 sub quota_admin {  sub quota_admin {
     my ($setquota,$changeHash) = @_;      my ($setquota,$changeHash) = @_;
     my $quotachanged;      my $quotachanged;
Line 2372  sub handler { Line 2405  sub handler {
         $context = 'domain';          $context = 'domain';
     }      }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['action','state']);          ['action','state','callingform','roletype','showrole','bulkaction']);
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb      if ($env{'form.action'} ne 'dateselect') {
         ({href=>"/adm/createuser",          &Apache::lonhtmlcommon::add_breadcrumb
           text=>"User Management"});              ({href=>"/adm/createuser",
                 text=>"User Management"});
       }
     my ($permission,$allowed) = &get_permission($context);      my ($permission,$allowed) = &get_permission($context);
     if (!$allowed) {      if (!$allowed) {
         $env{'user.error.msg'}=          $env{'user.error.msg'}=
Line 2426  sub handler { Line 2461  sub handler {
         if (! exists($env{'form.state'})) {          if (! exists($env{'form.state'})) {
             &Apache::lonuserutils::print_expire_menu($r,$context);              &Apache::lonuserutils::print_expire_menu($r,$context);
         } elsif ($env{'form.state'} eq 'done') {          } elsif ($env{'form.state'} eq 'done') {
             &Apache::lonuserutils::expire_user_list($r);              &Apache::lonuserutils::expire_user_list($r,$context);
         } else {          } else {
             &Apache::lonuserutils::print_expire_menu($r,$context);              &Apache::lonuserutils::print_expire_menu($r,$context);
         }          }
Line 2434  sub handler { Line 2469  sub handler {
     } elsif ($env{'form.action'} eq 'singleuser' && $permission->{'cusr'}) {      } elsif ($env{'form.action'} eq 'singleuser' && $permission->{'cusr'}) {
         my $phase = $env{'form.phase'};          my $phase = $env{'form.phase'};
         my @search = ('srchterm','srchby','srchin','srchtype','srchdomain');          my @search = ('srchterm','srchby','srchin','srchtype','srchdomain');
    &Apache::loncreateuser::restore_prev_selections();
    my $srch;
    foreach my $item (@search) {
       $srch->{$item} = $env{'form.'.$item};
    }
   
         if (($phase eq 'get_user_info') || ($phase eq 'userpicked')) {          if (($phase eq 'get_user_info') || ($phase eq 'userpicked')) {
             my $srch;  
             foreach my $item (@search) {  
                 $srch->{$item} = $env{'form.'.$item};  
             }  
             if ($env{'form.phase'} eq 'get_user_info') {              if ($env{'form.phase'} eq 'get_user_info') {
                 my ($currstate,$response,$forcenewuser,$results) =                   my ($currstate,$response,$forcenewuser,$results) = 
                     &user_search_result($srch);                      &user_search_result($srch);
Line 2465  sub handler { Line 2501  sub handler {
                         $response = '';                          $response = '';
                     }                      }
                     &print_user_modification_page($r,$ccuname,$ccdomain,                      &print_user_modification_page($r,$ccuname,$ccdomain,
                                                   $srch,$response);                                                    $srch,$response,$context);
                 } elsif ($currstate eq 'query') {                  } elsif ($currstate eq 'query') {
                     &print_user_query_page($r,'createuser');                      &print_user_query_page($r,'createuser');
                 } else {                  } else {
Line 2475  sub handler { Line 2511  sub handler {
             } elsif ($env{'form.phase'} eq 'userpicked') {              } elsif ($env{'form.phase'} eq 'userpicked') {
                 my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});                  my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});
                 my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});                  my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});
                 &print_user_modification_page($r,$ccuname,$ccdomain,$srch);                  &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
                                                 $context);
             }              }
         } elsif ($env{'form.phase'} eq 'update_user_data') {          } elsif ($env{'form.phase'} eq 'update_user_data') {
             &update_user_data($r);              &update_user_data($r);
         } else {          } else {
             &print_username_entry_form($r);              &print_username_entry_form($r,undef,$srch);
         }          }
     } elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {      } elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
         if ($env{'form.phase'} eq 'set_custom_roles') {          if ($env{'form.phase'} eq 'set_custom_roles') {
Line 2489  sub handler { Line 2526  sub handler {
             &custom_role_editor($r);              &custom_role_editor($r);
         }          }
     } elsif ($env{'form.action'} eq 'listusers' && $permission->{'view'}) {      } elsif ($env{'form.action'} eq 'listusers' && $permission->{'view'}) {
         my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);          if ($env{'form.phase'} eq 'bulkchange') {
         my $formname = 'studentform';              &Apache::lonhtmlcommon::add_breadcrumb
         if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {                  ({href=>'backPage(document.studentform)',
             ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) =                     text=>"List Users"});
                 &Apache::lonuserutils::courses_selector($env{'request.role.domain'},              my $setting = $env{'form.roletype'};
                                                         $formname);              my $choice = $env{'form.bulkaction'};
             my $js = &add_script($jscript).$cb_jscript;              $r->print(&header());
             my $loadcode =               $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
                 &Apache::lonuserutils::course_selector_loadcode($formname);                                                            'User_Management_List'));
             if ($loadcode ne '') {              if ($permission->{'cusr'}) {
                 $r->print(&header($js,{'onload' => $loadcode,}));                  &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 {              } else {
                 $r->print(&header($js));                  $r->print(&header(&add_script(&verify_user_display())));
             }              }
         } else {              $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
             $r->print(&header());                                                            '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'}) {      } elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) {
         $r->print(&header());          $r->print(&header());
         &Apache::lonhtmlcommon::add_breadcrumb          &Apache::lonhtmlcommon::add_breadcrumb
Line 2524  sub handler { Line 2576  sub handler {
         if (! exists($env{'form.state'})) {          if (! exists($env{'form.state'})) {
             &Apache::lonuserutils::print_expire_menu($r,$context);              &Apache::lonuserutils::print_expire_menu($r,$context);
         } elsif ($env{'form.state'} eq 'done') {          } elsif ($env{'form.state'} eq 'done') {
             &Apache::lonuserutiles::expire_user_list($r);              &Apache::lonuserutiles::expire_user_list($r,$context);
         } else {          } else {
             &print_expire_menu($r,$context);              &print_expire_menu($r,$context);
         }          }
         $r->print(&Apache::loncommon::end_page());          $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().
                        '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>'. 
                        &Apache::loncommon::end_page());
           }
     } else {      } else {
         $r->print(&header());          $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());          $r->print(&Apache::loncommon::end_page());
     }      }
     return OK;      return OK;
 }  }
   
 sub header {  sub header {
     my ($jscript,$loaditems) = @_;      my ($jscript,$loaditems,$args) = @_;
     my $start_page;      my $start_page;
     if (ref($loaditems) eq 'HASH') {      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 {      } else {
         $start_page=&Apache::loncommon::start_page('User Management',$jscript);          $start_page=&Apache::loncommon::start_page('User Management',$jscript,$args);
     }      }
     return $start_page;      return $start_page;
 }  }
Line 2553  sub add_script { Line 2616  sub add_script {
     return '<script type="text/javascript">'."\n".$js."\n".'</script>';      return '<script type="text/javascript">'."\n".$js."\n".'</script>';
 }  }
   
   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  #  Menu Phase One
Line 2777  sub user_search_result { Line 2854  sub user_search_result {
  {&Apache::lonnet::get('environment',   {&Apache::lonnet::get('environment',
      ['firstname',       ['firstname',
       'lastname',        'lastname',
       'permanentemail'])};        'permanentemail'],
         $cudomain,$cuname)};
                                 }                                  }
                             }                              }
                         }                          }
Line 3126  sub course_level_table { Line 3204  sub course_level_table {
 <td>'.$area.'<br />Domain: '.$domain.'</td>'."\n";  <td>'.$area.'<br />Domain: '.$domain.'</td>'."\n";
         if ($role ne 'cc') {          if ($role ne 'cc') {
                     if (%sections_count) {                      if (%sections_count) {
                         my $currsec = &course_sections(\%sections_count,$protectedcourse.'_'.$role);                          my $currsec = 
                               &Apache::lonuserutils::course_sections(\%sections_count,
                                                           $protectedcourse.'_'.$role);
                         $table .=                           $table .= 
                     '<td><table class="LC_createuser">'.                      '<td><table class="LC_createuser">'.
                      '<tr class="LC_section_row">                       '<tr class="LC_section_row">
Line 3166  ENDTIMEENTRY Line 3246  ENDTIMEENTRY
 <td>'.$plrole.'</td>  <td>'.$plrole.'</td>
 <td>'.$area.'</td>'."\n";  <td>'.$area.'</td>'."\n";
                 if (%sections_count) {                  if (%sections_count) {
                     my $currsec = &course_sections(\%sections_count,$customrole);                      my $currsec = 
                           &Apache::lonuserutils::course_sections(\%sections_count,
                                                                  $customrole);
                     $table.=                      $table.=
                    '<td><table class="LC_createuser">'.                     '<td><table class="LC_createuser">'.
                    '<tr class="LC_section_row"><td valign="top">'.                     '<tr class="LC_section_row"><td valign="top">'.
Line 3210  $table. Line 3292  $table.
     return $result;      return $result;
 }  }
   
 sub course_sections {  
     my ($sections_count,$role) = @_;  
     my $output = '';  
     my @sections = (sort {$a <=> $b} keys %{$sections_count});  
     if (scalar(@sections) == 1) {  
         $output = '<select name="currsec_'.$role.'" >'."\n".  
                   '  <option value="">Select</option>'."\n".  
                   '  <option value="">No section</option>'."\n".  
                   '  <option value="'.$sections[0].'" >'.$sections[0].'</option>'."\n";  
     } else {  
         $output = '<select name="currsec_'.$role.'" ';  
         my $multiple = 4;  
         if (scalar(@sections) < 4) { $multiple = scalar(@sections); }  
         $output .= 'multiple="multiple" size="'.$multiple.'">'."\n";  
         foreach my $sec (@sections) {  
             $output .= '<option value="'.$sec.'">'.$sec."</option>\n";  
         }  
     }  
     $output .= '</select>';   
     return $output;  
 }  
   
 sub course_level_dc {  sub course_level_dc {
     my ($dcdom) = @_;      my ($dcdom) = @_;
     my %customroles=&Apache::lonuserutils::my_custom_roles();      my %customroles=&Apache::lonuserutils::my_custom_roles();

Removed from v.1.191  
changed lines
  Added in v.1.203


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>