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

raeburn raeburn at source.lon-capa.org
Fri Sep 14 18:43:16 EDT 2018


raeburn		Fri Sep 14 22:43:16 2018 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    Backport 1.312, 1.313, 1.316
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.87 loncom/interface/domainprefs.pm:1.160.6.88
--- loncom/interface/domainprefs.pm:1.160.6.87	Sun Sep  2 15:22:28 2018
+++ loncom/interface/domainprefs.pm	Fri Sep 14 22:43:14 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.160.6.87 2018/09/02 15:22:28 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.88 2018/09/14 22:43:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1521,7 +1521,8 @@
                         if ($fullwidth ne '' && $fullheight ne '') {
                             if ($fullwidth > $width && $fullheight > $height) { 
                                 my $size = $width.'x'.$height;
-                                system("convert -sample $size $input $output");
+                                my @args = ('convert','-sample',$size,$input,$output);
+                                system({$args[0]} @args);
                                 $showfile = "/$imgdir/tn-".$filename;
                             }
                         }
@@ -7716,14 +7717,14 @@
     } else {
         my $source = $filepath.'/'.$file;
         my $logfile;
-        if (!open($logfile,">>$source".'.log')) {
+        if (!open($logfile,">>",$source.'.log')) {
             return (&mt('No write permission to Authoring Space'));
         }
         print $logfile
 "\n================= Publish ".localtime()." ================\n".
 $env{'user.name'}.':'.$env{'user.domain'}."\n";
 # Save the file
-        if (!open(FH,'>'.$source)) {
+        if (!open(FH,">",$source)) {
             &Apache::lonnet::logthis('Failed to create '.$source);
             return (&mt('Failed to create file'));
         }
@@ -7784,7 +7785,8 @@
                 if ($fullwidth ne '' && $fullheight ne '') { 
                     if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
                         my $thumbsize = $thumbwidth.'x'.$thumbheight;
-                        system("convert -sample $thumbsize $inputfile $outfile");
+                        my @args = ('convert','-sample',$thumbsize,$inputfile,$outfile);
+                        system({$args[0]} @args);
                         chmod(0660, $filepath.'/tn-'.$file);
                         if (-e $outfile) {
                             my $copyfile=$targetdir.'/tn-'.$file;
@@ -7863,7 +7865,7 @@
     {
         print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
         my $mfh;
-        if (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
+        if (open($mfh,">",$targetdir.'/'.$file.'.meta')) {
             foreach (sort(keys(%metadatafields))) {
                 unless ($_=~/\./) {
                     my $unikey=$_;
@@ -7897,7 +7899,7 @@
         next unless (ref($targetsource) eq 'ARRAY');
         my ($target,$source)=@{$targetsource};
         if ($source ne '') {
-            if (open(my $logfh,'>>'.$source.'.log')) {
+            if (open(my $logfh,">>",$source.'.log')) {
                 print $logfh "\nCleanup phase: Notifications\n";
                 my @subscribed=&subscribed_hosts($target);
                 foreach my $subhost (@subscribed) {
@@ -7923,7 +7925,7 @@
 sub subscribed_hosts {
     my ($target) = @_;
     my @subscribed;
-    if (open(my $fh,"<$target.subscription")) {
+    if (open(my $fh,"<","$target.subscription")) {
         while (my $subline=<$fh>) {
             if ($subline =~ /^($match_lonid):/) {
                 my $host = $1;
@@ -8122,16 +8124,20 @@
                                     #FIXME need to obsolete item in RES space
                                 } elsif ($env{'form.'.$type.'_image_'.$i.'.filename'}) {
                                     my ($cdom,$cnum) = split(/_/,$key);
-                                    my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,$type.'_image_'.$i,
-                                                                                  $cdom,$cnum,$type,$configuserok,
-                                                                                  $switchserver,$author_ok);
-                                    if ($imgurl) {
-                                        $confhash{$type}{$key}{'image'} = $imgurl;
-                                        $changes{$type}{$key} = 1; 
-                                    }
-                                    if ($error) {
-                                        &Apache::lonnet::logthis($error);
-                                        $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
+                                    if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
+                                        $errors .= '<li><span class="LC_error">'.&mt('Image not saved: could not find textbook course').'</li>';
+                                    } else {
+                                        my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,$type.'_image_'.$i,
+                                                                                      $cdom,$cnum,$type,$configuserok,
+                                                                                      $switchserver,$author_ok);
+                                        if ($imgurl) {
+                                            $confhash{$type}{$key}{'image'} = $imgurl;
+                                            $changes{$type}{$key} = 1; 
+                                        }
+                                        if ($error) {
+                                            &Apache::lonnet::logthis($error);
+                                            $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
+                                        }
                                     } 
                                 } elsif ($domconfig{$action}{$type}{$key}{'image'}) {
                                     $confhash{$type}{$key}{'image'} = 
@@ -8165,15 +8171,19 @@
                     if ($type eq 'textbooks') {
                         if ($env{'form.'.$type.'_addbook_image.filename'} ne '') {
                             my ($cdom,$cnum) = split(/_/,$newbook{$type});
-                            my ($imageurl,$error) =
-                                &process_textbook_image($r,$dom,$confname,$type.'_addbook_image',$cdom,$cnum,$type,
-                                                        $configuserok,$switchserver,$author_ok);
-                            if ($imageurl) {
-                                $confhash{$type}{$newbook{$type}}{'image'} = $imageurl;
-                            }
-                            if ($error) {
-                                &Apache::lonnet::logthis($error);
-                                $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
+                            if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
+                                $errors .= '<li><span class="LC_error">'.&mt('Image not saved: could not find textbook course').'</li>';
+                            } else {
+                                my ($imageurl,$error) =
+                                    &process_textbook_image($r,$dom,$confname,$type.'_addbook_image',$cdom,$cnum,$type,
+                                                            $configuserok,$switchserver,$author_ok);
+                                if ($imageurl) {
+                                    $confhash{$type}{$newbook{$type}}{'image'} = $imageurl;
+                                }
+                                if ($error) {
+                                    &Apache::lonnet::logthis($error);
+                                    $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
+                                }
                             }
                         }
                     }
@@ -8665,7 +8675,7 @@
         } elsif ($author_ok eq 'ok') {
             my ($result,$imageurl) =
                 &publishlogo($r,'upload',$caller,$dom,$confname,
-                             "$type/$dom/$cnum/cover",$width,$height);
+                             "$type/$cdom/$cnum/cover",$width,$height);
             if ($result eq 'ok') {
                 $url = $imageurl;
             } else {


More information about the LON-CAPA-cvs mailing list