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

raeburn raeburn at source.lon-capa.org
Sat Mar 29 16:25:29 EDT 2014


raeburn		Sat Mar 29 20:25:29 2014 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Eliminate some duplicated HTML, by grouping together calls to subroutines
    which require the same args, and including required subroutines in dispatch
    list keys in %prefs ('print' and 'modify' keys).
  - Modify some itemcount increments used to support alternating background 
    colors in table rows.
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.229 loncom/interface/domainprefs.pm:1.230
--- loncom/interface/domainprefs.pm:1.229	Mon Mar 17 02:36:56 2014
+++ loncom/interface/domainprefs.pm	Sat Mar 29 20:25:28 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.229 2014/03/17 02:36:56 raeburn Exp $
+# $Id: domainprefs.pm,v 1.230 2014/03/29 20:25:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -239,6 +239,8 @@
                                  col2 => '',},
                                 {col1 => 'Administrator Settings',
                                  col2 => '',}],
+                      print => \&print_rolecolors,
+                      modify => \&modify_rolecolors,
                     },
         'login' =>
                     { text => 'Log-in page options',
@@ -247,12 +249,16 @@
                                   col2 => '',},
                                  {col1 => 'Log-in Help',
                                   col2 => 'Value'}],
+                      print => \&print_login,
+                      modify => \&modify_login,
                     },
         'defaults' => 
                     { text => 'Default authentication/language/timezone/portal',
                       help => 'Domain_Configuration_LangTZAuth',
                       header => [{col1 => 'Setting',
                                   col2 => 'Value'}],
+                      print => \&print_defaults,
+                      modify => \&modify_defaults,
                     },
         'quotas' => 
                     { text => 'Blogs, personal web pages, webDAV/quotas, portfolios',
@@ -260,12 +266,16 @@
                       header => [{col1 => 'User affiliation',
                                   col2 => 'Available tools',
                                   col3 => 'Quotas, MB; (Authoring requires role)',}],
+                      print => \&print_quotas,
+                      modify => \&modify_quotas,
                     },
         'autoenroll' =>
                    { text => 'Auto-enrollment settings',
                      help => 'Domain_Configuration_Auto_Enrollment',
                      header => [{col1 => 'Configuration setting',
                                  col2 => 'Value(s)'}],
+                     print => \&print_autoenroll,
+                     modify => \&modify_autoenroll,
                    },
         'autoupdate' => 
                    { text => 'Auto-update settings',
@@ -276,24 +286,32 @@
                                  col2 => 'Affiliation'},
                                 {col1 => 'User population',
                                  col2 => 'Updatable user data'}],
+                     print => \&print_autoupdate,
+                     modify => \&modify_autoupdate,
                   },
         'autocreate' => 
                   { text => 'Auto-course creation settings',
                      help => 'Domain_Configuration_Auto_Creation',
                      header => [{col1 => 'Configuration Setting',
                                  col2 => 'Value',}],
+                     print => \&print_autocreate,
+                     modify => \&modify_autocreate,
                   },
         'directorysrch' => 
                   { text => 'Institutional directory searches',
                     help => 'Domain_Configuration_InstDirectory_Search',
                     header => [{col1 => 'Setting',
                                 col2 => 'Value',}],
+                    print => \&print_directorysrch,
+                    modify => \&modify_directorysrch,
                   },
         'contacts' =>
                   { text => 'Contact Information',
                     help => 'Domain_Configuration_Contact_Info',
                     header => [{col1 => 'Setting',
                                 col2 => 'Value',}],
+                    print => \&print_contacts,
+                    modify => \&modify_contacts,
                   },
         'usercreation' => 
                   { text => 'User creation',
@@ -304,6 +322,8 @@
                                 col2 => 'Usernames which may be created',},
                                {col1 => 'Context',
                                 col2 => 'Assignable authentication types'}],
+                    print => \&print_usercreation,
+                    modify => \&modify_usercreation,
                   },
         'selfcreation' => 
                   { text => 'Users self-creating accounts',
@@ -314,6 +334,8 @@
                                 col2 => 'Information user can enter'},
                                {col1 => 'Self-creation with e-mail as username',
                                 col2 => 'Settings'}],
+                    print => \&print_selfcreation,
+                    modify => \&modify_selfcreation,
                   },
         'usermodification' =>
                   { text => 'User modification',
@@ -322,6 +344,8 @@
                                 col2 => 'User information updatable in author context'},
                                {col1 => 'Target user has role',
                                 col2 => 'User information updatable in course context'}],
+                    print => \&print_usermodification,
+                    modify => \&modify_usermodification,
                   },
         'scantron' =>
                   { text => 'Bubblesheet format file',
@@ -329,6 +353,8 @@
                     header => [ {col1 => 'Item',
                                  col2 => '',
                               }],
+                    print => \&print_scantron,
+                    modify => \&modify_scantron,
                   },
         'requestcourses' => 
                  {text => 'Request creation of courses',
@@ -339,6 +365,8 @@
                               col2 => 'Value'},
                              {col1 => 'Available textbooks',
                               col2 => ''}],
