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

version 1.368, 2012/12/20 16:22:59 version 1.374, 2013/02/19 17:30:35
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 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 3062  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 3083  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) {      if ($changed) {
         $title = $lt{'uic'};          $r->print('<h3>'.$lt{'uic'}.'</h3>'.
         $r->print('<h4>'.$title.'</h4>'.  
                 &Apache::loncommon::start_data_table().                  &Apache::loncommon::start_data_table().
                 &Apache::loncommon::start_data_table_header_row());                  &Apache::loncommon::start_data_table_header_row());
         $r->print("<th>&nbsp;</th>\n");          $r->print("<th>&nbsp;</th>\n");
Line 3145  sub display_userinfo { Line 3144  sub display_userinfo {
             }              }
         }          }
         $r->print(&Apache::loncommon::end_data_table().'<br />');          $r->print(&Apache::loncommon::end_data_table().'<br />');
       } else {
           $r->print('<h3>'.$lt{'ui'}.'</h3>'.
                     '<p>'.&mt('No changes made to user information').'</p>');
     }      }
     return;      return;
 }  }
Line 3343  sub update_roles { Line 3345  sub update_roles {
  $env{'form.ccuname'},   $env{'form.ccuname'},
  $scope,$role,'','',$context);   $scope,$role,'','',$context);
                 $r->print(&Apache::lonhtmlcommon::confirm_success(                  $r->print(&Apache::lonhtmlcommon::confirm_success(
                             &mt('Revoking [_1] in [_2]', &Apache::lonnet::plaintext($role), '"'.&cid_to_cname($scope).'"<br />'),                              &mt('Revoking [_1] in [_2]',
                             $result ne "ok"));                                  &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,
Line 3358  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
                   my $result = &Apache::lonnet::revokecustomrole(
                       $env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context);
                 $r->print(&Apache::lonhtmlcommon::confirm_success(                  $r->print(&Apache::lonhtmlcommon::confirm_success(
                             &mt('Revoking custom role [_1] by [_2]:[_3] in [_4]',$4,$3,$2,'"'.&cid_to_cname($1).'"<br />'),                              &mt('Revoking custom role [_1] by [_2] in [_3]',
                             &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context) ne 'ok'));                                  $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 3377  sub update_roles { Line 3389  sub update_roles {
                                                 $context);                                                  $context);
                 $r->print(&Apache::lonhtmlcommon::confirm_success(                  $r->print(&Apache::lonhtmlcommon::confirm_success(
                             &mt('Deleting [_1] in [_2]',                              &mt('Deleting [_1] in [_2]',
                             &Apache::lonnet::plaintext($role),'"'.&cid_to_cname($scope).'"<br />'),$result ne 'ok'));                                  &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 3393  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(&confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',                  my $result =
                       $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"').'<br />'));                      &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);                  $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 3414  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 = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',&Apache::lonnet::plaintext($role),                              $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',
                                         '"'.&cid_to_cname($url).'"',&Apache::lonlocal::locallocaltime($now))).'<br />'.$logmsg.'<br />';                                          &Apache::lonnet::plaintext($role),
                                           &Apache::loncommon::show_role_extent($url,$context,'st'),
                                           &Apache::lonlocal::locallocaltime($now))).'<br />'.$logmsg.'<br />';
                         }                          }
                     }                      }
                 } else {                  } else {
Line 3431  sub update_roles { Line 3456  sub update_roles {
                                $env{'form.ccuname'},$url,$role,0,$now,'','',                                 $env{'form.ccuname'},$url,$role,0,$now,'','',
                                $context);                                 $context);
                         $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',                          $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
                                         &Apache::lonnet::plaintext($role),'"'.&cid_to_cname($url).'"').'<br />',$result ne "ok");                                          &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 3444  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(&Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling custom role [_1] by [_2] in [_3]',                  $r->print(&Apache::lonhtmlcommon::confirm_success(
                         $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"').'<br />'),$result ne "ok");                      &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 3585  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 4526  sub add_script { Line 4560  sub add_script {
   
 sub verify_user_display {  sub verify_user_display {
     my ($context) = @_;      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;      my $photos;
     if (($context eq 'course') && $env{'request.course.id'}) {      if (($context eq 'course') && $env{'request.course.id'}) {
         $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};          $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
Line 4549  function updateCols(caller) { Line 4588  function updateCols(caller) {
     var context = '$context';      var context = '$context';
     var photos = '$photos';      var photos = '$photos';
     if (caller == 'Status') {      if (caller == 'Status') {
         if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {          if ((context == 'domain') && 
             document.getElementById('showcolstatus').checked = true;              ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
             document.getElementById('showcolstatus').disabled = '';               (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community'))) {
             document.getElementById('showcolstart').checked = true;  
             document.getElementById('showcolend').checked = true;  
         } else {  
             document.getElementById('showcolstatus').checked = false;              document.getElementById('showcolstatus').checked = false;
             document.getElementById('showcolstatus').disabled = 'disabled';              document.getElementById('showcolstatus').disabled = 'disabled';
             document.getElementById('showcolstart').checked = false;              document.getElementById('showcolstart').checked = false;
             document.getElementById('showcolend').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 (caller == 'output') {
Line 4576  function updateCols(caller) { Line 4624  function updateCols(caller) {
         }          }
     }      }
     if (caller == 'showrole') {      if (caller == 'showrole') {
         if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') {          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').checked = true;
             document.getElementById('showcolrole').disabled = '';              document.getElementById('showcolrole').disabled = '';
         } else {          } else {
             document.getElementById('showcolrole').checked = false;              document.getElementById('showcolrole').checked = false;
             document.getElementById('showcolrole').disabled = 'disabled';              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;      return;
 }  }
Line 4826  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 4834  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 6945  sub get_selfenroll_titles { Line 7035  sub get_selfenroll_titles {
 #--------------------------------- functions for &phase_two and &phase_three  #--------------------------------- functions for &phase_two and &phase_three
   
 #--------------------------end of functions for &phase_two and &phase_three  #--------------------------end of functions for &phase_two and &phase_three
 sub cid_to_cname(){  
     my $courseid = shift;  
     $courseid =~ s/^\///;  
     $courseid =~ s/\//_/;  
     return $env{'course.'.$courseid.'.description'};  
 }  
 1;  1;
 __END__  __END__
   

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


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