--- loncom/interface/domainprefs.pm 2007/04/05 21:36:15 1.8 +++ loncom/interface/domainprefs.pm 2007/04/10 20:49:07 1.9 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.8 2007/04/05 21:36:15 raeburn Exp $ +# $Id: domainprefs.pm,v 1.9 2007/04/10 20:49:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,6 +38,7 @@ use Apache::lonhtmlcommon(); use Apache::lonlocal; use LONCAPA(); use LONCAPA::Enrollment; +use File::Copy; sub handler { my $r=shift; @@ -111,6 +112,7 @@ sub handler { &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:changePage(document.$phase,'display')", text=>"Domain Configuration"}); + my $confname = $dom.'-domainconfig'; if ($phase eq 'process') { &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:changePage(document.$phase,'$phase')", @@ -118,7 +120,8 @@ sub handler { &print_header($r,$phase); foreach my $item (@prefs) { $r->print('

'.&mt($item->{'text'}).'

'. - &process_changes($r,$dom,$item->{'action'},\@roles,%domconfig)); + &process_changes($r,$dom,$confname, + $item->{'action'},\@roles,%domconfig)); } $r->print('

'); &print_footer($r,$phase,'display','Back to actions menu'); @@ -135,7 +138,7 @@ sub handler { if ($item->{'action'} eq 'login') { $r->print(' '); } - &print_config_box($r,$dom,$phase,$item->{'action'}, + &print_config_box($r,$dom,$confname,$phase,$item->{'action'}, $item,$domconfig{$item->{'action'}}); } $r->print(' @@ -148,12 +151,13 @@ sub handler { } sub process_changes { - my ($r,$dom,$action,$roles,%domconfig) = @_; + my ($r,$dom,$confname,$action,$roles,%domconfig) = @_; my $output; if ($action eq 'login') { - $output = &modify_login($r,$dom,%domconfig); + $output = &modify_login($r,$dom,$confname,%domconfig); } elsif ($action eq 'rolecolors') { - $output = &modify_rolecolors($r,$dom,$roles,%domconfig); + $output = &modify_rolecolors($r,$dom,$confname,$roles, + %domconfig); } elsif ($action eq 'quotas') { $output = &modify_quotas($dom,%domconfig); } elsif ($action eq 'autoenroll') { @@ -165,7 +169,7 @@ sub process_changes { } sub print_config_box { - my ($r,$dom,$phase,$action,$item,$settings) = @_; + my ($r,$dom,$confname,$phase,$action,$item,$settings) = @_; $r->print(' @@ -185,7 +189,7 @@ sub print_config_box { if ($action eq 'autoupdate') { $r->print(&print_autoupdate('top',$dom,$settings)); } else { - $r->print(&print_rolecolors($phase,'student',$dom,$settings)); + $r->print(&print_rolecolors($phase,'student',$dom,$confname,$settings)); } $r->print('
@@ -201,7 +205,7 @@ sub print_config_box { if ($action eq 'autoupdate') { $r->print(&print_autoupdate('bottom',$dom,$settings)); } else { - $r->print(&print_rolecolors($phase,'coordinator',$dom,$settings).' + $r->print(&print_rolecolors($phase,'coordinator',$dom,$confname,$settings).' @@ -212,7 +216,7 @@ sub print_config_box { '.$item->{'header'}->[2]->{'col1'}.' '.$item->{'header'}->[2]->{'col2'}.' '. - &print_rolecolors($phase,'author',$dom,$settings).' + &print_rolecolors($phase,'author',$dom,$confname,$settings).' @@ -223,7 +227,7 @@ sub print_config_box { '.$item->{'header'}->[3]->{'col1'}.' '.$item->{'header'}->[3]->{'col2'}.' '. - &print_rolecolors($phase,'admin',$dom,$settings)); + &print_rolecolors($phase,'admin',$dom,$confname,$settings)); } } else { $r->print(' @@ -242,7 +246,7 @@ sub print_config_box { '.$item->{'header'}->[0]->{'col2'}.' '); if ($action eq 'login') { - $r->print(&print_login($dom,$phase,$settings)); + $r->print(&print_login($dom,$confname,$phase,$settings)); } elsif ($action eq 'quotas') { $r->print(&print_quotas($dom,$settings)); } elsif ($action eq 'autoenroll') { @@ -301,7 +305,7 @@ sub print_footer { } sub print_login { - my ($dom,$phase,$settings) = @_; + my ($dom,$confname,$phase,$settings) = @_; my %choices = &login_choices(); my ($catalogon,$catalogoff,$adminmailon,$adminmailoff); $catalogon = ' checked="checked" '; @@ -402,7 +406,7 @@ sub print_login { ''; $itemcount ++; - $datatable .= &display_color_options($dom,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text); + $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text); $datatable .= ''; return $datatable; } @@ -429,7 +433,7 @@ sub login_choices { } sub print_rolecolors { - my ($phase,$role,$dom,$settings) = @_; + my ($phase,$role,$dom,$confname,$settings) = @_; my %choices = &color_font_choices(); my @bgs = ('pgbg','tabbg','sidebg'); my @links = ('link','alink','vlink'); @@ -495,15 +499,14 @@ sub print_rolecolors { } } my $itemcount = 1; - my $datatable = &display_color_options($dom,$phase,$role,$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text); + my $datatable = &display_color_options($dom,$confname,$phase,$role,$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text); $datatable .= ''; return $datatable; } sub display_color_options { - my ($dom,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs, + my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs, $images,$bgs,$links,$alt_text) = @_; - my $configuname = $dom.'-domainconfig'; my $css_class = $itemcount%2?' class="LC_odd_row"':''; my $datatable = ''. ''.$choices->{'font'}.''; @@ -517,6 +520,7 @@ sub display_color_options { ' '.$fontlink. ''; + my $switchserver = &check_switchserver($dom,$confname); foreach my $img (@{$images}) { $itemcount ++; $css_class = $itemcount%2?' class="LC_odd_row"':''; @@ -529,8 +533,8 @@ sub display_color_options { $imgfile = $defaults->{$img}; } if ($imgfile) { - my $showfile; - if ($imgfile =~ m-^(/uploaded/\Q$dom\E/\Q$configuname\E/portfolio.*)/([^/]+)$-) { + my ($showfile,$fullsize); + if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) { my $urldir = $1; my $filename = $2; my @info = &Apache::lonnet::stat_file($designs->{$img}); @@ -554,18 +558,23 @@ sub display_color_options { my $input = "/home/httpd/html".$imgfile; my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename; if (!-e $output) { - system("convert -sample 200x50 $input $output"); + my ($width,$height) = &thumb_dimensions(); + my $size = $width.'x'.$height; + system("convert -sample $size $input $output"); } $showfile = '/'.$imgdir.'/tn-'.$filename; } } if ($showfile) { + $showfile = &Apache::loncommon::lonhttpdurl($showfile); + $fullsize = &Apache::loncommon::lonhttpdurl($imgfile); $datatable.= ''; if (!$is_custom->{$img}) { $datatable .= &mt('Default in use:').'
'; } - $datatable.= ''.
-                             $alt_text->{$img}.''; + $datatable.= ''.$alt_text->{$img}.
+                             ''; if ($is_custom->{$img}) { $datatable.='