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 guess it's almost done. I'll be waiting for the final release for 1.8!
Yes, it's very nearly done. Just got to work on the visual issues mentioned above and write the upgrade functions.
I hope you found out what is causing the changed avatar dimensions.

I also checked it on a fresh installation. All the avatars from users you get a notification are taking the chosen dimension in the MyAlerts configuration. This is reflected in the user profile and member list.

Now only hope that MentionMe will be updated soon also.
Can't wait for the updated version for 1.8.
(2014-12-05, 02:35 PM)TBO29 Wrote: [ -> ]I hope you found out what is causing the changed avatar dimensions.

I also checked it on a fresh installation. All the avatars from users  you get a notification are taking the chosen dimension in the MyAlerts configuration. This is reflected in the user profile and member list.

Now only hope that MentionMe will be updated soon also.

The current code doesn't even have a setting for the avatar dimensions in the MyAlerts settings, so no idea what might be causing that. I can't reproduce it on my board at all.
Hey, Euan T.

Approximately how many days till the release of the 1.8 version?
(2014-12-04, 08:07 AM)Euan T Wrote: [ -> ]
(2014-12-04, 02:04 AM)alv4 Wrote: [ -> ]OMG Sad
There's no way to use it with PHP 5.2 for MyBB 1.8? Sad
Sad

Only 5.3 and above is supported. 5.2 is waaaay out of date now. If I were you, I'd be complaining to my host to get upgraded. 

Yeah I know, I'm doing that but I don't see it soon.
There's any way to use the 1.6 version working in MyBB 1.8?
while they decide to update it :l
(2014-12-05, 08:47 PM)Pakistani Spirit Wrote: [ -> ]Hey, Euan T.

Approximately how many days till the release of the 1.8 version?

I can't say for definite. It depends how much free time I have.

(2014-12-05, 09:57 PM)alv4 Wrote: [ -> ]
(2014-12-04, 08:07 AM)Euan T Wrote: [ -> ]
(2014-12-04, 02:04 AM)alv4 Wrote: [ -> ]OMG Sad
There's no way to use it with PHP 5.2 for MyBB 1.8? Sad
Sad

Only 5.3 and above is supported. 5.2 is waaaay out of date now. If I were you, I'd be complaining to my host to get upgraded. 

Yeah I know, I'm doing that but I don't see it soon.
There's any way to use the 1.6 version working in MyBB 1.8?
while they decide to update it :l

It should be possible, with a few tweaks to the javaScript. The rest should work fine so long as you change the compatibility in the plugin.
I found the problem here in this code:

$maxDimensions = str_replace('|', 'x', $mybb->settings['myalerts_avatar_size']);

       $outputAlert['avatar'] = format_avatar($fromUser['avatar'], $mybb->settings['myalerts_avatar_size'], $maxDimensions);
       $outputAlert['avatar']['image'] = htmlspecialchars_uni($outputAlert['avatar']['image']);

If you can't reproduce it, then it might conflict with another plugin. I will make an exclusion check. Can it be a  problem with cache?

The previous code with fixed dimensions worked fine. Anyway I will check more accurately.

Edited: Checked. It conflicts with profilecomments, but the avatars of received alerts are still taking size of chosen configuration in MyAlerts configuration, in my case 34x34. See attachment.

In this test board, the admin blondie received alerts for pm's sent from TShadow and pippo and their avatars changed to 34x34, whilst the avatar from blondie remained with the default dimensions. Now receiving an alert from blondie, the default size also will change to 34x34. This happens on the member list, the profile and postbit. No other plugins were activated. Default theme.
Thanks for all your awesome work Euan T.

I found the error i have some vars changed since last revision and today i review all code and all is fie i only have one trouble, i send to you my own way to make alerts works to can set on wiki.

Hope it helps i forgot to send some parts but that parts won't change only to add alert, but if you wish i send to you that info too because i make it today and have to test only to deactivate and activate sentences to review if works fine because i change code, but i have the right code to all parts.

Thanks for this awesome work and i hope can help on wiki at least :s

Edit: I share this info i use it on my own plugin and works fine Big Grin

1.- Registering alert type: (Use install or activate functions to use it)
		$alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache);
			$alertType = new MybbStuff_MyAlerts_Entity_AlertType();
			$alertType->setCode('custom_alert_code');
			$alertType->setEnabled(true);
		$alertTypeManager->add($alertType);

2.- Unregistering alert type: (Use uninstall or deactivate functions to use it).
		$alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();
                $alertTypeManager->deleteByCode('custom_alert_code');

3.- Adding alert to database: (use your own function to set alert data).

    $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('custom_alert_code');
	
    if(isset($alertType) && $alertType->getEnabled()){
 	$alert = new MybbStuff_MyAlerts_Entity_Alert($uid, $alertType, 0);
                $alert->setExtraDetails(
				array('alert_extra_details_in_array')
		); 
	}
	
    MybbStuff_MyAlerts_AlertManager::getInstance()->addAlert($alert);

4.- Registering formatter: (to make accesible at the begining use global_start function).

	$formatterManager = MybbStuff_MyAlerts_AlertFormatterManager::getInstance();
        $formatterManager->registerFormatter(new CustomAlertsAlertFormatter($mybb, $lang, 'custom_alert_code'));		

5.- Displaying your custom alert: (add to the part of your own preference on your code).

 // Alert formatter for my custom alerts.
class CustomAlertAlertFormatter extends MybbStuff_MyAlerts_Formatter_AbstractFormatter{
		public function formatAlert(MybbStuff_MyAlerts_Entity_Alert $alert, array $outputAlert)
		{
        $alertContent = $alert->getExtraDetails();
        $customLink = $this->buildShowLink($alert);
		
			return $this->lang->sprintf(
				$this->lang->custom_alert,
				$outputAlert['from_user'],
				htmlspecialchars_uni($alertContent['t_subject']),					
				$outputAlert['dateline']
			);
		}

		public function init()
		{
			if (!$this->lang->custom_alert) {
				$this->lang->load('custom_alert');
			}
		}

		public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert)
		{
        $alertContent = $alert->getExtraDetails();
	// Set the page to redirect when you clic on your alert by default go to index.php
        $customLink = $this->mybb->settings['bburl'] . '/index.php';              

        return $customLink;
		}
	}

And that's all i wanna share with all of you it's the only i can do to contribute with this great plugin