4 # Lukas Mueller, April 6, 2005
8 use CXGN
::DB
::Connection
;
11 use CXGN
::People
::Forum
;
15 # create a page object
17 my $page = CXGN
::Page
-> new
( "Delete Post", "Lukas");
18 my $dbh = CXGN
::DB
::Connection
->new();
20 # check if there is a valid login going on
22 my $user_id = CXGN
::Login
->new($dbh)->verify_session();
24 # get the page arguments
28 topic_id: The id of the topic the post to be deleted belongs to.
29 post_id: The id of the post to be deleted.
30 confirm: a boolean that will ask for confirmation before deleting.
31 refering page: The page that called this script, so that we can
32 provide a link back to that page. This will no always be equal to the REFERER that
33 one can obtain from the Apache object!
37 my ($post_id, $confirm, $refering_page, $topic_id) = $page -> get_arguments
("post_id", "confirm", "refering_page", "topic_id");
39 my $sp_person_id = "";
41 my $post_person_id = undef;
42 my $post_text = undef;
46 $post = CXGN
::People
::Forum
::Post
-> new
($dbh, $post_id);
47 my $user = CXGN
::People
::Person
->new($dbh, $user_id);
49 $post_person_id = $post -> get_person_id
();
51 $post_text = $post -> get_post_text
();
53 my $post_person = CXGN
::People
::Person
-> new
($dbh, $post_person_id);
54 my $sp_person_id = $post_person -> get_sp_person_id
();
55 my $post_person_last_name = $post_person -> get_last_name
();
56 my $post_person_first_name = $post_person -> get_first_name
();
60 print "<h4>No such post</h4>\n<br />
61 The post you are trying to delete does not exist.
62 It may have been deleted previously or never existed.
63 <br /><br /><br /><br />\n";
67 elsif (($sp_person_id && ($user_id == $sp_person_id)) || $user->get_user_type() eq "curator") {
73 <h4>Confirm user comment delete</h4>
74 Comment \# $post_id from user <b>$post_person_first_name $post_person_last_name</b><br /><br />
75 Are you sure you want to delete this post? <br /><br />
77 <div class="boxbgcolor2">$post_text</div>
80 <form action="forum_post_delete.pl">
81 <input type="hidden" name="confirm" value="1" />
82 <input type="hidden" name="post_id" value="$post_id" />
83 <input type="hidden" name="refering_page" value="$refering_page" />
84 <input type="hidden" name="topic_id" value="$topic_id" />
85 <input type="submit" value="Delete" /><br /><br />
86 <a href="$refering_page">Go back</a>
95 my $rows = $post->delete();
99 print "<h4>Your post has been deleted.</h4>\n<br /><br /><br />";
101 print "<a href=\"$refering_page\">Go back to user comments on the detail page.</a><br /><br />\n";
106 print "<h4>ERROR</h4><h4>An error occurred during deletion. The post_id supplied may be invalid.</h4>";
115 print "<h4>POST CAN'T BE DELETED!</h4>\n";
116 print "<h4>Either this post_id does not exist anymore or you are not the owner of post $post_id. Only the posters can delete their own posts. Sorry!</h4>\n";
117 print "<br /><br /><a href=\"$refering_page\">Return to user comments.</a><br /><br />\n";
126 print "<h4>No post id was supplied. Nothing was deleted.</h4>\n";