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

jms jms@source.lon-capa.org
Tue, 10 Nov 2009 19:12:11 -0000


This is a MIME encoded message

--jms1257880331
Content-Type: text/plain

jms		Tue Nov 10 19:12:11 2009 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  New "Help Settings" page added to Domain Settings, with ability to turn the "Submit a bug" link on or off in the help menu
  
--jms1257880331
Content-Type: text/plain
Content-Disposition: attachment; filename="jms-20091110191211.txt"

Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.117 loncom/interface/domainprefs.pm:1.118
--- loncom/interface/domainprefs.pm:1.117	Sun Oct 25 15:53:25 2009
+++ loncom/interface/domainprefs.pm	Tue Nov 10 19:12:11 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.117 2009/10/25 15:53:25 raeburn Exp $
+# $Id: domainprefs.pm,v 1.118 2009/11/10 19:12:11 jms Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -202,11 +202,11 @@
                 'quotas','autoenroll','autoupdate','directorysrch',
                 'usercreation','usermodification','contacts','defaults',
                 'scantron','coursecategories','serverstatuses',
-                'requestcourses'],$dom);
+                'requestcourses','helpsettings'],$dom);
     my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
                        'autoupdate','directorysrch','contacts',
                        'usercreation','usermodification','scantron',
-                       'requestcourses','coursecategories','serverstatuses');
+                       'requestcourses','coursecategories','serverstatuses','helpsettings');
     my %prefs = (
         'rolecolors' =>
                    { text => 'Default color schemes',
@@ -319,6 +319,12 @@
                               col3 => 'Specific IPs',
                             }],
                  },
+        'helpsettings' =>
+                 {text   => 'Help page settings',
+                  help   => 'Domain_Configuration_Help_Settings',
+                  header => [{col1 => 'Setting',
+                              col2 => 'Value',}],
+                 },
     );
     my %servers = &dom_servers($dom);
     if (keys(%servers) > 1) {
@@ -415,6 +421,8 @@
         $output = &modify_serverstatuses($dom,%domconfig);
     } elsif ($action eq 'requestcourses') {
         $output = &modify_quotas($dom,$action,%domconfig);
+    } elsif ($action eq 'helpsettings') {
+        $output = &modify_helpsettings($dom,%domconfig);
     }
     return $output;
 }
@@ -465,6 +473,8 @@
             $colspan = ' colspan="2"';
         } elsif ($action eq 'requestcourses') {
             $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
+        } elsif ($action eq 'helpsettings') {
+            $output .= &print_helpsettings($dom,$settings,\$rowtotal);
         } else {
             $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
         }
@@ -600,7 +610,9 @@
             $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,$settings,\$rowtotal);
+    	}
     }
     $output .= '
    </table>
@@ -657,9 +669,8 @@
                            'coursecatalog' => 'on',
                            'adminmail'     => 'off',
                            'newuser'       => 'off',
-                           'submitbugs'	   => 'on',
                          );
