[LON-CAPA-cvs] cvs: loncom /html/adm/help/tex Domain_Configuration_InstDirectory_Search.tex /interface domainprefs.pm loncommon.pm loncreateuser.pm lonpickuser.pm lonrequestcourse.pm

raeburn raeburn at source.lon-capa.org
Sun Sep 4 21:46:13 EDT 2016


raeburn		Mon Sep  5 01:46:13 2016 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm loncommon.pm loncreateuser.pm 
                     	lonpickuser.pm lonrequestcourse.pm 
    /loncom/html/adm/help/tex	
                             	Domain_Configuration_InstDirectory_Search.tex 
  Log:
  - Domain Configuration for LON-CAPA Directory searches for user information
    for users in a domain.
    - Can disable for all, or can disable only for other domains.
    - Default: enabled for all domains.
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.276 loncom/interface/domainprefs.pm:1.277
--- loncom/interface/domainprefs.pm:1.276	Mon Aug 15 18:01:09 2016
+++ loncom/interface/domainprefs.pm	Mon Sep  5 01:46:07 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.276 2016/08/15 18:01:09 raeburn Exp $
+# $Id: domainprefs.pm,v 1.277 2016/09/05 01:46:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -307,9 +307,11 @@
                      modify => \&modify_autocreate,
                   },
         'directorysrch' => 
