diff --git a/LDP/lampadas/www/document_add.pl b/LDP/lampadas/www/document_add.pl new file mode 100755 index 00000000..d999ce0f --- /dev/null +++ b/LDP/lampadas/www/document_add.pl @@ -0,0 +1,58 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; +$conn=Pg::connectdb("dbname=$dbmain"); + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} + +$dbmain = "ldp"; +@row; + +$caller = param('caller'); + +$sql = "SELECT max(doc_id) from document"; +$result=$conn->exec($sql); +@row = $result->fetchrow; +$doc_id = $row[0] + 1; +$title = param('title'); +$title =~ s/\'/\'\'/; +$class = param('class'); +$format = param('format'); +$dtd = param('dtd'); + +$pub_status = param('pub_status'); + +$sql = "INSERT INTO document(doc_id, title, filename, class, format, dtd, dtd_version, version, last_update, url, isbn, pub_status, author_status, review_status, tickle_date, pub_date, ref_url, tech_review_status, maintained)"; +$sql = "$sql VALUES ($doc_id, '$title', NULL, '$class', '$format', '$dtd', NULL, NULL, NULL, NULL, NULL, $pub_status', '$author_status', 'U', NULL, NULL, NULL, 'U', 't')"; + +#print header; +#print start_html; +#print "

doc_id:$doc_id"; +#print "

title:$title"; +#print "

pub_status:$pub_status"; +#print "

class:$class"; +#print "

format:$format"; +#print "

dtd:$dtd"; +#print "

sql:$sql"; +#print end_html; +#exit; + +$conn->exec($sql); + +print $query->redirect("document_edit.pl?doc_id=$doc_id"); +#print $query->redirect($caller); + diff --git a/LDP/lampadas/www/document_edit.pl b/LDP/lampadas/www/document_edit.pl new file mode 100755 index 00000000..22660b9b --- /dev/null +++ b/LDP/lampadas/www/document_edit.pl @@ -0,0 +1,596 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$dbmain = "ldp"; +@row; + +# Read parameters +$doc_id = param('doc_id'); + +$conn=Pg::connectdb("dbname=$dbmain"); +die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status; + +$result = $conn->exec("SELECT doc_id, title, filename, class, format, dtd, dtd_version, version, last_update, url, isbn, pub_status, review_status, tickle_date, ref_url, pub_date, tech_review_status, maintained, license FROM document WHERE doc_id = $doc_id"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus; + +@row = $result->fetchrow; + + + +# Load from db +$doc_id = $row[0]; +$title = $row[1]; +$title =~ s/\s+$//; +$title =~ s/\'//; +$filename = $row[2]; +$filename =~ s/\s+$//; +$class = $row[3]; +$class =~ s/\s+$//; +$format = $row[4]; +$format =~ s/\s+$//; +$dtd = $row[5]; +$dtd =~ s/\s+$//; +$dtd_version = $row[6]; +$dtd_version =~ s/\s+$//; +$version = $row[7]; +$version =~ s/\s+$//; +$last_update = $row[8]; +$url = $row[9]; +$isbn = $row[10]; +$pub_status = $row[11]; +$review_status = $row[12]; +$tickle_date = $row[13]; +$ref_url = $row[14]; +$pub_date = $row[15]; +$tech_review_status = $row[16]; +$maintained = $row[17]; +$license = $row[18]; +$license =~ s/\s+$//; + + +# Read the votes +$votes_result = $conn->exec("select vote from doc_vote where doc_id = $doc_id"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $votes_result->resultStatus; +$vote_count = 0; +$vote_total = 0; +$vote_avg = 0; +while (@row = $votes_result->fetchrow) { + $vote = $row[0]; + $vote_count++; + $vote_total = $vote_total + $vote; +} +if ($vote_count > 0) { +$vote_avg = $vote_total / $vote_count; +} + +$votes_result = $conn->exec("select vote from doc_vote where doc_id = $doc_id"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $votes_result->resultStatus; +@row = $votes_result->fetchrow; +$vote = $row[0]; + + + +print header(-expires=>'now'); + +print "$title"; +print ""; +print ""; +print ""; + +print "

$title

\n"; + +print "

Index "; +print "Topics "; +print "Documents "; +print "Maintainers "; +print "Editors "; + +print "

ID: $doc_id"; + +print "

\n"; +print "\n"; + +print "\n"; +print "\n"; +print "\n"; +print "\n"; + +print ""; + +print ""; + +print ""; + +print ""; + +print "\n\n"; + +print ""; + +print ""; + +print ""; + +print "\n\n"; + +print ""; +print ""; +print ""; + +print "\n\n"; + +print ""; + +print ""; + +print ""; + +print "\n\n"; + +print ""; + +print "\n\n"; + +print ""; + +print "\n\n"; + +print ""; + +print ""; + +print ""; + +print "\n\n"; + +print ""; + + +print "
Document Details
Title:
Filename:
Status:"; +print "Class:\n"; +print "Maintained:\n"; +if ( $maintained eq "t" ) { print 'Yes'; } else { print 'No' } +#print ""; +print "
Review Status:"; +print "Tech Review:"; +print "License:"; +print "
Published:Updated:Version:
Format:"; +print "DTD:"; +print "DTD Version:"; +print ""; +print "
URL:
Home:
Tickle DateISBN:
Rating"; + +if ( $vote > 0 ) { + print "\n"; + for ( $i = 1; $i <= 10; $i++ ) { + print "\n"; + } + print "
  
\n"; +} +else { + print "Not rated"; +} + +print "
\n"; +print "
"; + + + + + + + + + +print "


"; + + + + +print "

Contributors

"; + +$authors_result = $conn->exec("SELECT maintainer.maintainer_id, role, active, document_maintainer.email, maintainer.email as author_email, maintainer_name FROM document_maintainer, maintainer WHERE doc_id = $doc_id and document_maintainer.maintainer_id = maintainer.maintainer_id ORDER BY active desc, maintainer_name"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $authors_result->resultStatus; + +print "

