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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Sun, 13 Jul 2008 00:00:51 -0000


This is a MIME encoded message

--raeburn1215907251
Content-Type: text/plain

raeburn		Sat Jul 12 20:00:51 2008 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - In "User modification" table can set which user information fields are editable when self-creating an account.
    - Applies (if institutional data field is blank) 
    - For the different institutional types defined for the domain + default ('Other Users' or 'Any Users' depending on whether defined types exist).    
  
  
--raeburn1215907251
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080712200051.txt"

Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.62 loncom/interface/domainprefs.pm:1.63
--- loncom/interface/domainprefs.pm:1.62	Wed Jul  9 17:34:27 2008
+++ loncom/interface/domainprefs.pm	Sat Jul 12 20:00:50 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.62 2008/07/09 21:34:27 raeburn Exp $
+# $Id: domainprefs.pm,v 1.63 2008/07/13 00:00:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -151,7 +151,9 @@
                     header => [{col1 => 'Target user has role',
                                 col2 => 'User information updateable in author context'},
                                {col1 => 'Target user has role',
-                                col2 => 'User information updateable in course context'}],
+                                col2 => 'User information updateable in course context'},
+                               {col1 => "Status of user",
+                                col2 => 'Information settable when self-creating account (if directory data blank)'}],
                   },
         'scantron' => 
                   { text => 'Scantron format file',
@@ -442,7 +444,19 @@
             &print_usercreation('bottom',$dom,$settings,\$rowtotal);
             $rowtotal ++;
         } elsif ($action eq 'usermodification') {
-            $output .= &print_usermodification('bottom',$dom,$settings,\$rowtotal);
+            $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal).'
+           </table>
+          </td>
+         </tr>
+         <tr>
+           <td>
+            <table class="LC_nested">
+             <tr class="LC_info_row">
+              <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
+              <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>      </tr>'.
+
+                       &print_usermodification('bottom',$dom,$settings,\$rowtotal);
+            $rowtotal ++;
         } elsif ($action eq 'coursecategories') {
             $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
         } else {
@@ -1683,10 +1697,14 @@
                );
     my $css_class = $rowcount%2?' class="LC_odd_row"':'';
     $output = '<tr '.$css_class.'>'.
-              '<td><span class="LC_nobreak">'.
-              &mt("Format rules to check for $text{$type}: ").
-              '</span></td>'.
-              '<td class="LC_left_item" colspan="2"><table>';
+              '<td><span class="LC_nobreak">';
+    if ($type eq 'email') {
+        $output .= &mt("Formats disallowed for $text{$type}: ");
+    } else {
+        $output .= &mt("Format rules to check for $text{$type}: ");
+    }
+    $output .= '</span></td>'.
+               '<td class="LC_left_item" colspan="2"><table>';
     my $rem;
     if (ref($ruleorder) eq 'ARRAY') {
         for (my $i=0; $i<@{$ruleorder}; $i++) {
@@ -1774,7 +1792,7 @@
             $$rowtotal ++;
             $rowcount ++;
         }
-    } else {
+    } elsif ($position eq 'middle') {
         $context = 'course';
         $rowcount = 0;
         foreach my $role ('st','ep','ta','in','cr') {
@@ -1783,6 +1801,20 @@
             $$rowtotal ++;
             $rowcount ++;
         }
+    } elsif ($position eq 'bottom') {
+        $context = 'selfcreate';
+        my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+        $usertypes->{'default'} = $othertitle;
+        if (ref($types) eq 'ARRAY') {
+            push(@{$types},'default');
+            $usertypes->{'default'} = $othertitle;
+            foreach my $status (@{$types}) {
+                $datatable .= &modifiable_userdata_row($context,$status,$settings,
+                                                       $numinrow,$rowcount,$usertypes);
+                $$rowtotal ++;
+                $rowcount ++;
+            }
+        }
     }
     return $datatable;
 }
@@ -2362,12 +2394,20 @@
 }
 
 sub modifiable_userdata_row {
-    my ($context,$role,$settings,$numinrow,$rowcount) = @_;
+    my ($context,$role,$settings,$numinrow,$rowcount,$usertypes) = @_;
     my $rolename;
-    if ($role eq 'cr') {
-        $rolename = &mt('Custom role');
+    if ($context eq 'selfcreate') {
+        if (ref($usertypes) eq 'HASH') {
+            $rolename = $usertypes->{$role};
+        } else {
+            $rolename = $role;
+        }
     } else {
-        $rolename = &Apache::lonnet::plaintext($role);
+        if ($role eq 'cr') {
+            $rolename = &mt('Custom role');
+        } else {
+            $rolename = &Apache::lonnet::plaintext($role);
+        }
     }
     my @fields = ('lastname','firstname','middlename','generation',
                   'permanentemail','id');
@@ -4090,10 +4130,11 @@
             $curr_usermodification{$key} = $domconfig{'usermodification'}{$key};
         }
     }
-    my @contexts = ('author','course');
+    my @contexts = ('author','course','selfcreate');
     my %context_title = (
                            author => 'In author context',
                            course => 'In course context',
+                           selfcreate => 'When self creating account', 
                         );
     my @fields = ('lastname','firstname','middlename','generation',
                   'permanentemail','id');
@@ -4101,6 +4142,12 @@
                   author => ['ca','aa'],
                   course => ['st','ep','ta','in','cr'],
                 );
+    my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+    if (ref($types) eq 'ARRAY') {
+        push(@{$types},'default');
+        $usertypes->{'default'} = $othertitle;
+    }
+    $roles{'selfcreate'} = $types;  
     my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
     my %modifyhash;
     foreach my $context (@contexts) {
@@ -4148,13 +4195,26 @@
                     if (ref($changes{$context}) eq 'ARRAY') {
                         foreach my $role (@{$changes{$context}}) {
                             my $rolename;
-                            if ($role eq 'cr') {
-                                $rolename = &mt('Custom');
+                            if ($context eq 'selfcreate') {
+                                $rolename = $role;
+                                if (ref($usertypes) eq 'HASH') {
+                                    if ($usertypes->{$role} ne '') {
+                                        $rolename = $usertypes->{$role};
+                                    }
+                                }
                             } else {
-                                $rolename = &Apache::lonnet::plaintext($role);
+                                if ($role eq 'cr') {
+                                    $rolename = &mt('Custom');
+                                } else {
+                                    $rolename = &Apache::lonnet::plaintext($role);
+                                }
                             }
                             my @modifiable;
-                            $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
+                            if ($context eq 'selfcreate') {
+                                $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Self-creation of account by users with status: [_1]  ',$rolename).'</span> - '.&mt('modifiable fields (if institutional data blank): ');
+                            } else {
+                                $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
+                            }
                             foreach my $field (@fields) {
                                 if ($modifyhash{$context}{$role}{$field}) {
                                     push(@modifiable,$fieldtitles{$field});

--raeburn1215907251--