[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm loncreateuser.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 31 Aug 2007 03:21:30 -0000


This is a MIME encoded message

--raeburn1188530490
Content-Type: text/plain

raeburn		Thu Aug 30 23:21:30 2007 EDT

  Modified files:              
    /loncom/interface	loncommon.pm loncreateuser.pm 
  Log:
  loncommon.pm
  - only display "Make new user" button following a matchless search for "username is <searchterm>" in the LON-CAPA domain of the user's current role.
  - display the "forcenew" radio buttons following other valid matchless searches.
  - add italicize span to standard_css()
  
  loncreateuser.pm
  - various wording changes to clarify the difference between searching in a LON-CAPA domain, and searching in an institutional directory.
  - eliminate use of ambiguous 'this' when referring to the domain/institution searched.
  - adding explanation (from rev 1.160) about new user creation, for cases where display of the "Make new user" button is inappropriate, and "forcenew" radio buttons are used instead.    
  
  
  
--raeburn1188530490
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20070830232130.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.575 loncom/interface/loncommon.pm:1.576
--- loncom/interface/loncommon.pm:1.575	Thu Aug 30 18:56:14 2007
+++ loncom/interface/loncommon.pm	Thu Aug 30 23:21:27 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.575 2007/08/30 22:56:14 albertel Exp $
+# $Id: loncommon.pm,v 1.576 2007/08/31 03:21:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4498,6 +4498,10 @@
   white-space: nowrap;
 }
 
+span.LC_cusr_emph {
+  font-style: italic;
+}
+
 table.LC_docs_documents {
   background: #BBBBBB;
   border-width: 0px;
@@ -5625,7 +5629,7 @@
                     'lastname'  => 'last name',
                     'lastfirst' => 'last name, first name',
                     'crs'       => 'in this course',
-                    'dom'       => 'in selected domain', 
+                    'dom'       => 'in selected LON-CAPA domain', 
                     'alc'       => 'all LON-CAPA',
                     'instd'     => 'in institutional directory for selected domain',
                     'exact'     => 'is',
@@ -5688,7 +5692,16 @@
     my ($newuserscript,$new_user_create);
 
     if ($forcenewuser) {
-	$new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" /> </p>';
+        if (ref($srch) eq 'HASH') {
+            if ($srch->{'srchby'} eq 'uname' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchin'} eq 'dom' && $srch->{'srchdomain'} eq $env{'request.role.domain'}) {
+	        $new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" /> </p>';
+            } else {
+                $new_user_create = &newuser_radio($caller);
+            }
+        } else {
+            $new_user_create = &newuser_radio($caller);
+        }
+
         $newuserscript = <<"ENDSCRIPT";
 
 function setSearch(createnew,callingForm) {
@@ -5814,6 +5827,11 @@
     return $output;
 }
 
+sub newuser_radio {
+    my ($caller) = @_;
+    return '<span class="LC_nobreak">'.&mt('Make new user if no match found: ').'<input type="radio" name="forcenew" value="1" onclick="javascript:setSearch(\'1\','.$caller.')" />'.&mt('Yes').'&nbsp;&nbsp;<input type="radio" name="forcenew" value="0" checked="checked" />'.&mt('No').'</span><br />';
+}
+
 
 
 =pod
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.179 loncom/interface/loncreateuser.pm:1.180
--- loncom/interface/loncreateuser.pm:1.179	Sun Aug 26 17:09:43 2007
+++ loncom/interface/loncreateuser.pm	Thu Aug 30 23:21:27 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.179 2007/08/26 21:09:43 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.180 2007/08/31 03:21:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2241,14 +2241,18 @@
             }
         }
     }
+    if ($response ne '') {
+        $response = '<span class="LC_warning">'.$response.'</span>';
+    }
     if ($srch->{'srchin'} eq 'instd') {
         my $instd_chk = &directorysrch_check($srch);
         if ($instd_chk ne 'ok') {
-            $response = $instd_chk;
+            $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 />';
         }
     }
     if ($response ne '') {
-        return ($currstate,'<span class="LC_warning">'.$response.'</span>');
+        return ($currstate,$response);
     }
     if ($srch->{'srchby'} eq 'uname') {
         if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs')) {
@@ -2257,7 +2261,8 @@
                     my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'});
                     if ($uhome eq 'no_host') {
                         my $domdesc = &Apache::lonnet::domain($env{'request.role.domain'},'description');
-                        $response = &mt('New users can only be created in the domain to which you current role belongs - [_1].',$env{'request.role.domain'}.' ('.$domdesc.')');
+                        my $showdom = &display_domain_info($env{'request.role.domain'});
+                        $response = &mt('New users can only be created in the domain to which your current role belongs - [_1].',$showdom);
                     } else {
                         $currstate = 'modify';
                     }
@@ -2397,13 +2402,14 @@
     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'}{'available'}) {
-            return &mt('Institutional directory search unavailable in domain: [_1]',$srch->{'srchdomain'}); 
+            return &mt('Institutional directory search is not available in domain: [_1]',$showdom); 
         }
         if ($dom_inst_srch{'directorysrch'}{'localonly'}) {
             if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {
-                return &mt('Insitutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$srch->{'srchdomain'}); 
+                return &mt('Institutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom); 
             }
             my @usertypes = split(/:/,$env{'environment.inststatus'});
             if (!@usertypes) {
@@ -2424,13 +2430,13 @@
                     push (@longtypes,$insttypes->{$item});
                 }
                 my $insttype_str = join(', ',@longtypes); 
-                return &mt('Directory search in domain: [_1] is unavailable to your user type: ',$srch->{'srchdomain'}).$insttype_str;
+                return &mt('Institutional directory search in domain: [_1] is not available to your user type: ',$showdom).$insttype_str;
             } 
         } else {
             $can_search = 1;
         }
     } else {
-        return &mt('Directory search has not been configured for domain: [_1]',$srch->{'srchdomain'});
+        return &mt('Institutional directory search has not been configured for domain: [_1]',$showdom);
     }
     my %longtext = &Apache::lonlocal::texthash (
                        uname     => 'username',
@@ -2443,10 +2449,10 @@
     if ($can_search) {
         if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') {
             if (!grep(/^\Q$srch->{'srchby'}\E$/,@{$dom_inst_srch{'directorysrch'}{'searchby'}})) {
-                return &mt('Directory search in domain: [_1] is not available for searching by "[_2]"',$srch->{'srchdomain'},$longtext{$srch->{'srchby'}});
+                return &mt('Institutional directory search in domain: [_1] is not available for searching by "[_2]"',$showdom,$longtext{$srch->{'srchby'}});
             }
         } else {
-            return &mt('Directory search in domain: [_1] is not available.', $srch->{'srchdomain'});
+            return &mt('Institutional directory search in domain: [_1] is not available.', $showdom);
         }
     }
     if ($can_search) {
@@ -2454,7 +2460,7 @@
             if (grep(/^\Q$srch->{'srchtype'}\E/,@{$dom_inst_srch{'directorysrch'}{'searchtypes'}})) {
                 return 'ok';
             } else {
-                return &mt('Directory search in domain [_1] is not available for the requested search type: "[_2]"',$srch->{'srchdomain'},$longtext{$srch->{'srchtype'}});
+                return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}});
             }
         } else {
             if ((($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') &&
@@ -2462,7 +2468,7 @@
                 ($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) {
                 return 'ok';
             } else {
-                return &mt('Directory search in domain [_1] is not available for the requested search type: "[_2]"',$srch->{'srchdomain'},$longtext{$srch->{'srchtype'}});
+                return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}});
             }
         }
     }
