--- loncom/publisher/lonpubdir.pm	2006/06/22 20:49:19	1.93
+++ loncom/publisher/lonpubdir.pm	2006/09/13 21:43:26	1.95
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.93 2006/06/22 20:49:19 albertel Exp $
+# $Id: lonpubdir.pm,v 1.95 2006/09/13 21:43:26 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -195,7 +195,7 @@ sub startpage {
 
     my $formaction='/priv/'.$uname.$thisdisfn.'/';
     $formaction=~s|/+|/|g;
-    my $pagetitle .= &Apache::loncommon::help_open_menu('','','','',3,'Authoring').
+    my $pagetitle .= &Apache::loncommon::help_open_menu('','',3,'Authoring').
         '<font face="Arial, Helvetica, sans-serif" size="+1"><b>Construction Space</b>:</font>&nbsp;'.
         '<form name="dirs" method="post" action="'.$formaction.
         '" target="_parent"><tt><b>'.
@@ -571,6 +571,7 @@ sub putresource {
     my $css_class='LC_browser_file';
     my $title='&nbsp;';
     my $publish_button=&mt('Publish');
+    my $cstr_dir = '/home/'.$uname.'/public_html/'.$thisdisfn.'/';
 #    my $action_buttons=
 #        '<br /><a target="_parent" href="/adm/cfile?action=delete&filename=/~'.
 #	$uname.'/'.$thisdisfn.'/'.$filename.'">'.
@@ -585,44 +586,67 @@ sub putresource {
            $same=1;
         } else {
            if (&Apache::londiff::are_different_files($resdir.'/'.$filename,
-	                                      '/home/'.$uname.'/public_html/'.$thisdisfn.'/'.$filename)) {
+						     $cstr_dir.'/'.$filename)) {
               $same=0;
            } else {
               $same=1;
            }
         }
+	my $meta_cmtime = (stat($cstr_dir.'/'.$filename.'.meta'))[9];
+	my $meta_rmtime = (stat($resdir.'/'.$filename.'.meta'))[9];
+	my $meta_same = 1;
+	if ($meta_rmtime < $meta_cmtime
+	    && &Apache::londiff::are_different_files($resdir.'/'.$filename.'.meta',
+						     $cstr_dir.'/'.$filename.'.meta')) {
+	    $meta_same = 0;
+	}
 	$publish_button=&mt('Re-publish');
+	my $rights_status =
+	    &mt(&getCopyRightString($targetdir.'/'.$filename)).' '.
+	    &mt(&getSourceRightString($targetdir.'/'.$filename));
+	$title = '<a href="/res/'.$targetdir.'/'.$filename.
+	    '.meta" target="cat">'.
+	    &getTitleString($targetdir.'/'.$filename).'</a>';
+	&Apache::lonnet::logthis("same $same meta $meta_same");
 	if ($same) {
-            $pubstatus = 'published';
-	    $status=&mt('Published').'<br />'.
-		&mt(&getCopyRightString($targetdir.'/'.$filename)).' '.
-		&mt(&getSourceRightString($targetdir.'/'.$filename));
 	    if (&Apache::lonnet::metadata($targetdir.'/'.$filename,'obsolete')) {
                 $pubstatus = 'obsolete';
 		$status=&mt('Obsolete');
-            }
+            } else {
+		if (!$meta_same) {
+		    $pubstatus = 'metamodified';
+		} else {
+		    $pubstatus = 'published';
+		}
+		$status=&mt('Published').
+		    '<br />'. $rights_status;
+	    }
 #	    } else {
 #		$action_buttons='';
 #	    }
-	    $title='<a href="/res/'.$targetdir.'/'.$filename.
-		'.meta" target="cat">'.
-		&getTitleString($targetdir.'/'.$filename).'</a>';
 	} else {
             $pubstatus = 'modified';
-	    $status=&mt('Modified').'<br />'.
-		&mt(&getCopyRightString($targetdir.'/'.$filename)).' '.
-		&mt(&getSourceRightString($targetdir.'/'.$filename));
+	    $status=&mt('Modified').
+		'<br />'. $rights_status;
 #	    $action_buttons='';
-	    $title='<a href="/res/'.$targetdir.'/'.$filename.'.meta" target="cat">'.
-		&getTitleString($targetdir.'/'.$filename).'</a>';
 	    if (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
 		$status.='<br /><a href="/adm/diff?filename=/~'.$uname.
 		    $thisdisfn.'/'.$filename.
 		    '&amp;versiontwo=priv" target="cat">'.&mt('Diffs').'</a>';
 	    }
-	}
+	} 
+
 	$title.="\n".'<br /><a href="/~'.$uname.$thisdisfn.'/'.$filename.'.meta">'. 
 	    ($$bombs{$targetdir.'/'.$filename}?'<img src="/adm/lonMisc/bomb.gif" border="0" alt="bomb" />':'Edit Metadata').'</a>';
+
+	if (!$meta_same) {
+	    $title = &mt('Metadata Modified').'<br />'.$title.
+		'<br /><a href="/adm/diff?filename=/~'.$uname.
+		$thisdisfn.'/'.$filename.'.meta'.
+		'&amp;versiontwo=priv" target="cat">'.&mt('Metadata Diffs').'</a>';
+	    $title.="\n".'<br /><a href="/adm/retrieve?filename=/~'.$uname.
+		$thisdisfn.'/'.$filename.'.meta" target="_parent">'.&mt('Retrieve Metadata').'</a>';
+	}
 	$status.="\n".'<br /><a href="/adm/retrieve?filename=/~'.$uname.
 	    $thisdisfn.'/'.$filename.'" target="_parent">'.&mt('Retrieve').'</a>';
     }