[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncreateuser.pm

raeburn raeburn at source.lon-capa.org
Sun Sep 18 14:10:55 EDT 2016


raeburn		Sun Sep 18 18:10:55 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	loncreateuser.pm 
  Log:
  - For 2.11
    - Backport 1.412
  
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.406.2.2 loncom/interface/loncreateuser.pm:1.406.2.3
--- loncom/interface/loncreateuser.pm:1.406.2.2	Fri Aug 12 18:33:17 2016
+++ loncom/interface/loncreateuser.pm	Sun Sep 18 18:10:54 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.406.2.2 2016/08/12 18:33:17 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.406.2.3 2016/09/18 18:10:54 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -813,7 +813,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');
@@ -822,7 +822,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" />
@@ -830,6 +832,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');
@@ -6826,10 +6831,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 '') {
@@ -7004,7 +7025,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;




More information about the LON-CAPA-cvs mailing list