Diff for /loncom/interface/Attic/londropadd.pm between versions 1.149 and 1.150

version 1.149, 2006/11/23 00:17:01 version 1.150, 2006/11/23 03:17:17
Line 60  sub modifystudent { Line 60  sub modifystudent {
     # if $csec is undefined, drop the student from all the courses matching      # if $csec is undefined, drop the student from all the courses matching
     # this one.  If $csec is defined, drop them from all other sections of       # this one.  If $csec is defined, drop them from all other sections of 
     # this course and add them to section $csec      # this course and add them to section $csec
     $courseid=~s/\_/\//g;      my $cdom = $env{'request.'.$courseid.'.domain'};
     $courseid=~s/^(\w)/\/$1/;      my $cnum = $env{'request.'.$courseid.'.num'};
     my %roles = &Apache::lonnet::dump('roles',$udom,$unam);      my %roles = &Apache::lonnet::dump('roles',$udom,$unam);
     my ($tmp) = keys(%roles);      my ($tmp) = keys(%roles);
     # Bail out if we were unable to get the students roles      # Bail out if we were unable to get the students roles
Line 69  sub modifystudent { Line 69  sub modifystudent {
     # Go through the roles looking for enrollment in this course      # Go through the roles looking for enrollment in this course
     my $result = '';      my $result = '';
     foreach my $course (keys(%roles)) {      foreach my $course (keys(%roles)) {
         if ($course=~/^$courseid(?:\/)*(?:\s+)*(\w+)*\_st$/) {          if ($course=~m{^/\Q$cdom\E/\Q$cnum\E(?:\/)*(?:\s+)*(\w+)*\_st$}) {
             # We are in this course              # We are in this course
             my $section=$1;              my $section=$1;
             $section='' if ($course eq $courseid.'_st');              $section='' if ($course eq "/$cdom/$cnum".'_st');
             if (defined($csec) && $section eq $csec) {              if (defined($csec) && $section eq $csec) {
                 $result .= 'ok:';                  $result .= 'ok:';
             } elsif ( ((!$section) && (!$csec)) || ($section ne $csec) ) {              } elsif ( ((!$section) && (!$csec)) || ($section ne $csec) ) {
Line 135  sub print_main_menu { Line 135  sub print_main_menu {
     my ($r,$enrl_permission,$view_permission,$grp_manage_permission,      my ($r,$enrl_permission,$view_permission,$grp_manage_permission,
         $grp_view_permission)=@_;          $grp_view_permission)=@_;
     #      #
     my ($cdom,$cnum) = split/_/,$env{'request.course.id'};      my $cid =$env{'request.course.id'};
       my $cdom=$env{'course.'.$cid.'.domain'};
       my $cnum=$env{'course.'.$cid.'.num'};
     my @menu =       my @menu = 
         (           ( 
           { text => 'Upload a class list',             { text => 'Upload a class list', 
Line 746  sub enroll_single_student { Line 748  sub enroll_single_student {
     $r->print('<h3>'.&mt('Enrolling Student').'</h3>');      $r->print('<h3>'.&mt('Enrolling Student').'</h3>');
     $r->print('<p>'.&mt('Enrolling').' '.$env{'form.cuname'}." \@ ".      $r->print('<p>'.&mt('Enrolling').' '.$env{'form.cuname'}." \@ ".
               $env{'form.lcdomain'}.'</p>');                $env{'form.lcdomain'}.'</p>');
     if (($env{'form.cuname'})&&($env{'form.cuname'}!~/\W/)&&      if (($env{'form.cuname'})
         ($env{'form.lcdomain'})&&($env{'form.lcdomain'}!~/\W/)) {   && ($env{'form.cuname'} 
       eq &LONCAPA::clean_username($env{'form.cuname'}))
    && ($env{'form.lcdomain'})
    && ($env{'form.lcdomain'}
       eq &LONCAPA::clean_domain($env{'form.lcdomain'}))) {
         # Deal with home server selection          # Deal with home server selection
         my $domain=$env{'form.lcdomain'};          my $domain=$env{'form.lcdomain'};
         my $desiredhost = $env{'form.lcserver'};          my $desiredhost = $env{'form.lcserver'};
Line 957  sub print_enroll_single_student_form { Line 963  sub print_enroll_single_student_form {
     my $r=shift;      my $r=shift;
     $r->print("<h3>".&mt('Enroll One Student')."</h3>");      $r->print("<h3>".&mt('Enroll One Student')."</h3>");
     #      #
     my $username = $env{'form.cuname'};      my $username = &LONCAPA::clean_username($env{'form.cuname'});
     my $domain   = $env{'form.cudomain'};      my $domain   = &LONCAPA::clean_domain($env{'form.cudomain'});
     $username=~s/\W//gs;  
     $domain=~s/\W//gs;  
     my $home = &Apache::lonnet::homeserver($username,$domain);      my $home = &Apache::lonnet::homeserver($username,$domain);
     # $new_user flags whether we are creating a new user or using an old one      # $new_user flags whether we are creating a new user or using an old one
     my $new_user = 1;      my $new_user = 1;
Line 1177  sub print_html_classlist { Line 1181  sub print_html_classlist {
     }      }
     my $status_select = &Apache::lonhtmlcommon::StatusOptions      my $status_select = &Apache::lonhtmlcommon::StatusOptions
         ($env{'form.Status'});          ($env{'form.Status'});
     my $cid=$env{'request.course.id'};      my $cid =$env{'request.course.id'};
     my $cdom=$env{'course.'.$cid.'.domain'};      my $cdom=$env{'course.'.$cid.'.domain'};
     my $cnum=$env{'course.'.$cid.'.num'};      my $cnum=$env{'course.'.$cid.'.num'};
     #      #
Line 1870  END Line 1874  END
 sub get_enrollment_data {  sub get_enrollment_data {
     my ($sname,$sdomain) = @_;      my ($sname,$sdomain) = @_;
     my $courseid = $env{'request.course.id'};      my $courseid = $env{'request.course.id'};
     $courseid =~ s:_:/:g;      my $cdom = $env{'request.'.$courseid.'.domain'};
       my $cnum = $env{'request.'.$courseid.'.num'};
     my %roles = &Apache::lonnet::dump('roles',$sdomain,$sname);      my %roles = &Apache::lonnet::dump('roles',$sdomain,$sname);
     my ($tmp) = keys(%roles);      my ($tmp) = keys(%roles);
     # Bail out if we were unable to get the students roles      # Bail out if we were unable to get the students roles
Line 1880  sub get_enrollment_data { Line 1885  sub get_enrollment_data {
     my $section = '';      my $section = '';
     my $count = scalar(keys(%roles));      my $count = scalar(keys(%roles));
     while (my ($course,$role) = each(%roles)) {      while (my ($course,$role) = each(%roles)) {
         if ($course=~ /^\/$courseid\/*\s*(\w+)*_st$/ ) {          if ($course=~m{^/\Q$cdom\E/\Q$cnum\E/*\s*(\w+)*_st$} ) {
             #              #
             # Get active role              # Get active role
             $section=$1;              $section=$1;
Line 2193  sub upfile_drop_add { Line 2198  sub upfile_drop_add {
             $amode = ''; # This causes the loop below to be skipped              $amode = ''; # This causes the loop below to be skipped
         }          }
     }      }
     unless (($domain=~/\W/) || ($amode eq '')) {      if ( $domain eq &clean_domain($domain)
    && ($amode ne '')) {
         #######################################          #######################################
         ##         Enroll Students           ##          ##         Enroll Students           ##
         #######################################          #######################################
Line 2227  sub upfile_drop_add { Line 2233  sub upfile_drop_add {
                         $gen=$entries{$fields{'gen'}};                          $gen=$entries{$fields{'gen'}};
                     }                      }
                 }                  }
                 if ($entries{$fields{'username'}}=~/\W/) {                  if ($entries{$fields{'username'}}
       ne &LONCAPA::clean_username($entries{$fields{'username'}})) {
                     $r->print('<br />'.                      $r->print('<br />'.
       &mt('<b>[_1]</b>: Unacceptable username for user [_2] [_3] [_4] [_5]',        &mt('<b>[_1]</b>: Unacceptable username for user [_2] [_3] [_4] [_5]',
           $entries{$fields{'username'}},$fname,$mname,$lname,$gen).            $entries{$fields{'username'}},$fname,$mname,$lname,$gen).

Removed from v.1.149  
changed lines
  Added in v.1.150


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