Diff for /loncom/interface/lonuserutils.pm between versions 1.83 and 1.84

version 1.83, 2009/03/05 23:58:00 version 1.84, 2009/03/09 05:25:40
Line 86  sub modifystudent { Line 86  sub modifystudent {
 sub modifyuserrole {  sub modifyuserrole {
     my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass,      my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass,
         $first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role,          $first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role,
         $end,$start,$checkid) = @_;          $end,$start,$checkid,$inststatus) = @_;
     my ($scope,$userresult,$authresult,$roleresult,$idresult);      my ($scope,$userresult,$authresult,$roleresult,$idresult);
     if ($setting eq 'course' || $context eq 'course') {      if ($setting eq 'course' || $context eq 'course') {
         $scope = '/'.$cid;          $scope = '/'.$cid;
Line 124  sub modifyuserrole { Line 124  sub modifyuserrole {
     $userresult =      $userresult =
         &Apache::lonnet::modifyuser($udom,$uname,$uid,$umode,$upass,$first,          &Apache::lonnet::modifyuser($udom,$uname,$uid,$umode,$upass,$first,
                                     $middle,$last,$gene,$forceid,$desiredhome,                                      $middle,$last,$gene,$forceid,$desiredhome,
                                     $email,$role,$start,$end);                                      $email,$inststatus);
     if ($userresult eq 'ok') {      if ($userresult eq 'ok') {
         if ($role ne '') {          if ($role ne '') {
             $role =~ s/_/\//g;              $role =~ s/_/\//g;
Line 408  sub javascript_validations { Line 408  sub javascript_validations {
          domain   => 'The optional domain field was not specified.',           domain   => 'The optional domain field was not specified.',
          continue => 'Continue adding users?',           continue => 'Continue adding users?',
          );           );
       if (($mode eq 'upload') && ($context eq 'domain')) {
           $alert{'inststatus'} = &mt('The optional affiliation field was not specified'); 
       }
     my $function_name = <<"END";      my $function_name = <<"END";
 $setsections_js  $setsections_js
   
 function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain) {  function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus) {
 END  END
     my ($authnum,%can_assign) =  &Apache::loncommon::get_assignable_auth($domain);      my ($authnum,%can_assign) =  &Apache::loncommon::get_assignable_auth($domain);
     my $auth_checks;      my $auth_checks;
Line 538  END Line 541  END
         }          }
         message+='$alert{'domain'}';          message+='$alert{'domain'}';
     }      }
   END
           if (($mode eq 'upload') && ($context eq 'domain')) {
               $optional_checks .= (<<END);
   
       if (foundinststatus==0) {
           if (message!='') {
               message+='\\n';
           }
           message+='$alert{'inststatus'}';
       }
   END
           }
           $optional_checks .= (<<END);
   
     if (message!='') {      if (message!='') {
         message+= '\\n$alert{'continue'}';          message+= '\\n$alert{'continue'}';
         if (confirm(message)) {          if (confirm(message)) {
Line 568  function verify(vf,sec_caller) { Line 585  function verify(vf,sec_caller) {
     var foundemail=0;      var foundemail=0;
     var foundrole=0;      var foundrole=0;
     var founddomain=0;      var founddomain=0;
       var foundinststatus=0;
     var tw;      var tw;
     for (i=0;i<=vf.nfields.value;i++) {      for (i=0;i<=vf.nfields.value;i++) {
         tw=eval('vf.f'+i+'.selectedIndex');          tw=eval('vf.f'+i+'.selectedIndex');
Line 579  function verify(vf,sec_caller) { Line 597  function verify(vf,sec_caller) {
         if (tw==10) { foundemail=1; }          if (tw==10) { foundemail=1; }
         if (tw==11) { foundrole=1; }          if (tw==11) { foundrole=1; }
         if (tw==12) { founddomain=1; }          if (tw==12) { founddomain=1; }
           if (tw==13) { foundinststatus=1; }
     }      }
     verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain);      verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus);
 }  }
   
 //  //
Line 602  function verify(vf,sec_caller) { Line 621  function verify(vf,sec_caller) {
 // 10 = email address  // 10 = email address
 // 11 = role  // 11 = role
 // 12 = domain  // 12 = domain
   // 13 = inststatus
   
 function flip(vf,tf) {  function flip(vf,tf) {
    var nw=eval('vf.f'+tf+'.selectedIndex');     var nw=eval('vf.f'+tf+'.selectedIndex');
Line 666  function verify(vf,sec_caller) { Line 686  function verify(vf,sec_caller) {
     var foundsec=0;      var foundsec=0;
     var foundrole=0;      var foundrole=0;
     var founddomain=0;      var founddomain=0;
       var foundinststatus=0;
     var tw;      var tw;
     for (i=0;i<=vf.nfields.value;i++) {      for (i=0;i<=vf.nfields.value;i++) {
         tw=eval('vf.f'+i+'.selectedIndex');          tw=eval('vf.f'+i+'.selectedIndex');
Line 676  function verify(vf,sec_caller) { Line 697  function verify(vf,sec_caller) {
         if (i==8 && tw!=0) { foundpwd=1; }          if (i==8 && tw!=0) { foundpwd=1; }
         if (i==9 && tw!=0) { foundrole=1; }          if (i==9 && tw!=0) { foundrole=1; }
         if (i==10 && tw!=0) { founddomain=1; }          if (i==10 && tw!=0) { founddomain=1; }
           if (i==13 && tw!=0) { foundinstatus=1; }
     }      }
     verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundrole,founddomain);      verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundrole,founddomain,foundinststatus);
 }  }
   
 function flip(vf,tf) {  function flip(vf,tf) {
Line 864  sub print_upload_manager_form { Line 886  sub print_upload_manager_form {
                                'email_choice' => 'scalar',                                 'email_choice' => 'scalar',
                                'role_choice' => 'scalar',                                 'role_choice' => 'scalar',
                                'domain_choice' => 'scalar',                                 'domain_choice' => 'scalar',
                                  'inststatus_choice' => 'scalar',
                              };                               };
     my $defdom = $env{'request.role.domain'};      my $defdom = $env{'request.role.domain'};
     if ($context eq 'course') {      if ($context eq 'course') {
Line 895  sub print_upload_manager_form { Line 918  sub print_upload_manager_form {
              ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],               ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
              ['email',&mt('E-mail Address'),   $env{'form.email_choice'}],               ['email',&mt('E-mail Address'),   $env{'form.email_choice'}],
              ['role',&mt('Role'),             $env{'form.role_choice'}],               ['role',&mt('Role'),             $env{'form.role_choice'}],
              ['domain',&mt('Domain'),         $env{'form.domain_choice'}]);               ['domain',&mt('Domain'),         $env{'form.domain_choice'}],
                ['inststatus',&mt('Affiliation'), $env{'form.inststatus_choice'}]);
         if ($env{'form.upfile_associate'} eq 'reverse') {          if ($env{'form.upfile_associate'} eq 'reverse') {
             &Apache::loncommon::csv_print_samples($r,\@records);              &Apache::loncommon::csv_print_samples($r,\@records);
             $i=&Apache::loncommon::csv_print_select_table($r,\@records,              $i=&Apache::loncommon::csv_print_select_table($r,\@records,
Line 3447  sub upfile_drop_add { Line 3471  sub upfile_drop_add {
                                                 'ipwd_choice' => 'scalar',                                                  'ipwd_choice' => 'scalar',
                                                 'email_choice' => 'scalar',                                                  'email_choice' => 'scalar',
                                                 'role_choice'  => 'scalar',                                                  'role_choice'  => 'scalar',
                                                 'domain_choice' => 'scalar'});                                                  'domain_choice' => 'scalar',
                                                   'inststatus_choice' => 'scalar'});
     #      #
     my ($startdate,$enddate) = &get_dates_from_form();      my ($startdate,$enddate) = &get_dates_from_form();
     if ($env{'form.makedatesdefault'}) {      if ($env{'form.makedatesdefault'}) {
Line 3530  sub upfile_drop_add { Line 3555  sub upfile_drop_add {
                     'permanentemail','id');                      'permanentemail','id');
     my %canmodify;      my %canmodify;
     if (&Apache::lonnet::allowed('mau',$domain)) {      if (&Apache::lonnet::allowed('mau',$domain)) {
           push(@userinfo,'inststatus');
         foreach my $field (@userinfo) {          foreach my $field (@userinfo) {
             $canmodify{$field} = 1;              $canmodify{$field} = 1;
         }          }
Line 3717  sub upfile_drop_add { Line 3743  sub upfile_drop_add {
                     if (defined($fields{'email'})) {                      if (defined($fields{'email'})) {
                         if (defined($entries{$fields{'email'}})) {                          if (defined($entries{$fields{'email'}})) {
                             $email=$entries{$fields{'email'}};                              $email=$entries{$fields{'email'}};
                             unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; }                        }                              unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; }
                           }
                       }
                       # determine affiliation
                       my $inststatus='';
                       if (defined($fields{'inststatus'})) {
                           if (defined($entries{$fields{'inststatus'}})) {
                               $inststatus=$entries{$fields{'inststatus'}};
                           }
                     }                      }
                     # determine user password                      # determine user password
                     my $password = $genpwd;                      my $password = $genpwd;
Line 3800  sub upfile_drop_add { Line 3834  sub upfile_drop_add {
                                 }                                  }
                             }                              }
                             my @newinfo = (\$fname,\$mname,\$lname,\$gen,\$email,\$id);                              my @newinfo = (\$fname,\$mname,\$lname,\$gen,\$email,\$id);
                             for (my $i=0; $i<@userinfo; $i++) {                              for (my $i=0; $i<@newinfo; $i++) {
                                 if (${$newinfo[$i]} ne '') {                                  if (${$newinfo[$i]} ne '') {
                                     if (!$canmodify{$userinfo[$i]}) {                                      if (!$canmodify{$userinfo[$i]}) {
                                         ${$newinfo[$i]} = '';                                          ${$newinfo[$i]} = '';
Line 3849  sub upfile_drop_add { Line 3883  sub upfile_drop_add {
                                      $fname,$mname,$lname,$gen,$sec,$enddate,                                       $fname,$mname,$lname,$gen,$sec,$enddate,
                                      $startdate,$env{'form.forceid'},                                       $startdate,$env{'form.forceid'},
                                      $desiredhost,$email,'manual','',$cid,                                       $desiredhost,$email,'manual','',$cid,
                                      '',$context);                                       '',$context,$inststatus);
                             $userresult = $roleresult;                              $userresult = $roleresult;
                         } else {                          } else {
                             if ($role ne '') {                               if ($role ne '') { 
Line 3869  sub upfile_drop_add { Line 3903  sub upfile_drop_add {
                                                     $mname,$lname,$gen,$sec,                                                      $mname,$lname,$gen,$sec,
                                                     $env{'form.forceid'},$desiredhost,                                                      $env{'form.forceid'},$desiredhost,
                                                     $email,$role,$enddate,                                                      $email,$role,$enddate,
                                                     $startdate,$checkid);                                                      $startdate,$checkid,$inststatus);
                                             }                                              }
                                         } elsif (@secs > 0) {                                          } elsif (@secs > 0) {
                                             $singlesec = $secs[0];                                              $singlesec = $secs[0];
Line 3884  sub upfile_drop_add { Line 3918  sub upfile_drop_add {
                                                     $id,$amode,$password,$fname,                                                      $id,$amode,$password,$fname,
                                                     $mname,$lname,$gen,$singlesec,                                                      $mname,$lname,$gen,$singlesec,
                                                     $env{'form.forceid'},$desiredhost,                                                      $env{'form.forceid'},$desiredhost,
                                                     $email,$role,$enddate,$startdate,$checkid);                                                      $email,$role,$enddate,$startdate,
                                                       $checkid,$inststatus);
                             }                              }
                         }                          }
                         if ($multiple) {                          if ($multiple) {

Removed from v.1.83  
changed lines
  Added in v.1.84


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