Diff for /loncom/interface/loncreateuser.pm between versions 1.301 and 1.306

version 1.301, 2009/08/04 18:02:30 version 1.306, 2009/08/08 00:36:00
Line 216  END_SCRIPT Line 216  END_SCRIPT
   
 sub build_tools_display {  sub build_tools_display {
     my ($ccuname,$ccdomain,$context) = @_;      my ($ccuname,$ccdomain,$context) = @_;
     my (@usertools,%userenv,$output);      my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay,
           $colspan);
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                    'blog'       => "Personal User Blog",                     'blog'       => "Personal User Blog",
                    'aboutme'    => "Personal Information Page",                     'aboutme'    => "Personal Information Page",
Line 235  sub build_tools_display { Line 236  sub build_tools_display {
                       'requestcourses.official','requestcourses.unofficial',                        'requestcourses.official','requestcourses.unofficial',
                       'requestcourses.community');                        'requestcourses.community');
         @usertools = ('official','unofficial','community');          @usertools = ('official','unofficial','community');
           @options =('norequest','approve','autolimit','validate');
           %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);
           %reqtitles = &courserequest_titles();
           %reqdisplay = &courserequest_display();
           $colspan = ' colspan="2"';
     } else {      } else {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,          %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
                           'tools.aboutme','tools.portfolio','tools.blog');                            'tools.aboutme','tools.portfolio','tools.blog');
         @usertools = ('aboutme','blog','portfolio');          @usertools = ('aboutme','blog','portfolio');
     }      }
     foreach my $item (@usertools) {      foreach my $item (@usertools) {
         my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off);          my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off,
               $currdisp,$custdisp,$custradio);
         $cust_off = 'checked="checked" ';          $cust_off = 'checked="checked" ';
         $tool_on = 'checked="checked" ';          $tool_on = 'checked="checked" ';
         $curr_access =            $curr_access =  
             &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,              &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
                                               $context);                                                $context);
         if ($userenv{$context.'.'.$item} eq '') {          if ($userenv{$context.'.'.$item} ne '') {
             $custom_access = 'default';  
             if (!$curr_access) {  
                 $tool_off = 'checked="checked" ';  
                 $tool_on = '';  
             }  
         } else {  
             $custom_access = 'custom';  
             $cust_on = ' checked="checked" ';              $cust_on = ' checked="checked" ';
             $cust_off = '';              $cust_off = '';
             if ($userenv{$context.'.'.$item} == 0) {          }
                 $tool_off = 'checked="checked" ';          if ($context eq 'requestcourses') {
                 $tool_on = '';              if ($userenv{$context.'.'.$item} eq '') {
                   $custom_access = &mt('Currently from default setting.'); 
               } else {
                   $custom_access = &mt('Currently from custom setting.');
               }
           } else {
               if ($userenv{$context.'.'.$item} eq '') {
                   $custom_access = 
                       &mt('Availability determined currently from default setting.');
                   if (!$curr_access) {
                       $tool_off = 'checked="checked" ';
                       $tool_on = '';
                   }
               } else {
                   $custom_access = 
                       &mt('Availability determined currently from custom setting.');
                   if ($userenv{$context.'.'.$item} == 0) {
                       $tool_off = 'checked="checked" ';
                       $tool_on = '';
                   }
             }              }
         }          }
         $output .= '  <tr class="LC_info_row">'."\n".          $output .= '  <tr class="LC_info_row">'."\n".
                    '   <td>'.$lt{$item}.'</td>'."\n".                     '   <td'.$colspan.'>'.$lt{$item}.'</td>'."\n".
                    '  </tr>'."\n".                     '  </tr>'."\n".
                    &Apache::loncommon::start_data_table_row()."\n".                     &Apache::loncommon::start_data_table_row()."\n";
                    '  <td>'.&mt('Availability determined currently from [_1] setting.',$custom_access).          if ($context eq 'requestcourses') {
                    '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$lt{'avai'}.': '.              my ($curroption,$currlimit);
                    ($curr_access?&mt('Yes'):&mt('No')).'</td>'."\n".              $curroption = $userenv{$context.'.'.$item};
               if (!$curroption) {
                   $curroption = 'norequest';
               }
               if ($curroption =~ /^autolimit=(\d*)$/) {
                   $currlimit = $1;
                   $currdisp = &mt('Yes, up to [quant,_1,request]/user',$currlimit); 
               } else {
                   $currdisp = $reqdisplay{$curroption};
               }
               $custdisp = '<table>';
               foreach my $option (@options) {
                   my $val = $option;
                   if ($option eq 'norequest') {
                       $val = 0;
                   }
                   if ($option eq 'validate') {
                       my $canvalidate = 0;
                       if (ref($validations{$item}) eq 'HASH') {
                           if ($validations{$item}{'_custom_'}) {
                               $canvalidate = 1;
                           }
                       }
                       next if (!$canvalidate);
                   }
                   my $checked = '';
                   if ($option eq $curroption) {
                       $checked = ' checked="checked"';
                   } elsif ($option eq 'autolimit') {
                       if ($curroption =~ /^autolimit/) {
                           $checked = ' checked="checked"';
                       }
                   }
                   $custdisp .= '<tr><td><span class="LC_nobreak"><label>'.
                                '<input type="radio" name="crsreq_'.$item.
                                '" value="'.$val.'"'.$checked.' />'.
                                $reqtitles{$option}.'</label>&nbsp;';
                   if ($option eq 'autolimit') {
                       $custdisp .= '<input type="text" name="crsreq_'.
                                    $item.'_limit" size="1" '.
                                    'value="'.$currlimit.'" />';
                    }
                    $custdisp .= '</span></td></tr>';
               }
               $custdisp .= '</table>';
               $custradio = '</span></td><td>'.&mt('Custom setting').'<br />'.$custdisp;
           } else {
               $currdisp = ($curr_access?&mt('Yes'):&mt('No'));
               $custdisp = '<span class="LC_nobreak"><label>'.
                           '<input type="radio" name="'.$context.'_'.$item.'"'. 
                           ' value="1"'. $tool_on.'/>'.&mt('On').'</label>&nbsp;<label>'.
                           '<input type="radio" name="'.$context.'_'.$item.'" value="0" '.
                           $tool_off.'/>'.&mt('Off').'</label></span>';
               $custradio = ('&nbsp;'x2).'--'.$lt{'cusa'}.':&nbsp;'.$custdisp.
                             '</span>';
           }
           $output .= '  <td'.$colspan.'>'.$custom_access.('&nbsp;'x4).
                      $lt{'avai'}.': '.$currdisp.'</td>'."\n".
                    &Apache::loncommon::end_data_table_row()."\n".                     &Apache::loncommon::end_data_table_row()."\n".
                    &Apache::loncommon::start_data_table_row()."\n".                     &Apache::loncommon::start_data_table_row()."\n".
                    '  <td><span class="LC_nobreak">'.$lt{'chse'}.': <label>'.                     '  <td style="vertical-align:top;"><span class="LC_nobreak">'.
                      $lt{'chse'}.': <label>'.
                    '<input type="radio" name="custom'.$item.'" value="0" '.                     '<input type="radio" name="custom'.$item.'" value="0" '.
                    $cust_off.'/>'.$lt{'usde'}.'</label>&nbsp;&nbsp;&nbsp;'.                     $cust_off.'/>'.$lt{'usde'}.'</label>'.('&nbsp;' x3).
                     '<label><input type="radio" name="custom'.$item.'" value="1" '.                     '<label><input type="radio" name="custom'.$item.'" value="1" '.
                    $cust_on.'/>'.$lt{'uscu'}.'</label>&nbsp;&nbsp;--&nbsp;&nbsp;'.                     $cust_on.'/>'.$lt{'uscu'}.'</label>'.$custradio.'</td>'.
                    $lt{'cusa'}.':&nbsp;<label>'.  
                    '<input type="radio" name="'.$context.'_'.$item.'" value="1" '.  
                    $tool_on.'/>'.&mt('On').'</label>&nbsp;<label>'.  
                    '<input type="radio" name="'.$context.'_'.$item.'" value="0" '.  
                    $tool_off.'/>'.&mt('Off').'</label></span></td>'."\n".  
                    &Apache::loncommon::end_data_table_row()."\n";                     &Apache::loncommon::end_data_table_row()."\n";
     }      }
     return $output;      return $output;
