MyBB Community Forums

Full Version: MyAlerts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Thank for response.

I may say i follow the guide to improve new alerts on plugins.

I want to add MyAlerts compatibyllity with some plugins but when i add the code something are wrong with my code thats for sure. I added some parts but when i run activate function an error appears.

I comment the second and the las line of code and all goes fine but no changes and i have to add manually the code to insert new alert instead running the class routine to do this.

If you wish i send this code thanks in advance.
Yes, please do send the code. The Wiki is also probably slightly out of date, so I will check that this afternoon and update it.
I´m ussing this on activate function:

	$my_alerts_info = myalerts_info();
	$verify = $my_alerts_info['version'];
	if($verify = "2.0.0"){
	$alertType = new MybbStuff_MyAlerts_Entity_AlertType();
	$alertType->setCode('CustomAlert');
	$alertType->setTitle('My Custom Alert');
	$alertType->setEnabled(true);
	$GLOBALS['mybbstuff_myalerts_alert_type_manager']->registerAlertType($alertType);
	}

On reference of wiki of this part of code:

$alertType = new MybbStuff_MyAlerts_Entity_AlertType()->setCode('my_custom_alert_code')->setTitle('Custom Alert Type')->setEnabled(true);
$GLOBALS['mybbstuff_myalerts_alert_type_manager']->registerAlertType($alertType);

But i got an error with Title and globalize alert type. (Of course wit the code i have)
Hi, Try this code:

$alertTypeManager = $GLOBALS['mybbstuff_myalerts_alert_type_manager'] || new MybbStuff_MyAlerts_AlertTypeManager($db, $cache);

$alertType = new MybbStuff_MyAlerts_Entity_AlertType()->setCode('my_custom_alert_code')->setEnabled(true);

$alertTypeManager->add($alertType);

The wiki needs updating as the title field was removed.

You will also need to create an alert formatter class and register it:

class MyCustomAlertFormatter extends MybbStuff_MyAlerts_Formatter_AbstractFormatter
{
    /**
     * Format an alert into it's output string to be used in both the main alerts listing page and the popup.
     *
     * @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to format.
     *
     * @return string The formatted alert string.
     */
    public function formatAlert(MybbStuff_MyAlerts_Entity_Alert $alert, array $outputAlert)
    {
        return $this->lang->sprintf(
            $this->lang->my_custom_alert_lang_string,
            $outputAlert['from_user_profilelink'],
            $this->buildShowLink($alert),
            $outputAlert['dateline']
        );
    }

    /**
     * Init function called before running formatAlert(). Used to load language files and initialize other required
     * resources.
     *
     * @return void
     */
    public function init()
    {
        if (!$this->lang->my_custom_alert_lang) {
            $this->lang->load('my_custom_alert_lang');
        }
    }

    /**
     * Build a link to an alert's content so that the system can redirect to it.
     *
     * @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the link for.
     *
     * @return string The built alert, preferably an absolute link.
     */
    public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert)
    {
        return "{$this->mybb->settings['bburl']}/reputation.php?uid={$this->mybb->user['uid']}";

    }
}

$plugins>add_hook('global_start', 'register_alert_formatter');
function register_alert_formatter()
{
    $formatterManager = $GLOBALS['mybbstuff_myalerts_alert_formatter_manager'] || new MybbStuff_MyAlerts_AlertFormatterManager($mybb, $lang);;

    $formatterManager->registerFormatter(new MyCustomAlertFormatter($mybb, $lang, 'my_custom_alert_code'));
}
Work so fine but on deactivate routine wich function have to use to delete alert data ?

Anyway i have some kind of trouble after registering only when i have to show new alert missing some info im working on that but i think some part is broken.

Thanks for your plugin and your awesome work im very gratefull and well i have to work only on the latest part.

Activation and record on db alert data is working fine on my first plugin but whe finish this others are so easy to coding.

I only have to work on deactivate to delete all data. Maybe on remove customized alert of my plugin i try to delete like the past one plugin u made 1.05 compat fully. But i dunno i feel fine if the alert text appears but i work next week on this.
Change the .info of plugin from 16* to 18* , It will run my alerts also in 1.8.3 ?
Still in development Sad yes it works but it is not a final stable version

EDIT: @Euan - do you havy ETA? I know you are busy but many users in my forum wanna this feature back (I used it in mybb 1.6). I didnt know that there wont be any alerts plugin for 1.8 when I switched to newer version Sad Thank you my friend
@Eldenroot you have to wait or use without some features i am testing on my test board and goes fine but there are some things Euan still working and there are a lot of time for developers too to make more easy add new customized alerts and have an stable version.

ETA as soon as he can im working on try to find how to set values to tell him and make a first stable release wheb ready but im sure when he got this thats for sure we have the first and functional stable release to work on other few tasks for the future.
(2014-11-22, 01:39 PM)Eldenroot Wrote: [ -> ]Still in development Sad yes it works but it is not a final stable version

EDIT: @Euan - do you havy ETA? I know you are busy but many users in my forum wanna this feature back (I used it in mybb 1.6). I didnt know that there wont be any alerts plugin for 1.8 when I switched to newer version Sad  Thank you my friend

It seems pretty stable right now, so hopefully very soon. I'm going to work on an update script tomorrow and iron out any install/uninstall issues. Other issues such as the PM link one will have to wait until 2.0.1 I think. 
Dont forget to fix visual errors in alert dropdown menu