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

version 1.362, 2012/08/14 15:45:06 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 1701  sub display_existing_roles { Line 1702  sub display_existing_roles {
                     $allowed=1;                      $allowed=1;
                 }                  }
             }              }
             if ($role_code eq 'ca' || $role_code eq 'au') {              if ($role_code eq 'ca' || $role_code eq 'au' || $role_code eq 'aa') {
                 $class='Construction Space';                  $class='Construction Space';
             } elsif ($role_code eq 'su') {              } elsif ($role_code eq 'su') {
                 $class='System';                  $class='System';
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 4496  sub handler { Line 4514  sub handler {
                           $cdom,$cnum,$coursedesc));                            $cdom,$cnum,$coursedesc));
         }          }
     } elsif ($env{'form.action'} eq 'changelogs') {      } elsif ($env{'form.action'} eq 'changelogs') {
           my $helpitem;
           if ($context eq 'course') {
               $helpitem = 'Course_User_Logs';
           }
         push (@{$brcrum},          push (@{$brcrum},
                  {href => '/adm/createuser?action=changelogs',                   {href => '/adm/createuser?action=changelogs',
                   text => 'User Management Logs',                    text => 'User Management Logs',
                   help => 'Course_User_Logs'});                    help => $helpitem});
         $bread_crumbs_component = 'User Changes';          $bread_crumbs_component = 'User Changes';
         $args = { bread_crumbs           => $brcrum,          $args = { bread_crumbs           => $brcrum,
                   bread_crumbs_component => $bread_crumbs_component};                    bread_crumbs_component => $bread_crumbs_component};
Line 4537  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 4659  sub print_main_menu { Line 4789  sub print_main_menu {
              permission => $permission->{'cusr'},               permission => $permission->{'cusr'},
              linktitle => 'Approve or reject author role requests',               linktitle => 'Approve or reject author role requests',
             },              },
               {
                linktext => 'Change Log',
                icon => 'document-properties.png',
                #help => 'Course_User_Logs',
                url => '/adm/createuser?action=changelogs',
                permission => $permission->{'cusr'},
                linktitle => 'View change log.',
               },
         );          );
                   
     }elsif ($context eq 'course'){      }elsif ($context eq 'course'){
Line 4775  sub print_main_menu { Line 4913  sub print_main_menu {
                 },                  },
             );              );
         }          }
     };      } elsif ($context eq 'author') {
 return Apache::lonhtmlcommon::generate_menu(@menu);          push(@{ $menu[2]->{items} }, #Category: Administration
               {
                linktext => 'Change Log',
                icon => 'document-properties.png',
                #help => 'Course_User_Logs',
                url => '/adm/createuser?action=changelogs',
                permission => $permission->{'cusr'},
                linktitle => 'View change log.',
               },
           );
       }
       return Apache::lonhtmlcommon::generate_menu(@menu);
 #               { text => 'View Log-in History',  #               { text => 'View Log-in History',
 #                 help => 'Course_User_Logins',  #                 help => 'Course_User_Logins',
 #                 action => 'logins',  #                 action => 'logins',