@@ -2491,26 +2497,35 @@
           'lastname' => 'last name',
           'lastfirst' => 'last name, first name',
           'crs' => 'this course',
-          'dom' => 'this domain',
-          'instd' => "your institution's directory",
+          'dom' => 'LON-CAPA domain: ',
+          'instd' => 'the institutional directory for domain: ',
     );
 
     my %single = (
+                   begins   => 'A match',
                    contains => 'A match',
-                   exact => 'An exact match',
+                   exact    => 'An exact match',
                  );
     my %nomatch = (
+                   begins   => 'No match',
                    contains => 'No match',
-                   exact => 'No exact match',
+                   exact    => 'No exact match',
                   );
     if (keys(%srch_results) > 1) {
         $currstate = 'select';
     } else {
         if (keys(%srch_results) == 1) {
             $currstate = 'modify';
-            $response = &mt("$single{$srch->{'srchtype'}} was found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
+            $response = &mt("$single{$srch->{'srchtype'}} was found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
+            if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
+                $response .= &display_domain_info($srch->{'srchdomain'});
+            }
         } else {
-            $response = '<span class="LC_warning">'.&mt("$nomatch{$srch->{'srchtype'}} found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}).'</span>';
+            $response = '<span class="LC_warning">'.&mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}",$srch->{'srchterm'});
+            if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
+                $response .= &display_domain_info($srch->{'srchdomain'});
+            }
+            $response .= '</span>';
             if ($srch->{'srchin'} ne 'alc') {
                 $forcenewuser = 1;
                 my $cansrchinst = 0; 
@@ -2522,22 +2537,37 @@
                         } 
                     }
                 }
-                if (($srch->{'srchby'} eq 'lastfirst') || 
-                    ($srch->{'srchby'} eq 'lastname')) {
-                    if ($srch->{'srchin'} eq 'crs') {
-                        $response .= '<br />'.&mt('You may want to broaden your search to the whole domain.'); 
-                    } elsif ($srch->{'srchin'} eq 'dom') {
-                        if ($cansrchinst) {
-                            $response .= '<br />'.&mt('You may want to broaden your search to a search of the institutional directory for this domain.');
-                        }
+                if ((($srch->{'srchby'} eq 'lastfirst') || 
+                     ($srch->{'srchby'} eq 'lastname')) &&
+                    ($srch->{'srchin'} eq 'dom')) {
+                    if ($cansrchinst) {
+                        $response .= '<br />'.&mt('You may want to broaden your search to a search of the institutional directory for the domain.');
                     }
                 }
+                if ($srch->{'srchin'} eq 'crs') {
+                    $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'})) {
+                $response .= '<br />'.&mt("<b>To add a new user</b> (you can only create new users in your current role's domain - <span class=\"LC_cusr_emph\">[_1]</span>) ...",$env{'request.role.domain'}).'<ul><li>'.&mt("Set '<span class=\"LC_cusr_emph\">Make new user if no match found</span>' to '<b>Yes</b>'").'</li><li>'.&mt('Provide the proposed username').'</li><li>'.&mt('Search').'</li></ul><br />';
             }
         }
     }
     return ($currstate,$response,$forcenewuser);
 }
 
+sub display_domain_info {
+    my ($dom) = @_;
+    my $output = $dom;
+    if ($dom ne '') { 
+        my $domdesc = &Apache::lonnet::domain($dom,'description');
+        if ($domdesc ne '') {
+            $output .= ' <span class="LC_cusr_emph">('.$domdesc.')</span>';
+        }
+    }
+    return $output;
+}
+
 sub crumb_utilities {
     my %elements = (
        crtuser => {

--raeburn1188530490--