Diff for /loncom/interface/loncreateuser.pm between versions 1.295.2.13 and 1.295.2.14

version 1.295.2.13, 2009/09/07 13:23:23 version 1.295.2.14, 2009/09/10 23:14:29
Line 229  sub build_tools_display { Line 229  sub build_tools_display {
                    'usde'       => "Use default",                     'usde'       => "Use default",
                    'uscu'       => "Use custom",                     'uscu'       => "Use custom",
                    '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',
     );      );
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,          %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
Line 292  sub build_tools_display { Line 292  sub build_tools_display {
             }              }
             if ($curroption =~ /^autolimit=(\d*)$/) {              if ($curroption =~ /^autolimit=(\d*)$/) {
                 $currlimit = $1;                  $currlimit = $1;
                 $currdisp = &mt('Yes, up to [quant,_1,request]/user',$currlimit);                  if ($currlimit eq '') {
                       $currdisp = &mt('Yes, automatic creation');
                   } else {
                       $currdisp = &mt('Yes, up to [quant,_1,request]/user',$currlimit);
                   }
             } else {              } else {
                 $currdisp = $reqdisplay{$curroption};                  $currdisp = $reqdisplay{$curroption};
             }              }
Line 326  sub build_tools_display { Line 330  sub build_tools_display {
                 if ($option eq 'autolimit') {                  if ($option eq 'autolimit') {
                     $custdisp .= '<input type="text" name="crsreq_'.                      $custdisp .= '<input type="text" name="crsreq_'.
                                  $item.'_limit" size="1" '.                                   $item.'_limit" size="1" '.
                                  'value="'.$currlimit.'" />';                                   'value="'.$currlimit.'" /></span><br />'.
                                    $reqtitles{'unlimited'};
                    } else {
                        $custdisp .= '</span>';
                  }                   }
                  $custdisp .= '</span></td></tr>';                   $custdisp .= '</td></tr>';
             }              }
             $custdisp .= '</table>';              $custdisp .= '</table>';
             $custradio = '</span></td><td>'.&mt('Custom setting').'<br />'.$custdisp;              $custradio = '</span></td><td>'.&mt('Custom setting').'<br />'.$custdisp;
