View Issue Details

IDProjectCategoryView StatusLast Update
0034430mantisbtplug-inspublic2024-05-11 17:23
Reportercas Assigned Toatrol  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionno change required 
Product Version2.26.1 
Summary0034430: Request for a new event
Description

the file core/commands/IssueNoteAddCommand.php does have an event_signal but this is coming after the update has been made.
Would be nice to have one pre-saving in the validate function.
Currently I have added it like follows:
Just before the line:

$this->user_id = auth_get_current_user_id();

add the following line:

event_signal( 'EVENT_BUGNOTE_CHECK', $this->text );

Additional Information

In an attempt to create an anti spam plugin need to ensure issues & notes are raised in a pre-defined language.
work in progress can be seen here: https://github.com/mantisbt-plugins/BanSpam

TagsNo tags attached.

Activities

atrol

atrol

2024-05-01 10:38

developer   ~0068877

@cas I didn't have a deeper look, but can't you use EVENT_BUGNOTE_DATA?

cas

cas

2024-05-01 10:48

reporter   ~0068878

@atrol, was my initial idea too but this kicks in after validation and processing.

atrol

atrol

2024-05-01 10:53

developer   ~0068879

The event is triggered before the note is stored in database.
Isn't this what you need?

cas

cas

2024-05-01 11:33

reporter   ~0068880

Are you sure? My test shows different. If I use that Event I do get a message but the note is already in the DB.

atrol

atrol

2024-05-01 11:36

developer   ~0068881

Snippet from function bugnote_add

    # Event integration
    $t_bugnote_text = event_signal( 'EVENT_BUGNOTE_DATA', $p_bugnote_text, $c_bug_id );

    # MySQL 4-bytes UTF-8 chars workaround #21101
    $t_bugnote_text = db_mysql_fix_utf8( $t_bugnote_text );

    # insert bugnote text
    db_param_push();
    $t_query = 'INSERT INTO {bugnote_text} ( note ) VALUES ( ' . db_param() . ' )';
    db_query( $t_query, array( $t_bugnote_text ) );
cas

cas

2024-05-01 11:56

reporter   ~0068882

My mistake, you are right. Reviewed my test and looked at EVENT_BUGNOTE_ADD.
Please close issue.