PDA

View Full Version : "Close thread after posting note" hack?


12-12-2000, 03:10 PM
I wonder if it exists a vB version?
Did a search for a thread about this but had no success...

What it does:
Allows forum moderators and admins to close threads after posting.

12-13-2000, 09:03 PM
OK, as nobody answered here I started trying to do it myself and managed it to work. :)
I copied the "openclosethread" part located on postings.php and pasted it into newreply.php. Then I added a "Close Thread after posting" box on the "newreply" template.
Only... I get two "thank you" messagges at once on the same page! The first tnx is about closing the thread while the second tnx is about posting a reply to this thread. How can I get rid of the reply one?

12-14-2000, 07:23 AM
Excellent, care to post the whole hack?

12-14-2000, 10:31 AM
Aren't you interested on waiting for a fix to the double message? No? Well, here's what I did:


Open newreply.php and look for:
eval("echo standardredirect(\$bbtitle,\"".gettemplate("redirect_postthanks")."\",\"$goto\");");
}
}

and add just below:
//check valid username and password and get user id
$userid=verifyusername($username,$password);

$getthread=$DB_site->query_first("SELECT forumid FROM thread WHERE threadid=$threadid");
$forumid=$getthread[forumid];

$foruminfo=$DB_site->query_first("SELECT active,allowposting FROM forum WHERE forumid=$forumid");
if ($foruminfo[active]==0) {
echo standarderror($bbtitle,gettemplate("error_forumclosed",0));
exit;
}
$threadinfo=$DB_site->query_first("SELECT open FROM thread WHERE threadid=$threadid");

$permissions=getpermissions($bbuserid,$bbusergroup id,$forumid);
if ($permissions[canview]==0 or ($permissions[canopenclose]==0 and $permissions[canadminedit]==0)) {
$firstpostinfo=$DB_site->query_first("SELECT userid FROM post WHERE threadid=$threadid ORDER BY dateline LIMIT 1");
eval("echo standarderror(\$bbtitle,\"".gettemplate("error_nopermission")."\");");
exit;
} elseif ($permissions[canadminedit]==0) {
$firstpostinfo=$DB_site->query_first("SELECT userid FROM post WHERE threadid=$threadid ORDER BY dateline LIMIT 1");
if ($bbuserid!=$firstpostinfo[userid]) {
eval("echo standarderror(\$bbtitle,\"".gettemplate("error_nopermission")."\");");
exit;
}
}

if ($threadinfo[open]==1) {
$DB_site->query("UPDATE thread SET open=0 WHERE threadid=$threadid");
$action="closing";
} else {
$DB_site->query("UPDATE thread SET open=1 WHERE threadid=$threadid");
$action="opening";
}

eval("echo standardredirect(\$bbtitle,\"".gettemplate("redirect_openclose")."\",\"showthread.php?threadid=$threadid\");");
Save and upload the modified file.


Now open the template "newreply" and insert into the FORM code wherever you want:
<INPUT TYPE="CHECKBOX" NAME="openclosethread" VALUE="yes"><b>Close Thread after posting?</b>
Apply the new changes and you're finished. :)

AGAIN...
if someone could plz plz plz plz plz fix the double "thank you" message that would be VERY apreciated!! :D :D :D

12-14-2000, 10:53 AM
WARNING !!!!
Do NOT use this hack as it does ALWAYS close threads even if you don't check the "Close thread" checkbox !!!

Help... :mad:

12-14-2000, 09:14 PM
LOL Sorry man I'm glad I didn't test it :)

12-15-2000, 08:44 PM
Here is the code for this hack that had worked for me very well:

Open newreply.php and look for:

// redirect
if ($visible==1) {
$goto="showthread.php?postid=$postid#post$postid";
} else {
$goto="forumdisplay.php?forumid=$forumid";
}

and add just below:

