Dear FireBoard users,
In order to further develope the need of Joomla for a robust forum, FireBoard component has been moved to its own new home and new name. You can find more information regarding the Kunena, the successor of FireBoard, at kunena.com. The current forum here will stay for some time more for referencing needs. You can find the FireBoard files under joomlacode.org and other files
Upgrading to Kunena is highly recommended!

Kunena! - To Speak!

A revolution is coming... Kunena - Swahili for: To Speak! THE Next generation of native Joomla based Forum ultra component. Forget what you know about Joomla based forums...
Amazingly Simple Lean and Clean Easier Customization
Kunena is about to redefine the world of Joomla! with the most simplistic ultra component out there. For ultimate performance based on state of the art development techniques, Kunena! is about to bring you... With an integrated plugin system that will allow you to extend Kunena beyond your wildest imaginations...
TOPIC: Subscribe to forum instead of thread
#14666
Subscribe to forum instead of thread 10 Years, 2 Months ago  
Firstly thanks for letting me in here to post.

There are loads of requests for the subscribe to forum (category) instead of (actually as well as) subscribe to individual threads.

I had a look at the code and the DB structure and I think I could code this. I\'m no code monkey but I can probably make something that works.

However it\'ll neeed to hold data in the DB and that means makign sure whatever I do will be compatible with whatever the dev\'s might want for the longer term...

Here\'s my original post on the main board which got lost in the ether of far too many people being a little excited about how good FB is!

[quote]OK so I thought I might have a bash at writing the Forum subscribe function (rather than topic subscribe) myself and posting the results here for future use in the code.

Here\'s where I got to so far:

template/showcat.php (Line 203) - Needs the button to subscribe / unsubscribe - broadly based on he code at template/view.php (Line 298)

