Plugin for custom email notifications

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
mentis

Plugin for custom email notifications

Post by mentis »

Dear Mantis developers and advanced users,

Despite the fact that the subject of custom email notifications was discussed on many articles on the web I humbly ask you to look at this again...

I have download the latest version of mantis - 1.2.12

I went through

http://www.mantisbt.org/docs/master/en/ ... lding.html
http://www.mantisbt.org/wiki/doku.php/m ... cow_powers
http://bugtracker.morinie.fr/mantis/dok ... e_a_plugin

and I managed to create a plugin that echos word 'ass' on the main page trigered by EVENT_CORE_READY event...

I would like to make my plugin a little bit more useful, namely:

I would like my plugin to send a custom email with custom content to custem email - specified in code/config file; through a remote SMTP with custom credentials. I want this email to be send when bug ticket changes its 'state'? to 'resolved'...

How to achieve such functionality?
atrol
Site Admin
Posts: 8575
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Plugin for custom email notifications

Post by atrol »

You should ignore this information as it is a non standard 3rd party plugin system for MantisBT 1.1.x, not for MantisBT 1.2.x

I recommend to study some of the plugins hosted at https://github.com/mantisbt-plugins
Please use Search before posting and read the Manual
mentis

Re: Plugin for custom email notifications

Post by mentis »

Thank you for your replay,

Is this event reference still valid?
http://www.mantisbt.org/wiki/doku.php/m ... ins_events

I couldn't find

Code: Select all


    EVENT_BUG_REPORTED ( Execute ) - Triggered when a new bug has been reported.
    EVENT_BUG_UPDATED ( Execute ) - Triggered when a bug has been updated.
    EVENT_BUG_RESOLVED ( Execute ) - Triggered when a bug is resolved.
    EVENT_BUG_CLOSED ( Execute ) - Triggered when a bug has been closed
    EVENT_BUG_NOTE_ADDED ( Execute ) - Triggered when a bugnote has been added to a bug. Is this superfluous because of EVENT_BUG_UPDATED?

anywhere in mantis folder...

if those events are no longer valid, what is the current equivalent?
atrol
Site Admin
Posts: 8575
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Plugin for custom email notifications

Post by atrol »

The one and only valid documentation is the source code ;-)
Have a look at core/events_inc.php for the events.

The Wiki has been written as a specification before the implementation
NOTE: The event list has not yet been finalized. You should not rely on this reference until events have been fully implemented.
Search for event_signal in MantisBT code to see where the events are triggered.
Please use Search before posting and read the Manual
mentis

Re: Plugin for custom email notifications

Post by mentis »

I'm puzzled X_x

What event is triggered when user changes status of a bug for example from 'new' to 'resolved' ?
How to hook to this event?

Is EVENT_UPDATE_BUG the one ?
how do I hook to it ?

Code: Select all

function hooks()
	{
		$hooks = array(
			'EVENT_UPDATE_BUG' => 'bug_fun',
		);

		return $hooks;
	}

        function bug_fun( $p_event, $p_bug_data, $p_bug_id ) {
		
		echo '<br/>';
		echo 'fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!';
		echo '<br/>';
		
	}
this doesn't work ;(

is BugData passed along with one of those events? Should I / Can I compare to bug_data->status ?
atrol
Site Admin
Posts: 8575
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Plugin for custom email notifications

Post by atrol »

Have a look at this plugin function update_bug
https://github.com/vincentsels/ProjectM ... gement.php

Search for

Code: Select all

if ( $p_bug_data->status >= config_get( 'bug_resolved_status_threshold' ) ) {
Please use Search before posting and read the Manual
mentis

Re: Plugin for custom email notifications

Post by mentis »

ok, so the hook works but wont echo, it will create a file...

Code: Select all

function bug_fun($p_event, $p_params) {
		
		echo '<br/>';
		echo $p_params->status;
		echo '<br/>';
		echo 'fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!';
		echo '<br/>';
		
		$ourFileName = "dyzurny.txt";
		$fh = fopen($ourFileName, 'w') or die("can't open file");
		
		fwrite($fh, $p_params->project_id . "\n");
		fwrite($fh, $p_params->reporter_id . "\n");
		fwrite($fh, $p_params->build . "\n");
		fwrite($fh, $p_params->platform . "\n");
		fwrite($fh, $p_params->os . "\n");
		fwrite($fh, $p_params->os_build . "\n");
		fwrite($fh, $p_params->version . "\n");
		fwrite($fh, $p_params->profile_id . "\n");
		fwrite($fh, $p_params->handler_id . "\n");
		fwrite($fh, $p_params->view_state . "\n");
		fwrite($fh, $p_params->category_id . "\n");
		fwrite($fh, $p_params->reproductibility . "\n");
		fwrite($fh, $p_params->severity . "\n");
		fwrite($fh, $p_params->priority . "\n");
		fwrite($fh, $p_params->projection . "\n");
		fwrite($fh, $p_params->eta . "\n");
		fwrite($fh, $p_params->resolution . "\n");
		fwrite($fh, $p_params->status . "\n");
		fwrite($fh, $p_params->summary . "\n");
		fwrite($fh, $p_params->description . "\n");
		fwrite($fh, $p_params->steps_to_reproduce . "\n");
		fwrite($fh, $p_params->additional_information . "\n");
		
		fclose($fh);
		
	}
output:

Code: Select all

3
1





0
1
10
1

50
30
10
10
20
20
werwer
werwer



how to get useful data out of it? data i could populate an email with?
atrol
Site Admin
Posts: 8575
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Plugin for custom email notifications

Post by atrol »

Sorry, I don't have time to give you step by step instructions.
You have to learn the concecpt of enumerations in MantisBT http://www.mantisbt.org/docs/master-1.2 ... MIZE.ENUMS
Have a look at file bug_view_inc.php around line 175 how to get displayable values from enums (get_enum_element)
Please use Search before posting and read the Manual
mentis

Re: Plugin for custom email notifications

Post by mentis »

Thank you very, very much for all your help :)

I finished my pluging, it works as I wanted :D
Post Reply