Line 378  sub coursereq_externaluser { Line 385  sub coursereq_externaluser {
         my ($curroption,$currlimit,$tooloff);          my ($curroption,$currlimit,$tooloff);
         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:($optregex)=?(\d*)$/,@curr)) {              foreach my $req (@curr) {
                 $curroption = $1;                  if ($req =~ /^\Q$cdom\E\:($optregex)=?(\d*)$/) {
                 $currlimit = $2;                      $curroption = $1;
                 if (!$curroption) {                      $currlimit = $2;
                     $curroption = 'norequest';                      last;
                 }                  }
             }              }
               if (!$curroption) {
                   $curroption = 'norequest';
                   $tooloff = ' checked="checked"';
               }
         } else {          } else {
             $curroption = 'norequest';              $curroption = 'norequest';
             $tooloff = ' checked="checked"';              $tooloff = ' checked="checked"';
         }          }
         $output.= &Apache::loncommon::start_data_table_row()."\n".          $output.= &Apache::loncommon::start_data_table_row()."\n".
                   '  <td><span class="LC_nobreak">'.$lt{$item}.': '.                    '  <td><span class="LC_nobreak">'.$lt{$item}.': </span></td><td>'.
                     '<table><tr><td valign="top">'."\n".
                   '<label><input type="radio" name="reqcrsotherdom_'.$item.                    '<label><input type="radio" name="reqcrsotherdom_'.$item.
                   '" value="0"'.$tooloff.' />'.$reqtitles{'norequest'}.                    '" value=""'.$tooloff.' />'.$reqtitles{'norequest'}.
                   '</label>&nbsp;';                    '</label></td>';
         foreach my $option (@options) {          foreach my $option (@options) {
             if ($option eq 'validate') {              if ($option eq 'validate') {
                 my $canvalidate = 0;                  my $canvalidate = 0;
Line 408  sub coursereq_externaluser { Line 420  sub coursereq_externaluser {
             if ($option eq $curroption) {              if ($option eq $curroption) {
                 $checked = ' checked="checked"';                  $checked = ' checked="checked"';
             }              }
             $output .= '<span class="LC_nobreak"><label>'.              $output .= '<td valign="top"><span class="LC_nobreak"><label>'.
                        '<input type="radio" name="reqcrsotherdom_'.$item.                         '<input type="radio" name="reqcrsotherdom_'.$item.
                        '" value="'.$option.'"'.$checked.' />'.                         '" value="'.$option.'"'.$checked.' />'.
                        $reqtitles{$option}.'</label>&nbsp;';                         $reqtitles{$option}.'</label>';
             if ($option eq 'autolimit') {              if ($option eq 'autolimit') {
                 $output .= '<input type="text" name="reqcrsotherdom_'.                  $output .= '&nbsp;<input type="text" name="reqcrsotherdom_'.
                            $item.'_limit" size="1" '.                             $item.'_limit" size="1" '.
                            'value="'.$currlimit.'" />';                             'value="'.$currlimit.'" /></span>'.
                              '<br />'.$reqtitles{'unlimited'};
               } else {
                   $output .= '</span>';
             }              }
             $output .= '&nbsp;'              $output .= '</td>';
         }          }
         $output .= '</span></td>'."\n".          $output .= '</td></tr></table></td>'."\n".
                    &Apache::loncommon::end_data_table_row()."\n";                     &Apache::loncommon::end_data_table_row()."\n";
     }      }
     return $output;      return $output;
Line 434  sub courserequest_titles { Line 449  sub courserequest_titles {
                                    approval   => 'Approval by Dom. Coord.',                                     approval   => 'Approval by Dom. Coord.',
                                    validate   => 'With validation',                                     validate   => 'With validation',
                                    autolimit  => 'Numerical limit',                                     autolimit  => 'Numerical limit',
                                      unlimited  => '(blank for unlimited)',
                  );                   );
     return %titles;         return %titles;
 }                       }
       
 sub courserequest_display {  sub courserequest_display {
     my %titles = &Apache::lonlocal::texthash (      my %titles = &Apache::lonlocal::texthash (
                                    approval   => 'Yes, need approval',                                     approval   => 'Yes, need approval',
                                    validate   => 'Yes, with validation',                                     validate   => 'Yes, with validation',
                                    norequest  => 'No',                                     norequest  => 'No',
    );        );
    return %titles;     return %titles;
 }  }
   
Line 709  ENDSCRIPT Line 725  ENDSCRIPT
               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>');
Line 2446  sub update_user_data { Line 2462  sub update_user_data {
         }          }
         &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,          &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,
                       \%changeHash,\%changed,\%newaccess,\%newaccesstext);                        \%changeHash,\%changed,\%newaccess,\%newaccesstext);
   
         if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {          if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
             &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext,              &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext,
                           \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);                            \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
Line 2693  END Line 2708  END
                            'aboutme'    => "Personal Information Page Availability",                             'aboutme'    => "Personal Information Page Availability",
                            'portfolio'  => "Portfolio Availability",                             'portfolio'  => "Portfolio Availability",
                            'official'   => "Can Request Official Courses",                             'official'   => "Can Request Official Courses",
                            'unofficial' => "Can Request Unofficial Course",                             'unofficial' => "Can Request Unofficial Courses",
                            'inststatus' => "Affiliation",                             'inststatus' => "Affiliation",
        );         );
             $r->print(<<"END");              $r->print(<<"END");