Line 288  sub build_tools_display { Line 360  sub build_tools_display {
   
 sub coursereq_externaluser {  sub coursereq_externaluser {
     my ($ccuname,$ccdomain,$cdom) = @_;      my ($ccuname,$ccdomain,$cdom) = @_;
     my (@usertools,%userenv,$output);      my (@usertools,@options,%validations,%userenv,$output);
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                    'official'   => 'Can request creation of official courses',                     'official'   => 'Can request creation of official courses',
                    'unofficial' => 'Can request creation of unofficial courses',                     'unofficial' => 'Can request creation of unofficial courses',
Line 299  sub coursereq_externaluser { Line 371  sub coursereq_externaluser {
                       'reqcrsotherdom.official','reqcrsotherdom.unofficial',                        'reqcrsotherdom.official','reqcrsotherdom.unofficial',
                       'reqcrsotherdom.community');                        'reqcrsotherdom.community');
     @usertools = ('official','unofficial','community');      @usertools = ('official','unofficial','community');
       @options = ('approve','validate','autolimit');
       %validations = &Apache::lonnet::auto_courserequest_checks($cdom);
       my $optregex = join('|',@options);
       my %reqtitles = &courserequest_titles();
     foreach my $item (@usertools) {      foreach my $item (@usertools) {
         my ($tool_on,$tool_off);          my ($curroption,$currlimit,$tooloff);
         $tool_off = 'checked="checked" ';  
         if ($userenv{'reqcrsotherdom.'.$item} ne '') {          if ($userenv{'reqcrsotherdom.'.$item} ne '') {
             my @curr = split(',',$userenv{'reqcrsotherdom.'.$item});              my @curr = split(',',$userenv{'reqcrsotherdom.'.$item});
             if (grep(/^\Q$cdom\E$/,@curr)) {              if (grep(/^\Q$cdom\E:($optregex)=?(\d*)$/,@curr)) {
                 $tool_on = 'checked="checked" ';                  $curroption = $1;
                 $tool_off = '';                  $currlimit = $2;
                   if (!$curroption) {
                       $curroption = 'norequest';
                   }
               }
           } else {
               $curroption = 'norequest';
               $tooloff = ' checked="checked"';
           }
           $output.= &Apache::loncommon::start_data_table_row()."\n".
                     '  <td><span class="LC_nobreak">'.$lt{$item}.': '.
                     '<label><input type="radio" name="reqcrsotherdom_'.$item.
                     '" value="0"'.$tooloff.' />'.$reqtitles{'norequest'}.
                     '</label>&nbsp;';
           foreach my $option (@options) {
               if ($option eq 'validate') {
                   my $canvalidate = 0;
                   if (ref($validations{$item}) eq 'HASH') {
                       if ($validations{$item}{'_external_'}) {
                           $canvalidate = 1;
                       }
                   }
                   next if (!$canvalidate);
               }
               my $checked = '';
               if ($option eq $curroption) {
                   $checked = ' checked="checked"';
               }
               $output .= '<span class="LC_nobreak"><label>'.
                          '<input type="radio" name="reqcrsotherdom_'.$item.
                          '" value="'.$option.'"'.$checked.' />'.
                          $reqtitles{$option}.'</label>&nbsp;';
               if ($option eq 'autolimit') {
                   $output .= '<input type="text" name="reqcrsotherdom_'.
                              $item.'_limit" size="1" '.
                              'value="'.$currlimit.'" />';
             }              }
               $output .= '&nbsp;'
         }          }
         $output .= &Apache::loncommon::start_data_table_row()."\n".          $output .= '</span></td>'."\n".
                    '  <td><span class="LC_nobreak">'.$lt{$item}.': <label>'.  
                    '<input type="radio" name="reqcrsotherdom_'.$item.'" value="1" '.  
                    $tool_on.'/>'.&mt('Yes').'</label>&nbsp;<label>'.  
                    '<input type="radio" name="reqcrsotherdom_'.$item.'" value="0" '.  
                    $tool_off.'/>'.&mt('No').'</label></span></td>'."\n".  
                    &Apache::loncommon::end_data_table_row()."\n";                     &Apache::loncommon::end_data_table_row()."\n";
     }      }
     return $output;      return $output;
 }  }
   
   sub courserequest_titles {
       my %titles = &Apache::lonlocal::texthash (
                                      official   => 'Official',
                                      unofficial => 'Unofficial',
                                      community  => 'Communities',
                                      norequest  => 'Not allowed',
                                      approve    => 'Approval by Dom. Coord.',
                                      validate   => 'With validation',
                                      autolimit  => 'Numerical limit',
                    );
       return %titles;
   }
   
   sub courserequest_display {
       my %titles = &Apache::lonlocal::texthash (
                                      approve    => 'Yes, need approval',
                                      validate   => 'Yes, with validation',
                                      norequest  => 'No',
      );
      return %titles;
   }
   
 # =================================================================== Phase one  # =================================================================== Phase one
   
 sub print_username_entry_form {  sub print_username_entry_form {
Line 530  END Line 658  END
   
 # =================================================================== Phase two  # =================================================================== Phase two
 sub print_user_selection_page {  sub print_user_selection_page {
     my ($r,$response,$srch,$srch_results,$srcharray,$context) = @_;      my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements) = @_;
     my @fields = ('username','domain','lastname','firstname','permanentemail');      my @fields = ('username','domain','lastname','firstname','permanentemail');
     my $sortby = $env{'form.sortby'};      my $sortby = $env{'form.sortby'};
   
Line 566  ENDSCRIPT Line 694  ENDSCRIPT
                                        'firstname'      => "first name",                                         'firstname'      => "first name",
                                        'permanentemail' => "permanent e-mail",                                         'permanentemail' => "permanent e-mail",
                                       );                                        );
     $r->print(&Apache::loncommon::start_page('User Management',$jscript));      if ($context eq 'requestcrs') {
           $r->print('<div>');
       } else {
           $r->print(&Apache::loncommon::start_page('User Management',$jscript));
   
     my %breadcrumb_text = &singleuser_breadcrumb();          my %breadcrumb_text = &singleuser_breadcrumb();
     &Apache::lonhtmlcommon::add_breadcrumb          &Apache::lonhtmlcommon::add_breadcrumb
         ({href=>"javascript:backPage(document.usersrchform,'','')",              ({href=>"javascript:backPage(document.usersrchform,'','')",
           text=>$breadcrumb_text{'search'},                text=>$breadcrumb_text{'search'},
           faq=>282,bug=>'Instructor Interface',},                faq=>282,bug=>'Instructor Interface',},
          {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",               {href=>"javascript:backPage(document.usersrchform,'get_user_info','select')",
           text=>$breadcrumb_text{'userpicked'},                text=>$breadcrumb_text{'userpicked'},
           faq=>282,bug=>'Instructor Interface',});                faq=>282,bug=>'Instructor Interface',});
     if ($env{'form.action'} eq 'singleuser') {          if ($env{'form.action'} eq 'singleuser') {
         $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',              $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
                                                       'Course_Change_Privileges'));                                                            'Course_Change_Privileges'));
         $r->print("<b>$lt{'usrch'}</b><br />");              $r->print("<b>$lt{'usrch'}</b><br />");
         $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));              $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
         $r->print('<h3>'.$lt{'usel'}.'</h3>');              $r->print('<h3>'.$lt{'usel'}.'</h3>');
     } elsif ($env{'form.action'} eq 'singlestudent') {          } elsif ($env{'form.action'} eq 'singlestudent') {
         $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',              $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
                                                       'Course_Add_Student'));                                                            'Course_Add_Student'));
         $r->print($jscript."<b>$lt{'stusrch'}</b><br />");              $r->print($jscript."<b>$lt{'stusrch'}</b><br />");
         $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));              $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context));
         $r->print('</form><h3>'.$lt{'stusel'}.'</h3>');              $r->print('</form><h3>'.$lt{'stusel'}.'</h3>');
           }
     }      }
     $r->print('<form name="usersrchform" method="post">'.      $r->print('<form name="usersrchform" method="post">'.
               &Apache::loncommon::start_data_table()."\n".                &Apache::loncommon::start_data_table()."\n".
Line 612  ENDSCRIPT Line 744  ENDSCRIPT
   
     foreach my $user (@sorted_users) {      foreach my $user (@sorted_users) {
         my ($uname,$udom) = split(/:/,$user);          my ($uname,$udom) = split(/:/,$user);
           my $onclick;
           if ($context eq 'requestcrs') {
               $onclick = 
                   'onclick="javascript:gochoose('."'$uname','$udom',".
                                                  "'$srch_results->{$user}->{firstname}',".
                                                  "'$srch_results->{$user}->{lastname}',".
                                                  "'$srch_results->{$user}->{permanentemail}'".');"';
           } else {
               $onclick = 
                   ' onclick="javascript:pickuser('."'".$uname."'".','."'".$udom."'".');"';
           }
         $r->print(&Apache::loncommon::start_data_table_row().          $r->print(&Apache::loncommon::start_data_table_row().
                   '<td><input type="button" name="seluser" value="'.&mt('Select').'" onclick="javascript:pickuser('."'".$uname."'".','."'".$udom."'".')" /></td>'.                    '<td><input type="button" name="seluser" value="'.&mt('Select').'" '.
                     $onclick.' /></td>'.
                   '<td><tt>'.$uname.'</tt></td>'.                    '<td><tt>'.$uname.'</tt></td>'.
                   '<td><tt>'.$udom.'</tt></td>');                    '<td><tt>'.$udom.'</tt></td>');
         foreach my $field ('lastname','firstname','permanentemail') {          foreach my $field ('lastname','firstname','permanentemail') {
Line 633  ENDSCRIPT Line 777  ENDSCRIPT
               ' <input type="hidden" name="currstate" value="select" />'."\n".                ' <input type="hidden" name="currstate" value="select" />'."\n".
               ' <input type="hidden" name="phase" value="get_user_info" />'."\n".                ' <input type="hidden" name="phase" value="get_user_info" />'."\n".
               ' <input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n");                ' <input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n");
     $r->print($response.'</form>'.&Apache::loncommon::end_page());      if ($context eq 'requestcrs') {
           $r->print($opener_elements.'</form></div>');
       } else {
           $r->print($response.'</form>'.&Apache::loncommon::end_page());
       }
 }  }
   
 sub print_user_query_page {  sub print_user_query_page {
Line 815  ENDTITLE Line 963  ENDTITLE
             &personal_data_display($ccuname,$ccdomain,$newuser,$context,              &personal_data_display($ccuname,$ccdomain,$newuser,$context,
                                    $inst_results{$ccuname.':'.$ccdomain});                                     $inst_results{$ccuname.':'.$ccdomain});
         $r->print($personal_table);          $r->print($personal_table);
   #FIXME
         my ($home_server_pick,$numlib) =           my ($home_server_pick,$numlib) = 
             &Apache::loncommon::home_server_form_item($ccdomain,'hserver',              &Apache::loncommon::home_server_form_item($ccdomain,'hserver',
                                                       'default','hide');                                                        'default','hide');
Line 826  $lt{'hs'}: $home_server_pick Line 975  $lt{'hs'}: $home_server_pick
         } else {          } else {
             $r->print($home_server_pick);              $r->print($home_server_pick);
         }          }
           if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
               $r->print('<br /><h3>'.&mt('User Can Request Creation of Courses in this Domain?').'</h3>'.
                         &Apache::loncommon::start_data_table().
                         &build_tools_display($ccuname,$ccdomain,
                                              'requestcourses').
                         &Apache::loncommon::end_data_table());
           }
         $r->print('</div>'."\n".'<div class="LC_left_float"><h3>'.          $r->print('</div>'."\n".'<div class="LC_left_float"><h3>'.
                   $lt{'lg'}.'</h3>');                    $lt{'lg'}.'</h3>');
         my ($fixedauth,$varauth,$authmsg);           my ($fixedauth,$varauth,$authmsg); 
Line 2002  sub update_user_data { Line 2158  sub update_user_data {
                 }                  }
             }              }
             foreach my $item (@requestcourses) {              foreach my $item (@requestcourses) {
                 $newcustom{$item} = $env{'form.requestcourses_'.$item};                  $newcustom{$item} = $env{'form.crsreq_'.$item};
                   if ($env{'form.crsreq_'.$item} eq 'autolimit') {
                       $newcustom{$item} .= '=';
                       unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
                           $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
                       }
                   }
                 $changed{$item} = &tool_admin($item,$newcustom{$item},                  $changed{$item} = &tool_admin($item,$newcustom{$item},
                                               \%changeHash,'requestcourses');                                                \%changeHash,'requestcourses');
             }              }
