[LON-CAPA-cvs] cvs: loncom /interface lonmeta.pm /publisher lonpublisher.pm
www
lon-capa-cvs@mail.lon-capa.org
Sun, 04 Jan 2004 00:28:22 -0000
www Sat Jan 3 19:28:22 2004 EDT
Modified files:
/loncom/interface lonmeta.pm
/loncom/publisher lonpublisher.pm
Log:
Work on bug #2335 - directory catalog info available in RES
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.56 loncom/interface/lonmeta.pm:1.57
--- loncom/interface/lonmeta.pm:1.56 Fri Jan 2 14:23:47 2004
+++ loncom/interface/lonmeta.pm Sat Jan 3 19:28:22 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.56 2004/01/02 19:23:47 www Exp $
+# $Id: lonmeta.pm,v 1.57 2004/01/04 00:28:22 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -656,7 +656,9 @@
'copyright','customdistributionfile','language','standards',
'lowestgradelevel','highestgradelevel',
'obsolete','obsoletereplacement') {
- $Apache::lonpublisher::metadatafields{$_}=$ENV{'form.new_'.$_};
+ if (defined($ENV{'form.new_'.$_})) {
+ $Apache::lonpublisher::metadatafields{$_}=$ENV{'form.new_'.$_};
+ }
unless ($Apache::lonpublisher::metadatafields{'copyright'}) {
$Apache::lonpublisher::metadatafields{'copyright'}='default';
}
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.159 loncom/publisher/lonpublisher.pm:1.160
--- loncom/publisher/lonpublisher.pm:1.159 Tue Dec 30 22:02:49 2003
+++ loncom/publisher/lonpublisher.pm Sat Jan 3 19:28:22 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.159 2003/12/31 03:02:49 www Exp $
+# $Id: lonpublisher.pm,v 1.160 2004/01/04 00:28:22 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1697,6 +1697,63 @@
}
closedir(DIR);
}
+
+#########################################
+# publish a default.meta file
+
+sub defaultmetapublish {
+ my ($r,$fn,$cuname,$cudom)=@_;
+ $fn=~s/^\/\~$cuname\//\/home\/$cuname\/public_html\//;
+ unless (-e $fn) {
+ return HTTP_NOT_FOUND;
+ }
+ my $target=$fn;
+ $target=~s/^\/home\/$cuname\/public_html\//$Apache::lonnet::perlvar{'lonDocRoot'}\/res\/$cudom\/$cuname\//;
+
+
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+
+ $r->print('<html><head><title>LON-CAPA Publishing</title></head>');
+ $r->print(&Apache::loncommon::bodytag('Catalog Information Publication'));
+
+# ---------------------------------------------------------------- Write Source
+ my $copyfile=$target;
+
+ my @parts=split(/\//,$copyfile);
+ my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]";
+
+ my $count;
+ for ($count=5;$count<$#parts;$count++) {
+ $path.="/$parts[$count]";
+ if ((-e $path)!=1) {
+ $r->print('<p>'.&mt('Created directory').' '.$parts[$count].'</p>');
+ mkdir($path,0777);
+ }
+ }
+
+ if (copy($fn,$copyfile)) {
+ $r->print('<p>'.&mt('Copied source file').'</p>');
+ } else {
+ return "<font color=\"red\">".
+ &mt('Failed to copy source').", $!, ".&mt('FAIL')."</font>";
+ }
+
+# --------------------------------------------------- Send update notifications
+
+ my @subscribed=&get_subscribed_hosts($target);
+ foreach my $subhost (@subscribed) {
+ $r->print('<p>'.&mt('Notifying host').' '.$subhost.':');$r->rflush;
+ my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);
+ $r->print($reply.'</p><br />');$r->rflush;
+ }
+# ------------------------------------------------------------------- Link back
+ my $link=$fn;
+ $link=~s/^\/home\/$cuname\/public_html\//\/priv\/$cuname\//;
+ $r->print("<a href='$link'>".&mt('Back to Catalog Information').'</a>');
+ $r->print('</body></html>');
+ return OK;
+}
#########################################
=pod
@@ -1754,6 +1811,14 @@
# -------------------------------------------------------------- Check filename
my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
+
+ ($cuname,$cudom)=
+ &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));
+
+# special publication: default.meta file
+ if ($fn=~/\/default.meta$/) {
+ return &defaultmetapublish($r,$fn,$cuname,$cudom);
+ }
$fn=~s/\.meta$//;
unless ($fn) {
@@ -1762,8 +1827,6 @@
return HTTP_NOT_FOUND;
}
- ($cuname,$cudom)=
- &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));
unless (($cuname) && ($cudom)) {
$r->log_reason($cuname.' at '.$cudom.
' trying to publish file '.$ENV{'form.filename'}.