How To: Hack Fireboard to offer Subscribe to Forum as well as Subscribe to thread

I started this How To as a thread at www.bestofjoomla.org however it doesn't actually show the code that well so I'm moving it here instead where hopefully folks can print it out and work through it. Heck I might even post the hacked files on here for download!

While this blue banner appears this hack is NOT FULLY TESTED it is based on the principle that the rest of the FB code will work around it! Test at your own risk. Not on a live server thanks.
One user has now reported this working... please keep us informed...

Before I start there are a few things you really need to know. This hack is provided under the GNU/GPL Licence Terms, as such it comes without warranty. It is your decision to use it. Remember to backup! Also if you have problems post on the forum - do not attempt to contact me directly. I am subscribed to the forum at the thread above so I will receive your post.

Second thing to note is that these instructions are being provided for Fireboard 1.0.4, if you are using an older version refer to the forum. If you are using a newer version there is no promises this will work

OK lets begin...

Step 1: Changing the table structure

The table jos_fb_subscriptions needs an extra column to hold the categories, and the thread needs to be not required. Executing the following SQL commands should suffice:

ALTER TABLE jos_fb_subscriptions CHANGE `thread` `thread` INT( 11 ) NULL DEFAULT '0'
ALTER TABLE jos_fb_subscriptions ADD `category` INT( 11 ) NULL DEFAULT '0'

Step 2: Edit showcat.php

Open ../components/com_fireboardf/templates/default/showcat.php and locate line 311 and insert the code:

//Start Hack by SBS
                  
                    if ($fbConfig['allowsubscriptions'] == 1 && ("" != $my_id || 0 != $my_id))
                    {
                        //$fb_thread==0 ? $check_thread=$catid : $check_thread=$fb_thread;
                        $database->setQuery("SELECT category from #__fb_subscriptions where userid='$my_id' and category='$catid'");
                        $fb_subscribed = $database->loadResult();

                        if ($fb_subscribed == "") {
                            $fb_cansubscribe = 1;
                        }
                        else {
                            $fb_cansubscribe = 0;
                        }
                    }

                    if ($my_id != 0 && $fbConfig['allowsubscriptions'] == 1 && $fb_cansubscribe == 1)
                    {
                    echo '<a href ="'.sefRelToAbs(JB_LIVEURLREL.'&func=post&do=subscribe&fb_thread=0&catid='.$catid.'&id='.$id).'" >';
                    echo $fbIcons['subscribe'] ? '<img src="' . JB_URLICONSPATH . '' . $fbIcons['subscribe'] . '" border="0" title="' . _VIEW_SUBSCRIBETXT . '" alt="' . _VIEW_SUBSCRIBETXT . '" />' : _VIEW_SUBSCRIBE;
                    echo "</a>";
                    }

                    if ($my_id != 0 && $fbConfig['allowsubscriptions'] == 1 && $fb_cansubscribe == 0)
                    {
                    echo '<a href = "'.sefRelToAbs(JB_LIVEURLREL.'&func=myprofile&do=unsubscribeitem&catid='.$catid).'" >';
                    echo $fbIcons['unsubscribe'] ? '<img src="' . JB_URLICONSPATH . '' . $fbIcons['unsubscribe'] . '" border="0" title="' . _VIEW_UNSUBSCRIBETXT . '" alt="' . _VIEW_UNSUBSCRIBETXT . '" />' : _VIEW_UNSUBSCRIBE;
                    echo "</a>";
			    	}
    
//End Hack by SBS

You can download a replacement copy of the FB 1.0.4 showcat.php file here (just rename it without the .txt ending), provided you haven't made any other changes and are using the default file.

Step 3: Edit post.php

Edit: .../components/com_fireboard/templates/default/post.php Lines 294 on wards to read:

$database->setQuery("SELECT DISTINCT * FROM #__fb_subscriptions AS a"
  . " \n LEFT JOIN #__users as u ON a.userid=u.id" 
  . " \n WHERE a.thread= '$querythread' OR a.category='$catid'");

Now in the same file replace Line 1079 with:

 //Start Hack By ShinyBlackShoe to allow category subscribe
            if ($fb_thread == "0"){  //sub cat instead of thread
            $database->setQuery("INSERT INTO #__fb_subscriptions (category,userid) VALUES ('$catid','$my->id')");
            }
            else {
                    $database-$gt;setQuery("INSERT INTO #__fb_subscriptions (thread,userid) VALUES ('$fb_thread','$my->id')");
            }
//End Hack by SBS

You can download a replacement copy of the FB 1.0.4 post.php file here (just rename it without the .txt ending), provided you haven't made any other changes and are using the default file.

Step 4: Edit userprofile.php

Edit: .../components/com_fireboard/templates/default/userprofile.php and replace line 580 with:

//Start Hack by ShinyBlackShoe to give forum subscribe
    if ($thread == "0"){ //unsub from cat not thread
        $database->setQuery("DELETE from #__fb_subscriptions where userid=$my->id and category=$catid");
    }
    else {
        $database->setQuery("DELETE from #__fb_subscriptions where userid=$my->id and thread=$thread");
    }
//End hack by SBS

You can download a replacement copy of the FB 1.0.4 userprofile.php file here (just rename it without the .txt ending), provided you haven't made any other changes and are using the default file.