-                  { text => 'Institutional directory searches',
+                  { text => 'Directory searches',
                     help => 'Domain_Configuration_InstDirectory_Search',
-                    header => [{col1 => 'Setting',
+                    header => [{col1 => 'Institutional Directory Setting',
+                                col2 => 'Value',},
+                               {col1 => 'LON-CAPA Directory Setting',
                                 col2 => 'Value',}],
                     print => \&print_directorysrch,
                     modify => \&modify_directorysrch,
@@ -697,10 +699,12 @@
     if (ref($item->{'header'}) eq 'ARRAY') {
         $numheaders = scalar(@{$item->{'header'}});
     }
+print STDERR "$action num ||$numheaders||\n";
     if ($numheaders > 1) {
         my $colspan = '';
         my $rightcolspan = '';
         if (($action eq 'rolecolors') || ($action eq 'defaults') ||
+            ($action eq 'directorysrch') ||
             (($action eq 'login') && ($numheaders < 4))) {
             $colspan = ' colspan="2"';
         }
@@ -718,7 +722,8 @@
         $rowtotal ++;
         if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
             ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
-            ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'ssl')) {
+            ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'ssl') ||
+            ($action eq 'directorysrch')) {
             $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {
             $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
@@ -774,7 +779,7 @@
             }
             $rowtotal ++;
         } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
-                  ($action eq 'defaults')) {
+                 ($action eq 'defaults') || ($action eq 'directorysrch')) {
             $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'login') {
             if ($numheaders == 4) {
@@ -887,7 +892,7 @@
            <td>
             <table class="LC_nested">
              <tr class="LC_info_row">';
-        if (($action eq 'login') || ($action eq 'directorysrch')) {
+        if ($action eq 'login') {
             $output .= '  
               <td class="LC_left_item" colspan="2">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
         } elsif ($action eq 'serverstatuses') {
@@ -931,9 +936,9 @@
         $rowtotal ++;
         if ($action eq 'quotas') {
             $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
-        } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || ($action eq 'directorysrch') ||
-                 ($action eq 'contacts') || ($action eq 'serverstatuses') || ($action eq 'loadbalancing') ||
-                 ($action eq 'ltitools')) {
+        } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || 
+                 ($action eq 'contacts') || ($action eq 'serverstatuses') || 
+                 ($action eq 'loadbalancing') || ($action eq 'ltitools')) {
             $output .= $item->{'print'}->($dom,$settings,\$rowtotal);
         } elsif ($action eq 'scantron') {
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
@@ -2718,115 +2723,149 @@
 }
 
 sub print_directorysrch {
-    my ($dom,$settings,$rowtotal) = @_;
-    my $srchon = ' ';
-    my $srchoff = ' checked="checked" ';
-    my ($exacton,$containson,$beginson);
-    my $localon = ' ';
-    my $localoff = ' checked="checked" ';
-    if (ref($settings) eq 'HASH') {
-        if ($settings->{'available'} eq '1') {
-            $srchon = $srchoff;
-            $srchoff = ' ';
-        }
-        if ($settings->{'localonly'} eq '1') {
-            $localon = $localoff;
-            $localoff = ' ';
-        }
-        if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
-            foreach my $type (@{$settings->{'searchtypes'}}) {
-                if ($type eq 'exact') {
+    my ($position,$dom,$settings,$rowtotal) = @_;
+    my $datatable;
+    if ($position eq 'top') {
+        my $instsrchon = ' ';
+        my $instsrchoff = ' checked="checked" ';
+        my ($exacton,$containson,$beginson);
+        my $instlocalon = ' ';
+        my $instlocaloff = ' checked="checked" ';
+        if (ref($settings) eq 'HASH') {
+            if ($settings->{'available'} eq '1') {
+                $instsrchon = $instsrchoff;
+                $instsrchoff = ' ';
+            }
+            if ($settings->{'localonly'} eq '1') {
+                $instlocalon = $instlocaloff;
+                $instlocaloff = ' ';
+            }
+            if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
+                foreach my $type (@{$settings->{'searchtypes'}}) {
+                    if ($type eq 'exact') {
+                        $exacton = ' checked="checked" ';
+                    } elsif ($type eq 'contains') {
+                        $containson = ' checked="checked" ';
+                    } elsif ($type eq 'begins') {
+                        $beginson = ' checked="checked" ';
+                    }
+                }
+            } else {
+                if ($settings->{'searchtypes'} eq 'exact') {
+                    $exacton = ' checked="checked" ';
+                } elsif ($settings->{'searchtypes'} eq 'contains') {
+                    $containson = ' checked="checked" ';
+                } elsif ($settings->{'searchtypes'} eq 'specify') {
                     $exacton = ' checked="checked" ';
-                } elsif ($type eq 'contains') {
                     $containson = ' checked="checked" ';
-                } elsif ($type eq 'begins') {
-                    $beginson = ' checked="checked" ';
                 }
             }
-        } else {
-            if ($settings->{'searchtypes'} eq 'exact') {
-                $exacton = ' checked="checked" ';
-            } elsif ($settings->{'searchtypes'} eq 'contains') {
-                $containson = ' checked="checked" ';
-            } elsif ($settings->{'searchtypes'} eq 'specify') {
-                $exacton = ' checked="checked" ';
-                $containson = ' checked="checked" ';
-            }
         }
-    }
-    my ($searchtitles,$titleorder) = &sorted_searchtitles();
-    my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+        my ($searchtitles,$titleorder) = &sorted_searchtitles();
+        my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
 
-    my $numinrow = 4;
-    my $cansrchrow = 0;
-    my $datatable='<tr class="LC_odd_row">'.
-                  '<td colspan="2"><span class ="LC_nobreak">'.&mt('Directory search available?').'</span></td>'.
-                  '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
-                  '<input type="radio" name="dirsrch_available"'.
-                  $srchon.' value="1" />'.&mt('Yes').'</label> '.
-                  '<label><input type="radio" name="dirsrch_available"'.
-                  $srchoff.' value="0" />'.&mt('No').'</label></span></td>'.
-                  '</tr><tr>'.
-                  '<td colspan="2"><span class ="LC_nobreak">'.&mt('Other domains can search?').'</span></td>'.
-                  '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
-                  '<input type="radio" name="dirsrch_localonly"'.
-                  $localoff.' value="0" />'.&mt('Yes').'</label> '.
-                  '<label><input type="radio" name="dirsrch_localonly"'.
-                  $localon.' value="1" />'.&mt('No').'</label></span></td>'.
-                  '</tr>';
-    $$rowtotal += 2;
-    if (ref($usertypes) eq 'HASH') {
-        if (keys(%{$usertypes}) > 0) {
-            $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
-                                         $numinrow,$othertitle,'cansearch');
-            $cansrchrow = 1;
+        my $numinrow = 4;
+        my $cansrchrow = 0;
+        $datatable='<tr class="LC_odd_row">'.
+                   '<td colspan="2"><span class ="LC_nobreak">'.&mt('Institutional directory search available?').'</span></td>'.
+                   '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
+                   '<input type="radio" name="dirsrch_available"'.
+                   $instsrchon.' value="1" />'.&mt('Yes').'</label> '.
+                   '<label><input type="radio" name="dirsrch_available"'.
+                   $instsrchoff.' value="0" />'.&mt('No').'</label></span></td>'.
+                   '</tr><tr>'.
+                   '<td colspan="2"><span class ="LC_nobreak">'.&mt('Other domains can search institution?').'</span></td>'.
+                   '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
+                   '<input type="radio" name="dirsrch_instlocalonly"'.
+                   $instlocaloff.' value="0" />'.&mt('Yes').'</label> '.
+                   '<label><input type="radio" name="dirsrch_instlocalonly"'.
+                   $instlocalon.' value="1" />'.&mt('No').'</label></span></td>'.
+                   '</tr>';
+        $$rowtotal += 2;
+        if (ref($usertypes) eq 'HASH') {
+            if (keys(%{$usertypes}) > 0) {
+                $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
+                                             $numinrow,$othertitle,'cansearch');
+                $cansrchrow = 1;
+            }
         }
-    }
-    if ($cansrchrow) {
-        $$rowtotal ++;
-        $datatable .= '<tr>';
-    } else {
-        $datatable .= '<tr class="LC_odd_row">';
-    }
-    $datatable .= '<td><span class ="LC_nobreak">'.&mt('Supported search methods').
-                  '</span></td><td class="LC_left_item" colspan="2"><table><tr>';
-    foreach my $title (@{$titleorder}) {
-        if (defined($searchtitles->{$title})) {
-            my $check = ' ';
-            if (ref($settings) eq 'HASH') {
-                if (ref($settings->{'searchby'}) eq 'ARRAY') {
-                    if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
-                        $check = ' checked="checked" ';
+        if ($cansrchrow) {
+            $$rowtotal ++;
+            $datatable .= '<tr>';
+        } else {
+            $datatable .= '<tr class="LC_odd_row">';
+        }
+        $datatable .= '<td><span class ="LC_nobreak">'.&mt('Supported search methods').
+                      '</span></td><td class="LC_left_item" colspan="2"><table><tr>';
+        foreach my $title (@{$titleorder}) {
+            if (defined($searchtitles->{$title})) {
+                my $check = ' ';
+                if (ref($settings) eq 'HASH') {
+                    if (ref($settings->{'searchby'}) eq 'ARRAY') {
+                        if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
+                            $check = ' checked="checked" ';
+                        }
                     }
                 }
+                $datatable .= '<td class="LC_left_item">'.
+                              '<span class="LC_nobreak"><label>'.
+                              '<input type="checkbox" name="searchby" '.
+                              'value="'.$title.'"'.$check.'/>'.
+                              $searchtitles->{$title}.'</label></span></td>';
             }
-            $datatable .= '<td class="LC_left_item">'.
-                          '<span class="LC_nobreak"><label>'.
-                          '<input type="checkbox" name="searchby" '.
-                          'value="'.$title.'"'.$check.'/>'.
-                          $searchtitles->{$title}.'</label></span></td>';
         }
-    }
-    $datatable .= '</tr></table></td></tr>';
-    $$rowtotal ++;
-    if ($cansrchrow) {
-        $datatable .= '<tr class="LC_odd_row">';
+        $datatable .= '</tr></table></td></tr>';
+        $$rowtotal ++;
+        if ($cansrchrow) {
+            $datatable .= '<tr class="LC_odd_row">';
+        } else {
+            $datatable .= '<tr>';
+        }
+        $datatable .= '<td><span class ="LC_nobreak">'.&mt('Search latitude').'</span></td>'.   
+                      '<td class="LC_left_item" colspan="2">'.
+                      '<span class="LC_nobreak"><label>'.
+                      '<input type="checkbox" name="searchtypes" '.
+                      $exacton.' value="exact" />'.&mt('Exact match').
+                      '</label> '.
+                      '<label><input type="checkbox" name="searchtypes" '.
+                      $beginson.' value="begins" />'.&mt('Begins with').
+                      '</label> '.
+                      '<label><input type="checkbox" name="searchtypes" '.
+                      $containson.' value="contains" />'.&mt('Contains').
+                      '</label></span></td></tr>';
+        $$rowtotal ++;
     } else {
-        $datatable .= '<tr>';
+        my $domsrchon = ' checked="checked" ';
+        my $domsrchoff = ' ';
+        my $domlocalon = ' ';
+        my $domlocaloff = ' checked="checked" ';
+        if (ref($settings) eq 'HASH') {
+            if ($settings->{'lclocalonly'} eq '1') {
+                $domlocalon = $domlocaloff;
+                $domlocaloff = ' ';
+            }
+            if ($settings->{'lcavailable'} eq '0') {
+                $domsrchoff = $domsrchon;
+                $domsrchon = ' ';
+            }
+        }
+        $datatable='<tr class="LC_odd_row">'.
+                      '<td colspan="2"><span class ="LC_nobreak">'.&mt('LON-CAPA directory search available?').'</span></td>'.
+                      '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
+                      '<input type="radio" name="dirsrch_domavailable"'.
+                      $domsrchon.' value="1" />'.&mt('Yes').'</label> '.
+                      '<label><input type="radio" name="dirsrch_domavailable"'.
+                      $domsrchoff.' value="0" />'.&mt('No').'</label></span></td>'.
+                      '</tr><tr>'.
+                      '<td colspan="2"><span class ="LC_nobreak">'.&mt('Other domains can search LON-CAPA domain?').'</span></td>'.
+                      '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
+                      '<input type="radio" name="dirsrch_domlocalonly"'.
+                      $domlocaloff.' value="0" />'.&mt('Yes').'</label> '.
+                      '<label><input type="radio" name="dirsrch_domlocalonly"'.
+                      $domlocalon.' value="1" />'.&mt('No').'</label></span></td>'.
+                      '</tr>';
+        $$rowtotal += 2;
     }
-    $datatable .= '<td><span class ="LC_nobreak">'.&mt('Search latitude').'</span></td>'.   
-                  '<td class="LC_left_item" colspan="2">'.
-                  '<span class="LC_nobreak"><label>'.
-                  '<input type="checkbox" name="searchtypes" '.
-                  $exacton.' value="exact" />'.&mt('Exact match').
-                  '</label> '.
-                  '<label><input type="checkbox" name="searchtypes" '.
-                  $beginson.' value="begins" />'.&mt('Begins with').
-                  '</label> '.
-                  '<label><input type="checkbox" name="searchtypes" '.
-                  $containson.' value="contains" />'.&mt('Contains').
-                  '</label></span></td></tr>';
-    $$rowtotal ++;
     return $datatable;
 }
 
@@ -9494,8 +9533,10 @@
             $currdirsrch{$key} = $domconfig{'directorysrch'}{$key};
         }
     }
-    my %title = ( available => 'Directory search available',
-                  localonly => 'Other domains can search',
+    my %title = ( available => 'Institutional directory search available',
+                  localonly => 'Other domains can search institution',
+                  lcavailable => 'LON-CAPA directory search available',
+                  lclocalonly => 'Other domains can search LON-CAPA domain', 
                   searchby => 'Search types',
                   searchtypes => 'Search latitude');
     my @offon = ('off','on');
@@ -9569,7 +9610,9 @@
     my %dirsrch_hash =  (
             directorysrch => { available => $env{'form.dirsrch_available'},
                                cansearch => \@cansearch,
-                               localonly => $env{'form.dirsrch_localonly'},
+                               localonly => $env{'form.dirsrch_instlocalonly'},
+                               lclocalonly => $env{'form.dirsrch_domlocalonly'},
+                               lcavailable => $env{'form.dirsrch_domavailable'},
                                searchby => \@searchby,
                                searchtypes => \@searchtypes,
                              }
@@ -9586,24 +9629,47 @@
                 $changes{'available'} = 1;
             }
         }
+        if (exists($currdirsrch{'lcavailable'})) {
+             if ($currdirsrch{'lcavailable'} ne $env{'form.dirsrch_domavailable'}) {
+                 $changes{'lcavailable'} = 1;
+             }
+        } else {
+            if ($env{'form.dirsrch_lcavailable'} eq '1') {
+                $changes{'lcavailable'} = 1;
+            }
+        }
         if (exists($currdirsrch{'localonly'})) {
-             if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) {
+             if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_instlocalonly'}) {
                  $changes{'localonly'} = 1;
              }
         } else {
-            if ($env{'form.dirsrch_localonly'} eq '1') {
+            if ($env{'form.dirsrch_instlocalonly'} eq '1') {
                 $changes{'localonly'} = 1;
             }
         }
+        if (exists($currdirsrch{'lclocalonly'})) {
+             if ($currdirsrch{'lclocalonly'} ne $env{'form.dirsrch_domlocalonly'}) {
+                 $changes{'lclocalonly'} = 1;
+             }
+        } else {
+            if ($env{'form.dirsrch_domlocalonly'} eq '1') {
+                $changes{'lclocalonly'} = 1;
+            }
+        }
         if (keys(%changes) > 0) {
             $resulttext = &mt('Changes made:').'<ul>';
             if ($changes{'available'}) {
                 $resulttext .= '<li>'.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").'</li>';
             }
+            if ($changes{'lcavailable'}) {
+                $resulttext .= '<li>'.&mt("$title{'lcavailable'} set to: $offon[$env{'form.dirsrch_domavailable'}]").'</li>';
+            }
             if ($changes{'localonly'}) {
-                $resulttext .= '<li>'.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").'</li>';
+                $resulttext .= '<li>'.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_instlocalonly'}]").'</li>';
             }
-
+            if ($changes{'lclocalonly'}) {
+                $resulttext .= '<li>'.&mt("$title{'lclocalonly'} set to: $otherdoms[$env{'form.dirsrch_domlocalonly'}]").'</li>';
+            }   
             if (ref($changes{'cansearch'}) eq 'ARRAY') {
                 my $chgtext;
                 if (ref($usertypes) eq 'HASH') {
@@ -9654,7 +9720,7 @@
             }
             $resulttext .= '</ul>';
         } else {
-            $resulttext = &mt('No changes made to institution directory search settings');
+            $resulttext = &mt('No changes made to directory search settings');
         }
     } else {
         $resulttext = '<span class="LC_error">'.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1252 loncom/interface/loncommon.pm:1.1253
--- loncom/interface/loncommon.pm:1.1252	Wed Aug 31 19:08:19 2016
+++ loncom/interface/loncommon.pm	Mon Sep  5 01:46:07 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1252 2016/08/31 19:08:19 raeburn Exp $
+# $Id: loncommon.pm,v 1.1253 2016/09/05 01:46:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -9959,6 +9959,22 @@
 sub user_picker {
     my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context) = @_;
     my $currdom = $dom;
+    my @alldoms = &Apache::lonnet::all_domains();
+    if (@alldoms == 1) {
+        my %domsrch = &Apache::lonnet::get_dom('configuration',
+                                               ['directorysrch'],$alldoms[0]);
+        my $domdesc = &Apache::lonnet::domain($alldoms[0],'description');
+        my $showdom = $domdesc;
+        if ($showdom eq '') {
+            $showdom = $dom;
+        }
+        if (ref($domsrch{'directorysrch'}) eq 'HASH') {
+            if ((!$domsrch{'directorysrch'}{'available'}) &&
+                ($domsrch{'directorysrch'}{'lcavailable'} eq '0')) {
+                return (&mt('LON-CAPA directory search is not available in domain: [_1]',$showdom),0);
+            }
+        }
+    }
     my %curr_selected = (
                         srchin => 'dom',
                         srchby => 'lastname',
@@ -10199,7 +10215,7 @@
                &Apache::lonhtmlcommon::row_closure(1). 
                &Apache::lonhtmlcommon::end_pick_box().
                '<br />';
-    return $output;
+    return ($output,1);
 }
 
 sub user_rule_check {
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.411 loncom/interface/loncreateuser.pm:1.412
--- loncom/interface/loncreateuser.pm:1.411	Sat Apr  2 04:30:20 2016
+++ loncom/interface/loncreateuser.pm	Mon Sep  5 01:46:07 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.411 2016/04/02 04:30:20 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.412 2016/09/05 01:46:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -818,7 +818,7 @@
     }
     my $cancreate =
         &Apache::lonuserutils::can_create_user($dom,$context,$usertype);
-    my $userpicker = 
+    my ($userpicker,$cansearch) = 
        &Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
                                        'document.crtuser',$cancreate,$usertype);
     my $srchbutton = &mt('Search');
@@ -827,7 +827,9 @@
     } elsif ($cancreate && $responsemsg ne '' && $inexact) {
         $srchbutton = &mt('Search or Add New User');
     }
-    my $output = <<"ENDBLOCK";
+    my $output;
+    if ($cansearch) {
+        $output = <<"ENDBLOCK";
 <form action="/adm/createuser" method="post" name="crtuser">
 <input type="hidden" name="action" value="$env{'form.action'}" />
 <input type="hidden" name="phase" value="get_user_info" />
@@ -835,6 +837,9 @@
 <input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.crtuser)" />
 </form>
 ENDBLOCK
+    } else {
+        $output = '<p>'.$userpicker.'</p>';
+    }
     if ($env{'form.phase'} eq '') {
         my $defdom=$env{'request.role.domain'};
         my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
@@ -6836,10 +6841,26 @@
         $response = '<span class="LC_warning">'.$response.'</span>';
     }
     if ($srch->{'srchin'} eq 'instd') {
-        my $instd_chk = &directorysrch_check($srch);
+        my $instd_chk = &instdirectorysrch_check($srch);
         if ($instd_chk ne 'ok') {
-            $response = '<span class="LC_warning">'.$instd_chk.'</span>'.
-                        '<br />'.&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').'<br /><br />';
+            my $domd_chk = &domdirectorysrch_check($srch);
+            $response = '<span class="LC_warning">'.$instd_chk.'</span><br />';
+            if ($domd_chk eq 'ok') {
+                $response = &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.');
+            }
+            $response .= '<br /><br />';
+        }
+    } else {
+        unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) { 
+            my $domd_chk = &domdirectorysrch_check($srch);
+            if ($domd_chk ne 'ok') {
+                my $instd_chk = &instdirectorysrch_check($srch);
+                $response = '<span class="LC_warning">'.$domd_chk.'</span><br />';
+                if ($instd_chk eq 'ok') {
+                    $response = &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.');
+                }
+                $response .= '<br /><br />';
+            }
         }
     }
     if ($response ne '') {
@@ -7003,7 +7024,8 @@
                 ($currstate,$response,$forcenewuser) = 
                     &build_search_response($context,$srch,%srch_results);
             } else {
-                my $showdom = &display_domain_info($srch->{'srchdomain'});                $response = '<span class="LC_warning">'.
+                my $showdom = &display_domain_info($srch->{'srchdomain'});
+                $response = '<span class="LC_warning">'.
                     &mt('Institutional directory search is not available in domain: [_1]',$showdom).
                     '</span><br />'.
                     &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
@@ -7014,7 +7036,26 @@
     return ($currstate,$response,$forcenewuser,\%srch_results);
 }
 
-sub directorysrch_check {
+sub domdirectorysrch_check {
+    my ($srch) = @_;
+    my $response;
+    my %dom_inst_srch = &Apache::lonnet::get_dom('configuration',
+                                             ['directorysrch'],$srch->{'srchdomain'});
+    my $showdom = &display_domain_info($srch->{'srchdomain'});
+    if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') {
+        if ($dom_inst_srch{'directorysrch'}{'lcavailable'} eq '0') {
+            return &mt('LON-CAPA directory search is not available in domain: [_1]',$showdom);
+        }
+        if ($dom_inst_srch{'directorysrch'}{'lclocalonly'}) {
+            if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {
+                return &mt('LON-CAPA directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom);
+            }
+        }
+    }
+    return 'ok';
+}
+
+sub instdirectorysrch_check {
     my ($srch) = @_;
     my $can_search = 0;
     my $response;
Index: loncom/interface/lonpickuser.pm
diff -u loncom/interface/lonpickuser.pm:1.5 loncom/interface/lonpickuser.pm:1.6
--- loncom/interface/lonpickuser.pm:1.5	Wed Jan  5 18:39:38 2011
+++ loncom/interface/lonpickuser.pm	Mon Sep  5 01:46:08 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Search for a user
 #
-# $Id: lonpickuser.pm,v 1.5 2011/01/05 18:39:38 raeburn Exp $
+# $Id: lonpickuser.pm,v 1.6 2016/09/05 01:46:08 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -215,7 +215,7 @@
 
     my $cancreate =
         &Apache::lonuserutils::can_create_user($dom,$context,$usertype);
-    my $userpicker =
+    my ($userpicker,$cansearch) =
        &Apache::loncommon::user_picker($dom,\%srch,$forcenewuser,
                                        'document.userpicker',$cancreate,
                                        $usertype,$context);
@@ -228,7 +228,9 @@
                        $env{'form.coursedom'}.'" />'."\n".
                        &set_opener_elems();
     unless ($env{'form.phase'} eq 'define_newuser') { 
-        $r->print(<<"ENDBLOCK");
+        if ($cansearch) {
+            
+            $r->print(<<"ENDBLOCK");
 <h3>$headertext</h3>
 <form action="/adm/pickuser" method="post" name="userpicker">
 $opener_elems
@@ -237,6 +239,14 @@
 <input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.userpicker)" />
 </form>
 ENDBLOCK
+        } else {
+            $r->print(<<"ENDBLOCK");
+<form action="/adm/pickuser" method="post" name="userpicker">
+$opener_elems
+<input type="hidden" name="phase" value="get_user_info" />
+</form>
+ENDBLOCK
+        }
     }
     if (($env{'form.phase'} eq 'get_user_info') && ($env{'form.srchterm'} ne '')) {
         $r->print('<hr /><div>'.&mt('Searching ...').'</div>');
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.98 loncom/interface/lonrequestcourse.pm:1.99
--- loncom/interface/lonrequestcourse.pm:1.98	Mon Apr  4 01:09:48 2016
+++ loncom/interface/lonrequestcourse.pm	Mon Sep  5 01:46:08 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.98 2016/04/04 01:09:48 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.99 2016/09/05 01:46:08 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2109,6 +2109,18 @@
         $output .= &Apache::lonhtmlcommon::row_headline().
                   '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'</h3>';
     }
+    my $cansearch = 1;
+    my @alldoms = &Apache::lonnet::all_domains();
+    if (@alldoms == 1) {
+        my %domsrch = &Apache::lonnet::get_dom('configuration',
+                                               ['directorysrch'],$alldoms[0]);
+        if (ref($domsrch{'directorysrch'}) eq 'HASH') {
+            if ((!$domsrch{'directorysrch'}{'available'}) &&
+                ($domsrch{'directorysrch'}{'lcavailable'} eq '0')) {
+                $cansearch = 0;
+            }
+        }
+    }
     for (my $i=0; $i<$persontotal; $i++) { 
         my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
         my $linkargstr = join("','", at linkargs);
@@ -2133,9 +2145,14 @@
         }
         $sectionselector .= $newtitle.
             '<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'."\n";
-        my $usersrchlinktxt = &mt('Search for user');
-        my $usersrchlink =  &Apache::loncommon::selectuser_link($formname, at linkargs,$dom,
-                            $usersrchlinktxt);
+        my $usersrchlink;
+        if ($cansearch) {
+            my $usersrchlinktxt = &mt('Search for user');
+            $usersrchlink = &Apache::loncommon::selectuser_link($formname, at linkargs,$dom,
+                                                                $usersrchlinktxt);
+        } else {
+            $usersrchlink = ' ';
+        }
         my $userchklinktxt = &mt('Check username');
         my $userchklink = &Apache::loncommon::selectuser_link($formname, at linkargs,$dom,
                             $userchklinktxt,'checkusername');
Index: loncom/html/adm/help/tex/Domain_Configuration_InstDirectory_Search.tex
diff -u loncom/html/adm/help/tex/Domain_Configuration_InstDirectory_Search.tex:1.3 loncom/html/adm/help/tex/Domain_Configuration_InstDirectory_Search.tex:1.4
--- loncom/html/adm/help/tex/Domain_Configuration_InstDirectory_Search.tex:1.3	Sat Aug 20 17:48:11 2016
+++ loncom/html/adm/help/tex/Domain_Configuration_InstDirectory_Search.tex	Mon Sep  5 01:46:13 2016
@@ -14,17 +14,18 @@
 Settings for directory searches are: 
 
 \begin{itemize}
-\item Set directory searches as available or unavailable in the domain
+\item Set institutional directory searches as available or unavailable in the domain
 \item Set whether users from other LON-CAPA domains can use the institutional
-directory search to search for users. Note: this only applies to institutional
-directory data, users with privileges to add users to a course will
-always be able to search the LON-CAPA user database for other domains.
+directory search to search for users.
 \item For searches by users within your domain, you can limit the users
-who can use directory search based on institutional status
+who can use institutional directory search based on institutional status
 \item Set which types of search method - username, last name or last name,first
 name are allowed for institutional searches
 \item Set which types of search latitude - exact match, begins with or contains
 - are allowed
+\item Set whether accounts within the LON-CAPA domain itself can be searched by
+users with privileges to add users to a course.
+\item Set whether users from other domains can search within a LON-CAPA domain.
 \end{itemize}
 In the case of a {}``contains'' type search at least
 three characters must be entered by the user as the search term. Searches


More information about the LON-CAPA-cvs mailing list