View Full Version : Reason for Closing Thread
WhSox21
09-18-2004, 10:00 PM
This hack is my first released free hack.
It runs no extra queries so it should not make any load times longer.
How it works:
Once you click on Close thread in the Thread Tools menu, it will pop up with a javascript alert asking for the reason you are closing. You may click cancel or ok. If you inputted something into the box it will save it and appear at the top right above the first post.
Modifications:
1 Table Modification
3 File Modifications
5 Template Modifications
1 Template Addition
Please click install if you install this hack.
www.hackvb.com - For your custom hacks!
*Note: This was only tested on vb 3.0.3. I have not tested it on any other versions and theoretically it should work, but I'm not sure.
Boofo
09-19-2004, 02:55 PM
Interesting hack. ;) You need to fix the instructions file for the following, though.
FIND:
-------------------
<!-- / toolbar -->
-------------------
BELOW IT ADD:
-------------------
$reaons
-------------------
Shouldn't that be $reason?
* Boofo clicks the install button. ;)
WhSox21
09-19-2004, 03:04 PM
Should be fixed now... Let me know if you have any troubles. I'd like to know if everything goes smoothly.
alqafelah
09-19-2004, 03:13 PM
thanks WhSox21
Great work :)
i'm clicked install it but i have error whene i save modification of SHOWTHREAD template :
The following error occurred when attempting to evaluate this template:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in ***/***/includes/adminfunctions_template.php(3055) : eval()'d code on line 131
This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
WhSox21
09-19-2004, 03:15 PM
I forgot the biggest part of the hack. I reuploaded the instructions!
Working on that for you. I have no idea why it gave you that error. It didn't give me that error.
WhSox21
09-19-2004, 03:18 PM
I see the problem. Where it says:
<if condition="$show['closethread']">
<script type="text/javascript">
<!--
function get_reason()
{
if (document.getElementById('ao_oct').checked == true)
{
var answer = prompt('What is your reason for closing this thread?', '');
document.threadadminform.reason.value = answer;
}
}
// -->
</script>
<if condition="$show['closethread']">
It has <if condition="$show['closethread']"> at the bottom that should be </if>
I fixed that now. I also updated the install file.
alqafelah
09-19-2004, 03:28 PM
work fine .. thanks alot :)
Vivi Ornitier
09-19-2004, 04:15 PM
does it work for quick reply closin?
WhSox21
09-19-2004, 04:33 PM
What do you mean exactly? As of now it only works when you use the thread tools menu.
alqafelah
09-19-2004, 04:38 PM
back :)
Whene i not write reason it show :
Reason thread was closed:
null
can you cancel show all table of reason if not reason? OR can i put default reason ?
WhSox21
09-19-2004, 04:41 PM
How did you get that error? That should not happen. I made it so that if you did not fill in a reason it would not display. What were the steps you took to do that? Did you click cancel or ok or how did you do it?
EDIT:
Are you sure you did all the steps in the install? Are you sure you edited postings.php file correctly?
alqafelah
09-19-2004, 04:48 PM
oh, yes .. your right .. i'm clicked Cancel ! with click Ok no problem .
thanks for support me :)
WhSox21
09-19-2004, 04:52 PM
If you click cancel you shouldn't recieve that either.
alqafelah
09-19-2004, 04:58 PM
that is what happened for me !
if i not write reason and click OK it's not display anything .. if CANCEL it's display !
WhSox21
09-19-2004, 05:01 PM
What version of vb are you using? Can you post me lines 165-182 of your postings.php file? It's not doing that for me when I click cancel nor should it for you. There is something wrong with your install or something.
alqafelah
09-19-2004, 05:10 PM
i'm using 3.03 ..
i will reinstall this hack and take what you request : ( all open/close section )
// ############################### start do open / close thread ###############################
if ($_POST['do'] == 'openclosethread')
{
// permission check
if (!can_moderate($threadinfo['forumid'], 'canopenclose'))
{
$forumperms = fetch_permissions($threadinfo['forumid']);
if (!($forumperms & CANVIEW) OR !($forumperms & CANOPENCLOSE))
{
print_no_permission();
}
else
{
if (!is_first_poster($threadid))
{
print_no_permission();
}
}
}
// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($foruminfo['forumid'], $foruminfo['password']);
if ($threadinfo['open'])
{
$threadinfo['open'] = 0;
$logaction = $vbphrase['closed_thread'];
$action = $vbphrase['closed'];
}
else
{
$threadinfo['open'] = 1;
$logaction = $vbphrase['opened_thread'];
$action = $vbphrase['opened'];
$_POST['reason'] = null;
}
log_moderator_action($threadinfo, $logaction);
$DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET open = $threadinfo[open], reason = '" . addslashes($_POST[reason]) . "' WHERE threadid = $threadid");
$_REQUEST['forceredirect'] = 1;
$url = "showthread.php?$session[sessionurl]t=$threadid";
eval(print_standard_redirect('redirect_openclose') );
}
// ############################### start delete thread ###############################
WhSox21
09-19-2004, 05:12 PM
Well, that file is correct. I'll see if I can't figure something else out?
WhSox21
09-19-2004, 05:16 PM
I figured it out. It's related to IE. You can do this to simply fix the problem:
postings.php
***************
FIND:
-------------------
$action = $vbphrase['closed'];
-------------------
BELOW IT ADD:
-------------------
if($_POST['reason'] == 'null') $_POST['reason'] = null;
shadiguy1
09-19-2004, 05:19 PM
i installed it the box pops up But after wards there is no reason listed for closing thread.
WhSox21
09-19-2004, 05:21 PM
Did you add the hidden field in showthread template?
shadiguy1
09-19-2004, 05:22 PM
i added everything in the instructions. do you have aim i can talk to you on?
alqafelah
09-19-2004, 05:33 PM
Excellent, fixed :)
thx and best wishes :)
shadiguy1
09-20-2004, 11:50 PM
whsox fixed it up for me thanks bro much appreciated.
drumsy
09-21-2004, 03:43 AM
One issue that arose with the vB2 version of this was that if the thread was closed, a reason was entered, and then the thread was reopened, the reason still showed. Has this been fixed in the vB3 version?
WhSox21
09-21-2004, 11:57 AM
Yep. I set the reason to null if they reopened the thread. If the reason is set to null then there is no displaying of the reason. let me know if you have any problems with my hack as I'm interested in having 100% proof hacks released by me! :)
Interesting and very useful hack :) Thanks!
WhSox21
09-21-2004, 09:19 PM
Not a problem!
HarryBO
10-15-2004, 11:48 PM
I have the same Problem as shadyguy1
i installed it the box pops up But after wards there is no reason listed for closing thread.
I hope somebody can help me!
Edit: Fixed it by myself!
WhSox21
10-16-2004, 03:53 AM
Can you share what the problem was for future fixes?
interesting.
This can lead to another mod "Reason for moving thread" too, isnt it?
dmark101
10-31-2004, 10:38 PM
One issue that arose with the vB2 version of this was that if the thread was closed, a reason was entered, and then the thread was reopened, the reason still showed. Has this been fixed in the vB3 version?
i used to have this hack installed on the vB2 version of my board. that hack also showed the reason and who closed it in the 'last post' field.
is there any reason for not having this functionality in this hack?
i did install BTW. :up:
WhSox21
10-31-2004, 11:25 PM
No, I never knew that. I'm aweful busy right now or I could do that, but I'm affraid I can't do it as of right now.
silentwille
11-10-2004, 06:31 PM
It's possible to edit the reason without open and reclose the thread ?
WhSox21
11-10-2004, 06:35 PM
Via the database. It is not possible as of now.
silentwille
11-10-2004, 06:41 PM
Ok, thanks
shadiguy1
12-30-2004, 07:52 PM
any chance at an updated version that will also list who closed the thread.
WhSox21
12-30-2004, 09:00 PM
Post in this thread in about a week and I'll try to get that done.
shadiguy1
12-30-2004, 09:17 PM
alright thanks...be Cool if it Said Thread Closed By:
shadiguy1
01-05-2005, 03:53 PM
Bumping thread like u asked you said you would add the thread closed by info to the hack in a small update
WhSox21
01-07-2005, 04:38 AM
I'll package everything up and send out an update tomorrow but since you've been waiting here it is:
Note this only applies when this is already installed!
Replace showthread_reason with this:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center" style="border-bottom-width:0px">
<tr>
<td class="alt1" width="100%">
<b>Reason thread was closed:</b> <br />
<div class="smallfont">
$thread[reason]
</div>
<if condition="!empty($thread[who])"><b>Thread Closed By:</b> <span class="smallfont">$thread[who]</span></if>
</td>
</tr>
</table>
Run this query:
ALTER TABLE thread ADD `who` VARCHAR(50) NOT NULL;
In postings.php find this:
$DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET open = $threadinfo[open], reason = '" . addslashes($_POST[reason]) . "' WHERE threadid = $threadid");
...and replace with...
$DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET open = $threadinfo[open], reason = '" . addslashes($_POST[reason]) . "', who = '" . addslashes($bbuserinfo[username]) . "' WHERE threadid = $threadid");
On a side note. Any previously closed threads will not have who closed them. Only threads closed in the future.
Let me know how it works! :up: :)
shadiguy1
01-07-2005, 03:26 PM
works awsome Thanks agian bro...
This hack is VB 3.05 compatiable.
I have 3.05 and just installed it, closing the thread brings up the pop up box askng for the reason, I put in the reason and click ok but I do not get the reason showing up when viewing the thread, what did I miss out or is this a none worker on the latest version of VB
Thanks
Chet
OK forget that, yes it does work with 3.0.5, I missed out the last template modification :o
dmark101
01-26-2005, 04:16 PM
cool on all the updates, including what i had originally asked about.
i just upgraded from 3.0.3 to 3.0.6 and it looks like i have to reinstall the hack, although it does show me the pop-up (it doesn't show the reason). i'll report back when i check all the files with the updated instructions. :)
WhSox21
01-26-2005, 04:52 PM
This is going to be a template problem most likely.
skydancer
10-08-2005, 09:34 PM
I can report that this hack still works in 3.5.0 with a few small changes.
I got rid of the last postings.php modification in the .txt which read
FIND:
-------------------
$DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET open = $threadinfo[open] WHERE threadid = $threadid");
-------------------
REPLACE WITH:
-------------------
$DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET open = $threadinfo[open], reason = '" . addslashes($_POST[reason]) . "' WHERE threadid = $threadid");
Instead, I did the following:
FIND:
$vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t=$threadid";
BEFORE IT, ADD:
$db->query("UPDATE " . TABLE_PREFIX . "thread SET reason='".addslashes($_POST[reason])."' WHERE threadid = $threadid");
It also may be useful to store the name of the moderator who closed it. To do this, I added:
FIND
if($_POST['reason'] == 'null') $_POST['reason'] = null;
BELOW IT, ADD:
$_POST['reason'] = "(".$vbulletin->userinfo['username'].") " . $_POST['reason'];
Cheers!
sd
COBRAws
10-10-2005, 03:14 AM
skydancer ure the man!
dmark101
11-18-2005, 04:23 PM
This is going to be a template problem most likely.
that's pretty much what it turned out to be.
my thanks to skydancer for porting this over to vB 3.5.x because i recently upgraded my board to that version. kudos. :D
now i have to install 3.5.1 and we're set. :)
serhat_kk
12-11-2005, 04:02 PM
it works ...Propz
Justice
12-14-2005, 01:31 AM
thanks to the author, and skydancer... does that 3.5.0 mod work with 3.5.2?
dmark101
12-14-2005, 05:30 PM
thanks to the author, and skydancer... does that 3.5.0 mod work with 3.5.2?
yes, it does. :)
Justice
12-15-2005, 08:07 AM
thanks
serhat_kk
12-17-2007, 08:40 AM
i need this for 3.6.x please
Pirat3
12-17-2007, 11:16 PM
i need this for 3.6.x please
same
MediaHound
12-25-2007, 03:13 PM
Same here, I need this for 3.6.x - have you guys attempted it?
dmark101
02-24-2008, 10:28 PM
Same here, I need this for 3.6.x - have you guys attempted it?
i just updated my 3.5.x software to 3.6.8 and it works PERFECTLY.
just remember to follow skydancer's advice toward the end of the text file. :D
sv1cec
03-25-2008, 09:39 AM
One question, does this mod take into consideration the permissions? In other words, I would like only the mods, supermods and admins to be able to see the reason for which a thread is closed. I can do it myself, but before installing everything, I would like to know if this is taken care of.
Many thanks.
MediaHound
05-30-2008, 06:53 PM
i just updated my 3.5.x software to 3.6.8 and it works PERFECTLY.
just remember to follow skydancer's advice toward the end of the text file. :D
Thank you! May I ask what version you are up to now with it working?
MediaHound
05-30-2008, 07:25 PM
OK I have it working on 3.7, thanks skydancer, dmark101, and WhSox21.
For the record, regarding skydancers fix -
This line appeared often:
$vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t=$threadid";
So I had to determine where to place:
$db->query("UPDATE " . TABLE_PREFIX . "thread SET reason='".addslashes($_POST[reason])."' WHERE threadid = $threadid");
Mine appears on about line 263... but I use some extra lines of comments in places. ymmv.
Here's to fixing it with each update!
I wish it used hooks and I wish it was a built in feature of vb! I hate editing core files, but we really need this modification on a board of mine.
MediaHound
06-09-2008, 07:18 PM
OK we're onto something here.
The big problem with this hack is that it does not use hooks.
Well, I added one of the file edits to a hook. So, if you do this as well, its one less manual edit each time you upgrade.
Visit your admin panel and under Plugins & Products, click add new plugin.
Product is vbulletin
Hook location is showthread_complete
For title you can use "Reason Post Closed - showthread_complete hook"
Execution order you can leave at 5 or whatever your default is
Code is:
if (!empty($thread['reason']))
{
eval('$reason = "' .fetch_template('showthread_reason') . '";');
}
Plugin is active - yes
then hit save.
Don't forget to remove the same code from the bottom of your showthread.php file.
Thats one less file edit each time you upgrade.
Now if we could figure out somehow to get the other file edits in postings.php to use hooks, we will be all set....
Its not fun that this breaks with each upgrade, I hate editing core files...
Whats the process to suggest new hook locations, anyway?
regitbull
07-15-2008, 03:23 PM
verry nice mod.
I installed it on my 3.7.2 board and its working perfect.
And thanks skydancer for posting the solution for
$DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET open = $threadinfo[open] WHERE threadid = $threadid");
That helped me to get the mod running on my board.
TheInsaneManiac
11-11-2008, 02:47 PM
Is it possible to do this for the mass close option?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.