Changeset 1285

Show
Ignore:
Timestamp:
12/30/06 12:45:30 (2 years ago)
Author:
jm3
Message:

split comment viewing and deletion

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • feedmelinks/comments/index.php

    r1284 r1285  
    11<?php 
    22        # $Id$ 
    3         include_once( "modules/utils.inc.php" ); 
     3        include_once( "../modules/utils.inc.php" ); 
    44        $site = getSiteUrl(); 
    55 
     
    2727                include( "$modules/header.inc.php" );  
    2828                $show_comments = true; 
    29  
    30                 if( $op == "delete" ) 
    31                         $show_comments = false; 
    3229?> 
    3330 
     
    3633                if( $who )  
    3734                        echo "Comments by and about $who"; 
    38                 else if( $op == "delete" ) 
    39                         echo "Delete comment:"; 
    4035                else 
    4136                        echo "My Comment Activity:"; 
     
    4338</h1> 
    4439<?php 
    45                 if( $op == "delete" && getOwnerForLink( $link ) == $u ) { 
    46  
    47                         $comments = get_file_safe( get_comments_file( $link, $u )); 
    48                         if( ! array_key_exists( $comment, $comments )) 
    49                                 bounceBack(); 
    50  
    51                         # cache it for displaying in any error messages 
    52                         $c = parse_comment( $comments[ $comment ]); 
    53                         echo '"' . $c["comment"] . '"' . " by " . getUserLink( $c["user"] ) . " from " . formatAsSimpleDate( $c["date"]) . " on " . getLink( $link ) . "</p>"; 
    54  
    55                         if( $debug ) 
    56                                 echo "<p>comment #$comment</p>"; 
    57  
    58                         # back up the comment file so the deletion can be un-done if necessary 
    59                         $undo_file = get_undo_file( $u, "comment", "delete" ); 
    60                         file_append_contents( $undo_file, $link . ":" . $comments[ $comment ]); 
    61  
    62                         # remove the comment line from the array 
    63                         $new_comments = $comments; 
    64                         unset( $new_comments[ $comment ]); 
    65                         if( $debug ) { 
    66                                 echo "<pre>post deletion"; 
    67                                 print_r( $new_comments ); 
    68                         } 
    69                          
    70                         # write the modified array back into the comment file 
    71                         file_put_contents( get_comments_file($link, $u), implode( "", $new_comments )); 
    72  
    73                         # send the user back to the link page with a note that the comment was deleted 
    74                         echo bounceTo( "/$link/m/Comment+deleted.", 1 ); 
    75  
    76                 } 
    7740                if( $show_comments ) { 
    7841?> 
     
    12184                        echo "<br />\n"; 
    12285                        echo "&nbsp; &nbsp; <em>$comment</em>\n"; 
    123                         echo " &nbsp; [<a href='/comments?op=delete&link=$linkId&comment=$line_num'>delete</a>]"; 
     86                        echo " &nbsp; [" .  get_comment_delete_link( $linkId, $line_num ) . "]"; 
    12487 
    12588                        echo "<br />\n"; 
     
    224187                        echo "<br />\n"; 
    225188                        echo "&nbsp; &nbsp; <em>$comment</em>\n"; 
    226                         echo " &nbsp; [<a href='/comments?op=delete&link=$linkId&comment=$line_num'>delete</a>]"; 
    227                         echo "<br />\n"; 
    228                         echo "<br />\n"; 
     189                        echo " &nbsp; " .  get_comment_delete_link( $linkId, $c - 1 ); 
     190                        echo "<br />\n<br />\n"; 
    229191 
    230192                        $c++;