\n"; +print ""; +while (@row = $authors_result->fetchrow) { + $maintainer_id = $row[0]; + $role = $row[1]; + $role =~ s/\s*$//; + if ( $row[2] eq 't' ) { $active = "Active" } else { $active = "Inactive" } + $feedback_email = $row[3]; + $email = $row[4]; + if ( $row[5] eq '' ) { $maintainer_name = 'J. Doe' } else { $maintainer_name = "$row[5]" } + print ""; + print ""; + print ""; + print ""; + print ""; + + print '"; + + print "\n"; + + print "\n"; + print "\n"; + print ""; + print "\n"; + print ""; + print "\n"; +} + +# For assigning a new contributor +#print ""; +print ""; +print ""; +print ""; +print ""; + +print '"; + +print "\n"; + +print "\n"; + +print "\n"; +print "\n"; +print "\n"; +print ""; +print "\n"; + +print "
StatusRoleNameFeedback EmailAction
$maintainer_nameDel
New Contributor
"; + +$sql = "SELECT maintainer_id, maintainer_name FROM maintainer ORDER BY maintainer_name"; +$authors_result = $conn->exec($sql); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $authors_result->resultStatus; + +print "\n"; +print "
\n"; +print "
Note: Deleting a record here doesn't delete the maintainer. It only deletes the association between the maintainer and this document.\n"; + + + + + + + + + +print "


"; + + + + + +print "

Topic Assignments

\n"; + +@topics; +@topic_names; + +$topic_count = 0; +$topic_result = $conn->exec("SELECT topic.topic_num, subtopic.subtopic_num, topic.topic_name, subtopic.subtopic_name FROM topic, subtopic WHERE subtopic.topic_num = topic.topic_num ORDER BY topic_num, subtopic_num"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $topic_result->resultStatus; +while (@row = $topic_result->fetchrow) { + $topic_count++; + $topics[$topic_count] = $row[0] . "." . $row[1]; + $topic_names[$topic_count] = $row[2] . ": " . $row[3]; +# print "

found: " . $topics[$rownum] . " = " . $topic_names[$rownum]; +} + +print "

\n"; +print "\n"; +$document_topic_result = $conn->exec("SELECT topic.topic_num, topic.topic_name, subtopic.subtopic_num, subtopic.subtopic_name FROM document_topic, subtopic, topic WHERE document_topic.topic_num = subtopic.topic_num and document_topic.subtopic_num = subtopic.subtopic_num AND subtopic.topic_num = topic.topic_num AND doc_id=$doc_id ORDER BY topic_num, subtopic_num"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $document_topic_result->resultStatus; + +while (@row = $document_topic_result->fetchrow) { + $topic_num = $row[0]; + $topic_name = $row[1]; + $subtopic_num = $row[2]; + $subtopic_name = $row[3]; + print "\n"; + print "\n"; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + print "\n"; + print "\n"; +} +print ""; +print ""; +print ""; +print ""; +print '\n"; +print "\n"; +print "\n"; +print "
TopicAction
$topic_num.$subtopic_num $topic_name: $subtopic_name
\n"; + + + +print "


"; + +print "

Audience Assignments

\n"; +print "

under construction. move along..."; + +#print "

\n"; +#print "\n"; +#$audience_result = $conn->exec("SELECT audience, audience_level, audience_description FROM document_audience, audience WHERE document_audience.doc_id = $doc_id AND document_audience.audience = audience.audience ORDER BY audience_level"); +#die $conn->errorMessage unless PGRES_TUPLES_OK eq $audience_result->resultStatus; + +#while (@row = $Audience_result->fetchrow) { +# $audience = $row[0]; +# $audience_level = $row[1]; +# $audience_description = $row[2]; +# print "\n"; +# print "\n"; +# print ""; +# print ""; +# print ""; +# print ""; +# print ""; +# print "\n"; +# print "\n"; +# print "\n"; +#} +#print ""; +#print ""; +#print ""; +#print ""; +#print '\n"; +#print "\n"; +#print "\n"; +#print "
AudienceDescription
$topic_num.$subtopic_num $topic_name: $subtopic_name
\n"; + + + + + +print "


"; + + + + + +print "

Editors

"; + +$authors_result = $conn->exec("SELECT editor.editor_id, editor_role, active, editor.email, editor.editor_name FROM document_editor, editor WHERE doc_id = $doc_id and document_editor.editor_id = editor.editor_id ORDER BY active desc, editor_name"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $authors_result->resultStatus; + +print "

\n"; +print ""; +while (@row = $authors_result->fetchrow) { + $editor_id = $row[0]; + $editor_role = $row[1]; + $editor_role =~ s/\s*$//; + if ( $row[2] eq 't' ) { $active = "Active" } else { $active = "Inactive" } + if ( $row[4] eq '' ) { $editor_name = 'J. Doe' } else { $editor_name = $row[4] } + print ""; + print ""; + print ""; + print ""; + print ""; + + print '"; + + print "\n"; + + print "\n"; + print "\n"; + print ""; + print "\n"; + print ""; + print "\n"; +} + + +# For assigning a new editor +print ""; +print ""; +print ""; +print ""; + +print '"; + +print "\n"; + +print "\n"; + +print "\n"; +print "\n"; +print "\n"; +print ""; +print "\n"; + +print "
StatusRoleNameEmailAction
$editor_name" . $row[3] . "Del
"; + +$sql = "SELECT editor_id, editor_name FROM editor ORDER BY editor_name"; +$editors_result = $conn->exec($sql); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $editors_result->resultStatus; + +print "\n"; +print "  
\n"; +print "
Note: Deleting a record here doesn't delete the editor. It only deletes the association between the editor and this document.\n"; + + + +print "


"; + +print "

Rating

\n"; + +print "

\n"; +for ( $i = 1; $i <= 10; $i++ ) { + print "\n"; +} +print "
   
\n"; + +print "

You can rate each document on a scale from 1 to 10, where 1 is very poor and 10 is excellent.\n"; +print "Your vote is averaged with the votes of others to obtain a rating for the document.\n"; + +print "

"; +print "

