View only my comments.
Permalink
August 22, 2014 at 6:16 PM
Can anyone give me an idea of how to make my guestbook/comments only show the ones I post?
I am wanting a form of note keeping per user for Church sermon posts and it needs to only show comments by the current member logged in.
Currently it shows a list of all comments by every member that posts a comment.
<?php defined ( 'C5_EXECUTE' ) or die ( "Access Denied." ) ; ?>
<?php $c = Page:: getCurrentPage ( ) ; ?>
<h4 class="guestBook-title"><?php echo $controller -> title ?> </h4>
<?php if ( $invalidIP ) { ?>
<div class="ccm-error"><p><?php echo $invalidIP ?> </p></div>
<?php } ?>
<?php
$u = User:: getByUserID ( $userID ) ;
if ( ! $dateFormat ) {
$dateFormat = t( 'M jS, Y' ) ;
}
$posts = $controller -> getEntries ( ) ;
$bp = $controller -> getPermissionObject ( ) ;
$dh = Loader:: helper ( 'date' ) ;
foreach ( $posts as $p ) { ?>
<?php defined ( 'C5_EXECUTE' ) or die ( "Access Denied." ) ; ?>
<?php $c = Page:: getCurrentPage ( ) ; ?>
<h4 class="guestBook-title"><?php echo $controller -> title ?> </h4>
<?php if ( $invalidIP ) { ?>
<div class="ccm-error"><p><?php echo $invalidIP ?> </p></div>
<?php } ?>
<?php
$u = User:: getByUserID ( $userID ) ;
if ( ! $dateFormat ) {
$dateFormat = t( 'M jS, Y' ) ;
}
$posts = $controller -> getEntries ( ) ;
$bp = $controller -> getPermissionObject ( ) ;
$dh = Loader:: helper ( 'date' ) ;
foreach ( $posts as $p ) { ?>
<?php if ( $p [ 'approved' ] || $bp -> canWrite ( ) ) { ?>
<div class="guestBook-entry<?php if ( $c -> getVersionObject ( ) -> getVersionAuthorUserName ( ) == $u -> getUserName ( ) ) { ?> authorPost <?php } ?> ">
<?php if ( $bp -> canWrite ( ) ) { ?>
<div class="guestBook-manage-links">
<a href="<?php echo $this -> action ( 'loadEntry' ) . "&entryID=" . $p [ 'entryID' ] ; ?> #guestBookForm"><?php echo t( 'Edit' ) ?> </a> |
<a href="<?php echo $this -> action ( 'removeEntry' ) . "&entryID=" . $p [ 'entryID' ] ; ?> " onclick="return confirm('<?php echo t( "Are you sure you would like to remove this note?" ) ?> ');"><?php echo t( 'Remove' ) ?> </a> |
<?php if ( $p [ 'approved' ] ) { ?>
<a href="<?php echo $this -> action ( 'unApproveEntry' ) . "&entryID=" . $p [ 'entryID' ] ; ?> "><?php echo t( 'Un-Approve' ) ?> </a>
<?php } else { ?>
<a href="<?php echo $this -> action ( 'approveEntry' ) . "&entryID=" . $p [ 'entryID' ] ; ?> "><?php echo t( 'Approve' ) ?> </a>
<?php } ?>
</div>
<?php } ?>
<div class="contentByLine">
<?php echo t( 'Posted by' ) ?>
<span class="userName">
<?php
if ( intval ( $p [ 'uID' ] ) ) {
$ui = UserInfo:: getByID ( intval ( $p [ 'uID' ] ) ) ;
if ( is_object ( $ui ) ) {
echo $ui -> getUserName ( ) ;
}
} else echo $p [ 'user_name' ] ;
?>
</span>
<?php echo t( 'on' ) ?>
<span class="contentDate">
<?php echo $dh -> date ( $dateFormat , strtotime ( $p [ 'entryDate' ] ) ) ; ?>
</span>
</div>
<?php echo nl2br ( $p [ 'commentText' ] ) ?>
</div>
<?php } ?>
<?php }
if ( isset ( $response ) ) { ?>
<!--- <?php echo $response ?> --->
<?php } ?>
<?php if ( $controller -> displayGuestBookForm ) { ?>
<?php
if ( ! $u -> isLoggedIn ( ) ) { ?>
<div><?php echo t( 'You must be logged in to create notes.' ) ?> <a href="<?php echo View:: url ( "/login" , "forward" , $c -> getCollectionID ( ) ) ?> "><?php echo t( 'Login' ) ?> »</a></div>
<?php } else if ( $u -> isLoggedIn ( ) ) { ?>
<a name="guestBookForm-<?php echo $controller -> bID ?> "></a>
<div id="guestBook-formBlock-<?php echo $controller -> bID ?> " class="guestBook-formBlock">
<!--- <h5 class="guestBook-formBlock-title"><?php echo t( 'My Note' ) ?> </h5> --->
<form method="post" action="<?php echo $this -> action ( 'form_save_entry' , '#guestBookForm-' . $controller -> bID ) ?> ">
<?php if ( isset ( $Entry -> entryID ) ) { ?>
<input type="hidden" name="entryID" value="<?php echo $Entry -> entryID ?> " />
<?php } ?>
<!--- <?php echo ( isset ( $errors [ 'commentText' ] ) ?"<br /><span class=\" error\" >" . $errors [ 'commentText' ] . "</span>" : "" ) ?> --->
<textarea name="commentText"><?php echo $Entry -> commentText ?>