[LON-CAPA-cvs] cvs: loncom /interface lonmeta.pm lonmsg.pm /publisher lonpubdir.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 31 Dec 2003 02:33:28 -0000


This is a MIME encoded message

--www1072838008
Content-Type: text/plain

www		Tue Dec 30 21:33:28 2003 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm lonmsg.pm 
    /loncom/publisher	lonpubdir.pm 
  Log:
  Bug #2444: error messages can be displayed from Construction Space
  
  
--www1072838008
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20031230213328.txt"

Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.51 loncom/interface/lonmeta.pm:1.52
--- loncom/interface/lonmeta.pm:1.51	Tue Dec 30 17:19:18 2003
+++ loncom/interface/lonmeta.pm	Tue Dec 30 21:33:27 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.51 2003/12/30 22:19:18 www Exp $
+# $Id: lonmeta.pm,v 1.52 2003/12/31 02:33:27 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -435,7 +435,6 @@
     my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/);
     $uri=~s/\.meta$//;
     my $disuri=&Apache::lonnet::clutter($uri);
-    $disuri=&Apache::lonhtmlcommon::crumbs($disuri);
 # version
     my $currentversion=&Apache::lonnet::getversion($disuri);
     my $versiondisplay='';
@@ -446,6 +445,8 @@
     } else {
 	$versiondisplay='Version: '.$currentversion;
     }
+# crumbify displayed URL
+    $disuri=&Apache::lonhtmlcommon::crumbs($disuri);
 # obsolete
     my $obsolete=$content{'obsolete'};
     my $obsoletewarning='';
@@ -570,77 +571,104 @@
 
   return OK if $r->header_only;
 # ---------------------------------------------------------------------- Header
-  my $bodytag=&Apache::loncommon::bodytag('Edit Catalog Information');
   my $disuri=$uri;
   my $fn=&Apache::lonnet::filelocation('',$uri);
-  $disuri=~s/^\/\~\w+//;
+  $disuri=~s/^\/\~/\/priv\//;
   $disuri=~s/\.meta$//;