\n"; +print "\n"; +print "\n"; +print "\n"; +print "
Votes:$vote_count
Average:$vote_avg
Your Vote:\n"; +print "\n"; +print "\n"; +print "
"; + +print "

"; + + + + + + +print "


"; + + + + + +$notes_result = $conn->exec("SELECT date_entered, notes, username FROM notes WHERE doc_id = $doc_id ORDER BY date_entered"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $notes_result->resultStatus; + +print "

Notes

\n"; + +print "
"; +print "

\n"; +print ""; +while (@row = $notes_result->fetchrow) { + $date_entered = $row[0]; + $notes = $row[1]; + $notes =~ s//>/; + $username = $row[2]; + print "\n"; +} +print "\n"; +print "\n"; +print ""; +print "
Date and TimeUserNote
$date_entered$username$notes
To add a note, type the note, then click Save.\n"; +print "\n"; +print "
\n"; +print "

"; + +print end_html; + diff --git a/LDP/lampadas/www/document_editor_add.pl b/LDP/lampadas/www/document_editor_add.pl new file mode 100755 index 00000000..be1ac85f --- /dev/null +++ b/LDP/lampadas/www/document_editor_add.pl @@ -0,0 +1,45 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$dbmain = "ldp"; +@row; + +# Read parameters +$caller = param('caller'); +$doc_id = param('doc_id'); +$editor_id = param('editor_id'); +$active = param('active'); +$editor_role = param('editor_role'); + +$conn=Pg::connectdb("dbname=$dbmain"); + +#print header; +#print start_html; +$sql = "INSERT INTO document_editor(doc_id, editor_id, active, editor_role) VALUES ($doc_id, $editor_id, '$active', '$editor_role')"; +$result=$conn->exec($sql); + + +#print header; +#print start_html; +#print $sql; +#print end_html; +#exit; + +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/document_editor_save.pl b/LDP/lampadas/www/document_editor_save.pl new file mode 100755 index 00000000..9ae1cb8d --- /dev/null +++ b/LDP/lampadas/www/document_editor_save.pl @@ -0,0 +1,44 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$dbmain = "ldp"; +@row; + +# Read parameters +$caller = param('caller'); +$doc_id = param('doc_id'); +$editor_id = param('editor_id'); +$active = param('active'); +$editor_role = param('editor_role'); +$chkDel = param('chkDel'); + +$conn=Pg::connectdb("dbname=$dbmain"); + +if ( $chkDel eq 'on' ) { + $sql = "DELETE FROM document_editor WHERE doc_id = $doc_id and editor_id = $editor_id"; + $result=$conn->exec($sql); +} +else { + $sql = "UPDATE document_editor SET active = '$active' WHERE doc_id = $doc_id and editor_id = $editor_id"; + $result=$conn->exec($sql); + $sql = "UPDATE document_editor SET editor_role = '$editor_role' WHERE doc_id = $doc_id and editor_id = $editor_id"; + $result=$conn->exec($sql); +} +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/document_jump.pl b/LDP/lampadas/www/document_jump.pl new file mode 100755 index 00000000..05adad6e --- /dev/null +++ b/LDP/lampadas/www/document_jump.pl @@ -0,0 +1,24 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$dbmain = "ldp"; +@row; +$query = new CGI; + +# Read parameters +$doc_id = param('doc_id'); + +$conn=Pg::connectdb("dbname=$dbmain"); +die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status; + +$result = $conn->exec("SELECT url FROM document WHERE doc_id=$doc_id"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus; + +@row = $result->fetchrow; + +# Load from db +$url = $row[0] =~ s/\s+$//; + +print $query->redirect("$url"); diff --git a/LDP/lampadas/www/document_list.pl b/LDP/lampadas/www/document_list.pl new file mode 100755 index 00000000..6d4edcb4 --- /dev/null +++ b/LDP/lampadas/www/document_list.pl @@ -0,0 +1,310 @@ +#!/usr/bin/perl + +use CGI qw(:standard); +use Pg; +use Time::localtime; + +$dbmain='ldp'; +@row; +$count = 0; +$query = new CGI; + +# Read parameters +$chkBACKGROUNDER = param('chkBACKGROUNDER'); +$chkHOWTO = param('chkHOWTO'); +$chkMINI = param('chkMINI'); +$chkGUIDE = param('chkGUIDE'); +$chkFAQ = param('chkFAQ'); +$chkQUICK = param('chkQUICK'); +$chkTEMPLATE = param('chkTEMPLATE'); + +# Optional Fields +$chkSTATUS = param('chkSTATUS'); +$chkCLASS = param('chkCLASS'); +$chkFORMAT = param('chkFORMAT'); +$chkDTD = param('chkDTD'); +$chkPUBDATE = param('chkPUBDATE'); +$chkLASTUPDATE = param('chkLASTUPDATE'); +$chkTICKLEDATE = param('chkTICKLEDATE'); +$chkREVIEWSTATUS = param('chkREVIEWSTATUS'); +$chkTECHSTATUS = param('chkTECHSTATUS'); +$chkURL = param('chkURL'); +$chkMAINTAINED = param('chkMAINTAINED'); +$chkLICENSE = param('chkLICENSE'); + +$SORT1 = param('strSORT1'); +$SORT2 = ""; +$SORT3 = ""; + +if ( $SORT1 ) { + $SORT2 = param('strSORT2'); + $SORT3 = param('strSORT3'); +} +else { + $SORT1 = "Title"; +} + +if ( $SORT2 ) { $SORT2 = ", $SORT2"; } +if ( $SORT3 ) { $SORT3 = ", $SORT3"; } + +# Clear +$BACKGROUNDER = ""; +$HOWTO = ""; +$MINI = ""; +$GUIDE = ""; +$FAQ = ""; +$QUICK = ""; +$TEMPLATE = ""; + +$STATUS = ""; +$CLASS = ""; +$FORMAT = ""; +$DTD = ""; +$PUBDATE = ""; +$LASTUPDATE = ""; +$TICKLEDATE = ""; +$REVIEWSTATUS = ""; +$TECHSTATUS = ""; +$URL = ""; +$MAINTAINED = ""; +$LICENSE = ""; + +# Translate them into checked phrases for checkboxes and WHERE clauses +$WHERE = "WHERE class in (''"; +if ( $chkBACKGROUNDER eq "on" ) { $BACKGROUNDER = "checked "; $WHERE = $WHERE . ",'BACKGROUNDER'"; } +if ( $chkHOWTO eq "on" ) { $HOWTO = "checked "; $WHERE = $WHERE . ",'HOWTO'"; } +if ( $chkMINI eq "on" ) { $MINI = "checked "; $WHERE = $WHERE . ",'MINI'"; } +if ( $chkGUIDE eq "on" ) { $GUIDE = "checked "; $WHERE = $WHERE . ",'GUIDE'"; } +if ( $chkFAQ eq "on" ) { $FAQ = "checked "; $WHERE = $WHERE . ",'FAQ'"; } +if ( $chkQUICK eq "on" ) { $QUICK = "checked "; $WHERE = $WHERE . ",'QUICK'"; } +if ( $chkTEMPLATE eq "on" ) { $TEMPLATE = "checked "; $WHERE = $WHERE . ",'TEMPLATE'"; } + +if ( length($WHERE) < 20 ) { $WHERE = $WHERE . ", 'BACKGROUNDER', 'HOWTO', 'MINI', 'GUIDE', 'FAQ', 'QUICK', 'TEMPLATE'" } + +$WHERE = $WHERE . ") "; + +if ( $chkSTATUS eq "on" ) { $STATUS = "checked "; } +if ( $chkCLASS eq "on" ) { $CLASS = "checked "; } +if ( $chkFORMAT eq "on" ) { $FORMAT = "checked "; } +if ( $chkDTD eq "on" ) { $DTD = "checked "; } +if ( $chkPUBDATE eq "on" ) { $PUBDATE = "checked "; } +if ( $chkLASTUPDATE eq "on" ) { $LASTUPDATE = "checked "; } +if ( $chkTICKLEDATE eq "on" ) { $TICKLEDATE = "checked "; } +if ( $chkREVIEWSTATUS eq "on" ) { $REVIEWSTATUS = "checked "; } +if ( $chkTECHSTATUS eq "on" ) { $TECHSTATUS = "checked "; } +if ( $chkURL eq "on" ) { $URL = "checked "; } +if ( $chkMAINTAINED eq "on" ) { $MAINTAINED = "checked "; } +if ( $chkLICENSE eq "on" ) { $LICENSE = "checked "; } + +# print the page +print header(-expires=>'now'); +print "\n"; +print "Document List\n"; +print "\n"; +print "\n"; +print "\n"; + +print "

