Diff for /loncom/cgi/enrollqueued.pl between versions 1.1 and 1.2

version 1.1, 2014/04/01 21:39:18 version 1.2, 2014/04/05 22:42:33
Line 79  use Apache::lonuserutils(); Line 79  use Apache::lonuserutils();
 use Apache::loncoursequeueadmin();  use Apache::loncoursequeueadmin();
 use Apache::lonlocal;  use Apache::lonlocal;
 use LONCAPA;  use LONCAPA;
   use IO::Socket;
   
 &main();  &main();
 exit 0;  exit 0;
Line 164  sub main { Line 165  sub main {
     if (ref($domconfig{'selfenrollment'}) eq 'HASH') {      if (ref($domconfig{'selfenrollment'}) eq 'HASH') {
         if (ref($domconfig{'selfenrollment'}{'validation'}) eq 'HASH') {          if (ref($domconfig{'selfenrollment'}{'validation'}) eq 'HASH') {
             if ($domconfig{'selfenrollment'}{'validation'}{'url'} =~ m{^https?://([^/]+)/}) {              if ($domconfig{'selfenrollment'}{'validation'}{'url'} =~ m{^https?://([^/]+)/}) {
                 my $validator_ip = gethostbyname($1);                  my $ip = gethostbyname($1);
                 if (($validator_ip ne '') && ($remote_ip eq $validator_ip)) {                  if ($ip ne '') {
                     $allowed = 1;                      my $validator_ip = inet_ntoa($ip);
                       if (($validator_ip ne '') && ($remote_ip eq $validator_ip)) {
                           $allowed = 1;
                       }
                   }
               } elsif ($domconfig{'selfenrollment'}{'validation'}{'url'} =~ m{^/}) {
                   if ($remote_ip ne '') {
                       if (($remote_ip eq '127.0.0.1') || ($remote_ip eq $ENV{'SERVER_ADDR'})) {
                           $allowed = 1;
                       }
                 }                  }
             }              }
         }          }
     }      }
   
     my (%params,@fields,$numrequired);      my (%params,@fields,$numrequired);
     if ($allowed ne '') {      if ($allowed) {
         &Apache::lonlocal::get_language_handle();          &Apache::lonlocal::get_language_handle();
         my ($validreq,@fields);          my ($validreq,@fields);
         if (ref($domconfig{'selfenrollment'}) eq 'HASH') {          if (ref($domconfig{'selfenrollment'}) eq 'HASH') {
             if (ref($domconfig{'selfenrollment'}{'validation'}) eq 'HASH') {              if (ref($domconfig{'selfenrollment'}{'validation'}) eq 'HASH') {
                 if (ref($domconfig{'selfenrollment'}{'validation'}{'fields'}) eq 'ARRAY') {                  if (ref($domconfig{'selfenrollment'}{'validation'}{'fields'}) eq 'ARRAY') {
                     $numrequired = @fields;                      $numrequired = scalar(@{$domconfig{'selfenrollment'}{'validation'}{'fields'}});
                     foreach my $field (@{$domconfig{'selfenrollment'}{'validation'}{'fields'}}) {                      foreach my $field (@{$domconfig{'selfenrollment'}{'validation'}{'fields'}}) {
                         $params{$field} = $query->param($field);                          $params{$field} = $query->param($field);
                         if ($field eq 'username') {                          if ($field eq 'username') {
Line 206  sub main { Line 217  sub main {
                                 $params{$field} = $query->param($field);                                  $params{$field} = $query->param($field);
                             }                              }
                         }                          }
                           if ($field eq 'description') {
                               $params{$field} = $query->param($field);
                           }
                     }                      }
                     if ($numrequired == scalar(keys(%params))) {                      if ($numrequired == scalar(keys(%params))) {
                         $validreq = 1;                          $validreq = 1;
Line 285  sub process_enrollment { Line 299  sub process_enrollment {
                 if ($requesthash{$cid}{status} eq 'pending') {                  if ($requesthash{$cid}{status} eq 'pending') {
                     my ($lonhost,$hostname,$handle);                      my ($lonhost,$hostname,$handle);
                     $lonhost = $requesthash{$cid}{'lonhost'};                      $lonhost = $requesthash{$cid}{'lonhost'};
                     if ($lonhost eq '') {                      if ($lonhost ne '') {
                         $hostname = &Apache::lonnet::hostname($lonhost);                          $hostname = &Apache::lonnet::hostname($lonhost);
                     }                      }
                     my $savedtoken = $requesthash{$cid}{'token'};                      my $savedtoken = $requesthash{$cid}{'token'};
Line 309  sub process_enrollment { Line 323  sub process_enrollment {
                                 return;                                  return;
                             }                              }
                         }                          }
                           $Apache::lonnet::env{'user.name'} = $uname;
                           $Apache::lonnet::env{'user.domain'} = $udom;
                         my $result =                          my $result =
                             &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,                              &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,
                                 undef,undef,undef,$usec,$access_end,$access_start,'selfenroll',                                  undef,undef,undef,$usec,$access_end,$access_start,'selfenroll',
                                 undef,$cid,1);                                  undef,$cid,1);
                           delete($Apache::lonnet::env{'user.name'});
                           delete($Apache::lonnet::env{'user.domain'});
                         if ($result eq 'ok') {                          if ($result eq 'ok') {
                             my %userrequest = (                              my %userrequest = (
                                 $cdom.'_'.$cnum => {                                  $cdom.'_'.$cnum => {
Line 330  sub process_enrollment { Line 348  sub process_enrollment {
 #  #
                             my @hosts = &Apache::lonnet::current_machine_ids();                              my @hosts = &Apache::lonnet::current_machine_ids();
                             if (grep(/^\Q$lonhost\E$/,@hosts) && ($handle) && ($hostname)) {                              if (grep(/^\Q$lonhost\E$/,@hosts) && ($handle) && ($hostname)) {
                                 if ($lonidsdir ne '') {                                      if ($lonidsdir ne '') {
                                     if (-e "$lonidsdir/$handle.id") {                                      if (-e "$lonidsdir/$handle.id") {
                                         my $protocol = $Apache::lonnet::protocol{$lonhost};                                          my $protocol = $Apache::lonnet::protocol{$lonhost};
                                         $protocol = 'http' if ($protocol ne 'https');                                          $protocol = 'http' if ($protocol ne 'https');
Line 338  sub process_enrollment { Line 356  sub process_enrollment {
                                     }                                      }
                                 }                                  }
                             }                              }
            
 #  #
 # otherwise point at default portal, or if non specified, at /adm/login?querystring where   # otherwise point at default portal, or if non specified, at /adm/login?querystring where 
 # querystring contains role=st./$cdom/$cnum  # querystring contains role=st./$cdom/$cnum

Removed from v.1.1  
changed lines
  Added in v.1.2


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