Evidence::showComments PHP Method

showComments() public method

public showComments ( $thread_id )
    public function showComments($thread_id)
    {
        global $reply_depth;
        $this->comments = array();
        $this->getComments($thread_id);
        $to_return = FALSE;
        if (count($this->comments) > 0) {
            $to_return = TRUE;
            foreach ($this->comments as $comment_id) {
                $this_comment = new Comment();
                $this_comment->populateFromId($comment_id);
                $commenter = new User();
                $commenter->populateFromId($this_comment->user_id);
                ?>
			
		<div class="comment" style="margin-left: <?php 
                echo $reply_depth * 50;
                ?>
">
		
		<a name="comment_<?php 
                echo $this_comment->id;
                ?>
" />
		
		<p class="by"><a href="<?php 
                echo $base_URL;
                ?>
profile/<?php 
                echo $commenter->username;
                ?>
"><?php 
                echo $commenter->name;
                ?>
</a> <?php 
                if ($thread_id == 0) {
                    ?>
writes<?php 
                } else {
                    ?>
replies<?php 
                }
                ?>
:</p>
		
		<p class="comment"><?php 
                echo nl2br($this_comment->comment);
                ?>
</p>
		
		<p class="time"><b>Time:</b> <?php 
                echo $this_comment->created;
                ?>
</p>
		
		<p class="classification"><b>Classification:</b> <?php 
                echo $this_comment->classification;
                ?>
</p>
		
		<p class="caveat"><b>Caveat:</b> <?php 
                echo $this_comment->caveat;
                ?>
</p>
		
		
		
		<?php 
                $reply_id = rand(0, 10000000000);
                ?>
		
		<p class="replyTo"><a style="cursor: pointer;" onclick="new Effect.BlindDown(reply<?php 
                echo $reply_id;
                ?>
);">Reply</a></p>
		
		<div class="replyToThis" id="reply<?php 
                echo $reply_id;
                ?>
" style="display: none;">
		
		<form method="post" class="edit" action="add_comment_action.php">

		<input type="hidden" name="this_url" value="<?php 
                echo $_SERVER['REQUEST_URI'];
                ?>
" />
		
		<input type="hidden" name="user_id" value="<?php 
                echo $active_user->id;
                ?>
" />
		
		<input type="hidden" name="evidence_id" value="<?php 
                echo $this->id;
                ?>
" />
		
		<input type="hidden" name="project_id" value="<?php 
                echo $this->project_id;
                ?>
" />
		
		<input type="hidden" name="hypothesis_id" value="0" />
		
		<input type="hidden" name="reply_to_id" value="<?php 
                echo $this_comment->id;
                ?>
" />
		
		<p><textarea rows="8" name="comment" cols="60"></textarea></p>
		
		<p><b>Classification</b> <select name="classification">
			<option value="U">Unclassified</option>
			<option value="C">Confidential</option>
			<option value="S">Secret</option>
			<option value="TS">Top Secret</option>
		</select> <b style="padding-left: 15px;">Caveat</b> <select name="caveat">
			<option value="">(No caveat)</option>
			<option value="FOUO/AIUO">FOUO/AIUO</option>
			<option value="SI">SI</option>
			<option value="TK">TK</option>
			<option value="HCS">HCS</option>
			<option value="G">G</option>
		</select></p>
		
		<p class="submit"><input class="button" type="submit" value="Add Reply" /></p>
		
		</form>
		
		</div>


		
		</div>
			
			<?php 
                $reply_depth++;
                $this->showComments($this_comment->id);
                $reply_depth--;
            }
        }
        return $to_return;
    }

Usage Example

</a> on <b><?php 
echo $active_evidence->created;
?>
</b>.</p>





<h3 class="comments">Discuss this Evidence</h3>



<?php 
$reply_depth = 0;
if ($active_evidence->showComments(0)) {
} else {
    echo '<p><i>No comments.</i></p>';
}
?>



<form method="post" class="edit" action="add_comment_action.php">

<input type="hidden" name="this_url" value="<?php 
echo $_SERVER['REQUEST_URI'];
?>
" />

<input type="hidden" name="user_id" value="<?php