+                  print => \&print_quotas,
+                  modify => \&modify_quotas,
                  },
         'requestauthor' =>
                  {text => 'Request Authoring Space',
@@ -347,6 +375,8 @@
                               col2 => 'Availability/Processing of requests',},
                              {col1 => 'Setting',
                               col2 => 'Value'}],
+                  print => \&print_quotas,
+                  modify => \&modify_quotas,
                  },
         'coursecategories' =>
                   { text => 'Cataloging of courses/communities',
@@ -356,6 +386,8 @@
                                {col1 => 'Categories',
                                 col2 => '',
                                }],
+                    print => \&print_coursecategories,
+                    modify => \&modify_coursecategories,
                   },
         'serverstatuses' =>
                  {text   => 'Access to server status pages',
@@ -364,12 +396,16 @@
                               col2 => 'Other named users',
                               col3 => 'Specific IPs',
                             }],
+                  print => \&print_serverstatuses,
+                  modify => \&modify_serverstatuses,
                  },
         'helpsettings' =>
                  {text   => 'Help page settings',
                   help   => 'Domain_Configuration_Help_Settings',
                   header => [{col1 => 'Help Settings (logged-in users)',
                               col2 => 'Value'}],
+                  print  => \&print_helpsettings,
+                  modify => \&modify_helpsettings,
                  },
         'coursedefaults' => 
                  {text => 'Course/Community defaults',
@@ -378,12 +414,16 @@
                               col2 => 'Value',},
                              {col1 => 'Defaults which can be overridden for each course by a DC',
                               col2 => 'Value',},],
+                  print => \&print_coursedefaults,
+                  modify => \&modify_coursedefaults,
                  },
         'privacy' => 
                  {text   => 'User Privacy',
                   help   => 'Domain_Configuration_User_Privacy',
                   header => [{col1 => 'Setting',
                               col2 => 'Value',}],
+                  print => \&print_privacy,
+                  modify => \&modify_privacy,
                  },
         'usersessions' =>
                  {text  => 'User session hosting/offloading',
@@ -394,6 +434,8 @@
                               col2 => 'Rules'},
                              {col1 => "Hosting domain's own users elsewhere",
                               col2 => 'Rules'}],
+                  print => \&print_usersessions,
+                  modify => \&modify_usersessions,
                  },
          'loadbalancing' =>
                  {text  => 'Dedicated Load Balancer(s)',
@@ -403,6 +445,8 @@
                               col3 => 'User affiliation',
                               col4 => 'Overrides'},
                             ],
+                  print => \&print_loadbalancing,
+                  modify => \&modify_loadbalancing,
                  },
     );
     if (keys(%servers) > 1) {
@@ -414,6 +458,8 @@
                                         col2 => ''},
                                        {col1 => 'Log-in Help',
                                         col2 => 'Value'}],
+                            print => \&print_login,
+                            modify => \&modify_login,
                            };
     }
 
@@ -613,16 +659,12 @@
               <td class="LC_right_item"'.$rightcolspan.'>'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
              </tr>';
         $rowtotal ++;
-        if ($action eq 'autoupdate') {
-            $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal);
-        } elsif ($action eq 'usercreation') {
-            $output .= &print_usercreation('top',$dom,$settings,\$rowtotal);
-        } elsif ($action eq 'selfcreation') {
-            $output .= &print_selfcreation('top',$dom,$settings,\$rowtotal);
-        } elsif ($action eq 'usermodification') {
-            $output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
+        if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
+            ($action eq 'usermodification') || ($action eq 'coursedefaults') ||
+            ($action eq 'selfenrollment') || ($action eq 'usersessions')) {
+            $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {
-            $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
+            $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
         } elsif ($action eq 'login') {
             if ($numheaders == 3) {
                 $colspan = ' colspan="2"';
@@ -630,16 +672,10 @@
             } else {
                 $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal);
             }
-        } elsif ($action eq 'requestcourses') {
-            $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
-        } elsif ($action eq 'requestauthor') {
+        } elsif (($action eq 'requestcourses') || ($action eq 'requestauthor')) {
             $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
-        } elsif ($action eq 'usersessions') {
-            $output .= &print_usersessions('top',$dom,$settings,\$rowtotal); 
         } elsif ($action eq 'rolecolors') {
             $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
-        } elsif ($action eq 'coursedefaults') {
-            $output .= &print_coursedefaults('top',$dom,$settings,\$rowtotal);
         }
         $output .= '
            </table>
@@ -649,39 +685,14 @@
            <td>
             <table class="LC_nested">
              <tr class="LC_info_row">
-              <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
-        $output .= '
+              <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[1]->{'col1'}).'</td>
               <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[1]->{'col2'}).'</td>
              </tr>';
             $rowtotal ++;
