EVENT_BUG_ACTION plugin

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
sara.rossi
Posts: 9
Joined: 01 Feb 2023, 11:01

EVENT_BUG_ACTION plugin

Post by sara.rossi »

Hi everyone,
i'm using Mantis 2.25 and I'm struggling with this plugin. Now I found the event EVENT_BUG_ACTION, that in the developers guide said :
This event allows plugins to perform post-processing of group actions performed from the View Issues page. The event will get called for each bug ID that was part of the group action event.
Parameters

<String>: Action title (see bug_actiongroup.php)
<Integer>: Bug ID


Checking on bug_actiongroup I found the action for close issue
witch( $f_action ) {

Code: Select all

         case 'CLOSE':
           $t_closed = config_get( 'bug_closed_status_threshold' );
         if( access_can_close_bug( $t_bug ) ) {
                if( ( $t_status < $t_closed ) &&
                    bug_check_workflow( $t_status, $t_closed ) ) {

               # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bu    gnote_text ) );
               bug_close( $t_bug_id, $f_bug_notetext, $f_bug_noteprivate );
             helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
           } else {
                   $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
                 }
            } else {
                 $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
            }
[/i]


⁠And the action that I want it's : when the reporter closes the ticket, I want to update the DB.
But not working and I don't know why.
Any idea?

function hooks()
{
return array(
"EVENT_BUG_ACTION"=> 'updateDatabase');
}

function updateDatabase( $p_event, $f_action, $p_bug_id) {
$bug_id = $p_bug_id->id;
if (strtolower($f_action) === 'close') {
if ($p_bug_id->project_id == 3 || $p_bug_id->project_id == 4) {
$t_bug_table = db_get_table('mantis_bug_table');
$t_query = "UPDATE $t_bug_table SET handler_id = 204 WHERE id = $bug_id";
db_query($t_query);

}
}
}
cas
Posts: 1622
Joined: 11 Mar 2006, 16:08
Contact:

Re: EVENT_BUG_ACTION plugin

Post by cas »

when this event is triggered it will execute the code but the standard code also continues. This may lead to unexpected results in your case.
Post Reply