Line 5466  sub selfenroll_date_forms { Line 5615  sub selfenroll_date_forms {
   
 sub print_userchangelogs_display {  sub print_userchangelogs_display {
     my ($r,$context,$permission) = @_;      my ($r,$context,$permission) = @_;
     my $formname = 'roleslog';      my $formname = 'rolelog';
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};      my ($username,$domain,$crstype,%roleslog);
     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};      if ($context eq 'domain') {
     my $crstype = &Apache::loncommon::course_type();          $domain = $env{'request.role.domain'};
     my %roleslog=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);          %roleslog=&Apache::lonnet::dump_dom('nohist_rolelog',$domain);
       } else {
           if ($context eq 'course') { 
               $domain = $env{'course.'.$env{'request.course.id'}.'.domain'};
               $username = $env{'course.'.$env{'request.course.id'}.'.num'};
               $crstype = &Apache::loncommon::course_type();
               my %saveable_parameters = ('show' => 'scalar',);
               &Apache::loncommon::store_course_settings('roles_log',
                                                         \%saveable_parameters);
               &Apache::loncommon::restore_course_settings('roles_log',
                                                           \%saveable_parameters);
           } elsif ($context eq 'author') {
               $domain = $env{'user.domain'}; 
               if ($env{'request.role'} =~ m{^au\./\Q$domain\E/$}) {
                   $username = $env{'user.name'};
               } else {
                   undef($domain);
               }
           }
           if ($domain ne '' && $username ne '') { 
               %roleslog=&Apache::lonnet::dump('nohist_rolelog',$domain,$username);
           }
       }
     if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); }      if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); }
   
     my %saveable_parameters = ('show' => 'scalar',);  
     &Apache::loncommon::store_course_settings('roles_log',  
                                               \%saveable_parameters);  
     &Apache::loncommon::restore_course_settings('roles_log',  
                                                 \%saveable_parameters);  
     # set defaults      # set defaults
     my $now = time();      my $now = time();
     my $defstart = $now - (7*24*3600); #7 days ago       my $defstart = $now - (7*24*3600); #7 days ago 
