From df1f587d045d8ba9ae7c30145ff9dc24a827ae1b Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Wed, 5 Sep 2007 16:48:14 +0000
Subject: [PATCH] Comment system updates: editor and private comments now
 functional.

---
 application/models/tables/RequestComments.php |  1 +
 application/views/request/view.xhtml          | 51 +++++++++++++++----
 document_root/css/request/view.oss            |  8 ++-
 document_root/javascript/request/view.js      |  4 ++
 4 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/application/models/tables/RequestComments.php b/application/models/tables/RequestComments.php
index 0ab512e6..e2853828 100644
--- a/application/models/tables/RequestComments.php
+++ b/application/models/tables/RequestComments.php
@@ -45,6 +45,7 @@ class RequestComments extends Nmc_Db_Table
         $where = array();
         $where[] = $db->quoteInto('request = ?', $request->getPrimaryKey());
         $where[] = $db->quoteInto('postTime > ?', $time->getTimestamp());
+        $where[] = $db->quoteInto('visibility = ?', 'global');
         $where = implode(' AND ', $where);
         $rowset = $this->fetchAll($where, $order, $count, $offset);
         return $rowset;
diff --git a/application/views/request/view.xhtml b/application/views/request/view.xhtml
index 0c2bb23d..9e22c6cc 100644
--- a/application/views/request/view.xhtml
+++ b/application/views/request/view.xhtml
@@ -92,11 +92,13 @@
         <div class="tabBar">
             <a href="#" id="commentsTab">Comments</a>
             <a href="#" id="editorCommentsTab">Editor Comments</a>
+            <a href="#" id="privateCommentsTab">Private Comments</a>
         </div>
+
+
         <div class="tabContent" id="commentsContent">
             <?php foreach ($this->comments as $comment) {
-                if ($comment->visibility == 'global' ||
-                    $comment->user->getPrimaryKey() == Nmc_User::getInstance()->getUser()->getPrimaryKey()) { ?>
+                if ($comment->visibility == 'global') { ?>
             <div class="comment">
                 <h3>Text:</h3>
                 <div><?php echo $comment->comment; ?></div>
@@ -105,19 +107,50 @@
 
             <form method="post" action="/Request/AddComment/<?php echo $this->request->getPrimaryKey(); ?>">
                 <div>
-                <?php echo $this->formTextarea('comment'); ?>
+                <textarea name="comment"></textarea>
                 </div>
+                <?php echo $this->formHidden('visibility', 'global'); ?>
+                <?php echo $this->formSubmit('submit', 'Add Comment'); ?>
+            </form>
+        </div>
+
+
+        <div class="tabContent" id="editorCommentsContent">
+            <?php foreach ($this->comments as $comment) {
+                if ($comment->visibility == 'editorial') { ?>
+            <div class="comment">
+                <h3>Text:</h3>
+                <div><?php echo $comment->comment; ?></div>
+            </div>
+            <?php }} ?>
+
+            <form method="post" action="/Request/AddComment/<?php echo $this->request->getPrimaryKey(); ?>">
                 <div>
-                <h3>Visibility</h3>
-                <?php echo $this->formRadio('visibility', null, null, array('self' => 'Self only', 'global' => 'Global')); ?>
+                <textarea name="comment"></textarea>
                 </div>
-                <div>
+                <?php echo $this->formHidden('visibility', 'editorial'); ?>
                 <?php echo $this->formSubmit('submit', 'Add Comment'); ?>
-                </div>
             </form>
         </div>
-        <div class="tabContent" id="editorCommentsContent">
-            EDITOR COMMENTS!
+
+
+        <div class="tabContent" id="privateCommentsContent">
+            <?php foreach ($this->comments as $comment) {
+                if ($comment->visibility == 'self' &&
+                    $comment->user->getPrimaryKey() == Nmc_User::getInstance()->getUser()->getPrimaryKey()) { ?>
+            <div class="comment">
+                <h3>Text:</h3>
+                <div><?php echo $comment->comment; ?></div>
+            </div>
+            <?php }} ?>
+
+            <form method="post" action="/Request/AddComment/<?php echo $this->request->getPrimaryKey(); ?>">
+                <div>
+                <textarea name="comment"></textarea>
+                </div>
+                <?php echo $this->formHidden('visibility', 'self'); ?>
+                <?php echo $this->formSubmit('submit', 'Add Comment'); ?>
+            </form>
         </div>
     </div>
     <?php } ?>
diff --git a/document_root/css/request/view.oss b/document_root/css/request/view.oss
index b8d7678a..0e197dda 100644
--- a/document_root/css/request/view.oss
+++ b/document_root/css/request/view.oss
@@ -77,9 +77,15 @@ div#comments {
         padding: 5px;
         background-color: #ddd;
         border: 1px solid #888;
+
+        textarea {
+            width: 95%;
+            height: 3em;
+        }
     }
 
-    #editorCommentsContent {
+    #editorCommentsContent,
+    #privateCommentsContent {
         display: none;
     }
 }
diff --git a/document_root/javascript/request/view.js b/document_root/javascript/request/view.js
index b0b88f81..b0d01824 100644
--- a/document_root/javascript/request/view.js
+++ b/document_root/javascript/request/view.js
@@ -15,14 +15,18 @@ function viewRequestSelectTab()
 {
     var commentsContent = document.getElementById('commentsContent');
     var editorCommentsContent = document.getElementById('editorCommentsContent');
+    var privateCommentsContent = document.getElementById('privateCommentsContent');
 
     commentsContent.style.display = 'none';
     editorCommentsContent.style.display = 'none';
+    privateCommentsContent.style.display = 'none';
 
     if (this.id == 'commentsTab') {
         commentsContent.style.display = 'block';
     } else if (this.id == 'editorCommentsTab') {
         editorCommentsContent.style.display = 'block';
+    } else if (this.id == 'privateCommentsTab') {
+        privateCommentsContent.style.display = 'block';
     }
 
     return false;
-- 
GitLab