Line 2648  sub tool_changes { Line 2810  sub tool_changes {
         return;          return;
     }      }
     if ($context eq 'reqcrsotherdom') {      if ($context eq 'reqcrsotherdom') {
           my @options = ('approve','validate','autolimit');
           my $optregex = join('|',@options);
           my %reqdisplay = &courserequest_display();
         my $cdom = $env{'request.role.domain'};          my $cdom = $env{'request.role.domain'};
         foreach my $tool (@{$usertools}) {          foreach my $tool (@{$usertools}) {
             $oldaccesstext->{$tool} = &mt('no');              $oldaccesstext->{$tool} = &mt('no');
Line 2666  sub tool_changes { Line 2831  sub tool_changes {
                 my @curr = split(',',$userenv->{$context.'.'.$tool});                  my @curr = split(',',$userenv->{$context.'.'.$tool});
                 my @new;                  my @new;
                 my $changedoms;                  my $changedoms;
                 if (grep(/^\Q$cdom\E$/,@curr)) {                  my $newop = $env{'form.'.$context.'_'.$tool};
                   if ($newop eq 'autolimit') {
                       $newop .= '=';
                       unless ($env{'form.'.$context.'_'.$tool.'_limit'} =~ /\D/) {
                           $newop .= $env{'form.'.$context.'_'.$tool.'_limit'};
                       }
                   }  
                   if (grep(/^\Q$cdom:($optregex\=?\d*)\E$/,@curr)) {
                     $oldaccesstext->{$tool} = &mt('yes');                      $oldaccesstext->{$tool} = &mt('yes');
                     unless ($env{'form.'.$context.'_'.$tool}) {                      my $oldop = $1;
                       if ($oldop ne $newop) {
                         $changedoms = 1;                          $changedoms = 1;
                         foreach my $dom (@curr) {                          foreach my $dom (@curr) {
                             unless ($dom eq $cdom) {                              unless ($dom eq $cdom) {
                                 push(@new,$dom);                                  push(@new,$dom);
                             }                              }
                         }                          }
                           if ($newop) {
                               push(@new,$cdom.':'.$newop);
                           }
                           @new = sort(@new);
                     }                      }
                 } elsif ($env{'form.'.$context.'_'.$tool}) {                  } elsif ($env{'form.'.$context.'_'.$tool}) {
                     $changedoms = 1;                      $changedoms = 1;
                     @new = sort(@curr,$cdom);                      @new = sort(@curr,$cdom.':'.$newop);
                 }                  }
                 $newaccesstext->{$tool} = $oldaccesstext->{$tool};                  $newaccesstext->{$tool} = $oldaccesstext->{$tool};
                 if ($changedoms) {                  if ($changedoms) {
Line 2690  sub tool_changes { Line 2867  sub tool_changes {
                                                   $context);                                                    $context);
                     if ($changed->{$tool}) {                      if ($changed->{$tool}) {
                         if ($env{'form.'.$context.'_'.$tool}) {                          if ($env{'form.'.$context.'_'.$tool}) {
                             $newaccesstext->{$tool} = &mt('yes');                               if ($env{'form.'.$context.'_'.$tool} eq 'autolimit') {
                                   if ($env{'form.'.$context.'_'.$tool.'_limit'} =~ /\D/) {
                                       $newaccesstext->{$tool} = &mt('Yes, processed automatically');
                                   } else {
                                       $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user).',$env{'form.'.$context.'_'.$tool.'_limit'});
                                   }
                               } else {  
                                   $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};
                               }
                         } else {                          } else {
                             $newaccesstext->{$tool} = &mt('no');                              $newaccesstext->{$tool} = &mt('No');
                         }                          }
                     }                      }
                 }                  }
Line 2701  sub tool_changes { Line 2886  sub tool_changes {
         return;          return;
     }      }
     foreach my $tool (@{$usertools}) {      foreach my $tool (@{$usertools}) {
           my $newval;
           if ($context eq 'requestcourses') {
               $newval = $env{'form.crsreq_'.$tool};
               if ($newval eq 'autolimit') {
                   $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'};
               }
           } else {  
               $newval = $env{'form.'.$context.'_'.$tool};
           }
         if ($userenv->{$context.'.'.$tool} ne '') {          if ($userenv->{$context.'.'.$tool} ne '') {
             $oldaccess->{$tool} = &mt('custom');              $oldaccess->{$tool} = &mt('custom');
             if ($userenv->{$context.'.'.$tool}) {              if ($userenv->{$context.'.'.$tool}) {
Line 2710  sub tool_changes { Line 2904  sub tool_changes {
             }              }
             $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};              $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
             if ($env{'form.custom'.$tool} == 1) {              if ($env{'form.custom'.$tool} == 1) {
                 if ($env{'form.'.$context.'_'.$tool} ne $userenv->{$context.'.'.$tool}) {                  if ($newval ne $userenv->{$context.'.'.$tool}) {
                     $changed->{$tool} = &tool_admin($tool,$env{'form.'.$context.'_'.$tool},                      $changed->{$tool} = &tool_admin($tool,$newval,$changeHash,
                                                   $changeHash,$context);                                                      $context);
                     if ($changed->{$tool}) {                      if ($changed->{$tool}) {
                         $newaccess->{$tool} = &mt('custom');                          $newaccess->{$tool} = &mt('custom');
                         if ($env{'form.'.$context.'_'.$tool}) {                          if ($newval) {
                             $newaccesstext->{$tool} = &mt("availability set to 'on'");                              $newaccesstext->{$tool} = &mt("availability set to 'on'");
                         } else {                          } else {
                             $newaccesstext->{$tool} = &mt("availability set to 'off'");                              $newaccesstext->{$tool} = &mt("availability set to 'off'");
Line 2748  sub tool_changes { Line 2942  sub tool_changes {
         } else {          } else {
             $oldaccess->{$tool} = &mt('default');              $oldaccess->{$tool} = &mt('default');
             if ($env{'form.custom'.$tool} == 1) {              if ($env{'form.custom'.$tool} == 1) {
                 $changed->{$tool} = &tool_admin($tool,$env{'form.'.$context.'_'.$tool},                  $changed->{$tool} = &tool_admin($tool,$newval,$changeHash,
                                                 $changeHash,$context);                                                  $context);
                 if ($changed->{$tool}) {                  if ($changed->{$tool}) {
                     $newaccess->{$tool} = &mt('custom');                      $newaccess->{$tool} = &mt('custom');
                     if ($env{'form.'.$context.'_'.$tool}) {                      if ($newval) {
                         $newaccesstext->{$tool} = &mt("availability set to 'on'");                          $newaccesstext->{$tool} = &mt("availability set to 'on'");
                     } else {                      } else {
                         $newaccesstext->{$tool} = &mt("availability set to 'off'");                          $newaccesstext->{$tool} = &mt("availability set to 'off'");
Line 5114  ENDSCRIPT Line 5308  ENDSCRIPT
   
     # Table Header      # Table Header
     my $tableheader =      my $tableheader =
         &Apache::loncommon::start_data_table()          &Apache::loncommon::start_data_table_header_row()
        .&Apache::loncommon::start_data_table_header_row()  
        .'<th>&nbsp;</th>'         .'<th>&nbsp;</th>'
        .'<th>'.&mt('When').'</th>'         .'<th>'.&mt('When').'</th>'
        .'<th>'.&mt('Who made the change').'</th>'         .'<th>'.&mt('Who made the change').'</th>'
Line 5200  sub role_display_filter { Line 5393  sub role_display_filter {
         }          }
         $output .= '<option value="'.$chgtype.'"'.$selstr.'>'.$lt{$chgtype}.'</option>'."\n";          $output .= '<option value="'.$chgtype.'"'.$selstr.'>'.$lt{$chgtype}.'</option>'."\n";
     }      }
     $output .= '</select></td>'.      $output .= '</select></td>'
                '<td>&nbsp;&nbsp;</td>'.                .'</tr></table>';
                '<td valign="middle"><input type="submit" value="'.  
                &mt('Update Display').'" /></td></tr></table>'.      # Update Display button
                '<span class="LC_roleslog_note">'.      $output .= '<p>'
                &mt('[_1]Note:[_2] Only changes made from servers running LON-CAPA 2.6.99.0 or later are displayed.');                .'<input type="submit" value="'.&mt('Update Display').'" />'
                 .'</p>';
   
       # Server version info
       $output .= '<p class="LC_info">'
                 .&mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.'
                     ,'2.6.99.0');
     if ($version) {      if ($version) {
         $output .= ' '.&mt('This server is version [_3].','<b>','</b>',$version);    }          $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version);
     $output .= '</span><hr /><br />';      }
       $output .= '</p><hr />';
     return $output;      return $output;
 }  }
   
Line 5596  sub build_search_response { Line 5796  sub build_search_response {
                     $response .= '<br />'.&mt('You may want to broaden your search to the selected LON-CAPA domain.');                      $response .= '<br />'.&mt('You may want to broaden your search to the selected LON-CAPA domain.');
                 }                  }
             }              }
             if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {              my $createdom = $env{'request.role.domain'};
               if ($context eq 'requestcrs') {
                   if ($env{'form.coursedom'} ne '') {
                       $createdom = $env{'form.coursedom'};
                   }
               }
               if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $createdom)) {
                 my $cancreate =                  my $cancreate =
                     &Apache::lonuserutils::can_create_user($env{'request.role.domain'},$context);                      &Apache::lonuserutils::can_create_user($createdom,$context);
                   my $targetdom = '<span class="LC_cusr_emph">'.$createdom.'</span>';
                 if ($cancreate) {                  if ($cancreate) {
                     my $showdom = &display_domain_info($env{'request.role.domain'});                       my $showdom = &display_domain_info($createdom); 
                     $response .= '<br /><br />'                      $response .= '<br /><br />'
                                 .'<b>'.&mt('To add a new user:').'</b>'                                  .'<b>'.&mt('To add a new user:').'</b>'
                                 .'<br />'                                  .'<br />';
                                 .&mt("(You can only create new users in your current role's domain - [_1])"                      if ($context eq 'requestcrs') {
                                     ,'<span class="LC_cusr_emph">'.$env{'request.role.domain'}.'</span>')                          $response .= &mt("(You can only define new users in the new course's domain - [_1])",$targetdom);
                                 .'<ul><li>'                      } else {
                           $response .= &mt("(You can only create new users in your current role's domain - [_1])",$targetdom);
                       }
                       $response .='<ul><li>'
                                 .&mt("Set 'Domain/institution to search' to: [_1]",'<span class="LC_cusr_emph">'.$showdom.'</span>')                                  .&mt("Set 'Domain/institution to search' to: [_1]",'<span class="LC_cusr_emph">'.$showdom.'</span>')
                                 .'</li><li>'                                  .'</li><li>'
                                 .&mt("Set 'Search criteria' to: [_1]username is ..... in selected LON-CAPA domain[_2]",'<span class="LC_cusr_emph">','</span>')                                  .&mt("Set 'Search criteria' to: [_1]username is ..... in selected LON-CAPA domain[_2]",'<span class="LC_cusr_emph">','</span>')
Line 5617  sub build_search_response { Line 5827  sub build_search_response {
                                 .'</li></ul><br />';                                  .'</li></ul><br />';
                 } else {                  } else {
                     my $helplink = ' href="javascript:helpMenu('."'display'".')"';                      my $helplink = ' href="javascript:helpMenu('."'display'".')"';
                     $response .= '<br /><br />'                      $response .= '<br /><br />';
                                 .&mt("You are not authorized to create new users in your current role's domain - [_1]."                      if ($context eq 'requestcrs') {
                                     ,'<span class="LC_cusr_emph">'.$env{'request.role.domain'}.'</span>')                          $response .= &mt("You are not authorized to defined new users in the new course's domain - [_1].",$targetdom);
                                 .'<br />'                      } else {
                                 .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'                          $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom);
                       }
                       $response .= '<br />'
                                    .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
                                     ,' <a'.$helplink.'>'                                      ,' <a'.$helplink.'>'
                                     ,'</a>')                                      ,'</a>')
                                 .'<br /><br />';                                   .'<br /><br />';
                 }                  }
             }              }
         }          }

Removed from v.1.301  
changed lines
  Added in v.1.306


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