Diff for /loncom/interface/loncreateuser.pm between versions 1.90 and 1.100

version 1.90, 2004/12/02 21:32:51 version 1.100, 2005/02/17 08:29:42
Line 73  my $authformint; Line 73  my $authformint;
 my $authformfsys;  my $authformfsys;
 my $authformloc;  my $authformloc;
   
 BEGIN {  sub initialize_authen_forms {
     $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;      my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/);
     my $krbdefdom=$1;      $krbdefdom= uc($krbdefdom);
     $krbdefdom=~tr/a-z/A-Z/;  
     my %param = ( formname => 'document.cu',      my %param = ( formname => 'document.cu',
                   kerb_def_dom => $krbdefdom                     kerb_def_dom => $krbdefdom 
                   );                    );
Line 123  sub print_username_entry_form { Line 122  sub print_username_entry_form {
     my $defdom=$ENV{'request.role.domain'};      my $defdom=$ENV{'request.role.domain'};
     my @domains = &Apache::loncommon::get_domains();      my @domains = &Apache::loncommon::get_domains();
     my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');      my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
       my $html=&Apache::lonxml::xmlbegin();
     my $bodytag =&Apache::loncommon::bodytag('Create Users, Change User Privileges').&Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface');      my $bodytag =&Apache::loncommon::bodytag('Create Users, Change User Privileges').&Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface');
     my $selscript=&Apache::loncommon::studentbrowser_javascript();      my $selscript=&Apache::loncommon::studentbrowser_javascript();
     my $sellink=&Apache::loncommon::selectstudent_link      my $sellink=&Apache::loncommon::selectstudent_link
Line 142  sub print_username_entry_form { Line 142  sub print_username_entry_form {
     my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');      my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
     my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles');      my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles');
     $r->print(<<"ENDDOCUMENT");      $r->print(<<"ENDDOCUMENT");
 <html>  $html
 <head>  <head>
 <title>The LearningOnline Network with CAPA</title>  <title>The LearningOnline Network with CAPA</title>
 $selscript  $selscript
Line 174  sub print_user_modification_page { Line 174  sub print_user_modification_page {
     my $ccuname=$ENV{'form.ccuname'};      my $ccuname=$ENV{'form.ccuname'};
     my $ccdomain=$ENV{'form.ccdomain'};      my $ccdomain=$ENV{'form.ccdomain'};
   
     $ccuname=~s/[\W|_]//gs;      $ccuname=~s/\W//g;
     $ccdomain=~s/[\W|_]//gs;      $ccdomain=~s/\W//g;
   
     unless (($ccuname) && ($ccdomain)) {      unless (($ccuname) && ($ccdomain)) {
  &print_username_entry_form($r);   &print_username_entry_form($r);
Line 211  sub print_user_modification_page { Line 211  sub print_user_modification_page {
                 return;                  return;
             }               } 
             var userrole = document.cu.role.options[document.cu.role.selectedIndex].value              var userrole = document.cu.role.options[document.cu.role.selectedIndex].value
             var section;              var section="";
             var numsections = 0;              var numsections = 0;
             for (var i=0; i<document.cu.currsec.length; i++) {              for (var i=0; i<document.cu.currsec.length; i++) {
                 if (document.cu.currsec.options[i].selected == true ) {                  if (document.cu.currsec.options[i].selected == true ) {
Line 272  sub print_user_modification_page { Line 272  sub print_user_modification_page {
     }      }
 ENDSCRIPT  ENDSCRIPT
     }      }
       my $html=&Apache::lonxml::xmlbegin();
     my $dochead =<<"ENDDOCHEAD";      my $dochead =<<"ENDDOCHEAD";
 <html>  $html
 <head>  <head>
 <title>The LearningOnline Network with CAPA</title>  <title>The LearningOnline Network with CAPA</title>
 <script type="text/javascript" language="Javascript">  <script type="text/javascript" language="Javascript">
Line 397  ENDFORMINFO Line 398  ENDFORMINFO
                     'lg'   => "Login Data"                      'lg'   => "Login Data"
        );         );
  my $genhelp=&Apache::loncommon::help_open_topic('Generation');   my $genhelp=&Apache::loncommon::help_open_topic('Generation');
           &initialize_authen_forms();
  $r->print(<<ENDNEWUSER);   $r->print(<<ENDNEWUSER);
 $dochead  $dochead
 <h1>$lt{'cnu'}</h1>  <h1>$lt{'cnu'}</h1>
Line 674  END Line 676  END
  $currentauth=~/^localauth:/   $currentauth=~/^localauth:/
  ) { # bad authentication scheme   ) { # bad authentication scheme
     if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {      if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
                   &initialize_authen_forms();
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash(
                                'err'   => "ERROR",                                 'err'   => "ERROR",
        'uuas'  => "This user has an unrecognized authentication scheme",         'uuas'  => "This user has an unrecognized authentication scheme",
Line 715  ENDBADAUTH Line 718  ENDBADAUTH
         } else { # Authentication type is valid          } else { # Authentication type is valid
     my $authformcurrent='';      my $authformcurrent='';
     my $authform_other='';      my $authform_other='';
               &initialize_authen_forms();
     if ($currentauth=~/^krb(4|5):/) {      if ($currentauth=~/^krb(4|5):/) {
  $authformcurrent=$authformkrb;   $authformcurrent=$authformkrb;
  $authform_other="<p>$authformint</p>\n".   $authform_other="<p>$authformint</p>\n".
Line 857  sub update_user_data { Line 861  sub update_user_data {
     my $error     = '<font color="#ff0000">'.&mt('Error').':</font>';      my $error     = '<font color="#ff0000">'.&mt('Error').':</font>';
     my $end       = '</body></html>';      my $end       = '</body></html>';
     # Print header      # Print header
       my $html=&Apache::lonxml::xmlbegin();
     $r->print(<<ENDTHREEHEAD);      $r->print(<<ENDTHREEHEAD);
 <html>  $html
 <head>  <head>
 <title>The LearningOnline Network with CAPA</title>  <title>The LearningOnline Network with CAPA</title>
 </head>  </head>
Line 1124  END Line 1129  END
  }   }
     }       } 
  } elsif ($_=~/^form\.ren/) {   } elsif ($_=~/^form\.ren/) {
               my $udom = $ENV{'form.ccdomain'};
               my $uname = $ENV{'form.ccuname'};
     if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) {      if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) {
                 my $url = $1;                  my $url = $1;
                 my $role = $2;                  my $role = $2;
Line 1131  END Line 1138  END
                 my $output;                  my $output;
                 if ($role eq 'st') {                  if ($role eq 'st') {
                     if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) {                      if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) {
                         my $result = &commit_studentrole(\$logmsg,$url,$role,$now,0,$1,$2,$3);                          my $result = &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')) {
                             $output = "Error: $result\n";                              $output = "Error: $result\n";
                         } else {                          } else {
Line 1150  END Line 1157  END
                 $r->print($output);                  $r->print($output);
     }       } 
  } elsif ($_=~/^form\.act/) {   } elsif ($_=~/^form\.act/) {
               my $udom = $ENV{'form.ccdomain'};
               my $uname = $ENV{'form.ccuname'};
     if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {      if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
                 # Activate a custom role                  # Activate a custom role
  my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);   my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
Line 1167  END Line 1176  END
                 my %sections = ();                  my %sections = ();
                 my $num_sections = &build_roles($ENV{'form.sec_'.$full},\%sections,$5);                  my $num_sections = &build_roles($ENV{'form.sec_'.$full},\%sections,$5);
                 if ($num_sections == 0) {                  if ($num_sections == 0) {
                     $r->print(&commit_customrole($url,$three,$four,$five,$start,$end));                      $r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
                 } else {                  } else {
                     foreach (sort {$a cmp $b} keys %sections) {                      foreach (sort {$a cmp $b} keys %sections) {
                         my $securl = $url.'/'.$_;                          my $securl = $url.'/'.$_;
         $r->print(&commit_customrole($securl,$three,$four,$five,$start,$end));          $r->print(&commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
                     }                      }
                 }                  }
     } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) {      } elsif ($_=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) {
  # Activate roles for sections with 3 id numbers   # Activate roles for sections with 3 id numbers
  # set start, end times, and the url for the class   # set start, end times, and the url for the class
  my ($one,$two,$three)=($1,$2,$3);   my ($one,$two,$three)=($1,$2,$3);
Line 1190  END Line 1199  END
                 my %sections = ();                  my %sections = ();
                 my $num_sections = &build_roles($ENV{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);                  my $num_sections = &build_roles($ENV{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
                 if ($num_sections == 0) {                  if ($num_sections == 0) {
                     $r->print(&commit_standardrole($url,$three,$start,$end,$one,$two,''));                      $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
                 } else {                  } else {
                     my $emptysec = 0;                      my $emptysec = 0;
                     foreach my $sec (sort {$a cmp $b} keys %sections) {                      foreach my $sec (sort {$a cmp $b} keys %sections) {
                         $sec =~ s/\W//g;                          $sec =~ s/\W//g;
                         if ($sec ne '') {                            if ($sec ne '') {  
                             my $securl = $url.'/'.$sec;                              my $securl = $url.'/'.$sec;
                             $r->print(&commit_standardrole($securl,$three,$start,$end,$one,$two,$sec));                              $r->print(&commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec));
                         } else {                          } else {
                             $emptysec = 1;                              $emptysec = 1;
                         }                          }
                     }                      }
                     if ($emptysec) {                      if ($emptysec) {
                         $r->print(&commit_standardrole($url,$three,$start,$end,$one,$two,''));                          $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
                     }                      }
                 }                   } 
     } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {      } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
Line 1220  END Line 1229  END
                 my %sections = ();                  my %sections = ();
                 my $num_sections = &build_roles($ENV{'form.sec_'.$1.'_'.$2},\%sections,$2);                  my $num_sections = &build_roles($ENV{'form.sec_'.$1.'_'.$2},\%sections,$2);
                 if ($num_sections == 0) {                  if ($num_sections == 0) {
                     $r->print(&commit_standardrole($url,$2,$start,$end,$1,undef,''));                      $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
                 } else {                  } else {
                     my $emptysec = 0;                      my $emptysec = 0;
                     foreach my $sec (sort {$a cmp $b} keys %sections) {                      foreach my $sec (sort {$a cmp $b} keys %sections) {
                         if ($sec ne '') {                          if ($sec ne '') {
                             my $securl = $url.'/'.$sec;                              my $securl = $url.'/'.$sec;
                             $r->print(&commit_standardrole($securl,$2,$start,$end,$1,undef,$sec));                              $r->print(&commit_standardrole($udom,$uname,$securl,$2,$start,$end,$1,undef,$sec));
                         } else {                          } else {
                             $emptysec = 1;                              $emptysec = 1;
                         }                          }
                     }                      }
                     if ($emptysec) {                      if ($emptysec) {
                         $r->print(&commit_standardrole($url,$2,$start,$end,$1,undef,''));                          $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
                     }                      }
                 }                  }
  # Assign the role and report it.  
  $r->print(&mt('Assigning').' '.$2.' in '.$url.': '.  
                          ($start?', '.&mt('starting').' '.localtime($start):'').  
                          ($end?', '.&mt('ending').' '.localtime($end):'').': <b>'.  
                           &Apache::lonnet::assignrole(  
                               $ENV{'form.ccdomain'},$ENV{'form.ccuname'},  
                               $url,$2,$end,$start)  
   .'</b><br>');  
     } else {      } else {
  $r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$_.'</tt></p><br>');   $r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$_.'</tt></p><br>');
             }              }
Line 1254  END Line 1255  END
 }  }
   
 sub commit_customrole {  sub commit_customrole {
     my ($url,$three,$four,$five,$end,$start) = @_;      my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_;
     my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url.      my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url.
                          ($start?', '.&mt('starting').' '.localtime($start):'').                           ($start?', '.&mt('starting').' '.localtime($start):'').
                          ($end?', ending '.localtime($end):'').': <b>'.                           ($end?', ending '.localtime($end):'').': <b>'.
               &Apache::lonnet::assigncustomrole(                &Apache::lonnet::assigncustomrole(
         $ENV{'form.ccdomain'},$ENV{'form.ccuname'},$url,$three,$four,$five,$end,$start).                   $udom,$uname,$url,$three,$four,$five,$end,$start).
               '</b><br>';                   '</b><br>';
     return $output;      return $output;
 }  }
   
 sub commit_standardrole {  sub commit_standardrole {
     my ($url,$three,$start,$end,$one,$two,$sec) = @_;      my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
     my $output;      my $output;
     my $logmsg;      my $logmsg;
     if ($three eq 'st') {      if ($three eq 'st') {
         my $result = &commit_studentrole(\$logmsg,$url,$three,$start,$end,$one,$two,$sec);          my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec);
         if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {          if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
             $output = "Error: $result\n";               $output = "Error: $result\n"; 
         } else {          } else {
Line 1280  sub commit_standardrole { Line 1281  sub commit_standardrole {
                &mt('Add to classlist').': <b>ok</b><br />';                 &mt('Add to classlist').': <b>ok</b><br />';
         }          }
     } else {      } else {
         $output = (&mt('Assigning').' '.$three.' in '.$url.          $output = &mt('Assigning').' '.$three.' in '.$url.
                ($start?', '.&mt('starting').' '.localtime($start):'').                 ($start?', '.&mt('starting').' '.localtime($start):'').
                ($end?', '.&mt('ending').' '.localtime($end):'').': <b>'.                 ($end?', '.&mt('ending').' '.localtime($end):'').': <b>'.
                &Apache::lonnet::assignrole(                 &Apache::lonnet::assignrole(
                    $ENV{'form.ccdomain'},$ENV{'form.ccuname'},                     $udom,$uname,$url,$three,$end,$start).
                    $url,$three,$end,$start).                     '</b><br>';
                    '</b><br>');  
     }      }
     return $output;      return $output;
 }  }
   
 sub commit_studentrole {  sub commit_studentrole {
     my ($logmsg,$url,$three,$start,$end,$one,$two,$sec) = @_;      my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
     my $udom = $ENV{'form.ccdomain'};  
     my $uname = $ENV{'form.ccuname'};  
     my $linefeed =  '<br />'."\n";      my $linefeed =  '<br />'."\n";
     my $result;      my $result;
     if (defined($one) && defined($two)) {      if (defined($one) && defined($two)) {
Line 1611  sub course_level_table { Line 1609  sub course_level_table {
  $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);   $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6);
  my ($domain,$cnum)=split(/\//,$thiscourse);   my ($domain,$cnum)=split(/\//,$thiscourse);
         my %sections_count = ();          my %sections_count = ();
         my $num_sections = &Apache::loncommon::get_sections($domain,$cnum,\%sections_count);          my $num_sections = 0;
           if (defined($ENV{'request.course.id'})) {
               if ($ENV{'request.course.id'} eq $domain.'_'.$cnum) {
                   $num_sections = &Apache::loncommon::get_sections($domain,$cnum,\%sections_count);
               }
           }
  foreach  ('st','ta','ep','ad','in','cc') {   foreach  ('st','ta','ep','ad','in','cc') {
     if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {      if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {
  my $plrole=&Apache::lonnet::plaintext($_);   my $plrole=&Apache::lonnet::plaintext($_);
Line 1706  sub course_sections { Line 1709  sub course_sections {
     my ($num_sections,$sections_count,$role) = @_;      my ($num_sections,$sections_count,$role) = @_;
     my $output = '';      my $output = '';
     my @sections = (sort {$a <=> $b} keys %{$sections_count});      my @sections = (sort {$a <=> $b} keys %{$sections_count});
     $output = '<select name="currsec_'.$role.'" ';      if ($num_sections == 1) {
     my $multiple = 4;          $output = '<select name="currsec_'.$role.'" >'."\n".
     if ($num_sections <4) { $multiple = $num_sections; }                    '  <option value="">Select</option>'."\n".
     $output .= '"multiple size="'.$multiple.'" >'."\n";                    '  <option value="">No section</option>'."\n".
     foreach (@sections) {                    '  <option value="'.$sections[0].'" >'.$sections[0].'</option>'."\n";
         $output .= '<option value="'.$_.'" />'.$_."\n";      } else {
           $output = '<select name="currsec_'.$role.'" ';
           my $multiple = 4;
           if ($num_sections <4) { $multiple = $num_sections; }
           $output .= '"multiple" size="'.$multiple.'">'."\n";
           foreach (@sections) {
               $output .= '<option value="'.$_.'">'.$_."</option>\n";
           }
     }      }
     $output .= '</select>';       $output .= '</select>'; 
     return $output;      return $output;

Removed from v.1.90  
changed lines
  Added in v.1.100


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