-  my $displayfile='Catalog Information for '.$disuri;
-  if ($disuri=~/\/default$/) {
-      my $dir=$disuri;
-      $dir=~s/default$//;
-      $displayfile=&mt('Default Cataloging Information for Directory').' '.
-	  $dir;
-  }
-  %Apache::lonpublisher::metadatafields=();
-  %Apache::lonpublisher::metadatakeys=();
-  &Apache::lonpublisher::metaeval(&Apache::lonnet::getfile($fn));
-  $r->print(<<ENDEDIT);
+  my $target=$uri;
+  $target=~s/^\/\~/\/res\/$ENV{'request.role.domain'}\//;
+  $target=~s/\.meta$//;
+  my $bombs=&Apache::lonmsg::retrieve_author_res_msg($target);
+  if ($bombs) {
+      if ($ENV{'form.delmsg'}) {
+	  if (&Apache::lonmsg::del_url_author_res_msg($target) eq 'ok') {
+	      $bombs=&mt('Messages deleted.');
+	  } else {
+	      $bombs=&mt('Error deleting messages');
+	  }
+      }
+      my $bodytag=&Apache::loncommon::bodytag('Error Messages');
+      my $del=&mt('Delete Messages');
+      $r->print(<<ENDBOMBS);
+<html><head><title>Edit Catalog Information</title></head>
+$bodytag
+<h1>$disuri</h1>
+<form method="post" name="defaultmeta">
+<input type="submit" name="delmsg" value="$del" />
+<br />$bombs
+</form>
+</body>
+</html>
+ENDBOMBS
+  } else {
+      my $displayfile='Catalog Information for '.$disuri;
+      if ($disuri=~/\/default$/) {
+	  my $dir=$disuri;
+	  $dir=~s/default$//;
+	  $displayfile=&mt('Default Cataloging Information for Directory').' '.
+	      $dir;
+      }
+      my $bodytag=&Apache::loncommon::bodytag('Edit Catalog Information');
+      %Apache::lonpublisher::metadatafields=();
+      %Apache::lonpublisher::metadatakeys=();
+      &Apache::lonpublisher::metaeval(&Apache::lonnet::getfile($fn));
+      $r->print(<<ENDEDIT);
 <html><head><title>Edit Catalog Information</title></head>
 $bodytag
 <h1>$displayfile</h1>
 <form method="post" name="defaultmeta">
 ENDEDIT
-  $r->print('<script language="JavaScript">'.
-	    &Apache::loncommon::browser_and_searcher_javascript.
-	    '</script>');
-   my %lt=&fieldnames();
-   foreach ('author','title','subject','keywords','abstract','notes',
-            'copyright','customdistributionfile','language','standards',
-	    'lowestgradelevel','highestgradelevel',
-            'obsolete','obsoletereplacement') {
-       $Apache::lonpublisher::metadatafields{$_}=$ENV{'form.new_'.$_};
-       unless ($Apache::lonpublisher::metadatafields{'copyright'}) {
-	   $Apache::lonpublisher::metadatafields{'copyright'}='default';
-       }
-       $r->print('<p>'.$lt{$_}.': '.&prettyinput($_,
-				  $Apache::lonpublisher::metadatafields{$_},
-				  'new_'.$_,'defaultmeta').'</p>');
-   }
-   if ($ENV{'form.store'}) {
-      my $mfh;
-      unless ($mfh=Apache::File->new('>'.$fn)) {
-            $r->print(
-            '<p><font color=red>'.&mt('Could not write metadata').', '.
-		      &mt('FAIL').'</font>');
-      } else {
-          foreach (sort keys %Apache::lonpublisher::metadatafields) {
-            unless ($_=~/\./) {
-                my $unikey=$_;
-                $unikey=~/^([A-Za-z]+)/;
-                my $tag=$1;
-                $tag=~tr/A-Z/a-z/;
-                print $mfh "\n\<$tag";
-                foreach 
-                  (split(/\,/,$Apache::lonpublisher::metadatakeys{$unikey})) {
-                    my $value=
-                       $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
-                    $value=~s/\"/\'\'/g;
-                    print $mfh ' '.$_.'="'.$value.'"';
-                }
-                print $mfh '>'.
-        &HTML::Entities::encode($Apache::lonpublisher::metadatafields{$unikey})
-                        .'</'.$tag.'>';
-            }
+      $r->print('<script language="JavaScript">'.
+		&Apache::loncommon::browser_and_searcher_javascript.
+		'</script>');
+      my %lt=&fieldnames();
+      foreach ('author','title','subject','keywords','abstract','notes',
+	       'copyright','customdistributionfile','language','standards',
+	       'lowestgradelevel','highestgradelevel',
+	       'obsolete','obsoletereplacement') {
+	  $Apache::lonpublisher::metadatafields{$_}=$ENV{'form.new_'.$_};
+	  unless ($Apache::lonpublisher::metadatafields{'copyright'}) {
+	      $Apache::lonpublisher::metadatafields{'copyright'}='default';
 	  }
-          $r->print('<p>'.&mt('Wrote Metadata'));
+	  $r->print('<p>'.$lt{$_}.': '.&prettyinput($_,
+						    $Apache::lonpublisher::metadatafields{$_},
+						    'new_'.$_,'defaultmeta').'</p>');
       }
-    }
-    $r->print(
- '<br /><input type="submit" name="store" value="'.
-&mt('Store Catalog Information').'"></form></body></html>');
-    return OK;
+      if ($ENV{'form.store'}) {
+	  my $mfh;
+	  unless ($mfh=Apache::File->new('>'.$fn)) {
+	      $r->print(
+			'<p><font color=red>'.&mt('Could not write metadata').', '.
+			&mt('FAIL').'</font>');
+	  } else {
+	      foreach (sort keys %Apache::lonpublisher::metadatafields) {
+		  unless ($_=~/\./) {
+		      my $unikey=$_;
+		      $unikey=~/^([A-Za-z]+)/;
+		      my $tag=$1;
+		      $tag=~tr/A-Z/a-z/;
+		      print $mfh "\n\<$tag";
+		      foreach 
+			  (split(/\,/,$Apache::lonpublisher::metadatakeys{$unikey})) {
+			      my $value=
+				  $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
+			      $value=~s/\"/\'\'/g;
+			      print $mfh ' '.$_.'="'.$value.'"';
+			  }
+		      print $mfh '>'.
+			  &HTML::Entities::encode($Apache::lonpublisher::metadatafields{$unikey})
+			  .'</'.$tag.'>';
+		  }
+	      }
+	      $r->print('<p>'.&mt('Wrote Metadata'));
+	  }
+      }
+      $r->print(
+		'<br /><input type="submit" name="store" value="'.
+		&mt('Store Catalog Information').'"></form></body></html>');
   }
+    return OK;
+ }
 }
 
 # ================================================================= BEGIN Block
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.76 loncom/interface/lonmsg.pm:1.77
--- loncom/interface/lonmsg.pm:1.76	Tue Dec 30 17:45:59 2003
+++ loncom/interface/lonmsg.pm	Tue Dec 30 21:33:27 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.76 2003/12/30 22:45:59 www Exp $
+# $Id: lonmsg.pm,v 1.77 2003/12/31 02:33:27 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -294,6 +294,14 @@
 sub del_url_author_res_msg {
     my $url=shift;
     $url=&Apache::lonnet::declutter($url);
+    my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//);
+    my @delmsgs=();
+    foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) {
+	if ($_=~/^\Q$url\E\_\d+$/) {
+	    push (@delmsgs,$_);
+	}
+    }
+    return &Apache::lonnet::del('nohist_res_msgs',\@delmsgs,$domain,$author);
 }
 
 # ================= Return hash with URLs for which there is a resource message
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.50 loncom/publisher/lonpubdir.pm:1.51
--- loncom/publisher/lonpubdir.pm:1.50	Tue Dec 30 17:19:18 2003
+++ loncom/publisher/lonpubdir.pm	Tue Dec 30 21:33:28 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.50 2003/12/30 22:19:18 www Exp $
+# $Id: lonpubdir.pm,v 1.51 2003/12/31 02:33:28 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -306,20 +306,20 @@
 	    }
 	    $title='<a href="/res/'.$targetdir.'/'.$filename.
 		'.meta" target=cat>'.
