You need to read the code. If you look at the if statement there, you'll see you can't just use use $vbulletin->bf_ugp_forumpermissions['cancontainposts'] (which is wrong, btw, it's $vbulletin->bf_ugp_forumpermissions['cancontainthreads']), you need to use it in conjunction with the options for the forum, like this:
PHP Code:
($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads'])
And, if you stick it in the if statement and it evals to true for a category and then continues, then it will never go through the loop to get the forums in that category. So, you need to eval it in the else. If it evals to true for a category, then skip the eval for the jumpforumbits.