Document List

\n"; + +#print "

Welcome, " . $query->remote_user(); + +print "

Index "; +print "Topics\n"; +print "Maintainers\n"; +print "Editors\n"; + +print "

\n"; +print "

Jump to a document by ID: \n"; +print "\n"; +print "

\n"; + +print "
"; + +print "

"; +print ""; +print "\n"; + +print "\n"; + +print "\n"; + +print "
ClassesOptional FieldsSorting Options
\n"; +print "Backgrounder
\n"; +print "HOWTOs
\n"; +print "Mini-HOWTOs
\n"; +print "Guides
\n"; +print "FAQs
\n"; +print "Quick References
\n"; +print "Templates\n"; +print "
\n"; +print "Status
\n"; +print "Class
\n"; +print "Format
\n"; +print "DTD
\n"; +print "Publication Date
\n"; +print "Last Update
\n"; +print "Tickle Date
\n"; +print "Review Status
\n"; +print "Tech Review Status
\n"; +print "URL
\n"; +print "Maintained
\n"; +print "License
\n"; +print "
\n"; +print "
"; + +print "
\n"; +print "\n"; + +print "

\n"; + +print "


"; + +print "

\n"; +print ""; +if ( $STATUS ) { print ""; } +if ( $REVIEWSTATUS ) { print ""; } +if ( $TECHSTATUS ) { print ""; } +if ( $MAINTAINED ) { print ""; } +if ( $LICENSE ) { print ""; } +if ( $CLASS ) { print ""; } +if ( $FORMAT ) { print ""; } +if ( $DTD ) { print ""; } +if ( $PUBDATE ) { print ""; } +if ( $LASTUPDATE ) { print ""; } +if ( $TICKLEDATE ) { print ""; } +if ( $URL ) { print ""; } +print "\n"; + + +# Connect and load the tuples +$conn=Pg::connectdb("dbname=$dbmain"); +$sql = "SELECT doc_id, title, pub_status_name, class, format, tickle_date, dtd, lr.review_status_name, tr.review_status_name as tech_review_status_name, url, pub_date, last_update, maintained, license FROM document, pub_status, review_status lr, review_status tr $WHERE AND document.pub_status=pub_status.pub_status AND document.review_status = lr.review_status and document.tech_review_status = tr.review_status ORDER BY $SORT1"; +#print ""; + +$result=$conn->exec("$sql"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus; + +while (@row = $result->fetchrow) { + $doc_id = $row[0]; + $title = $row[1]; + $pub_status_name = $row[2]; + $class = $row[3]; + $format = $row[4]; + $tickle_date = $row[5]; + $dtd = $row[6]; + $review_status_name = $row[7]; + $tech_review_status_name = $row[8]; + $url = $row[9]; + $pub_date = $row[10]; + $last_update = $row[11]; + $maintained = $row[12]; + $maintained =~ s/f/No/; + $maintained =~ s/t/Yes/; + $license = $row[13]; + print ""; + print ""; + if ( $STATUS) { print ""; } + if ( $REVIEWSTATUS) { print ""; } + if ( $TECHSTATUS) { print ""; } + if ( $MAINTAINED ) { print ""; } + if ( $LICENSE ) { print ""; } + if ( $CLASS ) { print ""; } + if ( $FORMAT) { print ""; } + if ( $DTD ) { print ""; } + if ( $PUBDATE ) { print ""; } + if ( $LASTUPDATE ) { print ""; } + if ( $TICKLEDATE ) { + $date = `date -I`; + if ( $date gt $tickle_date ) { + print "" + } + else { + print "" + } + } + if ( $URL ) { print ""; } + print "\n"; + $count++; +} +print "
TitleStatusReview StatusTech StatusMaintainedLicenseClassFormatDTDPub DateLast UpdateTickle DateURL
$sql
"; + print a({href=>"document_edit.pl?doc_id=$doc_id"},"$title"); + if ( $url ne "" ) { print "   Go!" } + print "$pub_status_name$review_status_name$tech_review_status_name$maintained$license$class$format$dtd$pub_date$last_update$tickle_date$tickle_date$url
\n"; + +print "

