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

raeburn raeburn at source.lon-capa.org
Thu Aug 24 20:33:14 EDT 2017


raeburn		Fri Aug 25 00:33:14 2017 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Sanity checking.
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.312 loncom/interface/domainprefs.pm:1.313
--- loncom/interface/domainprefs.pm:1.312	Fri Aug 25 00:07:45 2017
+++ loncom/interface/domainprefs.pm	Fri Aug 25 00:33:14 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.312 2017/08/25 00:07:45 raeburn Exp $
+# $Id: domainprefs.pm,v 1.313 2017/08/25 00:33:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -9269,17 +9269,21 @@
                                     #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'} = 
                                         $domconfig{$action}{$type}{$key}{'image'};
@@ -9312,15 +9316,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>';
+                                }
                             }
                         }
                     }




More information about the LON-CAPA-cvs mailing list