Line 2813  sub tool_changes { Line 2828  sub tool_changes {
         my %reqdisplay = &courserequest_display();          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');
               $newaccesstext->{$tool} = $oldaccesstext->{$tool};
             $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};              $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
               my $newop;
               if ($env{'form.'.$context.'_'.$tool}) {
                   $newop = $env{'form.'.$context.'_'.$tool};
                   if ($newop eq 'autolimit') {
                       my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
                       $limit =~ s/\D+//g;
                       $newop .= '='.$limit;
                   }
               }
             if ($userenv->{$context.'.'.$tool} eq '') {              if ($userenv->{$context.'.'.$tool} eq '') {
                 if ($env{'form.'.$context.'_'.$tool}) {                  if ($newop) {
                     $changed->{$tool}=&tool_admin($tool,$cdom,                      $changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop,
                                                   $changeHash,$context);                                                    $changeHash,$context);
                     if ($changed->{$tool}) {                      if ($changed->{$tool}) {
                         $newaccesstext->{$tool} = &mt('yes');                          $newaccesstext->{$tool} = &mt('Yes');
                     } else {                      } else {
                         $newaccesstext->{$tool} = $oldaccesstext->{$tool};                    }                          $newaccesstext->{$tool} = $oldaccesstext->{$tool};
                       }
                 }                  }
             } else {              } else {
                 my @curr = split(',',$userenv->{$context.'.'.$tool});                  my @curr = split(',',$userenv->{$context.'.'.$tool});
                 my @new;                  my @new;
                 my $changedoms;                  my $changedoms;
                 my $newop = $env{'form.'.$context.'_'.$tool};                  foreach my $req (@curr) {
                 if ($newop eq 'autolimit') {                      if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) {
                     $newop .= '=';                          $oldaccesstext->{$tool} = &mt('Yes');
                     unless ($env{'form.'.$context.'_'.$tool.'_limit'} =~ /\D/) {                          my $oldop = $1;
                         $newop .= $env{'form.'.$context.'_'.$tool.'_limit'};                          if ($oldop ne $newop) {
                     }                              $changedoms = 1;
                 }                              foreach my $item (@curr) {
                 if (grep(/^\Q$cdom:($optregex\=?\d*)\E$/,@curr)) {                                  my ($reqdom,$option) = split(':',$item);
                     $oldaccesstext->{$tool} = &mt('yes');                                  unless ($reqdom eq $cdom) {
                     my $oldop = $1;                                      push(@new,$item);
                     if ($oldop ne $newop) {                                  }
                         $changedoms = 1;  
                         foreach my $dom (@curr) {  
                             unless ($dom eq $cdom) {  
                                 push(@new,$dom);  
                             }                              }
                               if ($newop) {
                                   push(@new,$cdom.':'.$newop);
                               }
                               @new = sort(@new);
                         }                          }
                         if ($newop) {                          last;
                             push(@new,$cdom.':'.$newop);  
                         }  
                         @new = sort(@new);  
                     }                      }
                 } elsif ($env{'form.'.$context.'_'.$tool}) {                  }
                   if ((!$changedoms) && ($newop)) {
                     $changedoms = 1;                      $changedoms = 1;
                     @new = sort(@curr,$cdom.':'.$newop);                      @new = sort(@curr,$cdom.':'.$newop);
                 }                  }
                 $newaccesstext->{$tool} = $oldaccesstext->{$tool};  
                 if ($changedoms) {                  if ($changedoms) {
                     my $newdomstr;                      my $newdomstr;
                     if (@new) {                      if (@new) {
Line 2865  sub tool_changes { Line 2888  sub tool_changes {
                     if ($changed->{$tool}) {                      if ($changed->{$tool}) {
                         if ($env{'form.'.$context.'_'.$tool}) {                          if ($env{'form.'.$context.'_'.$tool}) {
                             if ($env{'form.'.$context.'_'.$tool} eq 'autolimit') {                              if ($env{'form.'.$context.'_'.$tool} eq 'autolimit') {
                                 if ($env{'form.'.$context.'_'.$tool.'_limit'} =~ /\D/) {                                  my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
                                     $newaccesstext->{$tool} = &mt('Yes, processed automatically');                                  $limit =~ s/\D+//g;
                                   if ($limit) {
                                       $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user.',$limit);
                                 } else {                                  } else {
                                     $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user).',$env{'form.'.$context.'_'.$tool.'_limit'});                                      $newaccesstext->{$tool} = &mt('Yes, processed automatically');
                                 }                                  }
                             } else {                              } else {
                                 $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};                                  $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};

Removed from v.1.295.2.13  
changed lines
  Added in v.1.295.2.14


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