MyBB Community Forums

Full Version: Unread thread subscriptions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone.

I'm trying to get a little notification system going here. Mainly looking to put a (1) or (2) or (n) next to a new "subscribed threads" link in the welcomeblock. http://forums.tyzoid.com/ (user test, password test123)

Is this possible with just editing the templates? and if so, what variable is that stored in?

Thanks.
Does anyone know how to do this?
I am not really sure what you want, but the test account login is wrong.
Should be fixed, the test account now works.

[attachment=28418]
Here is an example of when someone (me, and admin) is logged in to my forum. I have a link that leads to the current subscriptions, but I want to display a little number that corresponds to the number of unread subscriptions there are.

So, let's say I'm subscribed to a thread, another user posts in that thread, I would like to display a (1) next to "subscribed threads" (similar to the way unread pms are displayed). If possible, I would like to do this in the theme, and not have to use/write a plugin, but if it is the only way, I can do that.
You will need a plugin for that, I don't think there is any available. See usercp.php for the query it runs:
	// Thread Subscriptions with New Posts
	$query = $db->simple_select("threadsubscriptions", "sid", "uid = '".$mybb->user['uid']."'", array("limit" => 1));
	if($db->num_rows($query))
	{
		// ...
	}

You probably want to make sure the suer has permission to read all threads (i.e: one thread is unapproved or was moved to a private forum). That seems like around 4 queries per page though...

Ninja'd by 14 minutes, lol. Slowpoke xD
(2013-01-25, 04:05 PM)Leefish Wrote: [ -> ]Try this thread :

http://community.mybb.com/thread-129011.html
Thanks, but the solution for this thread regards modifying the core, something which I would do only as a last resort (and certainly not for something as aesthetic as this).

I will have to take a more close look at this later though.
(2013-01-25, 04:19 PM)Omar G. Wrote: [ -> ]You will need a plugin for that, I don't think there is any available. See usercp.php for the query it runs:
	// Thread Subscriptions with New Posts
	$query = $db->simple_select("threadsubscriptions", "sid", "uid = '".$mybb->user['uid']."'", array("limit" => 1));
	if($db->num_rows($query))
	{
		// ...
	}

You probably want to make sure the suer has permission to read all threads (i.e: one thread is unapproved or was moved to a private forum). That seems like around 4 queries per page though...

Ninja'd by 14 minutes, lol. Slowpoke xD

Thanks. Is this the actual code that runs? If I'd need to do some extra checking, shouldn't mybb do this as well?
[attachment=28420]
Does the code you posted output the number of subscribed threads? or no?

Thanks for both of your responses.
@ Tyzoid - to get the number of unread subscriptions then you will need to query somewhere, if it is not that important (only aesthetics) then you probably don't want 4 queries.

On the topic of modifying core files, have you looked at the patches plugin?

http://mods.mybb.com/view/patches
Quote:Thanks, but the solution for this thread regards modifying the core

Not really. That was a quick solution as pointed but you can easily hook at global_end if you are going to write your own plugin.

Quote:Is this the actual code that runs? If I'd need to do some extra checking, shouldn't mybb do this as well?

The code I mean is the one that runs in the index UCP page (usercp.php#3136), the box is only visible if there are any unread subscribed threads. And yes, MyBB does the check in that code.

Quote:Does the code you posted output the number of subscribed threads? or no?

No, it doesn't. Basically, that code is everything you need, just adapt it to just get the number.
(2013-01-25, 04:42 PM)Omar G. Wrote: [ -> ]-snip-
I see now, thanks.

(2013-01-25, 04:34 PM)Leefish Wrote: [ -> ]@ Tyzoid - to get the number of unread subscriptions then you will need to query somewhere, if it is not that important (only aesthetics) then you probably don't want 4 queries.

On the topic of modifying core files, have you looked at the patches plugin?

http://mods.mybb.com/view/patches

No, I haven't actually. It looks good Toungue the main reason I don't want to modify the core is so upgrades will be easier without breaking site functionality. This looks like it should mitigate that problem.