template/post.php (Line 219) - Needs to send email to people subscribed to category as well as topic (Note to self - ensure don\'t email same person twice, ?unique email)

template/post.php (Line 918) - Needs to be adapated to \'do subscribe -> category\'

template/userprofile.php (Line 554) - Needs to be adapted to \'do unsubscribe -> category\'

That all seems logical... (yeh right!)

So I need to store the subscriptions in a table. currently subscriptions are in the table:

jos_fb_subscriptions with three fields:

thread
userid
future1

?what is future1 for??

Would the fb devs like a different table (jos_fb_forum_subs) with a structure: forum, userid

OR are they planning to use future1 for it?

I\'m not bothered about the devs using my hacking - no doubt they\'ll do it better when they get a chance, but it\'d be nice if my existing users who\'ll\'ve subscribed don\'t end up having to re-subscribe when FB natively holds forum subscriptions?[/quote]

Thoughts would be EXTREMELY useful

Thanks
#14666
Subscribe to forum instead of thread 10 Years, 2 Months ago  
Firstly thanks for letting me in here to post.

There are loads of requests for the subscribe to forum (category) instead of (actually as well as) subscribe to individual threads.

I had a look at the code and the DB structure and I think I could code this. I\'m no code monkey but I can probably make something that works.

However it\'ll neeed to hold data in the DB and that means makign sure whatever I do will be compatible with whatever the dev\'s might want for the longer term...

Here\'s my original post on the main board which got lost in the ether of far too many people being a little excited about how good FB is!

[quote]OK so I thought I might have a bash at writing the Forum subscribe function (rather than topic subscribe) myself and posting the results here for future use in the code.

Here\'s where I got to so far:

template/showcat.php (Line 203) - Needs the button to subscribe / unsubscribe - broadly based on he code at template/view.php (Line 298)

template/post.php (Line 219) - Needs to send email to people subscribed to category as well as topic (Note to self - ensure don\'t email same person twice, ?unique email)

template/post.php (Line 918) - Needs to be adapated to \'do subscribe -> category\'

template/userprofile.php (Line 554) - Needs to be adapted to \'do unsubscribe -> category\'

That all seems logical... (yeh right!)

So I need to store the subscriptions in a table. currently subscriptions are in the table:

jos_fb_subscriptions with three fields:

thread
userid
future1

?what is future1 for??

Would the fb devs like a different table (jos_fb_forum_subs) with a structure: forum, userid

OR are they planning to use future1 for it?

I\'m not bothered about the devs using my hacking - no doubt they\'ll do it better when they get a chance, but it\'d be nice if my existing users who\'ll\'ve subscribed don\'t end up having to re-subscribe when FB natively holds forum subscriptions?[/quote]

Thoughts would be EXTREMELY useful

Thanks
#14673
Re:Subscribe to forum not thread 10 Years, 2 Months ago  
[b]To skip straight to the working code (Beta Version: please report any bugs!) for FB 1.0.3 follow this link [/b][url]
http://www.bestofjoomla.com/component/option,com_fireboard/func,view/Itemid,38/catid,68/id,21521[/url]

Well if i\'d known it was gonna be this easy, i\'d have done it months ago!

[b]I am attaching here instructions to hack several files, make database changes etc which will [u]hopefully[/u] allow you to have users subscribe to entire forum categories instead of just threads. [color=#FF0000]Before applying these hacks you MUST read the text immediately following...[/color][/b]

[ol]
[li]OK First thinsg first this is an ALPHA RELEASE - if you don\'t know what that means you shouldn\'t attempt this! It has been tested on only ONE SETUP with a dev server forum. I haven\'t yet put a live FB forum out to test this on... I suggest you don\'t either until you\'ve tested it to death.[/li]
[li]There are certain bits this doesn\'t deal with - users have a list of subscriptions in their profile - this is NOT intended to work with that list. [/li]
[li]It may even berak some of these other functions![/li]
[li]did I say BACKUP - no - [b][color=#FF0000]WELL BACKUP![/color][/b][/li]
[li]I am not particularly equipped to help debug this... so be prepared to get your coding fingers dirty![/li]
[li]I\'ve used the same language file as the thread subscriptions - so there are technically a few flaws in terminaology... but i wanted quick and easy[/li]
[/ol]

OK so now we can get down to hacking some code in... (all code below is GPL.. that means you can use it how you like, it also means it comes with no warranty that it a. works b. wont destroy your system)

[b]Stage 1: you need to modify the database structure slightly. I decided to add a field to the table jos_fb_subscriptions rather than play with anything the devs might use later.[/b]

[ul][li]OK - you need to change the properties for the field jos_fb_subscriptions.thread to allow it to have Null Values[/li]
[li]Then add a new field to the same table called [b]categories[/b], it needs to be an integer, default value 0, indexed, null allowed[/li][/ul]

[b]Stage 2: open the file: ../components/com_fireboard/templates/default/showcat.php[/b]
Here you should go to line 203* and [b]add[/b]
[code:1]
I\'ve had to delete this bit of code cause the forum doesn\'t like HTML in the code boxes!

I\'m attaching it as text file ;«»-)
[/code:1]
Save the file (and re-upload it if you edited it on a local PC)

[b]Stage 3 - Open the file: ../components/com_fireboard/templates/default/post.php[/b]
Find line 232 and change it from:
[code:1]
$database->setQuery(\"SELECT * FROM #__fb_subscriptions AS a\" . \"\\n LEFT JOIN #__users as u\" . \"\\n ON a.userid=u.id \" . \"\\n WHERE a.thread= \'$querythread\');[/code:1]
to:
[code:1]
$database->setQuery(\"SELECT * FROM #__fb_subscriptions AS a\" . \"\\n LEFT JOIN #__users as u\" . \"\\n ON a.userid=u.id \" . \"\\n WHERE a.thread= \'$querythread\' OR a.category=\'$catid\'\"«»); //Hacked by SBS[/code:1]

Now go to line 922 and replace:
[code:1]$database->setQuery(\"INSERT INTO #__fb_subscriptions (thread,userid) VALUES (\'$fb_thread\',\'$my->id\')\"«»);
[/code:1] with:
[code:1]//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->setQuery(\"INSERT INTO #__fb_subscriptions (thread,userid) VALUES (\'$fb_thread\',\'$my->id\')\"«»);
}
//End Hack by SBS[/code:1]
Save the file, reupload if editing locally.

[b]Stage 4 - Open the file: ../components/com_fireboard/templates/default/userprofile.php[/b]
Locate line 556 and replace:
[code:1]$database->setQuery(\"DELETE from #__fb_subscriptions where userid=$my->id and thread=$thread\"«»);[/code:1]
with:
[code:1]
//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[/code:1]
Save and re-uplaod if saved locally.

That should be it! Fingers crossed and get testing...




*I have referenced line numbers - its possible bug fixes etc will throw those no\'s out so here\'s the code you are actually looking for:
showcat.php - line 203 is immediately after this:
[code:1] //this user is allowed to post a new topic:
if ($fbIcons[\'new_topic\']) {
echo \'\';
}
else {
echo \'\' . _GEN_POST_NEW_TOPIC . \'\';
}
}[/code:1] [file name=hack_for_showcat.txt size=1871]http://www.bestofjoomla.com/components/com_fireboard/uploaded/files/hack_for_showcat.txt[/file]
#17163
Re:Subscribe to forum instead of thread 10 Years, 1 Month ago  
I love you, chap! Was nice to see some code after so many months of simple end-user CMS development
Your hack is simply a great and easy way to have something like an Egroup module for Joomla! A thousand thanks!

[b]BUT[/b]: There is one tiny, but crucial typo in what you have written: The field in the database has to have the name \"category\", not \"categories\". Just in case some non-experienced Joomla friend tries to hack this and doesn\'t know why it doesn\'t work ...
#17170
Re:Subscribe to forum instead of thread 10 Years, 1 Month ago  
Glad it worked. You are the first external user to have confirmed success, so thats great.

Thanks for spotting the typo...

Can you confirm which release you\'ve used it on - I need to get this tested on 1.0.2RC2 soon so that it can run from the live date for 1.0.2
#17273
Re:Subscribe to forum instead of thread 10 Years, 1 Month ago  
Hey Shoe,

okay, my enthusiasm was too fast (I was only testing the subscription on my local PC, not the sending out of notifications), but now it works. However, I had to change one line (and I can\'t exactly explain why):

In [b]line 232[/b] of [b]post.php[/b], I had to take out all the \"_CRLF_\", so that it reads now:

[code:1]$database->setQuery(\"SELECT * FROM #__fb_subscriptions AS a LEFT JOIN #__users as u ON a.userid=u.id \" . \" WHERE a.thread= \'$querythread\' OR a.category=\'$catid\'\"«»); [/code:1]

As I wanted to use the Fireboard module as an Egroup, I also wanted to have the people know to how many people the message was sent, so I added just below (after the \"if (count($subsList) > 0) {\" the following line:

[code:1]echo count($subsList).(count($subsList) > 1 ? \" members have\" : \" member has\"«»).\" received your message. \";
[/code:1]

Version: I am working on [b]Joomla 1.0.12[/b]. The site is hosted by Siteground, don\'t know about their server etc.

Oh, what I haven\'t checked out yet: What happens if I have subscribed to a forum and to a topic within the forum? Do I get 2 emails? ... let\'s see...

Christoph
#17277
Re:Subscribe to forum instead of thread 10 Years, 1 Month ago  
Yeah, I think you get several messages ...

it\'s been already a few years that I\'ve developed PHP/MySQL sites ... isn\'t there a MySQL syntax which selects UNIQUE userids so that you can filter out all the double entries?

If not, there are other choices:

1. Simply by changing in the backend whether the \"subscription\" button is always checked (filters out all those that don\'t notice).

2. Deleting all subscribe buttons inside \"show thread\" and \"post message\" templates.

3. Or writing some more codelines where we were (shouldn\'t be that difficult, but I have to get back to work now ;)

In any case: Thanks again (a lot, a lot, a lot) for your initiative. I wouldn\'t have dared to embark on long code analysis myself.

Christoph
#17371
Re:Subscribe to forum instead of thread 10 Years, 1 Month ago  
Not sure what went wrong with the _CRLF_ it must have been some bizarre cut\'n\'paste effect - on my original file they are in as /n but other than making the code pretty when its presented to the SQL I think they server no purpose.

SELECT DISTINCT * at the start of the selct line should do the trick (untested)

(Unique is not true SQL - althougb MySQL may understand it)

Thought I\'d cover this one - but now I can\'t see how I had so it must have been in the DB structure which isn\'t covered because of the way I went...
#17381
Re:Subscribe to forum instead of thread 10 Years, 1 Month ago  
Woooho... :woohoo:

I just put FB 1.0.2RC2 on a dev machine and tested this out and it works.

Here\'s the ammended line numbers:

showcat.php - line 203 is now line 306
post.php - line 232 now 268
- line 922 now 971
userprofile.php - line 556 now 581

Note the comments from biosphere:

[b]Extra field name should be [u]category[/u][/b] not categories
[b]either remove the _CRLF_ or repalce with \\\\n[/b] on post.php line 232->268
[b]also change that line to SELECT DISTINCT *[/b] to avoid duplicate emails if double subscribed.

Tested (2 messages - so not exactly exhaustive) and it still works....

As soon as stable is out I\'ll check those line numbers and see if we can find a better way to list these instructions...
#19040
Re:Subscribe to forum instead of thread 10 Years, 1 Month ago  
Looking at all those fixes and code changes that have to be done, I guess it would be a better solution to have this completely in the FB core, right? If so there should be both possibilities: Either subscribe to a thread ot to the category itself.

So, please, dev team (where are you right now - in holiday all together :P ?) post your statements here.

Thanks!
#19078
Re:Subscribe to forum instead of thread 10 Years, 1 Month ago  
there are only 4 code changes and 1 database change. All code changes can be cut\'n\'pasted

However, it is planned as a core feature - this is offered here as a temp fix to make it available.

I can tell you the core dev team are working on fixing issues with 1.0.2RC2 to get 1.0.2RC3 out...

However, I suspect the devs will want to tweak it better than I have - the language files might want to be seperate, plus there should be tweaks in the profile because subscribed categories don\'t show.

It is possible to subscribe to threads and categories using the stuff above....
Page: 123... 12