Count: $count"; + +print "


"; + +print "

New Document

\n"; + +print "

\n"; +print "\n"; +print "\n"; +print "\n"; + +print "\n"; + +print "\n"; + +print "\n"; + +print "\n"; + +print "\n"; +print "
Title:
Status:"; +print "\n"; +print "
Class:"; +print "\n"; +print "
Format:"; +print "\n"; +print "
DTD:"; +print "\n"; +print "
\n"; + +print end_html; + diff --git a/LDP/lampadas/www/document_maintainer_add.pl b/LDP/lampadas/www/document_maintainer_add.pl new file mode 100755 index 00000000..0153f372 --- /dev/null +++ b/LDP/lampadas/www/document_maintainer_add.pl @@ -0,0 +1,54 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$dbmain = "ldp"; +@row; + +# Read parameters +$caller = param('caller'); +$doc_id = param('doc_id'); +$maintainer_id = param('maintainer_id'); +$active = param('active'); +$role = param('role'); +$email = param('email'); + +$conn=Pg::connectdb("dbname=$dbmain"); + +#print header; +#print start_html; +$sql = "INSERT INTO document_maintainer(doc_id, maintainer_id, active, role, email) VALUES ($doc_id, $maintainer_id, '$active', '$role', '$email' )"; +$result=$conn->exec($sql); + +#update the maintained field in the document record +$sql = "SELECT COUNT(*) as active_maintainers FROM document_maintainer WHERE doc_id=$doc_id AND (role='Author' OR role='Co-Author' OR role='Maintainer') AND active='t'"; +$result=$conn->exec($sql); +@row = $result->fetchrow; +$active_maintainers = $row[0]; +if ( $active_maintainers > 0 ) { $maintained = "t" } else { $maintained = "f" } +$sql = "UPDATE document SET maintained='$maintained' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); + +#print header; +#print start_html; +#print $sql; +#print end_html; +#exit; + +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/document_maintainer_save.pl b/LDP/lampadas/www/document_maintainer_save.pl new file mode 100755 index 00000000..51723579 --- /dev/null +++ b/LDP/lampadas/www/document_maintainer_save.pl @@ -0,0 +1,62 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$dbmain = "ldp"; +@row; + +# Read parameters +$caller = param('caller'); +$doc_id = param('doc_id'); +$maintainer_id = param('maintainer_id'); +$active = param('active'); +$role = param('role'); +$email = param('email'); +$chkDel = param('chkDel'); + +$conn=Pg::connectdb("dbname=$dbmain"); + +#print header; +#print start_html; +if ( $chkDel eq 'on' ) { + $sql = "DELETE FROM document_maintainer WHERE doc_id = $doc_id and maintainer_id = $maintainer_id"; + $result=$conn->exec($sql); +} +else { + $sql = "UPDATE document_maintainer SET active = '$active' WHERE doc_id = $doc_id and maintainer_id = $maintainer_id"; + $result=$conn->exec($sql); + $sql = "UPDATE document_maintainer SET role = '$role' WHERE doc_id = $doc_id and maintainer_id = $maintainer_id"; + $result=$conn->exec($sql); + $sql = "UPDATE document_maintainer SET email = '$email' WHERE doc_id = $doc_id and maintainer_id = $maintainer_id"; + $result=$conn->exec($sql); + +# print "$sql
\n"; +# print "active_maintainers: $active_maintainers\n"; +} + +#update the maintained field in the document record +$sql = "SELECT COUNT(*) as active_maintainers FROM document_maintainer WHERE doc_id=$doc_id AND (role='Author' OR role='Co-Author' OR role='Maintainer') AND active='t'"; +$result=$conn->exec($sql); +@row = $result->fetchrow; +$active_maintainers = $row[0]; +if ( $active_maintainers > 0 ) { $maintained = "t" } else { $maintained = "f" } +$sql = "UPDATE document SET maintained='$maintained' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); + +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/document_note_add.pl b/LDP/lampadas/www/document_note_add.pl new file mode 100755 index 00000000..5434b180 --- /dev/null +++ b/LDP/lampadas/www/document_note_add.pl @@ -0,0 +1,35 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$dbmain = "ldp"; +@row; + +# Read parameters +$doc_id = param('doc_id'); + +$username = $query->remote_user(); + +$note = param('note'); +$note =~ s/\'/\'\'/; + +$conn=Pg::connectdb("dbname=$dbmain"); +$sql = "INSERT INTO notes (doc_id, date_entered, username, notes) values ($doc_id, now(), '$username', '$note')"; +$result=$conn->exec($sql); + +print $query->redirect("document_edit.pl?doc_id=$doc_id"); diff --git a/LDP/lampadas/www/document_save.pl b/LDP/lampadas/www/document_save.pl new file mode 100755 index 00000000..7cecd743 --- /dev/null +++ b/LDP/lampadas/www/document_save.pl @@ -0,0 +1,101 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$dbmain = "ldp"; +@row; + +# Read parameters +$doc_id = param('doc_id'); +$title = param('title'); +$title =~ s/\'/\'\'/; +$filename = param('filename'); +$filename =~ s/\'/\'\'/; +$class = param('class'); +$format = param('format'); +$dtd = param('dtd'); +$dtd_version = param('dtd_version'); +$version = param('version'); +$version =~ s/\'/\'\'/; +$last_update = param('last_update'); +$url = param('url'); +$isbn = param('isbn'); +$pub_status = param('pub_status'); +$review_status = param('review_status'); +$tickle_date = param('tickle_date'); +$ref_url = param('ref_url'); +$pub_date = param('pub_date'); +$tech_review_status = param('tech_review_status'); +$maintained = param('maintained'); +$license = param('license'); + +$conn=Pg::connectdb("dbname=$dbmain"); + +#This is horribly inefficient, but allows partial saves. +#For our volume, it hardly matters. +$sql = "UPDATE document SET title='$title' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET filename='$filename' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET class='$class' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET format='$format' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET dtd='$dtd' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET dtd_version='$dtd_version' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET version='$version' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET last_update='$last_update' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET url='$url' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET isbn='$isbn' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET pub_status='$pub_status' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET review_status='$review_status' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); + +if ( $tickle_date eq '' ) +{ $sql = "UPDATE document SET tickle_date=NULL WHERE doc_id=$doc_id"; } +else +{ $sql = "UPDATE document SET tickle_date='$tickle_date' WHERE doc_id=$doc_id"; } +$result=$conn->exec($sql); + +$sql = "UPDATE document SET ref_url='$ref_url' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET pub_date='$pub_date' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET tech_review_status='$tech_review_status' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET maintained='$maintained' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); +$sql = "UPDATE document SET license='$license' WHERE doc_id=$doc_id"; +$result=$conn->exec($sql); + +print $query->redirect("document_edit.pl?doc_id=$doc_id"); + + +print header; +print start_html; +print "

