From b9db13f6a80d17b1073388b369b9f12774f9ba2d Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Thu, 21 Oct 2004 19:52:35 +0000 Subject: [PATCH] add a delete button to comments when the user is an admin --- deletecomment.php | 53 ++++++++++++++++++++++++++++++++++++++++++++ include/comments.php | 17 +++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 deletecomment.php diff --git a/deletecomment.php b/deletecomment.php new file mode 100644 index 0000000..3deda40 --- /dev/null +++ b/deletecomment.php @@ -0,0 +1,53 @@ +parentId; + +/* delete the comment from the database */ +$result = mysql_query("DELETE FROM appComments WHERE commentId = '$commentId'"); + +if (!$result) +{ + errorpage('Internal Database Access Error',mysql_error()); + exit; +} + +/* fixup the child comments so the parentId points to a valid parent comment */ +$result = mysql_query("UPDATE appComments set parentId = '$deletedParentId' WHERE parentId = '$commentId'"); +if(!$result) +{ + errorpage('Internal database error fixing up the parentId of child comments'); + exit; +} + +addmsg("Comment deleted", "green"); +redirect(apidb_fullurl("appview.php?appId=$appId&versionId=$versionId")); + +?> diff --git a/include/comments.php b/include/comments.php index 1430181..036c517 100644 --- a/include/comments.php +++ b/include/comments.php @@ -63,7 +63,22 @@ function view_app_comment($ob) echo " [reply to this] \n"; - echo "\n"; + echo "\n"; + + // delete message button, for admins + //TODO: application managers should also see this button + if(havepriv("admin")) + { + echo ""; + echo '
',"\n"; + echo "commentId>"; + echo "appId>"; + echo "versionId>
","\n"; + echo ""; + } + + echo "\n"; + echo html_frame_end(); }