--- loncom/interface/domainprefs.pm 2007/04/13 16:21:15 1.12
+++ loncom/interface/domainprefs.pm 2007/05/29 15:58:41 1.17
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.12 2007/04/13 16:21:15 raeburn Exp $
+# $Id: domainprefs.pm,v 1.17 2007/05/29 15:58:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -145,7 +145,7 @@ sub handler {
');
- &print_footer($r,$phase,'process','Store changes');
+ &print_footer($r,$phase,'process','Save changes');
}
return OK;
}
@@ -550,6 +550,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) {
@@ -559,12 +560,17 @@ sub display_color_options {
my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename;
if (!-e $output) {
my ($width,$height) = &thumb_dimensions();
- my $size = $width.'x'.$height;
- system("convert -sample $size $input $output");
+ 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);
@@ -733,16 +739,15 @@ sub print_quotas {
$datatable .= '
'.
''.&mt($othertitle).' | '.
''.
- ' Mb |
';
return $datatable;
}
sub print_autoenroll {
my ($dom,$settings) = @_;
- my $defdom = $dom;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
- my ($runon,$runoff);
+ my ($defdom,$runon,$runoff);
if (ref($settings) eq 'HASH') {
if (exists($settings->{'run'})) {
if ($settings->{'run'} eq '0') {
@@ -764,6 +769,14 @@ sub print_autoenroll {
if (exists($settings->{'sender_domain'})) {
$defdom = $settings->{'sender_domain'};
}
+ } else {
+ if ($autorun) {
+ $runon = ' checked="checked" ';
+ $runoff = ' ';
+ } else {
+ $runoff = ' checked="checked" ';
+ $runon = ' ';
+ }
}
my $domform = &Apache::loncommon::select_dom_form($defdom,'sender_domain',1);
my $datatable=''.
@@ -772,7 +785,7 @@ sub print_autoenroll {
''.&mt('Yes').' '.
''.
+ $runoff.' value="0" />'.&mt('No').''.
'
'.
''.&mt('Notification messages - sender').
' | '.
@@ -1229,6 +1242,26 @@ sub thumb_dimensions {
return ('200','50');
}
+sub check_dimensions {
+ my ($inputfile) = @_;
+ my ($fullwidth,$fullheight);
+ if ($inputfile =~ m|^[/\w.\-]+$|) {
+ if (open(PIPE,"identify $inputfile 2>&1 |")) {
+ my $imageinfo = ;
+ if (!close(PIPE)) {
+ &Apache::lonnet::logthis("Failed to close PIPE opened to retrieve image information for $inputfile");
+ }
+ chomp($imageinfo);
+ my ($fullsize) =
+ ($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)\s+/);
+ if ($fullsize) {
+ ($fullwidth,$fullheight) = split(/x/,$fullsize);
+ }
+ }
+ }
+ return ($fullwidth,$fullheight);
+}
+
sub check_configuser {
my ($uhome,$dom,$confname,$servadm) = @_;
my ($configuserok,%currroles);
@@ -1361,17 +1394,23 @@ $env{'user.name'}.':'.$env{'user.domain'
if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) {
my $inputfile = $filepath.'/'.$file;
my $outfile = $filepath.'/'.'tn-'.$file;
- my $thumbsize = $thumbwidth.'x'.$thumbheight;
- system("convert -sample $thumbsize $inputfile $outfile");
- chmod(0660, $filepath.'/tn-'.$file);
- if (-e $outfile) {
- my $copyfile=$targetdir.'/tn-'.$file;
- if (copy($outfile,$copyfile)) {
- print $logfile "\nCopied source to ".$copyfile."\n";
- &write_metadata($dom,$confname,$formname,$targetdir,
- 'tn-'.$file,$logfile);
- } else {
- print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
+ my ($fullwidth,$fullheight) = &check_dimensions($inputfile);
+ if ($fullwidth ne '' && $fullheight ne '') {
+ if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
+ my $thumbsize = $thumbwidth.'x'.$thumbheight;
+ system("convert -sample $thumbsize $inputfile $outfile");
+ chmod(0660, $filepath.'/tn-'.$file);
+ if (-e $outfile) {
+ my $copyfile=$targetdir.'/tn-'.$file;
+ if (copy($outfile,$copyfile)) {
+ print $logfile "\nCopied source to ".$copyfile."\n";
+ &write_metadata($dom,$confname,$formname,
+ $targetdir,'tn-'.$file,$logfile);
+ } else {
+ print $logfile "\nUnable to write ".$copyfile.
+ ':'.$!."\n";
+ }
+ }
}
}
}
@@ -1483,6 +1522,7 @@ sub modify_quotas {
$formhash{$1} = $env{$key};
}
}
+ $formhash{'default'} = $env{'form.defaultquota'};
if (ref($domconfig{'quotas'}) eq 'HASH') {
foreach my $key (keys(%{$domconfig{'quotas'}})) {
if (exists($formhash{$key})) {
@@ -1536,10 +1576,17 @@ sub modify_autoenroll {
my %title = ( run => 'Auto-enrollment active',
sender => 'Sender for notification messages');
my @offon = ('off','on');
+ my $sender_uname = $env{'form.sender_uname'};
+ my $sender_domain = $env{'form.sender_domain'};
+ if ($sender_domain eq '') {
+ $sender_uname = '';
+ } elsif ($sender_uname eq '') {
+ $sender_domain = '';
+ }
my %autoenrollhash = (
autoenroll => { run => $env{'form.autoenroll_run'},
- sender_uname => $env{'form.sender_uname'},
- sender_domain => $env{'form.sender_domain'},
+ sender_uname => $sender_uname,
+ sender_domain => $sender_domain,
}
);
@@ -1555,18 +1602,10 @@ sub modify_autoenroll {
$changes{'run'} = 1;
}
}
- if (exists($currautoenroll{sender_uname})) {
- if ($currautoenroll{'sender_uname'} ne $env{'form.sender_uname'}) {
- $changes{'sender'} = 1;
- }
- } else {
+ if ($currautoenroll{'sender_uname'} ne $sender_uname) {
$changes{'sender'} = 1;
}
- if (exists($currautoenroll{sender_domain})) {
- if ($currautoenroll{'sender_domain'} ne $env{'form.sender_domain'}) {
- $changes{'sender'} = 1;
- }
- } else {
+ if ($currautoenroll{'sender_domain'} ne $sender_domain) {
$changes{'sender'} = 1;
}
if (keys(%changes) > 0) {
@@ -1575,7 +1614,11 @@ sub modify_autoenroll {
$resulttext .= ''.&mt("$title{'run'} set to $offon[$env{'form.autoenroll_run'}]").'';
}
if ($changes{'sender'}) {
- $resulttext .= ''.&mt("$title{'sender'} set to [_1]",$env{'form.sender_uname'}.':'.$env{'form.sender_domain'}).'';
+ if ($sender_uname eq '' || $sender_domain eq '') {
+ $resulttext .= ''.&mt("$title{'sender'} set to default (course owner).").'';
+ } else {
+ $resulttext .= ''.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'';
+ }
}
$resulttext .= '';
} else {
|