$sql"; +print end_html; +exit; + diff --git a/LDP/lampadas/www/document_topic_add.pl b/LDP/lampadas/www/document_topic_add.pl new file mode 100755 index 00000000..8259faae --- /dev/null +++ b/LDP/lampadas/www/document_topic_add.pl @@ -0,0 +1,38 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$dbmain = "ldp"; +@row; + +# Read parameters +$caller = param('caller'); +$doc_id = param('doc_id'); +$topic = param('topic'); + +@topic_subtopic_num = split /\./, $topic; +$topic_num = $topic_subtopic_num[0]; +$subtopic_num = $topic_subtopic_num[1]; + +$sql = "INSERT INTO document_topic (doc_id, topic_num, subtopic_num) VALUES ($doc_id, $topic_num, $subtopic_num)"; + +$conn=Pg::connectdb("dbname=$dbmain"); +$result=$conn->exec($sql); + +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/document_topic_del.pl b/LDP/lampadas/www/document_topic_del.pl new file mode 100755 index 00000000..eb3d54a2 --- /dev/null +++ b/LDP/lampadas/www/document_topic_del.pl @@ -0,0 +1,35 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$dbmain = "ldp"; +@row; + +# Read parameters +$doc_id = param('doc_id'); +$topic_num = param('topic_num'); +$subtopic_num = param('subtopic_num'); +$caller = param('caller'); + +$conn=Pg::connectdb("dbname=$dbmain"); + +$sql = "DELETE FROM document_topic WHERE doc_id=$doc_id AND topic_num=$topic_num AND subtopic_num=$subtopic_num"; +$result=$conn->exec($sql); + +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/document_vote_save.pl b/LDP/lampadas/www/document_vote_save.pl new file mode 100755 index 00000000..89539daf --- /dev/null +++ b/LDP/lampadas/www/document_vote_save.pl @@ -0,0 +1,38 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} + +$dbmain = "ldp"; +@row; + +$conn=Pg::connectdb("dbname=$dbmain"); + +$doc_id = param('doc_id'); +$vote = param('vote'); +$username = $query->remote_user(); + +$sql = "DELETE FROM doc_vote WHERE doc_id=$doc_id AND username='$username'"; +$result=$conn->exec($sql); + +$sql = "INSERT INTO doc_vote(doc_id, username, vote) values ($doc_id, '$username', $vote)"; +$result=$conn->exec($sql); + +$conn->exec($sql); + +print $query->redirect("document_edit.pl?doc_id=$doc_id"); + diff --git a/LDP/lampadas/www/editor_add.pl b/LDP/lampadas/www/editor_add.pl new file mode 100755 index 00000000..a9170e84 --- /dev/null +++ b/LDP/lampadas/www/editor_add.pl @@ -0,0 +1,51 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} + +$dbmain = "ldp"; +@row; + +$conn=Pg::connectdb("dbname=$dbmain"); + +# Read parameters +$caller = param('caller'); +$editor_name = param('editor_name'); +$editor_name =~ s/\'/\'\'/; +$email = param('email'); + +$sql = "SELECT max(editor_id) from editor"; +$result=$conn->exec($sql); +@row = $result->fetchrow; +$editor_id = $row[0] + 1; + +$sql = "INSERT INTO editor(editor_id, editor_name, email) VALUES ($editor_id, '$editor_name', '$email')"; + +#print header; +#print start_html; +#print "

$editor_name"; +#print "

$email"; +#print "

$editor_id"; +#print "

$sql"; +#print end_html; +#exit; + +$conn->exec($sql); + +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/editor_edit.pl b/LDP/lampadas/www/editor_edit.pl new file mode 100755 index 00000000..2bca07b8 --- /dev/null +++ b/LDP/lampadas/www/editor_edit.pl @@ -0,0 +1,84 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; +$query = new CGI; + +$dbmain = "ldp"; +@row; + +# Read parameters +$editor_id = param('editor_id'); + +# Load data from db and call edit form +$conn=Pg::connectdb("dbname=$dbmain"); + + +$result = $conn->exec("SELECT editor_id, editor_name, email, notes from editor where editor_id = $editor_id"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus; + +@row = $result->fetchrow; + +# Load from db +$editor_id = $row[0]; +$editor_name = $row[1]; +$editor_name =~ s/\s*$//; +$email = $row[2]; +$email =~ s/\s*$//; +$notes = $row[3]; +$notes =~ s/\s*$//; + + +print header(-expires=>'now'); + +print "$editor_name"; +print ""; +print ""; + +print "

$editor_name

\n"; + +print "

