Best of joomla gives you news, joomla templates, tutorials and websites about Joomla , FireBoard and FireMessage official page.
| No account yet?   |
Welcome, Guest
Please Login or Register.    Lost Password?
Completed and In-progress User Contributions
Go to bottom Post Reply Favoured: 13
TOPIC:
#14666
Subscribe to forum instead of thread 11 Months, 3 Weeks 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!

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?


Thoughts would be EXTREMELY useful

Thanks
polc1410 (User)
Senior Boarder
Posts: 62
graphgraph
User Offline Click here to see the profile of this user
 
The administrator has disabled public write access.  
#14673
Re:Subscribe to forum not thread 11 Months, 3 Weeks ago  
To skip straight to the working code (Beta Version: please report any bugs!) for FB 1.0.3 follow this link
http://www.bestofjoomla.com/component/option,com_fireboard/func,view/Itemid,38/catid,68/id,21521


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

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


  1. 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.

  2. 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.

  3. It may even berak some of these other functions!

  4. did I say BACKUP - no - WELL BACKUP!

  5. I am not particularly equipped to help debug this... so be prepared to get your coding fingers dirty!

  6. 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



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)

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.

  • OK - you need to change the properties for the field jos_fb_subscriptions.thread to allow it to have Null Values

  • Then add a new field to the same table called categories, it needs to be an integer, default value 0, indexed, null allowed


Stage 2: open the file: ../components/com_fireboard/templates/default/showcat.php
Here you should go to line 203* and add
Code:


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 ;«»-)


Save the file (and re-upload it if you edited it on a local PC)

Stage 3 - Open the file: ../components/com_fireboard/templates/default/post.php
Find line 232 and change it from:
Code:


$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');

to:
Code:


$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


Now go to line 922 and replace:
Code:

$database->setQuery("INSERT INTO #__fb_subscriptions (thread,userid) VALUES ('$fb_thread','$my->id')"«»);

with:
Code:

//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

Save the file, reupload if editing locally.

Stage 4 - Open the file: ../components/com_fireboard/templates/default/userprofile.php
Locate line 556 and replace:
Code:

$database->setQuery("DELETE from #__fb_subscriptions where userid=$my->id and thread=$thread"«»);

with:
Code:


//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

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:

//this user is allowed to post a new topic:
if ($fbIcons['new_topic']) {
echo '';
}
else {
echo '' . _GEN_POST_NEW_TOPIC . '';
}
}
File Attachment:
File Name: hack_for_showcat.txt
File Size: 1871
polc1410 (User)
Senior Boarder
Posts: 62
graphgraph
User Offline Click here to see the profile of this user
 
Last Edit: 2007/09/10 02:15 By polc1410.
 
The administrator has disabled public write access.  
#17163
Re:Subscribe to forum instead of thread 11 Months 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!

BUT: 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 ...
biosphere (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
 
The administrator has disabled public write access.  
#17170
Re:Subscribe to forum instead of thread 11 Months 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
polc1410 (User)
Senior Boarder
Posts: 62
graphgraph
User Offline Click here to see the profile of this user
 
The administrator has disabled public write access.  
#17273
Re:Subscribe to forum instead of thread 11 Months 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 line 232 of post.php, I had to take out all the "_CRLF_", so that it reads now:

Code:

$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'"«»);


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:

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



Version: I am working on Joomla 1.0.12. 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
biosphere (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
 
The administrator has disabled public write access.  
#17277
Re:Subscribe to forum instead of thread 11 Months 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
biosphere (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
 
The administrator has disabled public write access.  
#17371
Re:Subscribe to forum instead of thread 11 Months 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...
polc1410 (User)
Senior Boarder
Posts: 62
graphgraph
User Offline Click here to see the profile of this user
 
The administrator has disabled public write access.  
#17381
Re:Subscribe to forum instead of thread 11 Months ago  
Woooho...

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:

Extra field name should be category not categories
either remove the _CRLF_ or repalce with \\n on post.php line 232->268
also change that line to SELECT DISTINCT * 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...
polc1410 (User)
Senior Boarder
Posts: 62
graphgraph
User Offline Click here to see the profile of this user
 
Last Edit: 2007/08/08 00:04 By polc1410.
 
The administrator has disabled public write access.  
#19040
Re:Subscribe to forum instead of thread 10 Months, 2 Weeks 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 ?) post your statements here.

Thanks!
Roaster (User)
Expert Boarder
Posts: 136
graphgraph
User Offline Click here to see the profile of this user
 
cu,
Michael
 
The administrator has disabled public write access.  
#19078
Re:Subscribe to forum instead of thread 10 Months, 2 Weeks 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....
polc1410 (User)
Senior Boarder
Posts: 62
graphgraph
User Offline Click here to see the profile of this user
 
The administrator has disabled public write access.  
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop