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

raeburn raeburn@source.lon-capa.org
Sun, 19 Sep 2010 16:44:44 -0000


This is a MIME encoded message

--raeburn1284914684
Content-Type: text/plain

raeburn		Sun Sep 19 16:44:44 2010 EDT

  Modified files:              (Branch: GCI_3)
    /loncom/interface	loncreateuser.pm 
  Log:
  - Customization for GCI_3.
    - Usernames added for new users added via "Add/Modify a Student" must be e-mail addresses. Lower case enforced for new users.
    - Case sensitivity eliminated when searching for existing users, unless
      exact match to existing user with case used in search term.
    - Customization of wording for GCI. 
  
  
--raeburn1284914684
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100919164444.txt"

Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.329.2.3 loncom/interface/loncreateuser.pm:1.329.2.4
--- loncom/interface/loncreateuser.pm:1.329.2.3	Mon Aug  9 23:39:43 2010
+++ loncom/interface/loncreateuser.pm	Sun Sep 19 16:44:44 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.329.2.3 2010/08/09 23:39:43 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.329.2.4 2010/09/19 16:44:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -472,6 +472,7 @@
     my ($r,$context,$response,$srch,$forcenewuser,$crstype) = @_;
     my $defdom=$env{'request.role.domain'};
     my $formtoset = 'crtuser';
+    my $is_custom = &Apache::loncommon::needs_gci_custom();
     if (exists($env{'form.startrolename'})) {
         $formtoset = 'docustom';
         $env{'form.rolename'} = $env{'form.startrolename'};
@@ -499,7 +500,7 @@
     my %breadcrumb_text = &singleuser_breadcrumb($crstype);
     my $title = 'User Management';
     if ($context eq 'course') {
-        if (&Apache::loncommon::needs_gci_custom()) {
+        if ($is_custom) {
             $title = 'Enrollment and Student Activity';
         }
     }
@@ -666,7 +667,7 @@
 ENDBLOCK
     if ($env{'form.phase'} eq '') {
         my $defdom=$env{'request.role.domain'};
-        my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
+        my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain','',1);
         my %lt=&Apache::lonlocal::texthash(
                   'enro' => 'Enroll one student',
                   'enrm' => 'Enroll one member',
@@ -715,7 +716,7 @@
 <table>
  <tr>
   <td>$lt{'usr'}:</td>
-  <td><input type="text" size="15" name="srchterm" /></td>
+  <td><input type="text" size="25" name="srchterm" /></td>
   <td>&nbsp;$lt{'dom'}:</td><td>$domform</td>
   <td>&nbsp;$sellink&nbsp;</td>
   <td>&nbsp;<input name="userrole" type="submit" value="$buttontext" /></td>
@@ -760,6 +761,7 @@
     my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements,$crstype) = @_;
     my @fields = ('username','domain','lastname','firstname','permanentemail');
     my $sortby = $env{'form.sortby'};
+    my $is_custom = &Apache::loncommon::needs_gci_custom();
 
     if (!grep(/^\Q$sortby\E$/,@fields)) {
         $sortby = 'lastname';
@@ -800,7 +802,7 @@
     } else {
         my $title = 'User Management';
         if ($context eq 'course') {
-            if (&Apache::loncommon::needs_gci_custom()) {
+            if ($is_custom) {
                 $title = 'Enrollment and Student Activity';
             }
         }
@@ -930,12 +932,21 @@
     my %abv_auth = &auth_abbrev();
     my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules);
     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
+    my $is_custom = &Apache::loncommon::needs_gci_custom();
+    if ($is_custom) {
+        if ($uhome eq 'no_host') {
+            my $lc_ccuname = lc($ccuname);
+            if ($lc_ccuname ne $ccuname) {
+                $uhome = &Apache::lonnet::homeserver($lc_ccuname,$ccdomain);
+                $ccuname = $lc_ccuname;
+            }
+        }
+    }
     if ($uhome eq 'no_host') {
-        my $usertype;
         my ($rules,$ruleorder) =
             &Apache::lonnet::inst_userrules($ccdomain,'username');
-            $usertype =
-                &Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules);
+        my $usertype =
+            &Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules);
         my $cancreate =
             &Apache::lonuserutils::can_create_user($ccdomain,$context,
                                                    $usertype);
@@ -945,17 +956,26 @@
                 official   => 'institutional',
                 unofficial => 'non-institutional',
             );
+            if ($ccdomain eq 'gci') {
+                $usertypetext{'unofficial'} = 'institutional',
+            }
             my $response;
             if ($env{'form.origform'} eq 'crtusername') {
-                $response =  '<span class="LC_warning">'.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain).
-                            '</span><br />';
+                if ($is_custom) {
+                    $response = '<span class="LC_warning">'.&mt('Invalid format for username for new user: [_1]','<b>'.$ccuname.'</b>').
+                                '</span><br />';
+                } else {
+                    $response =  '<span class="LC_warning">'.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain).'</span><br />';
+                }
             }
             $response .= '<p class="LC_warning">'
                         .&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.")
-                        .' '
-                        .&mt('Please contact the [_1]helpdesk[_2] for assistance.'
-                            ,'<a href="'.$helplink.'">','</a>')
-                        .'</p><br />';
+                        .'<br />';
+            if ($ccdomain eq 'gcitest') {
+                $response .= &mt('Enter a valid e-mail address as the username for the new user.').' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.'
+                             ,'<a href="'.$helplink.'">','</a>')
+                             .'</p><br />';
+            }
             $env{'form.phase'} = '';
             &print_username_entry_form($r,$context,$response,undef,undef,$crstype);
             return;
@@ -1008,7 +1028,7 @@
     }
     my $title = 'User Management';
     if ($context eq 'course') {
-        if (&Apache::loncommon::needs_gci_custom()) {
+        if ($is_custom) {
             $title = 'Enrollment and Student Activity';
         }
     }
@@ -2169,7 +2189,8 @@
 
 # ================================================================= Phase Three
 sub update_user_data {
-    my ($r,$context,$crstype) = @_; 
+    my ($r,$context,$crstype) = @_;
+    my $is_custom = &Apache::loncommon::needs_gci_custom();
     my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
                                           $env{'form.ccdomain'});
     # Error messages
@@ -2224,7 +2245,7 @@
     }
     my $title = 'User Management';
     if ($context eq 'course') {
-        if (&Apache::loncommon::needs_gci_custom()) {
+        if ($is_custom) {
             $title = 'Enrollment and Student Activity';
         }
     }
@@ -2719,7 +2740,8 @@
                                         $changeHash{'tools.'.$key};
                                 } else {
                                     $newenvhash{'environment.availabletools.'.$key} =
-          &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},                                            $key,'reload','tools');
+          &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+                                            $key,'reload','tools');
                                 }
                             }
                         }
@@ -3655,9 +3677,10 @@
         $context = 'domain';
         $crstype = $env{'form.templatecrstype'};
     }
+    my $is_custom = &Apache::loncommon::needs_gci_custom();
     my $title = 'User Management';
     if ($context eq 'course') {
-        if (&Apache::loncommon::needs_gci_custom()) {
+        if ($is_custom) {
             $title = 'Enrollment and Student Activity';
         }
     }
@@ -3930,8 +3953,9 @@
                  .'// ]]>'."\n"
                  .'</script>'."\n";
     my $title = 'User Management';
+    my $is_custom = &Apache::loncommon::needs_gci_custom();
     if ($context eq 'course') {
-        if (&Apache::loncommon::needs_gci_custom()) {
+        if ($is_custom) {
             $title = 'Enrollment and Student Activity';
         }
     }
@@ -4025,8 +4049,9 @@
         $context = 'domain';
     }
     my $title = 'User Management';
+    my $is_custom = &Apache::loncommon::needs_gci_custom();
     if ($context eq 'course') {
-        if (&Apache::loncommon::needs_gci_custom()) {
+        if ($is_custom) {
             $title = 'Enrollment and Student Activity';
         }
     }
@@ -4073,8 +4098,12 @@
         if (! exists($env{'form.state'})) {
             &Apache::lonuserutils::print_first_users_upload_form($r,$context);
         } elsif ($env{'form.state'} eq 'got_file') {
+            my $formname;
+            if ($env{'form.caller'} eq 'requestcrs') {
+                $formname = 'studentform';
+            }
             &Apache::lonuserutils::print_upload_manager_form($r,$context,
-                                                             $permission,$crstype);
+                                                             $permission,$crstype,$formname);
         } elsif ($env{'form.state'} eq 'enrolling') {
             if ($env{'form.datatoken'}) {
                 &Apache::lonuserutils::upfile_drop_add($r,$context,$permission);
@@ -4097,7 +4126,7 @@
             if ($env{'form.phase'} eq 'createnewuser') {
                 my $response;
                 if ($env{'form.srchterm'} !~ /^$match_username$/) {
-                    my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
+                    my $response = '<p class="LC_warning">'.&mt('You must specify a valid username. Only the following are allowed: letters numbers - . @').'</p>';
                     $env{'form.phase'} = '';
                     &print_username_entry_form($r,$context,$response,$srch,undef,$crstype);
                 } else {
@@ -4359,7 +4388,8 @@
 #  Menu Phase One
 sub print_main_menu {
     my ($permission,$context,$crstype) = @_;
-    if (($context eq 'course') && (&Apache::loncommon::needs_gci_custom())) {
+    my $is_custom = &Apache::loncommon::needs_gci_custom();
+    if (($context eq 'course') && ($is_custom)) {
         return &print_gci_main_menu($permission,$context,$crstype)
     }
     my $linkcontext = $context;
@@ -5673,7 +5703,7 @@
     if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'instd')) {
         if (($srch->{'srchdomain'} eq '') || 
 	    ! (&Apache::lonnet::domain($srch->{'srchdomain'}))) {
-            $response = &mt('You must specify a valid domain when searching in a domain or institutional directory.')
+            $response = '<p class="LC_warning">'.&mt('You must specify a valid domain when searching in a domain or institutional directory.').'</p>';
         }
     }
     if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') ||
@@ -5686,7 +5716,7 @@
                 }
             }
             if ($unamecheck !~ /^$match_username$/) {
-                $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
+                $response = '<p class="LC_warning">'.&mt('You must specify a valid username. Only the following are allowed: letters numbers - . @').'</p>';
             }
         }
     }
@@ -5861,7 +5891,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.').

--raeburn1284914684--