Index \n"; +print "Topics \n"; +print "Documents \n"; +print "Maintainers "; +print "Editors"; + +print "

ID: $editor_id"; +print "

"; +print ""; +printf "

\n"; +print ''; +print ''; +print "\n"; +print ""; +print "
Name:
Email:
Notes:
"; +print "

"; + +$docs_result = $conn->exec("SELECT document.doc_id, document.title, class, pub_status.pub_status_name, document_editor.editor_role, document_editor.active FROM document_editor, document, pub_status WHERE document_editor.editor_id = $editor_id AND document.pub_status = pub_status.pub_status AND document_editor.doc_id = document.doc_id ORDER BY document.title"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $docs_result->resultStatus; + +print "\n

Documents

\n"; +printf "

"; +while (@row = $docs_result->fetchrow) { + $doc_id = $row[0]; + $title = $row[1]; + $class = $row[2]; + $pub_status_name = $row[3]; + $editor_role = $row[4]; + $active = $row[5]; + if ( $active eq 't' ) { $active = "Active" } else { $active = "Inactive" } + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print ""; + print "\n"; +} +printf "
TitleClassDoc StatusRoleActive
$title$class$pub_status_name$editor_role$active
\n"; + +print end_html; + diff --git a/LDP/lampadas/www/editor_list.pl b/LDP/lampadas/www/editor_list.pl new file mode 100755 index 00000000..e5c6fc13 --- /dev/null +++ b/LDP/lampadas/www/editor_list.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$dbmain='ldp'; +@row; +$count = 0; + +# Connect and load the tuples +$conn=Pg::connectdb("dbname=$dbmain"); +$result=$conn->exec("SELECT editor_id, editor_name, email FROM editor ORDER BY editor_name"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus; + +# print the page +print header(-expires=>'now'); +print "LDP Editors"; +print ""; +print ""; +print ""; + +print "

LDP Editors

\n"; + +print "

Index \n"; +print "Topics \n"; +print "Documents \n"; +print "Maintainers \n"; + +print "

\n"; +while (@row = $result->fetchrow) { + $editor_id = $row[0]; + $editor_name = $row[1]; + if ( $editor_name eq "" ) { $editor_name = 'J. Doe' } + $email = $row[2]; + print ""; + print ""; + $count++; +} +print "
"; + print a({href=>"editor_edit.pl?editor_id=$editor_id"},"$editor_name"); + print "
\n"; + +print "

Count: $count"; + +print "


\n"; + +print "

New Editor

\n"; + +print "

\n"; +print "\n"; +print "\n"; +print "\n"; +print "\n"; +print "\n"; +print "
Name:
Email:
\n"; + +print end_html; + diff --git a/LDP/lampadas/www/editor_save.pl b/LDP/lampadas/www/editor_save.pl new file mode 100755 index 00000000..177ac8b4 --- /dev/null +++ b/LDP/lampadas/www/editor_save.pl @@ -0,0 +1,36 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} + +$dbmain = "ldp"; +@row; + +# Read parameters +$editor_id = param('editor_id'); +$editor_name = param('editor_name'); +$editor_name =~ s/\'/\'\'/; +$email = param('email'); +$notes = param('notes'); +$notes =~ s/\'/\'\'/; + +$conn=Pg::connectdb("dbname=$dbmain"); +$sql = "UPDATE editor SET editor_name='$editor_name', email='$email', notes='$notes' WHERE editor_id = $editor_id"; +$result=$conn->exec($sql); +print $query->redirect("editor_edit.pl?editor_id=$editor_id"); + diff --git a/LDP/lampadas/www/maintainer_add.pl b/LDP/lampadas/www/maintainer_add.pl new file mode 100755 index 00000000..e6d4a5a3 --- /dev/null +++ b/LDP/lampadas/www/maintainer_add.pl @@ -0,0 +1,50 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$conn=Pg::connectdb("dbname=$dbmain"); + +$dbmain = "ldp"; +@row; + +# Read parameters +$caller = param('caller'); +$maintainer_name = param('maintainer_name'); +$maintainer_name =~ s/\'/\'\'/; +$email = param('email'); + +$sql = "SELECT max(maintainer_id) from maintainer"; +$result=$conn->exec($sql); +@row = $result->fetchrow; +$maintainer_id = $row[0] + 1; + +$sql = "INSERT INTO maintainer(maintainer_id, maintainer_name, email) VALUES ($maintainer_id, '$maintainer_name', '$email')"; +$conn->exec($sql); + +#print header; +#print start_html; +#print "

$maintainer_name"; +#print "

$email"; +#print "

$maintainer_id"; +#print "

$sql"; +#print end_html; +#exit; + + +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/maintainer_edit.pl b/LDP/lampadas/www/maintainer_edit.pl new file mode 100755 index 00000000..f2549f44 --- /dev/null +++ b/LDP/lampadas/www/maintainer_edit.pl @@ -0,0 +1,87 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$dbmain = "ldp"; +@row; + +# Read parameters +$maintainer_id = param('maintainer_id'); + +# Load data from db and call edit form +$conn=Pg::connectdb("dbname=$dbmain"); + + +$result = $conn->exec("SELECT maintainer_id, maintainer_name, email from maintainer where maintainer_id = $maintainer_id"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus; + +@row = $result->fetchrow; + +# Load from db +$maintainer_id = $row[0]; +$maintainer_name = $row[1]; +$maintainer_name =~ s/\s*$//; +$email = $row[2]; +$email =~ s/\s*$//; + +print header(-expires=>'now'); + +print "$maintainer_name"; +print ""; +print ""; + +print "

$maintainer_name

\n"; + +print "

Index \n"; +print "Documents \n"; +print "Maintainers \n"; +print "Editors \n"; + +print "

ID: $maintainer_id"; +print "

"; +printf "

\n"; +print ""; +printf "

\n"; +print 'Name:
'; +printf "

\n"; +print 'Email:
'; +printf "

\n"; +print ""; +print "

