MyBB Community Forums

Full Version: MyAlerts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I couldnt make autorefresh work, rest seems okay for me.
Autorefresh only occurs on the alerts listing page.
Oh... Would be awesome if it refreshes on the index page too.
That would add quite a large amount of load to the site.
I managed to do that by combining another mod ( http://mods.mybb.com/view/ajax-pm-notification )

Changed his function in his code to

if($mybb->user['unreadAlerts']==1)

and

if($mybb->user['unreadAlerts']>1)

viola!

displaying a popup alert if i get a PM or your alerts Wink
(2013-06-03, 10:01 AM)Shade Wrote: [ -> ]
(2013-06-03, 04:05 AM)buzzle Wrote: [ -> ]The alert_setting_values table is almost empty and only records when a user explicitly sets their preferences.

This would probably be the same thing Wildcard suggested to do with the setting system with "reverse logic". Sharing your work would be nice Big Grin

Yeah, sharing would make sense, wouldn't it? :p

This is the gist of it:
- Rename "alert_setting_values" to "alert_setting_values_data" in the database (or in the create table statement in the install section, if not already installed)
- Update the tablename in myalerts.php to "alert_setting_values_data" wherever "alert_setting_values" is updated/inserted (functions myalerts_register_do_end, myalerts_user_delete, myalerts_page (on delete/insert only)
- Create this view:
CREATE OR REPLACE VIEW alert_setting_values AS
	    SELECT IFNULL(v.id, CONCAT(u.uid, s.id)) AS id,
	    u.uid AS user_id,
	    s.id AS setting_id,
	    IFNULL(v.value, 1) AS value
	    FROM users u INNER JOIN alert_settings s
	    LEFT OUTER JOIN alert_setting_values_data v ON v.setting_id = s.id AND v.user_id = u.uid;

I was initially concerned with the performance of the outer join, but even without indexes performance is fine (we have 2500 members, 7 alert types, 750k posts, around 10k alerts daily). With tuning, performance will not be an issue.

I also considered adding a "default value" column on alert_settings so I could specify whether the default is 0 or 1 for each alert type (to be returned in the query), but I didn't have the need for it at the time.

I will post my modified version, but need to first edit out some custom code to handle our "like" button alerts (based on SaeedGh's "thanks" plugin.)
plugin not works with apart themes, when click on alert javascript not work
@mostarac check the first post. It details a fix for Apart.

@buzzle am I right in thinking that mySQL doesn't support views? I believe it's limited to MSSQL and possibly Oracle.
fixed now how to change alerts background from white to other color
Change the alerts.css stylesheet from the ACP.