Diff for /loncom/interface/loncreateuser.pm between versions 1.363 and 1.374

version 1.363, 2012/08/17 22:43:31 version 1.374, 2013/02/19 17:30:35
Line 111  sub initialize_authen_forms { Line 111  sub initialize_authen_forms {
   
 sub auth_abbrev {  sub auth_abbrev {
     my %abv_auth = (      my %abv_auth = (
                      krb5     => 'krb',                       krb5      => 'krb',
                      krb4     => 'krb',                       krb4      => 'krb',
                      internal => 'int',                       internal  => 'int',
                      localuth => 'loc',                       localauth => 'loc',
                      unix     => 'fsys',                       unix      => 'fsys',
                    );                     );
     return %abv_auth;      return %abv_auth;
 }  }
Line 1319  ENDAUTH Line 1319  ENDAUTH
         $r->print($portfolioform.$domroleform);          $r->print($portfolioform.$domroleform);
         if ($env{'form.action'} eq 'singlestudent') {          if ($env{'form.action'} eq 'singlestudent') {
             $r->print(&date_sections_select($context,$newuser,$formname,              $r->print(&date_sections_select($context,$newuser,$formname,
                                             $permission));                                              $permission,$crstype));
         }          }
         $r->print('</div><div class="LC_clear_float_footer"></div>');          $r->print('</div><div class="LC_clear_float_footer"></div>');
     } else { # user already exists      } else { # user already exists
Line 1421  ENDNOTOOLSPRIV Line 1421  ENDNOTOOLSPRIV
             unless ($gotdiv) {              unless ($gotdiv) {
                 $r->print('<div class="LC_left_float">');                  $r->print('<div class="LC_left_float">');
             }              }
             $r->print(&date_sections_select($context,$newuser,$formname));              $r->print(&date_sections_select($context,$newuser,$formname,
         }                                               $permission,$crstype));
           }
         if ($gotdiv) {          if ($gotdiv) {
             $r->print('</div><div class="LC_clear_float_footer"></div>');              $r->print('</div><div class="LC_clear_float_footer"></div>');
         }          }
Line 1495  sub singleuser_breadcrumb { Line 1496  sub singleuser_breadcrumb {
 }  }
   
 sub date_sections_select {  sub date_sections_select {
     my ($context,$newuser,$formname,$permission) = @_;      my ($context,$newuser,$formname,$permission,$crstype) = @_;
     my $cid = $env{'request.course.id'};      my $cid = $env{'request.course.id'};
     my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);      my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);
     my $date_table = '<h3>'.&mt('Starting and Ending Dates').'</h3>'."\n".      my $date_table = '<h3>'.&mt('Starting and Ending Dates').'</h3>'."\n".
Line 1504  sub date_sections_select { Line 1505  sub date_sections_select {
     my $rowtitle = 'Section';      my $rowtitle = 'Section';
     my $secbox = '<h3>'.&mt('Section').'</h3>'."\n".      my $secbox = '<h3>'.&mt('Section').'</h3>'."\n".
         &Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,          &Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,
                                               $permission);                                                $permission,$context,'',$crstype);
     my $output = $date_table.$secbox;      my $output = $date_table.$secbox;
     return $output;      return $output;
 }  }