-		($$bombs{$targetdir.'/'.$filename}?'<img src="/adm/lonMisc/bomb.gif" />':'').
 		getTitleString($targetdir.'/'.$filename, 'title').'</a>';
 	} else {
 	    $status=&mt('Modified');
             $bgcolor='#FFFFCC';
 	    $title='<a href="/res/'.$targetdir.'/'.$filename.'.meta" target=cat>'.
-		($$bombs{$targetdir.'/'.$filename}?'<img src="/adm/lonMisc/bomb.gif" />':'').
 		getTitleString($targetdir.'/'.$filename,'title').'</a>';
 	    if (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
 		$status.='<br><a href="/adm/diff?filename=/~'.$uname.
 		    $thisdisfn.'/'.$filename.
 		    '&versiontwo=priv" target=cat>'.&mt('Diffs').'</a>';
 	    }
-	}   
+	}
+	$title.='<br /><a href="/~'.$uname.$thisdisfn.'/'.$filename.'.meta">'. 
+	    ($$bombs{$targetdir.'/'.$filename}?'<img src="/adm/lonMisc/bomb.gif" />':'Edit Metadata').'</a>';
 	$status.='<br><a href="/adm/retrieve?filename=/~'.$uname.
 	    $thisdisfn.'/'.$filename.'" target=cat>'.&mt('Retrieve').'</a>';
     }

--www1072838008--