Line 5519  sub print_userchangelogs_display { Line 5685  sub print_userchangelogs_display {
   
     # Form Header      # Form Header
     $r->print('<form action="/adm/createuser" method="post" name="'.$formname.'">'.      $r->print('<form action="/adm/createuser" method="post" name="'.$formname.'">'.
               &role_display_filter($formname,$cdom,$cnum,\%curr,$version,$crstype));                &role_display_filter($context,$formname,$domain,$username,\%curr,
                                      $version,$crstype));
   
     # Create navigation      # Create navigation
     my ($nav_script,$nav_links) = &userlogdisplay_nav($formname,\%curr,$more_records);      my ($nav_script,$nav_links) = &userlogdisplay_nav($formname,\%curr,$more_records);
Line 5532  sub print_userchangelogs_display { Line 5699  sub print_userchangelogs_display {
        .'<th>'.&mt('When').'</th>'         .'<th>'.&mt('When').'</th>'
        .'<th>'.&mt('Who made the change').'</th>'         .'<th>'.&mt('Who made the change').'</th>'
        .'<th>'.&mt('Changed User').'</th>'         .'<th>'.&mt('Changed User').'</th>'
        .'<th>'.&mt('Role').'</th>'         .'<th>'.&mt('Role').'</th>';
        .'<th>'.&mt('Section').'</th>'  
        .'<th>'.&mt('Context').'</th>'      if ($context eq 'course') {
           $tableheader .= '<th>'.&mt('Section').'</th>';
       }
       $tableheader .=
           '<th>'.&mt('Context').'</th>'
        .'<th>'.&mt('Start').'</th>'         .'<th>'.&mt('Start').'</th>'
        .'<th>'.&mt('End').'</th>'         .'<th>'.&mt('End').'</th>'
        .&Apache::loncommon::end_data_table_header_row();         .&Apache::loncommon::end_data_table_header_row();
Line 5603  sub print_userchangelogs_display { Line 5774  sub print_userchangelogs_display {
         if ($roleslog{$id}{'logentry'}{'selfenroll'}) {          if ($roleslog{$id}{'logentry'}{'selfenroll'}) {
             $chgcontext = 'selfenroll';              $chgcontext = 'selfenroll';
         }          }
         my %lt = &rolechg_contexts($crstype);          my %lt = &rolechg_contexts($context,$crstype);
         if ($chgcontext ne '' && $lt{$chgcontext} ne '') {          if ($chgcontext ne '' && $lt{$chgcontext} ne '') {
             $chgcontext = $lt{$chgcontext};              $chgcontext = $lt{$chgcontext};
         }          }
Line 5613  sub print_userchangelogs_display { Line 5784  sub print_userchangelogs_display {
            .'<td>'.&Apache::lonlocal::locallocaltime($roleslog{$id}{'exe_time'}).'</td>'             .'<td>'.&Apache::lonlocal::locallocaltime($roleslog{$id}{'exe_time'}).'</td>'
            .'<td>'.$whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}.'</td>'             .'<td>'.$whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}.'</td>'
            .'<td>'.$changed{$roleslog{$id}{'uname'}.':'.$roleslog{$id}{'udom'}}.'</td>'             .'<td>'.$changed{$roleslog{$id}{'uname'}.':'.$roleslog{$id}{'udom'}}.'</td>'
            .'<td>'.&Apache::lonnet::plaintext($roleslog{$id}{'logentry'}{'role'},$crstype).'</td>'             .'<td>'.&Apache::lonnet::plaintext($roleslog{$id}{'logentry'}{'role'},$crstype).'</td>');
            .'<td>'.$sec.'</td>'          if ($context eq 'course') { 
            .'<td>'.$chgcontext.'</td>'              $r->print('<td>'.$sec.'</td>');
           }
           $r->print(
               '<td>'.$chgcontext.'</td>'
            .'<td>'.$rolestart.'</td>'             .'<td>'.$rolestart.'</td>'
            .'<td>'.$roleend.'</td>'             .'<td>'.$roleend.'</td>'
            .&Apache::loncommon::end_data_table_row()."\n");             .&Apache::loncommon::end_data_table_row()."\n");
Line 5683  ENDSCRIPT Line 5857  ENDSCRIPT
 }  }
   
 sub role_display_filter {  sub role_display_filter {
     my ($formname,$cdom,$cnum,$curr,$version,$crstype) = @_;      my ($context,$formname,$cdom,$cnum,$curr,$version,$crstype) = @_;
     my $context = 'course';      my $lctype;
     my $lctype = lc($crstype);      if ($context eq 'course') {
           $lctype = lc($crstype);
       }
     my $nolink = 1;      my $nolink = 1;
     my $output = '<table><tr><td valign="top">'.      my $output = '<table><tr><td valign="top">'.
                  '<span class="LC_nobreak"><b>'.&mt('Changes/page:').'</b></span><br />'.                   '<span class="LC_nobreak"><b>'.&mt('Changes/page:').'</b></span><br />'.
Line 5700  sub role_display_filter { Line 5876  sub role_display_filter {
         &Apache::lonhtmlcommon::date_setter($formname,'rolelog_end_date',          &Apache::lonhtmlcommon::date_setter($formname,'rolelog_end_date',
                                             $curr->{'rolelog_end_date'},undef,                                              $curr->{'rolelog_end_date'},undef,
                                             undef,undef,undef,undef,undef,undef,$nolink);                                              undef,undef,undef,undef,undef,undef,$nolink);
     my %lt = &rolechg_contexts($crstype);      my %lt = &rolechg_contexts($context,$crstype);
     $output .= '<td valign="top"><b>'.&mt('Window during which changes occurred:').'</b><br />'.      $output .= '<td valign="top"><b>'.&mt('Window during which changes occurred:').'</b><br />'.
                '<table><tr><td>'.&mt('After:').                 '<table><tr><td>'.&mt('After:').
                '</td><td>'.$startform.'</td></tr>'.                 '</td><td>'.$startform.'</td></tr>'.
Line 5714  sub role_display_filter { Line 5890  sub role_display_filter {
         $output .= ' selected="selected"';          $output .= ' selected="selected"';
     }      }
     $output .=  '>'.&mt('Any').'</option>'."\n";      $output .=  '>'.&mt('Any').'</option>'."\n";
     my @roles = &Apache::lonuserutils::course_roles($context,undef,1,$lctype);      my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype);
     foreach my $role (@roles) {      foreach my $role (@roles) {
         my $plrole;          my $plrole;
         if ($role eq 'cr') {          if ($role eq 'cr') {
Line 5732  sub role_display_filter { Line 5908  sub role_display_filter {
                '<td>&nbsp;&nbsp;</td>'.                 '<td>&nbsp;&nbsp;</td>'.
                '<td valign="top"><b>'.                 '<td valign="top"><b>'.
                &mt('Context:').'</b><br /><select name="chgcontext">';                 &mt('Context:').'</b><br /><select name="chgcontext">';
     foreach my $chgtype ('any','auto','updatenow','createcourse','course','domain','selfenroll','requestcourses') {      my @posscontexts;
       if ($context eq 'course') {
           @posscontexts = ('any','auto','updatenow','createcourse','course','domain','selfenroll','requestcourses');
       } elsif ($context eq 'domain') {
           @posscontexts = ('any','domain','requestauthor','domconfig','server');
       } else {
           @posscontexts = ('any','author','domain');
       } 
       foreach my $chgtype (@posscontexts) {
         my $selstr = '';          my $selstr = '';
         if ($curr->{'chgcontext'} eq $chgtype) {          if ($curr->{'chgcontext'} eq $chgtype) {
             $selstr = ' selected="selected"';              $selstr = ' selected="selected"';
         }          }
         if (($chgtype eq 'auto') || ($chgtype eq 'updatenow')) {          if ($context eq 'course') {
             next if (!&Apache::lonnet::auto_run($cnum,$cdom));              if (($chgtype eq 'auto') || ($chgtype eq 'updatenow')) {
                   next if (!&Apache::lonnet::auto_run($cnum,$cdom));
               }
         }          }
         $output .= '<option value="'.$chgtype.'"'.$selstr.'>'.$lt{$chgtype}.'</option>'."\n";          $output .= '<option value="'.$chgtype.'"'.$selstr.'>'.$lt{$chgtype}.'</option>'."\n";
     }      }
Line 5751  sub role_display_filter { Line 5937  sub role_display_filter {
               .'</p>';                .'</p>';
   
     # Server version info      # Server version info
       my $needsrev = '2.11.0';
       if ($context eq 'course') {
           $needsrev = '2.7.0';
       }
       
     $output .= '<p class="LC_info">'      $output .= '<p class="LC_info">'
               .&mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.'                .&mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.'
                   ,'2.6.99.0');                    ,$needsrev);
     if ($version) {      if ($version) {
         $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version);          $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version);
     }      }
Line 5762  sub role_display_filter { Line 5953  sub role_display_filter {
 }  }
   
 sub rolechg_contexts {  sub rolechg_contexts {
     my ($crstype) = @_;      my ($context,$crstype) = @_;
     my %lt = &Apache::lonlocal::texthash (      my %lt;
       if ($context eq 'course') {
           %lt = &Apache::lonlocal::texthash (
                                              any          => 'Any',                                               any          => 'Any',
                                              auto         => 'Automated enrollment',                                               auto         => 'Automated enrollment',
                                              updatenow    => 'Roster Update',                                               updatenow    => 'Roster Update',
Line 5773  sub rolechg_contexts { Line 5966  sub rolechg_contexts {
                                              selfenroll   => 'Self-enrolled',                                               selfenroll   => 'Self-enrolled',
                                              requestcourses => 'Course Request',                                               requestcourses => 'Course Request',
                                          );                                           );
     if ($crstype eq 'Community') {          if ($crstype eq 'Community') {
         $lt{'createcourse'} = &mt('Community Creation');              $lt{'createcourse'} = &mt('Community Creation');
         $lt{'course'} = &mt('User Management in community');              $lt{'course'} = &mt('User Management in community');
         $lt{'requestcourses'} = &mt('Community Request');              $lt{'requestcourses'} = &mt('Community Request');
     }          }
       } elsif ($context eq 'domain') {
           %lt = &Apache::lonlocal::texthash (
                                                any           => 'Any',
                                                domain        => 'User Management in domain',
                                                requestauthor => 'Authoring Request',
                                                server        => 'Command line script (DC role)',
                                                domconfig     => 'Self-enrolled',
                                            );
       } else {
           %lt = &Apache::lonlocal::texthash (
                                                any    => 'Any',
                                                domain => 'User Management in domain',
                                                author => 'User Management by author',
                                            );
       } 
     return %lt;      return %lt;
 }  }
   
Line 6298  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 6792  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 6822  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.362  
changed lines
  Added in v.1.374


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