MyBB Community Forums

Full Version: MentionMe (MyAlerts Integrated Mention)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
If you need help with MentionMe click here!

This was the initial alpha thread-- this is not the support thread.

I have seen a lot of people saying that they would like to have a mention plugin integrated with MyAlerts and I totally agree. It took a little time, but I have a working version as we speak.

I am using someone else's mention plugin, http://mods.mybb.com/view/mention and have made the appropriate customizations to allow it to create alerts when the name is first mentioned (in a reply or new thread).

However I have had one stumbling block:

To have my user setting display its custom text I had to directly modify myalerts.lang.php . . . how can I separate my plugin's language and still have it work?

Here is the code I have edited from Euanator's Integration Wiki to add the setting:

$plugins->add_hook('myalerts_possible_settings', 'mention_alerts_setting');

function mention_alerts_setting(&$possible_settings)
{
	$possible_settings[] = 'mention';
	// And we should add a language variable $lang->myalerts_setting_fictionalAward
}

Euanator Wrote:// And we should add a language variable $lang->myalerts_setting_fictionalAward

I tried defining that lang variable in the function like:

$l['myalerts_setting_mention']='Receive an alert when someone mentions your username?';

but it did nothing. Sad So to make it work I have just modified the lang file included with MyAlerts (and again for my parse_alert hook, but I know how to separate it)

I would really feel much better if I could do this without modifying the original language file.

Any help would be appreciated.
Have you tried adding a new language file and calling it with $lang->load?
(2012-12-11, 08:56 AM)euantor Wrote: [ -> ]Have you tried adding a new language file and calling it with $lang->load?

I actually want to go hide under a rock right now Blush

Until you suggested it so simply, I wasn't thinking that any $lang->load command I placed into my code that hooks into myalerts_possible_settings would effect the code after the hook :p

That works anyway so even if I look stupid you solved my problem Smile

Thanks Euan Smile

One more question:

This plugin I am modifying is licensed under GNU GPL v3 . . .

So when I am done, should/can I upload this plugin to the mods site? Or should I attempt to contact the plugin author about my edits?

Sorry I realize this isn't exactly a development question, but I just don't want to do something unethical out of ignorance.

As always I appreciate you guys helping me out Smile
No idea to be perfectly honest. I'm not so good with licenses - hence why I just use the MIT license as it seems fairly easy to understand Wink
Did the alerts settings hook worked for you? Seems that it adds nothing in UCP alerts settings list.
I'm pretty sure it did when I tested it. Is there even a checkbox that shows up?

You could temporarily add this to the myalerts file just below where the hook is ran:

var_dump($possible_settings);
Doesn't work (error DECODING_CONTENT_FAILED, 330). But maybe it's my plugin's fault.
Well, that's certainly strange. I've never seen that error ever before o.O
That's Chrome (HTTP error 330), not the plugin itself, but it may be caused by it, I'm a newbie and I don't know if my code is correct.
(2012-12-11, 07:42 PM)Shade Wrote: [ -> ]Did the alerts settings hook worked for you? Seems that it adds nothing in UCP alerts settings list.

Not at first . . .

I am trying to remember exactly what I was doing wrong with the settings at first but I only remembered that I went to GitHub and got the latest download and then did the same for PluginLibrary and after that it was fairly smooth sailing.

There is one typo in the My Alerts Integration Wiki though.

This code:

$plugins->add_hook('myalerts_alerts_output_start', 'fictionalAwards_alerts_output');
function fictionalAwards_alerts_output(&$alert)
{
	global $mybb, $lang;
	if ($alert['type'] == 'fictionalAward' AND $mybb->user['myalerts_settings']['fictionalAward'])
	{
		$alert['message'] = $lang->sprintf($lang->fictionalAward_alert, $alert['user'], $awardURL, $alert['dateline']);
		$alert['rowType'] = 'fictionalAward';
	}
}

should be:

$plugins->add_hook('myalerts_alerts_output_start', 'fictionalAwards_alerts_output');
function fictionalAwards_alerts_output(&$alert)
{
	global $mybb, $lang;
	if ($alert['alert_type'] == 'fictionalAward' AND $mybb->user['myalerts_settings']['fictionalAward'])
	{
		$alert['message'] = $lang->sprintf($lang->fictionalAward_alert, $alert['user'], $awardURL, $alert['dateline']);
		$alert['rowType'] = 'fictionalAward';
	}
}

The diff being $alert['type'] should be $alert['alert-type']

	if ($alert['alert_type'] == 'fictionalAward' AND $mybb->user['myalerts_settings']['fictionalAward'])

An aside:

Is there a way to make new alerts start out as activated by all members when the plugin is installed?

My only recourse at this point is to use a query to change all users alert_settings to all alerts on and then warn my forum members that they will have to reset their alert preferences.

If it is off by default when I announce it I will spend the rest of my life explaining to people how it works :p
Pages: 1 2 3