Line 1651  sub display_existing_roles { Line 1652  sub display_existing_roles {
                 $allowed=1;                  $allowed=1;
             }              }
             unless ($allowed) {              unless ($allowed) {
                 my $isowner = &is_courseowner($cid,$coursedata{'internal.courseowner'});                  my $isowner = &Apache::lonuserutils::is_courseowner($cid,$coursedata{'internal.courseowner'});
                 if ($isowner) {                  if ($isowner) {
                     if (($role_code eq 'co') && ($class eq 'Community')) {                      if (($role_code eq 'co') && ($class eq 'Community')) {
                         $allowed = 1;                          $allowed = 1;
Line 1672  sub display_existing_roles { Line 1673  sub display_existing_roles {
                 }                  }
             }              }
             if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {              if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
                 $carea.='<br />Section: '.$3;                  $carea.='<br />'.&mt('Section: [_1]',$3);
                 $sortkey.="\0$3";                  $sortkey.="\0$3";
                 if (!$allowed) {                  if (!$allowed) {
                     if ($env{'request.course.sec'} eq $3) {                      if ($env{'request.course.sec'} eq $3) {
Line 2432  sub update_user_data { Line 2433  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.$rtnlink);                  $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'}.' ('.&Apache::loncommon::plainname($env{'form.ccuname'},
     $r->print('<p class="LC_info">'.&mt('Please be patient').'</p>');                          $env{'form.ccdomain'}).')', $env{'form.ccdomain'}).'</h3>');
       my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,2);
   
     my (%alerts,%rulematch,%inst_results,%curr_rules);      my (%alerts,%rulematch,%inst_results,%curr_rules);
     my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');      my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
Line 2499  sub update_user_data { Line 2501  sub update_user_data {
                 }                  }
             }              }
         }          }
           &Apache::lonhtmlcommon::Increment_PrgWin($r, \%prog_state);
  # Call modifyuser   # Call modifyuser
  my $result = &Apache::lonnet::modifyuser   my $result = &Apache::lonnet::modifyuser
     ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'},      ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'},
Line 2588  sub update_user_data { Line 2591  sub update_user_data {
     $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);          $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);    
  }   }
     }      }
   
     $r->rflush(); # Finish display of header before time consuming actions start      $r->rflush(); # Finish display of header before time consuming actions start
       &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state);
     ##      ##
     my (@userroles,%userupdate,$cnum,$cdom,%namechanged);      my (@userroles,%userupdate,$cnum,$cdom,%namechanged);
     if ($context eq 'course') {      if ($context eq 'course') {
Line 2902  sub update_user_data { Line 2904  sub update_user_data {
                                         $changeHash{'tools.'.$key};                                          $changeHash{'tools.'.$key};
                                 } else {                                  } else {
                                     $newenvhash{'environment.availabletools.'.$key} =                                      $newenvhash{'environment.availabletools.'.$key} =
           &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},                                            $key,'reload','tools');            &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
             $key,'reload','tools');
                                 }                                  }
                             }                              }
                         }                          }
Line 3005  sub update_user_data { Line 3008  sub update_user_data {
                   .&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts,\%curr_rules)                    .&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts,\%curr_rules)
                   .'</span>');                    .'</span>');
     }      }
       &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
     if ($env{'form.action'} eq 'singlestudent') {      if ($env{'form.action'} eq 'singlestudent') {
         &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype);          &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype);
         $r->print('<p><a href="javascript:backPage(document.userupdate)">');          $r->print('<p><a href="javascript:backPage(document.userupdate)">');
Line 3036  sub update_user_data { Line 3040  sub update_user_data {
         if ($env{'form.popup'}) {          if ($env{'form.popup'}) {
             $r->print('<p><a href="javascript:window.close()">'.&mt('Close window').'</a></p>');              $r->print('<p><a href="javascript:window.close()">'.&mt('Close window').'</a></p>');
         } else {          } else {
             $r->print('<p><a href="javascript:backPage(document.userupdate,'."'$env{'form.prevphase'}','modify'".')">'              $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(['<a href="javascript:backPage(document.userupdate,'."'$env{'form.prevphase'}','modify'".')">'
                      .&mt('Modify this user: [_1]','<span class="LC_cusr_emph">'.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.')</span>').'</a>'                       .&mt('Modify this user: [_1]','<span class="LC_cusr_emph">'.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.')</span>').'</a>',
                      .('&nbsp;'x5).'<a href="javascript:backPage(document.userupdate)">'                       '<a href="javascript:backPage(document.userupdate)">'.&mt('Create/Modify Another User').'</a>']));
                      .&mt('Create/Modify Another User').'</a></p>');  
         }          }
     }      }
 }  }
Line 3060  sub display_userinfo { Line 3063  sub display_userinfo {
                    ref($newsetting) eq 'HASH' &&                     ref($newsetting) eq 'HASH' &&
                    ref($newsettingtext) eq 'HASH');                     ref($newsettingtext) eq 'HASH');
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
          'ui'             => 'User Information (unchanged)',           'ui'             => 'User Information',
          'uic'            => 'User Information Changed',           'uic'            => 'User Information Changed',
          'firstname'      => 'First Name',           'firstname'      => 'First Name',
          'middlename'     => 'Middle Name',           'middlename'     => 'Middle Name',
