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

comment deletion implemented with auto-return to the last page you were on, and a status message

Files:

Legend:

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

    r1285 r1286  
    2121<h1> Delete comment: </h1> 
    2222<?php 
    23                 if( getOwnerForLink( $link ) != $u ) 
    24                                bounceBack(); 
    25  
    26                 $comments = get_file_safe( get_comments_file( $link, $u )); 
     23                $owner = getOwnerForLink( $link ); 
     24                $comments = get_file_safe( get_comments_file( $link, $owner )); 
     25                 
     26                # verify that the comment being deleted exists: 
    2727                if( ! array_key_exists( $comment, $comments )) 
    2828                        bounceBack(); 
     29                 
     30                # extract the fields: 
     31                $c = parse_comment( $comments[ $comment ]); 
     32                $commenter = $c["user"]; 
     33 
     34                if( $owner != $u && $commenter != $u ) 
     35                                echo bounceBack(); 
    2936 
    3037                # cache it for displaying in any error messages 
    31                 $c = parse_comment( $comments[ $comment ]); 
    32                 echo '"' . $c["comment"] . '"' . " by " . getUserLink( $c["user"] ) . " from " . formatAsSimpleDate( $c["date"]) . " on " . getLink( $link ) . "</p>"; 
     38                echo '"' . $c["comment"] . '"' . " by " . getUserLink( $commenter ) . " from " . formatAsSimpleDate( $c["date"]) . " on " . getLink( $link ) . "</p>"; 
    3339 
    3440                if( $debug ) 
     
    3642 
    3743                # back up the comment file so the deletion can be un-done if necessary 
    38                 $undo_file = get_undo_file( $u, "comment", "delete" ); 
     44                $undo_file = get_undo_file( $u, "comment", "delete" ); # note that the COMMENTER owns the undo - not the link-owner 
    3945                file_append_contents( $undo_file, $link . ":" . $comments[ $comment ]); 
    4046 
     
    4854                 
    4955                # write the modified array back into the comment file 
    50                 file_put_contents( get_comments_file($link, $u), implode( "", $new_comments )); 
     56                file_put_contents( get_comments_file($link, $owner), implode( "", $new_comments )); 
    5157 
    5258                # send the user back to the link page with a note that the comment was deleted 
    53                 echo bounceTo( "/$link/m/Comment+deleted.", 1 ); 
     59                echo bounceTo( $from ? "$from?mesg=Comment+from+$commenter+deleted." : "/$link/m/Comment+from+$commenter+deleted.", 1 ); 
    5460?> 
    5561