-        if ($action eq 'autoupdate') {
-            $output .= &print_autoupdate('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_autoupdate('bottom',$dom,$settings,\$rowtotal);
-            $rowtotal ++;
-        } elsif ($action eq 'usercreation') {
-            $output .= &print_usercreation('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_usercreation('bottom',$dom,$settings,\$rowtotal);
-            $rowtotal ++;
-        } elsif ($action eq 'selfcreation') {
-            $output .= &print_selfcreation('middle',$dom,$settings,\$rowtotal).'
+        if (($action eq 'autoupdate') || ($action eq 'usercreation') ||
+            ($action eq 'selfcreation') || ($action eq 'selfenrollment') ||
+            ($action eq 'usersessions')) {
+            $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal).'
            </table>
           </td>
          </tr>
@@ -691,11 +702,11 @@
              <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_selfcreation('bottom',$dom,$settings,\$rowtotal);
+             </tr>'."\n".
+            $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
             $rowtotal ++;
-        } elsif ($action eq 'usermodification') {
-            $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal);
+        } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults')) {
+            $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {
             $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
         } elsif ($action eq 'login') {
@@ -730,21 +741,6 @@
                        &print_textbookcourses($dom,$settings,\$rowtotal);
         } elsif ($action eq 'requestauthor') {
             $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
-        } elsif ($action eq 'usersessions') {
-            $output .= &print_usersessions('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_usersessions('bottom',$dom,$settings,\$rowtotal);
-            $rowtotal ++;
-        } elsif ($action eq 'coursedefaults') {
-            $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'rolecolors') {
             $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
            </table>
@@ -823,24 +819,14 @@
         $rowtotal ++;
         if ($action eq 'quotas') {
             $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
-        } elsif ($action eq 'autoenroll') {
-            $output .= &print_autoenroll($dom,$settings,\$rowtotal);
-        } elsif ($action eq 'autocreate') {
-            $output .= &print_autocreate($dom,$settings,\$rowtotal);
-        } elsif ($action eq 'directorysrch') {
-            $output .= &print_directorysrch($dom,$settings,\$rowtotal);
-        } elsif ($action eq 'contacts') {
-            $output .= &print_contacts($dom,$settings,\$rowtotal);
-        } elsif ($action eq 'defaults') {
-            $output .= &print_defaults($dom,$settings,\$rowtotal);
+        } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || ($action eq 'directorysrch') ||
+                 ($action eq 'contacts') || ($action eq 'defaults') || ($action eq 'serverstatuses') ||
+                 ($action eq 'loadbalancing')) {
+            $output .= $item->{'print'}->($dom,$settings,\$rowtotal);
         } elsif ($action eq 'scantron') {
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
-        } elsif ($action eq 'serverstatuses') {
-            $output .= &print_serverstatuses($dom,$settings,\$rowtotal);
         } elsif ($action eq 'helpsettings') {
             $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal);
-        } elsif ($action eq 'loadbalancing') {
-            $output .= &print_loadbalancing($dom,$settings,\$rowtotal);
         }
     }
     $output .= '
@@ -2782,19 +2768,21 @@
                 '<td class="LC_right_item"><span class="LC_nobreak">'.
                 '<input type="text" name="anonsurvey_threshold"'.
                 ' value="'.$currdefresponder.'" size="5" /></span>'.
-                '</td></tr>'."\n".
-                '<tr><td><span class="LC_nobreak">'.
-                $choices{'uploadquota'}.
-                '</span></td>'.
-                '<td align="right" class="LC_right_item">'.
-                '<table><tr>';
+                '</td></tr>'."\n";
+        $itemcount ++;
+        $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+        $datatable .= '<tr'.$css_class.'><td><span class="LC_nobreak">'.
+                      $choices{'uploadquota'}.
+                      '</span></td>'.
+                      '<td align="right" class="LC_right_item">'.
+                      '<table><tr>';
         foreach my $type (@types) {
             $datatable .= '<td align="center">'.&mt($type).'<br />'.
                            '<input type="text" name="uploadquota_'.$type.'"'.
                            ' value="'.$curruploadquota{$type}.'" size="5" /></td>';
         }
         $datatable .= '</tr></table></td></tr>'."\n";
-        $itemcount += 2;
+        $itemcount ++;
         my $onclick = 'toggleCredits(this.form);';
         my $display = 'none';
         if ($currusecredits) {
@@ -2825,6 +2813,7 @@
             &radiobutton_prefs($current,\@toggles,\%defaultchecked,
                                \%choices,$itemcount,$onclick,$additional);
         $datatable .= $table;
+        $itemcount ++;
     }
     $$rowtotal += $itemcount;
     return $datatable;
@@ -4071,7 +4060,7 @@
             $$rowtotal ++;
             $rowcount ++;
         }
-    } elsif ($position eq 'middle') {
+    } elsif ($position eq 'bottom') {
         $context = 'course';
         $rowcount = 0;
         foreach my $role ('st','ep','ta','in','cr') {
@@ -9083,7 +9072,8 @@
     if ($putresult eq 'ok') {
         if (keys(%changes) > 0) {
             my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
-            if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || ($changes{'uploadquota'})) {
+            if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || 
+                ($changes{'uploadquota'})) {
                 if ($changes{'canuse_pdfforms'}) {
                     $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
                 }


More information about the LON-CAPA-cvs mailing list