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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Fri, 01 Jun 2007 01:14:51 -0000


albertel		Thu May 31 21:14:51 2007 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - import any previously set images and publish them on initial config pass
    (properly handles the delete case, and case where they are on not the
     primary library server)
  
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.17 loncom/interface/domainprefs.pm:1.18
--- loncom/interface/domainprefs.pm:1.17	Tue May 29 11:58:41 2007
+++ loncom/interface/domainprefs.pm	Thu May 31 21:14:51 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.17 2007/05/29 15:58:41 raeburn Exp $
+# $Id: domainprefs.pm,v 1.18 2007/06/01 01:14:51 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -522,13 +522,14 @@
                   '</span></td></tr>';
     my $switchserver = &check_switchserver($dom,$confname);
     foreach my $img (@{$images}) {
-        $itemcount ++;
+	$itemcount ++;
         $css_class = $itemcount%2?' class="LC_odd_row"':'';
         $datatable .= '<tr'.$css_class.'>'.
                       '<td>'.$choices->{$img}.'</td>';
-        my $imgfile;
+        my ($imgfile, $img_import);
         if ($designs->{$img} ne '') {
             $imgfile = $designs->{$img};
+	    $img_import = ($imgfile =~ m{^/adm/});
         } else {
             $imgfile = $defaults->{$img};
         }
@@ -578,6 +579,9 @@
                 if (!$is_custom->{$img}) {
                     $datatable .= &mt('Default in use:').'<br />';
                 }
+		if ($img_import) {
+		    $datatable.= '<input type="hidden" name="'.$role.'_import_'.$img.'" value="'.$imgfile.'" />';
+		}
                 $datatable.= '<a href="'.$fullsize.'" target="_blank"><img src="'.
                              $showfile.'" alt="'.$alt_text->{$img}.
                              '" border="0" /></a></td>';
@@ -1052,6 +1056,15 @@
         }
         my ($width,$height) = &thumb_dimensions();
         foreach my $img (@images) {
+	    if ( ! $env{'form.'.$role.'_'.$img.'.filename'} 
+		 && !defined($domconfig->{$role}{$img})
+		 && !$env{'form.'.$role.'_del_'.$img}
+		 && $env{'form.'.$role.'_import_'.$img}) {
+		# import the old configured image from the .tab setting
+		# if they haven't provided a new one 
+		$domconfig->{$role}{$img} = 
+		    $env{'form.'.$role.'_import_'.$img};
+	    }
             if ($env{'form.'.$role.'_'.$img.'.filename'} ne '') {
                 my $error;
                 if ($configuserok eq 'ok') {
@@ -1091,6 +1104,7 @@
                                             $dom,$confname,$img,$width,$height);
                                 if ($result eq 'ok') {
                                     $confhash->{$role}{$img} = $logourl;
+				    $changes{$role}{'images'}{$img} = 1;
                                 }
                             }
                         }
@@ -1505,6 +1519,7 @@
     }
     my @ids=&Apache::lonnet::current_machine_ids();
     foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+    $allowed=0;
     if (!$allowed) {
 	$switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role=dc./'.$dom.'/">'.&mt('Switch Server').'</a>';
     }