Line 3081  sub display_userinfo { Line 3084  sub display_userinfo {
          'prvs'           => 'Previous Value:',           'prvs'           => 'Previous Value:',
          'chto'           => 'Changed To:'           'chto'           => 'Changed To:'
     );      );
     my $title = $lt{'ui'};   
     if ($changed) {  
         $title = $lt{'uic'};  
     }  
     $r->print('<h4>'.$title.'</h4>'.  
               &Apache::loncommon::start_data_table().  
               &Apache::loncommon::start_data_table_header_row());  
     if ($changed) {      if ($changed) {
           $r->print('<h3>'.$lt{'uic'}.'</h3>'.
                   &Apache::loncommon::start_data_table().
                   &Apache::loncommon::start_data_table_header_row());
         $r->print("<th>&nbsp;</th>\n");          $r->print("<th>&nbsp;</th>\n");
     }          $r->print('<th><b>'.$lt{'prvs'}.'</b></th>');
     my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');          $r->print('<th><span class="LC_nobreak"><b>'.$lt{'chto'}.'</b></span></th>');
     foreach my $item (@userinfo) {          $r->print(&Apache::loncommon::end_data_table_header_row());
         $r->print("<th>$lt{$item}</th>\n");          my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
     }          
     foreach my $entry (@{$order}) {  
         if ($canshow->{$entry}) {  
             if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {  
                 foreach my $item (@{$requestcourses}) {  
                     $r->print("<th>$lt{$item}</th>\n");  
                 }  
             } elsif ($entry eq 'tools') {  
                 foreach my $item (@{$usertools}) {  
                     $r->print("<th>$lt{$item}</th>\n");  
                 }  
             } else {  
                 $r->print("<th>$lt{$entry}</th>\n");  
             }  
         }  
     }  
     $r->print(&Apache::loncommon::end_data_table_header_row().  
              &Apache::loncommon::start_data_table_row());  
     if ($changed) {  
         $r->print('<td><b>'.$lt{'prvs'}.'</b></td>'."\n");  
     }  
     foreach my $item (@userinfo) {  
         $r->print('<td>'.$userenv->{$item}.' </td>'."\n");  
     }  
     foreach my $entry (@{$order}) {  
         if ($canshow->{$entry}) {  
             if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {  
                 foreach my $item (@{$requestcourses}) {  
                     $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");  
                 }  
             } elsif ($entry eq 'tools') {  
                 foreach my $item (@{$usertools}) {  
                     $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");  
                 }  
             } else {  
                 $r->print("<td>$oldsetting->{$entry} $oldsettingtext->{$entry} </td>\n");  
             }  
         }  
     }  
     $r->print(&Apache::loncommon::end_data_table_row());  
     if ($changed) {  
         $r->print(&Apache::loncommon::start_data_table_row().  
                   '<td><span class="LC_nobreak"><b>'.$lt{'chto'}.'</b></span></td>'."\n");  
         foreach my $item (@userinfo) {          foreach my $item (@userinfo) {
             my $value = $env{'form.c'.$item};              my $value = $env{'form.c'.$item};
             if ($namechangedhash->{$item}) {              #show changes only:
                 $value = '<span class="LC_cusr_emph">'.$value.'</span>';              unless($value eq $userenv->{$item}){
                   $r->print(&Apache::loncommon::start_data_table_row());
   
                   $r->print("<td>$lt{$item}</td>\n");
                   $r->print('<td>'.$userenv->{$item}.' </td>');
                   $r->print("<td>$value </td>\n");
   
                   $r->print(&Apache::loncommon::end_data_table_row());
             }              }
             $r->print("<td>$value </td>\n");  
         }          }
         foreach my $entry (@{$order}) {          foreach my $entry (@{$order}) {
             if ($canshow->{$entry}) {              if ($canshow->{$entry} && ($newsetting->{$entry} ne $newsetting->{$entry})) {
                   $r->print(&Apache::loncommon::start_data_table_row());
                 if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {                  if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
                     foreach my $item (@{$requestcourses}) {                      foreach my $item (@{$requestcourses}) {
                           $r->print("<td>$lt{$item}</td>\n");
                           $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
                         my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};                          my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
                         if ($changedhash->{$item}) {                          if ($changedhash->{$item}) {
                             $value = '<span class="LC_cusr_emph">'.$value.'</span>';                              $value = '<span class="LC_cusr_emph">'.$value.'</span>';
Line 3156  sub display_userinfo { Line 3123  sub display_userinfo {
                     }                      }
                 } elsif ($entry eq 'tools') {                  } elsif ($entry eq 'tools') {
                     foreach my $item (@{$usertools}) {                      foreach my $item (@{$usertools}) {
                           $r->print("<td>$lt{$item}</td>\n");
                           $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
                         my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};                          my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
                         if ($changedhash->{$item}) {                          if ($changedhash->{$item}) {
                             $value = '<span class="LC_cusr_emph">'.$value.'</span>';                              $value = '<span class="LC_cusr_emph">'.$value.'</span>';
Line 3163  sub display_userinfo { Line 3132  sub display_userinfo {
                         $r->print("<td>$value </td>\n");                          $r->print("<td>$value </td>\n");
                     }                      }
                 } else {                  } else {
                       $r->print("<td>$lt{$entry}</td>\n");
                       $r->print("<td>$oldsetting->{$entry} $oldsettingtext->{$entry} </td>\n");
                     my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry};                      my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry};
                     if ($changedhash->{$entry}) {                      if ($changedhash->{$entry}) {
                         $value = '<span class="LC_cusr_emph">'.$value.'</span>';                          $value = '<span class="LC_cusr_emph">'.$value.'</span>';
                     }                      }
                     $r->print("<td>$value </td>\n");                      $r->print("<td>$value </td>\n");
                 }                  }
                   $r->print(&Apache::loncommon::end_data_table_row());
             }              }
         }          }
         $r->print(&Apache::loncommon::end_data_table_row());          $r->print(&Apache::loncommon::end_data_table().'<br />');
       } else {
           $r->print('<h3>'.$lt{'ui'}.'</h3>'.
                     '<p>'.&mt('No changes made to user information').'</p>');
     }      }
     $r->print(&Apache::loncommon::end_data_table().'<br />');  
     return;      return;
 }  }
   
Line 3370  sub update_roles { Line 3344  sub update_roles {
     &Apache::lonnet::revokerole($env{'form.ccdomain'},      &Apache::lonnet::revokerole($env{'form.ccdomain'},
  $env{'form.ccuname'},   $env{'form.ccuname'},
  $scope,$role,'','',$context);   $scope,$role,'','',$context);
         $r->print(&mt('Revoking [_1] in [_2]: [_3]',                  $r->print(&Apache::lonhtmlcommon::confirm_success(
       $role,$scope,'<b>'.$result.'</b>').'<br />');                              &mt('Revoking [_1] in [_2]',
                                   &Apache::lonnet::plaintext($role),
                                   &Apache::loncommon::show_role_extent($scope,$context,$role)),
                                   $result ne "ok").'<br />');
                   if ($result ne "ok") {
                       $r->print(&mt('Error: [_1]',$result).'<br />');
                   }
  if ($role eq 'st') {   if ($role eq 'st') {
     my $result =       my $result = 
                         &Apache::lonuserutils::classlist_drop($scope,                          &Apache::lonuserutils::classlist_drop($scope,
                             $env{'form.ccuname'},$env{'form.ccdomain'},                              $env{'form.ccuname'},$env{'form.ccdomain'},
     $now);      $now);
     $r->print($result);                      $r->print(&Apache::lonhtmlcommon::confirm_success($result));
  }   }
                 if (!grep(/^\Q$role\E$/,@rolechanges)) {                  if (!grep(/^\Q$role\E$/,@rolechanges)) {
                     push(@rolechanges,$role);                      push(@rolechanges,$role);
Line 3385  sub update_roles { Line 3365  sub update_roles {
     }      }
     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:').                  my $result = &Apache::lonnet::revokecustomrole(
                       ' '.$4.' by '.$3.':'.$2.' in '.$1.': <b>'.                      $env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context);
                       &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},                  $r->print(&Apache::lonhtmlcommon::confirm_success(
   $env{'form.ccuname'},$1,$2,$3,$4,'','',$context).                              &mt('Revoking custom role [_1] by [_2] in [_3]',
  '</b><br />');                                  $4,$3.':'.$2,&Apache::loncommon::show_role_extent($1,$context,'cr')),
                               $result ne 'ok').'<br />');
                   if ($result ne "ok") {
                       $r->print(&mt('Error: [_1]',$result).'<br />');
                   }
                 if (!grep(/^cr$/,@rolechanges)) {                  if (!grep(/^cr$/,@rolechanges)) {
                     push(@rolechanges,'cr');                      push(@rolechanges,'cr');
                 }                  }
Line 3403  sub update_roles { Line 3387  sub update_roles {
  $env{'form.ccuname'},   $env{'form.ccuname'},
  $scope,$role,$now,0,1,'',   $scope,$role,$now,0,1,'',
                                                 $context);                                                  $context);
         $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,                  $r->print(&Apache::lonhtmlcommon::confirm_success(
       '<b>'.$result.'</b>').'<br />');                              &mt('Deleting [_1] in [_2]',
                                   &Apache::lonnet::plaintext($role),
                                   &Apache::loncommon::show_role_extent($scope,$context,$role)),
                               $result ne 'ok').'<br />');
                   if ($result ne "ok") {
                       $r->print(&mt('Error: [_1]',$result).'<br />');
                   }
   
  if ($role eq 'st') {   if ($role eq 'st') {
     my $result =       my $result = 
                         &Apache::lonuserutils::classlist_drop($scope,                          &Apache::lonuserutils::classlist_drop($scope,
                             $env{'form.ccuname'},$env{'form.ccdomain'},                              $env{'form.ccuname'},$env{'form.ccdomain'},
     $now);      $now);
     $r->print($result);      $r->print(&Apache::lonhtmlcommon::confirm_success($result));
  }   }
                 if (!grep(/^\Q$role\E$/,@rolechanges)) {                  if (!grep(/^\Q$role\E$/,@rolechanges)) {
                     push(@rolechanges,$role);                      push(@rolechanges,$role);
Line 3419  sub update_roles { Line 3410  sub update_roles {
     if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {      if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
                 my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);                  my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
 # Delete custom role  # Delete custom role
                 $r->print(&mt('Deleting custom role [_1] by [_2] in [_3]',                  my $result =
                       $rolename,$rnam.':'.$rdom,$url).': <b>'.                      &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
                       &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},                          $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
                          $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,                          0,1,$context);
                          0,1,$context).'</b><br />');                  $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',
                         $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
                         $result ne "ok").'<br />');
                   if ($result ne "ok") {
                       $r->print(&mt('Error: [_1]',$result).'<br />');
                   }
   
                 if (!grep(/^cr$/,@rolechanges)) {                  if (!grep(/^cr$/,@rolechanges)) {
                     push(@rolechanges,'cr');                      push(@rolechanges,'cr');
                 }                  }