"; + +$docs_result = $conn->exec("SELECT document.doc_id, document.title, class, pub_status.pub_status_name, document_maintainer.role, document_maintainer.active, document_maintainer.email FROM document_maintainer, document, pub_status WHERE document_maintainer.maintainer_id = $maintainer_id AND document.pub_status = pub_status.pub_status AND document_maintainer.doc_id = document.doc_id ORDER BY document.title"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $docs_result->resultStatus; + +print "

Documents

\n"; +printf "

"; +while (@row = $docs_result->fetchrow) { + $doc_id = $row[0]; + $title = $row[1]; + $class = $row[2]; + $pub_status_name = $row[3]; + $role = $row[4]; + $active = $row[5]; + if ( $active eq 't' ) { $active = "Active" } else { $active = "Inactive" } + $feedback_email = $row[6]; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print ""; + print "\n"; +} +printf "
TitleClassDoc StatusRoleActiveFeedback Email
$title$class$pub_status_name$role$active$feedback_email
\n"; + + + + +print end_html; + diff --git a/LDP/lampadas/www/maintainer_list.pl b/LDP/lampadas/www/maintainer_list.pl new file mode 100755 index 00000000..d5555498 --- /dev/null +++ b/LDP/lampadas/www/maintainer_list.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$dbmain='ldp'; +@row; +$count = 0; + +# Connect and load the tuples +$conn=Pg::connectdb("dbname=$dbmain"); +$result=$conn->exec("SELECT maintainer_id, maintainer_name, email FROM maintainer ORDER BY maintainer_name"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus; + +# print the page +print header(-expires=>'now'); +print "LDP Maintainers"; +print ""; +print ""; +print ""; + +print "

LDP Maintainers

\n"; + +print "

Index \n"; +print "Topics \n"; +print "Documents \n"; +print "Editors \n"; + +print "

\n"; +while (@row = $result->fetchrow) { + $maintainer_id = $row[0]; + $maintainer_name = $row[1]; + if ( $maintainer_name eq "" ) { $maintainer_name = 'J. Doe' } + $email = $row[2]; + print ""; + print ""; + $count++; +} +print "
"; + print a({href=>"maintainer_edit.pl?maintainer_id=$maintainer_id"},"$maintainer_name"); + print "
\n"; + +print "

Count: $count"; + +print "


\n"; + +print "

New Maintainer

\n"; + +print "

\n"; +print "\n"; +print "\n"; +print "\n"; +print "\n"; +print "\n"; +print "
Name:
Email:
\n"; + +print end_html; + diff --git a/LDP/lampadas/www/maintainer_save.pl b/LDP/lampadas/www/maintainer_save.pl new file mode 100755 index 00000000..4a243f46 --- /dev/null +++ b/LDP/lampadas/www/maintainer_save.pl @@ -0,0 +1,33 @@ +#! /usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$query = new CGI; + +$username = $query->remote_user(); +if ( $username eq "guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} +$dbmain = "ldp"; +@row; + +# Read parameters +$maintainer_id = param('maintainer_id'); +$maintainer_name = param('maintainer_name'); +$maintainer_name =~ s/\'/\'\'/; +$email = param('email'); + +$conn=Pg::connectdb("dbname=$dbmain"); +$sql = "UPDATE maintainer SET maintainer_name='$maintainer_name', email='$email' WHERE maintainer_id = $maintainer_id"; +$result=$conn->exec($sql); +print $query->redirect("maintainer_edit.pl?maintainer_id=$maintainer_id"); + diff --git a/LDP/lampadas/www/permission.pl b/LDP/lampadas/www/permission.pl new file mode 100755 index 00000000..943d758c --- /dev/null +++ b/LDP/lampadas/www/permission.pl @@ -0,0 +1,12 @@ +$username = $query->remote_user(); +if ( $username="guest") { + print header; + print "No Permission\n"; + print "\n"; + print "\n"; + print "

No Permission

\n"; + print "You do not have permission to modify the database.\n"; + print "

You need to get an account before you can modify data.\n"; + print end_html; + exit; +} diff --git a/LDP/lampadas/www/topic_list.pl b/LDP/lampadas/www/topic_list.pl new file mode 100755 index 00000000..249b8582 --- /dev/null +++ b/LDP/lampadas/www/topic_list.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl + +use CGI qw(:standard); +use Pg; + +$dbmain='ldp'; +@row; +$last_topic_num = 0; +$last_subtopic_num = 0; + +# Connect and load the tuples +$conn=Pg::connectdb("dbname=$dbmain"); +$sql = "SELECT topic.topic_num, topic.topic_name, subtopic.subtopic_num, subtopic.subtopic_name, document.doc_id, document.title, topic_description, subtopic_description FROM topic, subtopic, document_topic, document WHERE topic.topic_num = subtopic.topic_num and topic.topic_num = document_topic.topic_num and subtopic.subtopic_num = document_topic.subtopic_num and document_topic.doc_id = document.doc_id ORDER BY topic_num, subtopic_num, title"; + +$result=$conn->exec("$sql"); +die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus; + +# print the page +#print header(-expires=>'now'); +print header; +print "\n"; +print "LDP Document Database\n"; +print "\n"; +print "\n"; +print "\n"; + +print "

Topic Listing

\n"; + +print "

Index \n"; +print "Documents \n"; +print "Maintainers\n"; +print "Editors\n"; + +while (@row = $result->fetchrow) { + $topic_num = $row[0]; + $topic_name = $row[1]; + $subtopic_num = $row[2]; + $subtopic_name = $row[3]; + $doc_id = $row[4]; + $title = $row[5]; + $topic_description = $row[6]; + $subtopic_description = $row[7]; + + if ( $topic_num != $last_topic_num ) { + print "


"; + print "

$topic_num $topic_name

\n"; + print "
$topic_description
\n"; + } + if ( $subtopic_num != $last_subtopic_num ) { + print "

$topic_num.$subtopic_num $subtopic_name

\n"; + print "
$subtopic_description
\n"; + } + print a({href=>"document_edit.pl?doc_id=$doc_id"},"$title"); + print "
\n"; + + $last_topic_num = $topic_num; + $last_subtopic_num = $subtopic_num; +} + +print end_html; +