-    my @toggles = ('coursecatalog','adminmail','newuser','submitbugs');
+    my @toggles = ('coursecatalog','adminmail','newuser');
     my (%checkedon,%checkedoff);
     foreach my $item (@toggles) {
         if ($defaultchecked{$item} eq 'on') { 
@@ -791,7 +802,6 @@
             coursecatalog => 'Display Course/Community Catalog link?',
             adminmail     => "Display Administrator's E-mail Address?",
             disallowlogin => "Login page requests redirected",
-            submitbugs    => "Display &quot;Submit Bug&quot; link?",
             hostid        => "Server",
             serverurl     => "Redirect to log-in via:",
             directlogin   => "No redirect",
@@ -1918,6 +1928,62 @@
     return $datatable;
 }
 
+sub print_helpsettings {
+
+	my ($dom,$settings,$rowtotal) = @_;
+	my ($css_class,$datatable);
+	my $itemcount = 1;
+	my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
+	
+	%choices =
+        &Apache::lonlocal::texthash (
+            submitbugs => 'Display &quot;Submit a bug&quot; link?',
+    );
+	
+	%defaultchecked = ('submitbugs' => 'on');
+	
+	@toggles = ('submitbugs',);
+    
+    foreach my $item (@toggles) {
+        if ($defaultchecked{$item} eq 'on') { 
+            $checkedon{$item} = ' checked="checked" ';
+            $checkedoff{$item} = ' ';
+        } elsif ($defaultchecked{$item} eq 'off') {
+            $checkedoff{$item} = ' checked="checked" ';
+            $checkedon{$item} = ' ';
+        }
+    }
+    
+    if (ref($settings) eq 'HASH') {
+        foreach my $item (@toggles) {
+            if ($settings->{$item} eq '1') {
+                $checkedon{$item} =  ' checked="checked" ';
+                $checkedoff{$item} = ' ';
+            } elsif ($settings->{$item} eq '0') {
+                $checkedoff{$item} =  ' checked="checked" ';
+                $checkedon{$item} = ' ';
+            }
+        }
+     }
+    
+     foreach my $item (@toggles) {
+        $css_class = $itemcount%2?' class="LC_odd_row"':'';
+        $datatable .=  
+            '<tr'.$css_class.'><td><span class="LC_nobreak">'.$choices{$item}.
+            '</span></td>'.
+            '<td class="LC_right_item"><span class="LC_nobreak">'.
+            '<label><input type="radio" name="'.
+            $item.'" '.$checkedon{$item}.' value="1" />'.&mt('Yes').
+            '</label>&nbsp;<label><input type="radio" name="'.$item.'" '.
+            $checkedoff{$item}.' value="0" />'.&mt('No').'</label>'.
+            '</span></td>'.
+            '</tr>';
+        $itemcount ++;
+     }
+     return $datatable;
+	
+}
+
 sub contact_titles {
     my %titles = &Apache::lonlocal::texthash (
                    'supportemail' => 'Support E-mail address',
@@ -3139,7 +3205,6 @@
     my %title = ( coursecatalog => 'Display course catalog',
                   adminmail => 'Display administrator E-mail address',
                   newuser => 'Link for visitors to create a user account',
-                  submitbugs => 'Link for users to submit a bug',
                   loginheader => 'Log-in box header');
     my @offon = ('off','on');
     my %curr_loginvia;
@@ -3153,7 +3218,7 @@
     my %loginhash;
     ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
                                            \%domconfig,\%loginhash);
-    my @toggles = ('coursecatalog','adminmail','newuser','submitbugs');
+    my @toggles = ('coursecatalog','adminmail','newuser');
     foreach my $item (@toggles) {
         $loginhash{login}{$item} = $env{'form.'.$item};
     }
@@ -3183,12 +3248,11 @@
     my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
                                              $dom);
     if ($putresult eq 'ok') {
-        my @toggles = ('coursecatalog','adminmail','newuser','submitbugs');
+        my @toggles = ('coursecatalog','adminmail','newuser');
         my %defaultchecked = (
                     'coursecatalog' => 'on',
                     'adminmail'     => 'off',
                     'newuser'       => 'off',
-                    'submitbugs'	=> 'on',
         );
         if (ref($domconfig{'login'}) eq 'HASH') {
             foreach my $item (@toggles) {
@@ -5626,6 +5690,72 @@
     return $resulttext;
 }
 
+sub modify_helpsettings {
+    my ($dom,%domconfig) = @_;
+ 	my ($resulttext,$errors,%changes,%helphash);
+ 	
+ 	my %defaultchecked = ('submitbugs'	=> 'on');
+ 	my @offon = ('off','on');
+    my %title = ( submitbugs => 'Display link for users to submit a bug');
+    my @toggles = ('submitbugs');
+
+    $helphash{'helpsettings'} = {};
+    
+    if (ref($domconfig{'helpsettings'}) ne 'HASH') {
+        if ($domconfig{'helpsettings'} eq '') {
+            $domconfig{'helpsettings'} = {};
+        }
+    }
+    
+    if (ref($domconfig{'helpsettings'}) eq 'HASH') {
+    	
+        foreach my $item (@toggles) {
+        	
+			if ($defaultchecked{$item} eq 'on') { 
+				if (($domconfig{'helpsettings'}{$item} eq '') &&
+					 ($env{'form.'.$item} eq '0')) {
+					$changes{$item} = 1;
+				} elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+					$changes{$item} = 1;
+				}
+			} elsif ($defaultchecked{$item} eq 'off') {
+				if (($domconfig{'helpsettings'}{$item} eq '') &&
+					 ($env{'form.'.$item} eq '1')) {
+					$changes{$item} = 1;
+				} elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+					$changes{$item} = 1;
+				}
+			}
+			$helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+		}  
+    }
+    
+    my $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,
+                                             $dom);
+                                             
+    if ($putresult eq 'ok') {
+        if (keys(%changes) > 0) {
+			$resulttext = &mt('Changes made:').'<ul>';
+			foreach my $item (sort(keys(%changes))) {
+				if ($item eq 'submitbugs') {
+					$resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
+				}
+			}
+			$resulttext .= '</ul>';
+		} else {
+			$resulttext = &mt('No changes made to help settings');
+		}
+    } else {
+        $resulttext = '<span class="LC_error">'.
+	    &mt('An error occurred: [_1]',$putresult).'</span>';
+    }
+    if ($errors) {
+        $resulttext .= &mt('The following errors occurred: ').'<ul>'.
+                       $errors.'</ul>';
+    }
+    return $resulttext;
+}
+
 sub recurse_check {
     my ($chkcats,$categories,$depth,$name) = @_;
     if (ref($chkcats->[$depth]{$name}) eq 'ARRAY') {

--jms1257880331--