diff --git a/LDP/lampadas/www/document_edit.pl b/LDP/lampadas/www/document_edit.pl
index e8a7704c..2d068571 100755
--- a/LDP/lampadas/www/document_edit.pl
+++ b/LDP/lampadas/www/document_edit.pl
@@ -99,7 +99,7 @@ print "\n";
print "
\n";
print "Document Details |
\n";
print "Title: | | \n";
-print "Edit (test) |
\n";
+print "Wiki Editing (beta) | \n";
print "Filename: | |
\n";
print "";
@@ -185,6 +185,7 @@ if ( $format eq "XML" ) { print ''; } else { print
if ( $format eq "TEXT" ) { print ''; } else { print '' }
if ( $format eq "LaTeX" ) { print ''; } else { print '' }
if ( $format eq "PDF" ) { print ''; } else { print '' }
+if ( $format eq "WIKI" ) { print ''; } else { print '' }
print "";
print "DTD: | ";
@@ -249,6 +250,69 @@ print "";
+$test = 'x';
+
+if ($test) {
+print " ";
+
+
+
+
+print "Versions";
+
+$rev_result = $conn->exec("SELECT rev_id, version, pub_date, initials, notes FROM document_rev WHERE doc_id=$doc_id ORDER BY pub_date, version");
+die $conn->errorMessage unless PGRES_TUPLES_OK eq $rev_result->resultStatus;
+
+print "\n";
+}
+
+
+
+
+
diff --git a/LDP/lampadas/www/document_editor_add.pl b/LDP/lampadas/www/document_editor_add.pl
index 0cdb143e..d0f543e6 100755
--- a/LDP/lampadas/www/document_editor_add.pl
+++ b/LDP/lampadas/www/document_editor_add.pl
@@ -23,7 +23,7 @@ if ($username ne $row[0]) {
print $query->redirect("../newaccount.html");
exit;
} else {
- if (($row[1] ne 't') and ($row[2] != $doc_id)) {
+ if ($row[1] ne 't') {
print $query->redirect("../wrongpermission.html");
exit;
}
diff --git a/LDP/lampadas/www/document_list.pl b/LDP/lampadas/www/document_list.pl
index 15c222a4..201b45a8 100755
--- a/LDP/lampadas/www/document_list.pl
+++ b/LDP/lampadas/www/document_list.pl
@@ -51,6 +51,15 @@ if ( $SORT3 ) { $SORT3 = ", $SORT3"; }
$strSTATUS = param('strSTATUS');
+$mydocuments = param("MyDocuments");
+$reload = param('Reload');
+
+# if we're not reloading, the default is to show only Active ('N') documents.
+unless (($reload eq 'Reload') or ($mydocuments eq 'MyDocuments')) {
+ $strSTATUS = 'N';
+}
+
+
# Clear
$BACKGROUNDER = "";
$HOWTO = "";
@@ -107,6 +116,11 @@ if ( $chkFILENAME eq "on" ) { $FILENAME = "checked "; }
# connect to the database
$conn=Pg::connectdb("dbname=$dbmain");
+$username = $query->remote_user();
+$result=$conn->exec("SELECT username, admin, maintainer_id FROM username WHERE username='$username'");
+@row = $result->fetchrow;
+$admin = $row[1];
+
# print the page
print header(-expires=>'now');
print "\n";
@@ -200,7 +214,7 @@ print "\n";
print " | \n";
print "
\n";
-print "\n";
+print "\n";
$username=$query->remote_user();
$result=$conn->exec("SELECT count(*) FROM username WHERE username='$username'");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
@@ -222,7 +236,7 @@ if ($row[0] > 0) {
}
$doc_id_sql .= ")";
}
- print "\n";
+ print "\n";
}
@@ -260,8 +274,7 @@ $sql .= " AND document.pub_status=pub_status.pub_status";
$sql .= " AND document.review_status = lr.review_status";
$sql .= " AND document.tech_review_status = tr.review_status";
if ( $strSTATUS ) { $sql = $sql . " AND document.pub_status='" . $strSTATUS . "'" };
-$MyDocuments = param("MyDocuments");
-if (($doc_id_sql) and ($MyDocuments)) { $sql .= " AND $doc_id_sql" }
+if (($doc_id_sql) and ($mydocuments)) { $sql .= " AND $doc_id_sql" }
$sql = $sql . " ORDER BY $SORT1";
#print "$sql |
";
@@ -321,64 +334,67 @@ print "\n";
print "Count: $count";
-print "
";
+if ($admin eq 't') {
+ print "
";
-print "New Document
\n";
+ print "New Document
\n";
-print "\n";
+}
print end_html;
diff --git a/LDP/lampadas/www/document_maintainer_add.pl b/LDP/lampadas/www/document_maintainer_add.pl
index dbd23a16..f4c2092c 100755
--- a/LDP/lampadas/www/document_maintainer_add.pl
+++ b/LDP/lampadas/www/document_maintainer_add.pl
@@ -24,9 +24,14 @@ if ($username ne $row[0]) {
print $query->redirect("../newaccount.html");
exit;
} else {
- if (($row[1] ne 't') and ($row[2] != $doc_id)) {
- print $query->redirect("../wrongpermission.html");
- exit;
+ if ($row[1] ne 't') {
+ $user_maintainer_id = $row[2];
+ $result=$conn->exec("SELECT count(*) FROM document_maintainer WHERE maintainer_id=$user_maintainer_id AND doc_id=$doc_id AND active='t'");
+ @row = $result->fetchrow;
+ unless ($row[0]) {
+ print $query->redirect("../wrongpermission.html");
+ exit;
+ }
}
}
diff --git a/LDP/lampadas/www/document_maintainer_save.pl b/LDP/lampadas/www/document_maintainer_save.pl
index 90d350d5..42825a90 100755
--- a/LDP/lampadas/www/document_maintainer_save.pl
+++ b/LDP/lampadas/www/document_maintainer_save.pl
@@ -25,9 +25,14 @@ if ($username ne $row[0]) {
print $query->redirect("../newaccount.html");
exit;
} else {
- if (($row[1] ne 't') and ($row[2] != $doc_id)) {
- print $query->redirect("../wrongpermission.html");
- exit;
+ if ($row[1] ne 't') {
+ $user_maintainer_id = $row[2];
+ $result=$conn->exec("SELECT count(*) FROM document_maintainer WHERE maintainer_id=$user_maintainer_id AND doc_id=$doc_id AND active='t'");
+ @row = $result->fetchrow;
+ unless ($row[0]) {
+ print $query->redirect("../wrongpermission.html");
+ exit;
+ }
}
}
diff --git a/LDP/lampadas/www/document_rev_add.pl b/LDP/lampadas/www/document_rev_add.pl
new file mode 100755
index 00000000..a265709f
--- /dev/null
+++ b/LDP/lampadas/www/document_rev_add.pl
@@ -0,0 +1,59 @@
+#! /usr/bin/perl
+
+use CGI qw(:standard);
+use Pg;
+
+$query = new CGI;
+$dbmain = "ldp";
+@row;
+
+# Read parameters
+$caller = param('caller');
+$doc_id = param('doc_id');
+$rev_version = param('rev_version');
+$rev_date = param('rev_date');
+$rev_init = param('rev_init');
+$rev_note = param('rev_note');
+
+while ($rev_note =~ /\'/) {
+ $rev_note =~ s/\'/a1s2d3f4/;
+}
+while ($rev_note =~ /a1s2d3f4/) {
+ $rev_note =~ s/a1s2d3f4/\'\'/;
+}
+
+$conn=Pg::connectdb("dbname=$dbmain");
+
+$username = $query->remote_user();
+$result=$conn->exec("SELECT username, admin, maintainer_id FROM username WHERE username='$username'");
+@row = $result->fetchrow;
+if ($username ne $row[0]) {
+ print $query->redirect("../newaccount.html");
+ exit;
+} else {
+ if ($row[1] ne 't') {
+ $user_maintainer_id = $row[2];
+ $result=$conn->exec("SELECT count(*) FROM document_maintainer WHERE maintainer_id=$user_maintainer_id AND doc_id=$doc_id AND active='t'");
+ @row = $result->fetchrow;
+ unless ($row[0]) {
+ print $query->redirect("../wrongpermission.html");
+ exit;
+ }
+ }
+}
+
+$sql = "SELECT max(rev_id) FROM document_rev WHERE doc_id = $doc_id";
+$result=$conn->exec($sql);
+@row = $result->fetchrow;
+$rev_id = $row[0] + 1;
+
+$sql = "INSERT INTO document_rev(rev_id, doc_id, version, pub_date, initials, notes) VALUES ($rev_id, $doc_id, '$rev_version', '$rev_date', '$rev_init', '$rev_note')";
+$result=$conn->exec($sql);
+
+#print "Content-Type: text/plain\n\n";
+#print "$sql\n";
+
+print $query->redirect($caller)
+
+
+
diff --git a/LDP/lampadas/www/document_rev_save.pl b/LDP/lampadas/www/document_rev_save.pl
new file mode 100755
index 00000000..cafcfd90
--- /dev/null
+++ b/LDP/lampadas/www/document_rev_save.pl
@@ -0,0 +1,60 @@
+#! /usr/bin/perl
+
+use CGI qw(:standard);
+use Pg;
+
+$query = new CGI;
+$dbmain = "ldp";
+@row;
+
+# Read parameters
+$caller = param('caller');
+$rev_id = param('rev_id');
+$doc_id = param('doc_id');
+$rev_version = param('rev_version');
+$rev_date = param('rev_date');
+$rev_init = param('rev_init');
+$rev_note = param('rev_note');
+while ($rev_note =~ /\'/) {
+ $rev_note =~ s/\'/a1s2d3f4/;
+}
+while ($rev_note =~ /a1s2d3f4/) {
+ $rev_note =~ s/a1s2d3f4/\'\'/;
+}
+$chkDel = param('chkDel');
+
+$conn=Pg::connectdb("dbname=$dbmain");
+
+$username = $query->remote_user();
+$result=$conn->exec("SELECT username, admin, maintainer_id FROM username WHERE username='$username'");
+@row = $result->fetchrow;
+if ($username ne $row[0]) {
+ print $query->redirect("../newaccount.html");
+ exit;
+} else {
+ if ($row[1] ne 't') {
+ $user_maintainer_id = $row[2];
+ $result=$conn->exec("SELECT count(*) FROM document_maintainer WHERE maintainer_id=$user_maintainer_id AND doc_id=$doc_id AND active='t'");
+ @row = $result->fetchrow;
+ unless ($row[0]) {
+ print $query->redirect("../wrongpermission.html");
+ exit;
+ }
+ }
+}
+
+if ( $chkDel eq 'on' ) {
+ $sql = "DELETE FROM document_rev WHERE rev_id = $rev_id";
+ $result=$conn->exec($sql);
+}
+else {
+ $result=$conn->exec("UPDATE document_rev SET version = '$rev_version' WHERE rev_id = $rev_id");
+ $result=$conn->exec("UPDATE document_rev SET pub_date = '$rev_date' WHERE rev_id = $rev_id");
+ $result=$conn->exec("UPDATE document_rev SET initials = '$rev_init' WHERE rev_id = $rev_id");
+ $result=$conn->exec("UPDATE document_rev SET notes = '$rev_note' WHERE rev_id = $rev_id");
+}
+
+print $query->redirect($caller)
+
+
+
diff --git a/LDP/lampadas/www/document_save.pl b/LDP/lampadas/www/document_save.pl
index 28241743..45c0fe05 100755
--- a/LDP/lampadas/www/document_save.pl
+++ b/LDP/lampadas/www/document_save.pl
@@ -49,9 +49,14 @@ if ($username ne $row[0]) {
print $query->redirect("../newaccount.html");
exit;
} else {
- if (($row[1] ne 't') and ($row[2] != $doc_id)) {
- print $query->redirect("../wrongpermission.html");
- exit;
+ if ($row[1] ne 't') {
+ $maintainer_id = $row[2];
+ $result=$conn->exec("SELECT count(*) FROM document_maintainer WHERE maintainer_id=$maintainer_id AND doc_id=$doc_id AND active='t'");
+ @row = $result->fetchrow;
+ unless ($row[0]) {
+ print $query->redirect("../wrongpermission.html");
+ exit;
+ }
}
}
diff --git a/LDP/lampadas/www/document_wiki.pl b/LDP/lampadas/www/document_wiki.pl
index b0ae449c..74472a46 100755
--- a/LDP/lampadas/www/document_wiki.pl
+++ b/LDP/lampadas/www/document_wiki.pl
@@ -224,9 +224,12 @@ if ($preview or $docbook) {
}
if ($docbook) {
- &printheader;
- print "
\n";
- print "\n";
+# &printheader;
+# print "
\n";
+# print "\n";
+
+ print "Content-Type: text/plain; charset=ISO-8859-1\n\n";
+
while ($sgml =~ /\) {
$sgml =~ s/\</;
}
@@ -234,8 +237,9 @@ if ($docbook) {
$sgml =~ s/\>/>/;
}
print $sgml;
- print "
\n";
- print "\n";
+# print "
\n";
+# print "\n";
+
}
if ($preview) {
diff --git a/LDP/lampadas/www/document_wiki_big.pl b/LDP/lampadas/www/document_wiki_big.pl
new file mode 100755
index 00000000..ac127a89
--- /dev/null
+++ b/LDP/lampadas/www/document_wiki_big.pl
@@ -0,0 +1,355 @@
+#! /usr/bin/perl
+
+$editcols = 80;
+$editrows = 25;
+
+use CGI qw(:standard);
+use Pg;
+
+$query = new CGI;
+$dbmain = "ldp";
+@row;
+$section_max = 25;
+
+# Read parameters
+$doc_id = param('doc_id');
+$notes = param('notes');
+$revision = param('revision');
+
+$section = 0;
+while ($section <= $section_max) {
+ $section++;
+ $wiki_section = param("wiki$section");
+ if ($wiki_section) {
+ if ($wiki) {
+ $wiki .= "\n";
+ }
+ $wiki .= $wiki_section;
+ }
+}
+$section = 0;
+
+$save = param('Save');
+$preview = param('Preview');
+$docbook = param('DocBook');
+
+$conn=Pg::connectdb("dbname=$dbmain");
+die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status;
+
+$username = $query->remote_user();
+$result=$conn->exec("SELECT username, admin, maintainer_id FROM username WHERE username='$username'");
+@row = $result->fetchrow;
+if ($username ne $row[0]) {
+ print $query->redirect("../newaccount.html");
+ exit;
+} else {
+ if ($row[1] ne 't') {
+ $maintainer_id = $row[2];
+ $result=$conn->exec("SELECT count(*) FROM document_maintainer WHERE maintainer_id=$maintainer_id AND doc_id=$doc_id AND active='t'");
+ @row = $result->fetchrow;
+ unless ($row[0]) {
+ print $query->redirect("../wrongpermission.html");
+ exit;
+ }
+ }
+}
+
+if ($save) {
+ while ($wiki =~ /\\/) {
+ $wiki =~ s/\\/a1s2d3f4/;
+ }
+ while ($wiki =~ /a1s2d3f4/) {
+ $wiki =~ s/a1s2d3f4/\\\\/;
+ }
+ while ($wiki =~ /&/) {
+ $wiki =~ s/&/a1s2d3f4/;
+ }
+ while ($wiki =~ /a1s2d3f4/) {
+ $wiki =~ s/a1s2d3f4/&/;
+ }
+ while ($wiki =~ /\'/) {
+ $wiki =~ s/\'/a1s2d3f4/;
+ }
+ while ($wiki =~ /a1s2d3f4/) {
+ $wiki =~ s/a1s2d3f4/\'\'/;
+ }
+ while ($notes =~ /\'/) {
+ $notes =~ s/\'/a1s2d3f4/;
+ }
+ while ($notes =~ /a1s2d3f4/) {
+ $notes =~ s/a1s2d3f4/\'\'/;
+ }
+
+ #find out how many prior revisions there were
+ $result = $conn->exec("SELECT count(*) FROM document_wiki WHERE doc_id = $doc_id");
+ die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
+ @row = $result->fetchrow;
+ $revisions = $row[0];
+
+# &printheader;
+# print $wiki;
+# print end_html;
+# exit;
+
+ if ($revisions >= $revision ) {
+ &printheader;
+ print "Edit conflict!\n";
+ print "
You were editing version $revisions, but trying to save to version $revision\n";
+ print end_html;
+ } elsif ($wiki eq '') {
+ &printheader;
+ print "
No content to save!\n";
+ print end_html;
+ } else {
+ $revision = $revisions + 1;
+ $sql = "INSERT INTO document_wiki(doc_id, revision, date_entered, wiki, notes, username) VALUES ($doc_id, $revision, now(), '$wiki', '$notes', '$username')";
+ $result=$conn->exec($sql);
+ print $query->redirect("document_edit.pl?doc_id=$doc_id");
+ }
+ exit;
+}
+
+#load document meta-data
+$result = $conn->exec("SELECT title, filename, class FROM document WHERE doc_id = $doc_id");
+die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
+@row = $result->fetchrow;
+$title = $row[0];
+$title =~ s/\s+$//;
+$filename = $row[1];
+$class = $row[2];
+$class =~ s/\s+$//;
+
+#find out how many prior revisions there were
+$result = $conn->exec("SELECT count(*) FROM document_wiki WHERE doc_id = $doc_id");
+die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
+@row = $result->fetchrow;
+$revisions = $row[0];
+
+#if we're not previewing, load data from database and determine version
+unless ($preview or $docbook) {
+ $result = $conn->exec("SELECT wiki FROM document_wiki WHERE doc_id = $doc_id ORDER BY revision DESC LIMIT 1, 0");
+ die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
+ @row = $result->fetchrow;
+ $revision = $revisions + 1;
+ $wiki = $row[0];
+ $wiki =~ s/\s+$//;
+ while ($wiki =~ /) {
+ $wiki =~ s/</;
+ }
+ while ($wiki =~ />/) {
+ $wiki =~ s/>/>/;
+ }
+
+ &printheader;
+ print "
\n";
+ print end_html;
+}
+
+if ($preview or $docbook) {
+ $txtfile = "/tmp/" . rand() . ".txt";
+ $sgmlfile = $txtfile;
+ $sgmlfile =~ s/\.txt/\.sgml/;
+ $htmlfile = $txtfile;
+ $htmlfile =~ s/\.txt/\.html/;
+ $abstractfile = $txtfile;
+ $abstractfile =~ s/\./abs\./;
+ $abstractsgmlfile = $sgmlfile;
+ $abstractsgmlfile =~ s/\./abs\./;
+ system("rm $sgmlfile");
+
+ open(TXT, "> $txtfile");
+ print TXT $wiki;
+ close(TXT);
+
+ $cmd = "/usr/lib/cgi-bin/gldp.org/txt2db.pl -o $sgmlfile $txtfile";
+ system($cmd);
+
+ $sgml = '' . "\n";
+ if ($class eq 'FAQ') {
+ $sgml .= "\n";
+ } else {
+ $sgml .= "\n";
+ }
+ $sgml .= "\n";
+
+ $result = $conn->exec("SELECT title, last_update, abstract FROM document WHERE doc_id = $doc_id");
+ die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
+ while (@row = $result->fetchrow) {
+ $title = $row[0];
+ $date = $row[1];
+
+ #insert paragraphs in the abstract where appropriate.
+ $abstract = $row[2];
+ open(ABSTRACT, "> $abstractfile");
+ print ABSTRACT $abstract;
+ close(ABSTRACT);
+
+ $cmd = "/usr/lib/cgi-bin/gldp.org/txt2db.pl -o $abstractsgmlfile $abstractfile";
+ system($cmd);
+
+ $abstract = "";
+ open(ABSTRACTSGML, $abstractsgmlfile);
+ while () {
+ $abstract .= $_;
+ }
+
+ #build the document header.
+ $sgml .= "$title\n";
+ $sgml .= "$date\n";
+ $sgml .= "$date\n";
+ $sgml .= "$abstract\n";
+ }
+
+ $result = $conn->exec("SELECT m.maintainer_name, dm.email FROM document_maintainer dm, maintainer m WHERE doc_id = $doc_id AND dm.maintainer_id = m.maintainer_id AND active='t'");
+ die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
+ while (@row = $result->fetchrow) {
+ $name = $row[0];
+ $email = $row[1];
+ $sgml .= "\n";
+ $sgml .= "\n";
+ $sgml .= "\n";
+ $sgml .= "$name\n";
+ $sgml .= "\n";
+ $sgml .= "\n";
+ $sgml .= "\n";
+ }
+
+ $sgml .= "\n";
+
+ open(SGML, $sgmlfile);
+ while () {
+ $line = $_;
+ $sgml .= $line;
+ while ($line =~ /) {
+ $line =~ s/</;
+ }
+ while ($line =~ />/) {
+ $line =~ s/>/>/;
+ }
+ $buf .= "
$line";
+ }
+ close(SGML);
+
+ $sgml .= "\n";
+
+ open(SGML, "> $sgmlfile");
+ print SGML $sgml;
+ close(SGML);
+}
+
+if ($docbook) {
+# &printheader;
+# print "
\n";
+# print "\n";
+
+ print "Content-Type: text/plain; charset=ISO-8859-1\n\n";
+
+# while ($sgml =~ /) {
+# $sgml =~ s/</;
+# }
+# while ($sgml =~ />/) {
+# $sgml =~ s/>/>/;
+# }
+ print $sgml;
+# print "
\n";
+# print "