if ($close) {

//check valid username and password and get user id
$userid=verifyusername($username,$password);

$getthread=$DB_site->query_first("SELECT forumid FROM thread WHERE threadid=$threadid");
$forumid=$getthread[forumid];

$foruminfo=$DB_site->query_first("SELECT active,allowposting FROM forum WHERE forumid=$forumid");
if ($foruminfo[active]==0) {
echo standarderror($bbtitle,gettemplate("error_forumclosed",0));
exit;
}
$threadinfo=$DB_site->query_first("SELECT open FROM thread WHERE threadid=$threadid");

$permissions=getpermissions($bbuserid,$bbusergroup id,$forumid);
if ($permissions[canview]==0 or ($permissions[canopenclose]==0 and $permissions[canadminedit]==0)) {
$firstpostinfo=$DB_site->query_first("SELECT userid FROM post WHERE threadid=$threadid ORDER BY dateline LIMIT 1");
eval("echo standarderror(\$bbtitle,\"".gettemplate("error_nopermission")."\");");
exit;
} elseif ($permissions[canadminedit]==0) {
$firstpostinfo=$DB_site->query_first("SELECT userid FROM post WHERE threadid=$threadid ORDER BY dateline LIMIT 1");
if ($bbuserid!=$firstpostinfo[userid]) {
eval("echo standarderror(\$bbtitle,\"".gettemplate("error_nopermission")."\");");
exit;
}
}

$DB_site->query("UPDATE thread SET open=0 WHERE threadid=$threadid");
$action="closing";

eval("echo standardredirect(\$bbtitle,\"".gettemplate("redirect_openclose")."\",\"showthread.php?threadid=$threadid\");");
exit;

}

Save and upload the modified file.

Now open the template "newreply" and under:

<BR><INPUT TYPE="CHECKBOX" NAME="signature" VALUE="yes" $signaturechecked> <B>Show Signature:</B> include your profile signature. Only registered users may have signatures.

add this:

<BR><INPUT TYPE="CHECKBOX" NAME="close" VALUE="yes"> <B>Close Thread after posting</B>


I hope that will help anyone :)

12-15-2000, 09:02 PM
Thank you very much man!! :)
It worked perfectly except... there's still a double "thank you" msg. Could tell me how to display only the "Thank you for closing the thread, Cr4z33. You are now being taken to the thread."?

12-15-2000, 09:19 PM
Mhhm...on my test-board there is no double "thank you" msg. displayed are you sure you have added the code corectly in the right place ??

12-16-2000, 06:41 AM
When you say to look for:
// redirect
if ($visible==1) {
$goto="showthread.php?postid=$postid#post$postid";
} else {
$goto="forumdisplay.php?forumid=$forumid";
}

I've another piece just under it with the obsolete tnx msg:
eval("echo standardredirect(\$bbtitle,\"".gettemplate("redirect_postthanks")."\",\"$goto\");");
}

How shall I edit it so that there's no more double messages while closing a thread? :)

12-16-2000, 08:58 AM
But in my code there is a exit; after the close msg so it shouldn't display a second thanks msg.
I don't know what your mistake is because on my board it work fine without a second msg.
Check your code again !!

12-16-2000, 10:42 AM
Originally posted by zap
But in my code there is a exit; after the close msg so it shouldn't display a second thanks msg.
I don't know what your mistake is because on my board it work fine without a second msg.
Check your code again !!

I checked every step told by you and there's nothing to do... I'm not used with PHP so dunno what's wrong/missing. :(
Anyway if you/someone else can help me here's a sample of the "thank you" msg around line 170 that I would not like to see while closing a thread:
// redirect
if ($prevpost[visible]==1) {
$goto="showthread.php?postid=$postid#post$postid";
} else {
$goto="forumdisplay.php?forumid=$forumid";
}
eval("echo standardredirect(\$bbtitle,\"".gettemplate("redirect_postthanks")."\",\"$goto\");");

} else {

$DB_site->query("INSERT INTO post (postid,threadid,title,username,userid,dateline,pa getext,allowsmilie,email,signature,ipaddress,iconi d,visible) VALUES (NULL,$threadid,'".addslashes($title)."','".addslashes($postusername)."',$userid,".time().",'".addslashes($message)."',$allowsmilie,$email,$signature,'$ipaddress',$ico nid,$visible)");
$postid=$DB_site->insert_id();


[Edited by Cr4z33 on 12-16-2000 at 07:45 AM]

12-16-2000, 12:02 PM
im not gettin double thanks.
but thanks for the hack :D