Line 3439  sub update_roles { Line 3436  sub update_roles {
                 my $output;                  my $output;
                 if ($role eq 'st') {                  if ($role eq 'st') {
                     if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {                      if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
                         my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);                          my ($cdom,$cnum,$csec) = ($1,$2,$3);
                           my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context);
                         if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {                          if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
                             if ($result eq 'refused' && $logmsg) {                              if ($result eq 'refused' && $logmsg) {
                                 $output = $logmsg;                                  $output = $logmsg;
                             } else {                               } else { 
                                 $output = "Error: $result\n";                                  $output = &mt('Error: [_1]',$result)."\n";
                             }                              }
                         } else {                          } else {
                             $output = &mt('Assigning').' '.$role.' in '.$url.                              $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',
                                       &mt('starting').' '.localtime($now).                                          &Apache::lonnet::plaintext($role),
                                       ': <br />'.$logmsg.'<br />'.                                          &Apache::loncommon::show_role_extent($url,$context,'st'),
                                       &mt('Add to classlist').': <b>ok</b><br />';                                          &Apache::lonlocal::locallocaltime($now))).'<br />'.$logmsg.'<br />';
                         }                          }
                     }                      }
                 } else {                  } else {
     my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},      my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
                                $env{'form.ccuname'},$url,$role,0,$now,'','',                                 $env{'form.ccuname'},$url,$role,0,$now,'','',
                                $context);                                 $context);
     $output = &mt('Re-enabling [_1] in [_2]: [_3]',                          $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
       $role,$url,'<b>'.$result.'</b>').'<br />';                                          &Apache::lonnet::plaintext($role),
  }                                          &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'<br />';
                       if ($result ne "ok") {
                           $output .= &mt('Error: [_1]',$result).'<br />';
                       }
                   }
                 $r->print($output);                  $r->print($output);
                 if (!grep(/^\Q$role\E$/,@rolechanges)) {                  if (!grep(/^\Q$role\E$/,@rolechanges)) {
                     push(@rolechanges,$role);                      push(@rolechanges,$role);
Line 3471  sub update_roles { Line 3473  sub update_roles {
                 my $result = &Apache::lonnet::assigncustomrole(                  my $result = &Apache::lonnet::assigncustomrole(
                                $env{'form.ccdomain'}, $env{'form.ccuname'},                                 $env{'form.ccdomain'}, $env{'form.ccuname'},
                                $url,$rdom,$rnam,$rolename,0,$now,undef,$context);                                 $url,$rdom,$rnam,$rolename,0,$now,undef,$context);
                 $r->print(&mt('Re-enabling custom role [_1] by [_2] in [_3]: [_4]',                  $r->print(&Apache::lonhtmlcommon::confirm_success(
                           $rolename,$rnam.':'.$rdom,$url,'<b>'.$result.'</b>').'<br />');                      &mt('Re-enabling custom role [_1] by [_2] in [_3]',
                           $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
                       $result ne "ok").'<br />');
                   if ($result ne "ok") {
                       $r->print(&mt('Error: [_1]',$result).'<br />');
                   }
                 if (!grep(/^cr$/,@rolechanges)) {                  if (!grep(/^cr$/,@rolechanges)) {
                     push(@rolechanges,'cr');                      push(@rolechanges,'cr');
                 }                  }
Line 3612  sub update_roles { Line 3619  sub update_roles {
 # Flush the course logs so reverse user roles immediately updated  # Flush the course logs so reverse user roles immediately updated
     $r->register_cleanup(\&Apache::lonnet::flushcourselogs);      $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
     if (@rolechanges == 0) {      if (@rolechanges == 0) {
         $r->print(&mt('No roles to modify'));          $r->print('<p>'.&mt('No roles to modify').'</p>');
     }      }
     return @rolechanges;      return @rolechanges;
 }  }
Line 3692  sub get_defaultquota_text { Line 3699  sub get_defaultquota_text {
 sub update_result_form {  sub update_result_form {
     my ($uhome) = @_;      my ($uhome) = @_;
     my $outcome =       my $outcome = 
     '<form name="userupdate" method="post" />'."\n";      '<form name="userupdate" method="post" action="">'."\n";
     foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') {      foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') {
         $outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n";          $outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n";
     }      }
Line 4259  sub handler { Line 4266  sub handler {
             if ($env{'form.phase'} eq 'createnewuser') {              if ($env{'form.phase'} eq 'createnewuser') {
                 my $response;                  my $response;
                 if ($env{'form.srchterm'} !~ /^$match_username$/) {                  if ($env{'form.srchterm'} !~ /^$match_username$/) {
                     my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');                      my $response =
                           '<span class="LC_warning">'
                          .&mt('You must specify a valid username. Only the following are allowed:'
                              .' letters numbers - . @')
                          .'</span>';
                     $env{'form.phase'} = '';                      $env{'form.phase'} = '';
                     &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum);                      &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum);
                 } else {                  } else {
Line 4380  sub handler { Line 4391  sub handler {
                      bread_crumbs_component => $bread_crumbs_component};                       bread_crumbs_component => $bread_crumbs_component};
             my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);              my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
             my $formname = 'studentform';              my $formname = 'studentform';
               my $hidecall = "hide_searching();";
             if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') ||              if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') ||
                 ($env{'form.roletype'} eq 'community'))) {                  ($env{'form.roletype'} eq 'community'))) {
                 if ($env{'form.roletype'} eq 'course') {                  if ($env{'form.roletype'} eq 'course') {
Line 4396  sub handler { Line 4408  sub handler {
                                    );                                     );
                     $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements);                      $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements);
                 }                  }
                 $jscript .= &verify_user_display();                  $jscript .= &verify_user_display($context)."\n".
                               &Apache::loncommon::check_uncheck_jscript();
                 my $js = &add_script($jscript).$cb_jscript;                  my $js = &add_script($jscript).$cb_jscript;
                 my $loadcode =                   my $loadcode = 
                     &Apache::lonuserutils::course_selector_loadcode($formname);                      &Apache::lonuserutils::course_selector_loadcode($formname);
                 if ($loadcode ne '') {                  if ($loadcode ne '') {
                     $args->{add_entries} = {onload => $loadcode};                      $args->{add_entries} = {onload => "$loadcode;$hidecall"};
                   } else {
                       $args->{add_entries} = {onload => $hidecall};
                 }                  }
                 $r->print(&header($js,$args));                  $r->print(&header($js,$args));
             } else {              } else {
                 $r->print(&header(&add_script(&verify_user_display()),$args));                  $args->{add_entries} = {onload => $hidecall};
                   $jscript = &verify_user_display($context).
                              &Apache::loncommon::check_uncheck_jscript(); 
                   $r->print(&header(&add_script($jscript),$args));
             }              }
             &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,              &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
                          $formname,$totcodes,$codetitles,$idlist,$idlist_titles);                           $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
Line 4541  sub add_script { Line 4559  sub add_script {
 }  }
   
 sub verify_user_display {  sub verify_user_display {
       my ($context) = @_;
       my %lt = &Apache::lonlocal::texthash (
           course    => 'course(s): description, section(s), status',
           community => 'community(s): description, section(s), status',
           author    => 'author',
       );
       my $photos;
       if (($context eq 'course') && $env{'request.course.id'}) {
           $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
       }
     my $output = <<"END";      my $output = <<"END";
   
   function hide_searching() {
       if (document.getElementById('searching')) {
           document.getElementById('searching').style.display = 'none';
       }
       return;
   }
   
 function display_update() {  function display_update() {
     document.studentform.action.value = 'listusers';      document.studentform.action.value = 'listusers';
     document.studentform.phase.value = 'display';      document.studentform.phase.value = 'display';
     document.studentform.submit();      document.studentform.submit();
 }  }
   
   function updateCols(caller) {
       var context = '$context';
       var photos = '$photos';
       if (caller == 'Status') {
           if ((context == 'domain') && 
               ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
                (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community'))) {
               document.getElementById('showcolstatus').checked = false;
               document.getElementById('showcolstatus').disabled = 'disabled';
               document.getElementById('showcolstart').checked = false;
               document.getElementById('showcolend').checked = false;
           } else {
               if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
                   document.getElementById('showcolstatus').checked = true;
                   document.getElementById('showcolstatus').disabled = '';
                   document.getElementById('showcolstart').checked = true;
                   document.getElementById('showcolend').checked = true;
               } else {
                   document.getElementById('showcolstatus').checked = false;
                   document.getElementById('showcolstatus').disabled = 'disabled';
                   document.getElementById('showcolstart').checked = false;
                   document.getElementById('showcolend').checked = false;
               }
           }
       }
       if (caller == 'output') {
           if (photos == 1) {
               if (document.getElementById('showcolphoto')) {
                   var photoitem = document.getElementById('showcolphoto');
                   if (document.studentform.output.options[document.studentform.output.selectedIndex].value == 'html') {
                       photoitem.checked = true;
                       photoitem.disabled = '';
                   } else {
                       photoitem.checked = false;
                       photoitem.disabled = 'disabled';
                   }
               }
           }
       }
       if (caller == 'showrole') {
           if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') ||
               (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'cr')) {
               document.getElementById('showcolrole').checked = true;
               document.getElementById('showcolrole').disabled = '';
           } else {
               document.getElementById('showcolrole').checked = false;
               document.getElementById('showcolrole').disabled = 'disabled';
           }
           if (context == 'domain') {
               if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
                   (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {
                   document.getElementById('showcolstatus').checked = false;
                   document.getElementById('showcolstatus').disabled = 'disabled';
                   document.getElementById('showcolstart').checked = false;
                   document.getElementById('showcolend').checked = false;
               } else {
                   if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
                       document.getElementById('showcolstatus').checked = true;
                       document.getElementById('showcolstatus').disabled = '';
                       document.getElementById('showcolstart').checked = true;
                       document.getElementById('showcolend').checked = true;
                   }
               }
               if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'domain') {
                   document.getElementById('showcolextent').disabled = 'disabled';
                   document.getElementById('showcolextent').checked = 'false';
                   document.getElementById('showextent').style.display='none';
                   document.getElementById('showcoltextextent').innerHTML = '';
               } else {
                   document.getElementById('showextent').style.display='block';
                   document.getElementById('showextent').style.textAlign='left';
                   document.getElementById('showextent').style.textFace='normal';
                   if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'author') {
                       document.getElementById('showcolextent').disabled = '';
                       document.getElementById('showcolextent').checked = 'true';
                       document.getElementById('showcoltextextent').innerHTML="$lt{'author'}";
                   } else {
                       document.getElementById('showcolextent').disabled = '';
                       document.getElementById('showcolextent').checked = 'true';
                       if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community') {
                           document.getElementById('showcoltextextent').innerHTML="$lt{'community'}";
                       } else {
                           document.getElementById('showcoltextextent').innerHTML="$lt{'course'}";
                       }
                   }
               }
           }
       }
       return;
   }
   
 END  END
     return $output;      return $output;
   
