﻿id	summary	reporter	owner	description	type	status	priority	component	resolution	keywords	cc
13	AJAX_setTopicStatus causes javascript error because addLoadEvent is not available	_ck_	so1o	"Around line 600 in support-forum.php, function AJAX_setTopicStatus() starts with  
{{{ if (is_topic()) { }}} 
which is not a good enough check, before it adds some javascript code to include with the webpage.

When addLoadEvent is called in the browser, it's not available to most users. I cannot figure out the correct logic, but non-members definitely do not have the required function loaded. Admin are the only ones that get jquery in a default bbpress install so maybe just test for that.

{{{
if (is_topic() &&  bb_is_user_logged_in()) {
}}}

is a simple but incomplete solution from the PHP side.

From the javascript side you could test for

{{{ if(typeof addLoadEvent == 'function') { }}}

So I combined the two and change the start to this:
{{{
		if (is_topic() &&  bb_is_user_logged_in()) {
			$r = '<script type=""text/javascript"">' . ""\n"";
			$r.= 'if (typeof addLoadEvent == ""function"") {' . ""\n"";

}}}

and near the end you have to add:

{{{
			$r .= '	);' . ""\n"";
}}}
"	defect	closed	normal	support-forum	fixed		
