--- loncom/interface/domainprefs.pm 2007/04/05 21:36:15 1.8 +++ loncom/interface/domainprefs.pm 2007/06/04 14:14:27 1.20 @@ -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.20 2007/06/04 14:14:27 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,25 +138,26 @@ 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(' '); - &print_footer($r,$phase,'process','Store changes'); + &print_footer($r,$phase,'process','Save changes'); } return OK; } 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,20 +520,22 @@ sub display_color_options { ' '.$fontlink. ''; + my $switchserver = &check_switchserver($dom,$confname); foreach my $img (@{$images}) { - $itemcount ++; + $itemcount ++; $css_class = $itemcount%2?' class="LC_odd_row"':''; $datatable .= ''. ''.$choices->{$img}.''; - my $imgfile; + my ($imgfile, $img_import); if ($designs->{$img} ne '') { $imgfile = $designs->{$img}; + $img_import = ($imgfile =~ m{^/adm/}); } else { $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}); @@ -546,6 +551,7 @@ sub display_color_options { $showfile = ''; } } elsif ($imgfile =~ m-^/(adm/[^/]+)/([^/]+)$-) { + $showfile = $imgfile; my $imgdir = $1; my $filename = $2; if (-e "/home/httpd/html/$imgdir/tn-".$filename) { @@ -554,18 +560,31 @@ 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 ($fullwidth,$fullheight) = &check_dimensions($input); + if ($fullwidth ne '' && $fullheight ne '') { + if ($fullwidth > $width && $fullheight > $height) { + my $size = $width.'x'.$height; + system("convert -sample $size $input $output"); + $showfile = '/'.$imgdir.'/tn-'.$filename; + } + } } - $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}.''; + if ($img_import) { + $datatable.= ''; + } + $datatable.= ''.$alt_text->{$img}.
+                             ''; if ($is_custom->{$img}) { $datatable.=' '. ''. + $runoff.' value="0" />'.&mt('No').''. ''. ''.&mt('Notification messages - sender'). ''. @@ -822,10 +853,11 @@ sub print_autoupdate { if (keys(%{$usertypes}) > 0) { $othertitle = &mt('Other users'); } - my @fields = ('lastname','firstname','middlename','gen','email','id'); + my @fields = ('lastname','firstname','middlename','gen', + 'permanentemail','id'); my %fieldtitles = &Apache::lonlocal::texthash ( id => 'Student/Employee ID', - email => 'E-mail address', + permanentemail => 'E-mail address', lastname => 'Last Name', firstname => 'First Name', middlename => 'Middle Name', @@ -894,14 +926,14 @@ sub usertype_update_row { } sub modify_login { - my ($r,$dom,%domconfig) = @_; + my ($r,$dom,$confname,%domconfig) = @_; my ($resulttext,$errors,$colchgtext,%changes,%colchanges); my %title = ( coursecatalog => 'Display course catalog', adminmail => 'Display administrator E-mail address'); my @offon = ('off','on'); my %loginhash; - ($errors,%colchanges) = &modify_colors($r,$dom,['login'],\%domconfig, - \%loginhash); + ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'], + \%domconfig,\%loginhash); $loginhash{login}{coursecatalog} = $env{'form.coursecatalog'}; $loginhash{login}{adminmail} = $env{'form.adminmail'}; if (ref($colchanges{'login'}) eq 'HASH') { @@ -937,10 +969,11 @@ sub modify_login { $resulttext = &mt('No changes made to log-in page settings'); } } else { - $resulttext = &mt('An error occurred: [_1]',$putresult); + $resulttext = ''. + &mt('An error occurred: [_1]',$putresult).''; } if ($errors) { - $resulttext .= &mt('The following errors occurred: ').'