Line 4788  sub print_main_menu { Line 4914  sub print_main_menu {
             );              );
         }          }
     } elsif ($context eq 'author') {      } elsif ($context eq 'author') {
           push(@{ $menu[2]->{items} }, #Category: Administration
             {              {
              linktext => 'Change Log',               linktext => 'Change Log',
              icon => 'document-properties.png',               icon => 'document-properties.png',
Line 4796  sub print_main_menu { Line 4923  sub print_main_menu {
              permission => $permission->{'cusr'},               permission => $permission->{'cusr'},
              linktitle => 'View change log.',               linktitle => 'View change log.',
             },              },
           );
     }      }
     return Apache::lonhtmlcommon::generate_menu(@menu);      return Apache::lonhtmlcommon::generate_menu(@menu);
 #               { text => 'View Log-in History',  #               { text => 'View Log-in History',
Line 6378  sub course_level_table { Line 6506  sub course_level_table {
  my $thiscourse=$protectedcourse;   my $thiscourse=$protectedcourse;
  $thiscourse=~s:_:/:g;   $thiscourse=~s:_:/:g;
  my %coursedata=&Apache::lonnet::coursedescription($thiscourse);   my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
         my $isowner = &is_courseowner($protectedcourse,$coursedata{'internal.courseowner'});          my $isowner = &Apache::lonuserutils::is_courseowner($protectedcourse,$coursedata{'internal.courseowner'});
  my $area=$coursedata{'description'};   my $area=$coursedata{'description'};
         my $crstype=$coursedata{'type'};          my $crstype=$coursedata{'type'};
  if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; }   if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; }
Line 6872  sub update_selfenroll_config { Line 7000  sub update_selfenroll_config {
     my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum);      my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum);
     if (ref($visactions) eq 'HASH') {      if (ref($visactions) eq 'HASH') {
         if (!$visible) {          if (!$visible) {
             $r->print('<br />'.$visactions->{'miss'}.'<br />'.$visactions->{'yous'}.              $r->print('<br /><span class="LC_warning">'.$visactions->{'miss'}.'</span><br />'.$visactions->{'yous'}.
                       '<br />');                        '<br />');
             if (ref($vismsgs) eq 'ARRAY') {              if (ref($vismsgs) eq 'ARRAY') {
                 $r->print('<br />'.$visactions->{'take'}.'<ul>');                  $r->print('<br />'.$visactions->{'take'}.'<ul>');
Line 6902  sub get_selfenroll_titles { Line 7030  sub get_selfenroll_titles {
     return (\@row,\%lt);      return (\@row,\%lt);
 }  }
   
 sub is_courseowner {  
     my ($thiscourse,$courseowner) = @_;  
     if ($courseowner eq '') {  
         if ($env{'request.course.id'} eq $thiscourse) {  
             $courseowner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};  
         }  
     }  
     if ($courseowner ne '') {  
         if ($courseowner eq $env{'user.name'}.':'.$env{'user.domain'}) {  
             return 1;  
         }  
     }  
     return;  
 }  
   
 #---------------------------------------------- end functions for &phase_two  #---------------------------------------------- end functions for &phase_two
   
 #--------------------------------- functions for &phase_two and &phase_three  #--------------------------------- functions for &phase_two and &phase_three

Removed from v.1.363  
changed lines
  Added in v.1.374


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