Diff for /loncom/interface/loncommon.pm between versions 1.562 and 1.563

version 1.562, 2007/08/14 19:32:27 version 1.563, 2007/08/15 16:25:14
Line 1424  sub select_level_form { Line 1424  sub select_level_form {
   
 =pod  =pod
   
 =item * select_dom_form($defdom,$name,$includeempty)  =item * select_dom_form($defdom,$name,$includeempty,$showdomdesc)
   
 Returns a string containing a <select name='$name' size='1'> form to   Returns a string containing a <select name='$name' size='1'> form to 
 allow a user to select the domain to preform an operation in.    allow a user to select the domain to preform an operation in.  
Line 1433  See loncreateuser.pm for an example invo Line 1433  See loncreateuser.pm for an example invo
 If the $includeempty flag is set, it also includes an empty choice ("no domain  If the $includeempty flag is set, it also includes an empty choice ("no domain
 selected");  selected");
   
   If the $showdomdesc flag is set, the domain name is followed by the domain description. 
   
 =cut  =cut
   
 #-------------------------------------------  #-------------------------------------------
 sub select_dom_form {  sub select_dom_form {
     my ($defdom,$name,$includeempty) = @_;      my ($defdom,$name,$includeempty,$showdomdesc) = @_;
     my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());      my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
     if ($includeempty) { @domains=('',@domains); }      if ($includeempty) { @domains=('',@domains); }
     my $selectdomain = "<select name=\"$name\" size=\"1\">\n";      my $selectdomain = "<select name=\"$name\" size=\"1\">\n";
     foreach my $dom (@domains) {      foreach my $dom (@domains) {
         $selectdomain.="<option value=\"$dom\" ".          $selectdomain.="<option value=\"$dom\" ".
             ($dom eq $defdom ? 'selected="selected" ' : '').              ($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom;
                 ">$dom</option>\n";          if ($showdomdesc) {
               if ($dom ne '') {
                   my $domdesc = &Apache::lonnet::domain($dom,'description');
                   if ($domdesc ne '') {
                       $selectdomain .= ' ('.$domdesc.')';
                   }
               } 
           }
           $selectdomain .= "</option>\n";
     }      }
     $selectdomain.="</select>";      $selectdomain.="</select>";
     return $selectdomain;      return $selectdomain;
Line 5565  sub user_picker { Line 5575  sub user_picker {
         $srchterm = $srch->{'srchterm'};          $srchterm = $srch->{'srchterm'};
     }      }
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
                     'usr'       => 'Search for',                      'usr'       => 'Search criteria',
                     'or'        => 'or',                      'doma'      => 'Domain/institution to search',
                     'doma'      => 'domain',  
                     'uname'     => 'username',                      'uname'     => 'username',
                     'lastname'  => 'last name',                      'lastname'  => 'last name',
                     'lastfirst' => 'last name, first name',                      'lastfirst' => 'last name, first name',
Line 5578  sub user_picker { Line 5587  sub user_picker {
                     'exact'     => 'is',                      'exact'     => 'is',
                     'contains'  => 'contains',                      'contains'  => 'contains',
                                        );                                         );
     my $domform = &select_dom_form($currdom,'srchdomain',1);      my $domform = &select_dom_form($currdom,'srchdomain',1,1);
       my $srchinsel = ' <select name="srchin">';
     my $srchin;  
   
     my @srchins = ('crs','dom','alc','instd');      my @srchins = ('crs','dom','alc','instd');
   
Line 5590  sub user_picker { Line 5598  sub user_picker {
         #       has been completed.          #       has been completed.
         next if ($option eq 'alc');          next if ($option eq 'alc');
         next if ($option eq 'crs' && !$env{'request.course.id'});          next if ($option eq 'crs' && !$env{'request.course.id'});
         my $checked =($curr_selected{'srchin'} eq $option) ?'checked="checked"'          if ($curr_selected{'srchin'} eq $option) {
                                                    :'';              $srchinsel .= ' 
  my $extra = ($option eq 'dom') ? $domform     <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';
                                : '';          } else {
  $srchin.=<<ROW              $srchinsel .= '
  <tr>     <option value="'.$option.'">'.$lt{$option}.'</option>';
    <td>          }
      <label><input type="radio" name="srchin" value="$option" $checked /> $lt{$option}</label> $extra  
    </td>  
 </tr>  
 ROW  
     }      }
       $srchinsel .= "\n  </select>\n";
   
     my $srchbysel =  ' <select name="srchby">';      my $srchbysel =  ' <select name="srchby">';
     foreach my $option ('uname','lastname','lastfirst') {      foreach my $option ('uname','lastname','lastfirst') {
Line 5641  function setSearch(createnew) { Line 5646  function setSearch(createnew) {
             }              }
         }          }
         for (var i=0; i<document.crtuser.srchin.length; i++) {          for (var i=0; i<document.crtuser.srchin.length; i++) {
             if ( document.crtuser.srchin[i].value == 'dom') {              if ( document.crtuser.srchin.options[i].value == 'dom') {
  document.crtuser.srchin[i].checked = 1;   document.crtuser.srchin.selectedIndex = i;
             }              }
         }          }
         for (var i=0; i<document.crtuser.srchtype.length; i++) {          for (var i=0; i<document.crtuser.srchtype.length; i++) {
Line 5677  function validateEntry() { Line 5682  function validateEntry() {
     var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value;      var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value;
     var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value;      var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value;
     var srchterm =  document.crtuser.srchterm.value;      var srchterm =  document.crtuser.srchterm.value;
       var srchin = document.crtuser.srchin.options[document.crtuser.srchin.selectedIndex].value;
     var msg = "";      var msg = "";
   
     if (srchterm == "") {      if (srchterm == "") {
Line 5687  function validateEntry() { Line 5693  function validateEntry() {
     if (srchtype== 'contains') {      if (srchtype== 'contains') {
         if (srchterm.length < 3) {          if (srchterm.length < 3) {
             checkok = 0;              checkok = 0;
             msg += "The text you are searching for must contain at least three characters when using a 'contained in' type search.\\n";              msg += "The text you are searching for must contain at least three characters when using a 'contains' type search.\\n";
         }          }
     }      }
     if (srchin == 'instd') {      if (srchin == 'instd') {
Line 5729  $new_user_create Line 5735  $new_user_create
   
 <table>  <table>
  <tr>   <tr>
   <td> $srchbysel    <td>$lt{'usr'}:</td>
        $srchtypesel     <td>$srchbysel
        <input type="text" size="15" name="srchterm" value="$srchterm" />        $srchtypesel 
         <input type="text" size="15" name="srchterm" value="$srchterm" />
         &nbsp;&nbsp;$srchinsel 
     </td>
    </tr>
    <tr>
     <td align="right">$lt{'doma'}:</td>
     <td>$domform</td>
   </td>    </td>
  </tr>   </tr>
 $srchin  
 </table>  </table>
 <br />  <br />
 END_BLOCK  END_BLOCK

Removed from v.1.562  
changed lines
  Added in v.1.563


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