Opened 19 years ago
Closed 18 years ago
#13 closed defect (fixed)
AJAX_setTopicStatus causes javascript error because addLoadEvent is not available
| Reported by: | _ck_ | Owned by: | so1o |
|---|---|---|---|
| Priority: | normal | Component: | support-forum |
| Keywords: | Cc: |
Description
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";

AJAX status switching is removed from support-forum as of 3.0.2