PDA

View Full Version : Deleting thread when there's reply


warpeditor
06-06-2003, 05:38 PM
Hi,

Right now, our registered members can delete their own post and thread they started. However, is it possible to make registered members CAN delete post but CANNOT delete thread when there's reply?

Is there any hack for this? I couldn't find one.

MetroSports82
06-06-2003, 07:45 PM
i've tried to come up with something similar to this in the past, but gave up after coming up unsuccessful. :( but, thats a very good idea there warpeditor! especially when you want to avoid having users delete a large thread, that might have alot of replies, (for intent purpose to get back at someone, or whatever). but on the other hand, having them the access to delete it, if it was a thread that was mistakenly created, or what not. and also, just to quickly add to this idea if you will. there should be a way to have it selectable. say after 5 or 10 replies, that a thread is allowed to be deleted by the thread starter, from deleting the first post. after that number, it should then be disabled. that would be nice. ;)

warpeditor
06-07-2003, 01:53 AM
Thanks for reply.

One of our registered member deleted all the thread he created because he got upset with others reply/comments about his post. There even was some thread with 200+ replies but all gone. Then I thought this could be a good idea.

Any ideas?

MetroSports82
06-08-2003, 02:50 PM
ok, tell ya what.. i'm gonna try this again, even thought i came up flat out my face the first time. i'll let you know if i get anything to work properly, with the correct functions. in the meantime, this is the block of code that i will be working on, to see what needs to be tweaked around, to get this feature working. ;)

- editpost.php -
// ############################### start update post ###############################
if ($HTTP_POST_VARS['action']=="updatepost") {

// check for message
if ($message=="") {
eval("standarderror(\"".gettemplate("error_nosubject")."\");");
exit;
}

// decode check boxes
$parseurl=iif($parseurl=="yes",1,0);
$email=iif($email=="yes",1,0);
$allowsmilie=iif($disablesmilies=="yes",0,1);
$signature=iif($signature=="yes",1,0);

$editedbysql="";
if ($showeditedby and $postinfo[dateline]<(time()-($noeditedbytime*60)) and !($getperms[ismoderator] and !$showeditedbyadmin)) {
$editedbysql=",edituserid='$bbuserinfo[userid]',editdate='".time()."'";
}

// check max images
if ($maximages!=0) {
$parsedmessage=bbcodeparse($message,$threadinfo['forumid'],$allowsmilie);
if (countchar($parsedmessage,"<img")>$maximages) {
eval("standarderror(\"".gettemplate("error_toomanyimages")."\");");
exit;
}
}

if (!isset($iconid) or $iconid=="") {
$iconid=0;
}
$iconid=intval($iconid);

if ($parseurl) {
$message=parseurl($message);
}

$attachmentsql="";
if ($postinfo[attachmentid]!=0) {
// check attachment status
// keep, delete, update
if (trim($attachmentaction)=="delete") {
$attachmentsql=",attachmentid=0";
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
updatethreadcount($threadinfo[threadid]);
}
if (trim($attachmentaction)=="new") {
// sort attachement
if (is_array($HTTP_POST_FILES)) {
$attachment = $HTTP_POST_FILES['attachment']['tmp_name'];
$attachment_name = $HTTP_POST_FILES['attachment']['name'];
$attachment_size = $HTTP_POST_FILES['attachment']['size'];
}
if (trim($attachment)!="none" and trim($attachment)!="" and trim($attachment_name)!="") {
$attachmentid=acceptupload($foruminfo[moderateattach]);
$attachmentsql=",attachmentid='$attachmentid'";
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
}
}
}

// remove sessionhash from urls:
$message = stripsession($message);

$title=censortext($title);
$message=censortext($message);

if (strlen($message)>$postmaxchars and $postmaxchars!=0) {
eval("standarderror(\"".gettemplate("error_toolong")."\");");
}

// find out if first post
$getpost=$DB_site->query_first("SELECT postid FROM post WHERE threadid=$threadinfo[threadid] ORDER BY dateline LIMIT 1");
if ($getpost[postid]==$postid) {
$isfirst=1;
} else {
$isfirst=0;
}
if ($isfirst and $title!="" and $postinfo[dateline]+$editthreadtitlelimit*60>time()) {
$DB_site->query("UPDATE thread SET title='".addslashes(htmlspecialchars($title))."', iconid=".intval($iconid)." WHERE threadid=$threadinfo[threadid]");
//$title="";
}

if ($email) {
if (!$checkid=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid=$postinfo[userid] AND threadid=$threadinfo[threadid]")) {
$DB_site->query("INSERT INTO subscribethread (subscribethreadid,userid,threadid) VALUES (NULL,$postinfo[userid],$threadinfo[threadid])");
} // else : already subscribed, so no need to do that again
} else {
if ($checkid=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid=$postinfo[userid] AND threadid=$threadinfo[threadid]")) {
$DB_site->query("DELETE FROM subscribethread WHERE userid=$postinfo[userid] AND threadid=$threadinfo[threadid]");
} // else : already unsubscribed, so no need to unsubscribe
}

$DB_site->query("UPDATE post SET title='".addslashes(htmlspecialchars($title))."',pagetext='".addslashes($message)."',allowsmilie='$allowsmilie',showsignature='$signa ture',iconid='$iconid'$editedbysql$attachmentsql WHERE postid='$postid'");
unindexpost($postid);
indexpost($postid);

eval("standardredirect(\"".gettemplate("redirect_editthanks")."\",\"showthread.php?s=$session[sessionhash]&postid=$postid#post$postid\");");
}

if ($action=="deletepost") {
if ($deletepost=="yes") {
//get first post in thread
$getfirst=$DB_site->query_first("SELECT postid,dateline FROM post WHERE threadid='$threadid' ORDER BY dateline LIMIT 1");
if ($getfirst[postid]==$postid) {
// delete thread
if ($getperms[candeletethread]) {
deletethread($threadinfo[threadid],$foruminfo[countposts]);
updateforumcount($threadinfo[forumid]);
eval("standardredirect(\"".gettemplate("redirect_deletethread")."\",\"forumdisplay.php?s=$session[sessionhash]&forumid=$threadinfo[forumid]\");");
} else {
show_nopermission();
}
} else {
//delete just this post
$foruminfo=getforuminfo($threadinfo[forumid]);
deletepost($postid,$foruminfo[countposts],$threadinfo[threadid]);

updatethreadcount($threadinfo[threadid]);
updateforumcount($threadinfo[forumid]);

eval("standardredirect(\"".gettemplate("redirect_deletepost")."\",\"showthread.php?s=$session[sessionhash]&threadid=$threadinfo[threadid]\");");
}
} else {
eval("standardredirect(\"".gettemplate("redirect_nodelete")."\",\"showthread.php?s=$session[sessionhash]&postid=$postid#post$postid\");");
}
}

hopefully for me anyway, the 2nd time around will be a charm. though i'm very pesimistic.. :disappointed:

Metro.

warpeditor
06-08-2003, 03:03 PM
Thanks for your interest, Metro!

Since I don't know php enough to do hack, I will just wait for you to come up with something then. Thanks again.