Skip to content

Commit

Permalink
Create event EVENT_BUG_ACTIONGROUP_FORM
Browse files Browse the repository at this point in the history
Create event EVENT_BUG_ACTIONGROUP_FORM to add custom content to the
group action page form.
For example: custom inputs that can later be evaluated when processing
EVENT_BUG_ACTION.

Fixes: #13126
  • Loading branch information
cproensa authored and vboctor committed Oct 23, 2017
1 parent 1a3aec6 commit b1c3160
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bug_actiongroup_add_note_inc.php
Expand Up @@ -38,6 +38,10 @@
return;
}

# This variable is defined in parent script
global $t_event_params;
$t_event_params['has_bugnote'] = true;

require_api( 'access_api.php' );
require_api( 'bug_api.php' );
require_api( 'config_api.php' );
Expand Down
6 changes: 6 additions & 0 deletions bug_actiongroup_ext_page.php
Expand Up @@ -36,6 +36,9 @@
return;
}

# This variable is defined in parent script
global $t_event_params;

require_api( 'authentication_api.php' );
require_api( 'bug_group_action_api.php' );
require_api( 'form_api.php' );
Expand Down Expand Up @@ -73,6 +76,9 @@
<?php
bug_group_action_print_hidden_fields( $f_bug_arr );
bug_group_action_print_action_fields( $t_external_action );

# signal plugin event for additional fields
event_signal( 'EVENT_BUG_ACTIONGROUP_FORM', array( $t_event_params ) );
?>
<tr class="spacer"></tr>
<?php bug_group_action_print_bug_list( $f_bug_arr ); ?>
Expand Down
17 changes: 17 additions & 0 deletions bug_actiongroup_page.php
Expand Up @@ -30,6 +30,7 @@
* @uses config_api.php
* @uses constant_inc.php
* @uses custom_field_api.php
* @uses event_api.php
* @uses form_api.php
* @uses gpc_api.php
* @uses helper_api.php
Expand All @@ -48,6 +49,7 @@
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'custom_field_api.php' );
require_api( 'event_api.php' );
require_api( 'form_api.php' );
require_api( 'gpc_api.php' );
require_api( 'helper_api.php' );
Expand All @@ -72,6 +74,12 @@
$t_multiple_projects = false;
$t_projects = array();

# Array of parameters to be used with plugin event
$t_event_params = array();
$t_event_params['bug_ids'] = $f_bug_arr;
$t_event_params['action'] = $f_action;
$t_event_params['has_bugnote'] = false;

bug_cache_array_rows( $f_bug_arr );

foreach( $f_bug_arr as $t_bug_id ) {
Expand All @@ -85,6 +93,8 @@
}
}
}
$t_event_params['multiple_projects'] = $t_multiple_projects;

if( $t_multiple_projects ) {
$t_project_id = ALL_PROJECTS;
$t_projects[ALL_PROJECTS] = ALL_PROJECTS;
Expand Down Expand Up @@ -122,6 +132,7 @@
if( strpos( $f_action, $t_custom_fields_prefix ) === 0 ) {
$t_custom_field_id = (int)substr( $f_action, utf8_strlen( $t_custom_fields_prefix ) );
$f_action = 'CUSTOM';
$t_event_params['action'] = $f_action;
}

# Form name
Expand Down Expand Up @@ -217,10 +228,13 @@
$t_question_title = sprintf( lang_get( 'actiongroup_menu_update_field' ), lang_get_defaulted( $t_custom_field_def['name'] ) );
$t_button_title = $t_question_title;
$t_form = 'custom_field_' . $t_custom_field_id;
$t_event_params['custom_field_id'] = $t_custom_field_id;
break;
default:
trigger_error( ERROR_GENERIC, ERROR );
}
$t_event_params['has_bugnote'] = $t_bugnote;

bug_group_action_print_top();
?>

Expand Down Expand Up @@ -363,6 +377,9 @@
<?php
}

# signal plugin event for additional fields
event_signal( 'EVENT_BUG_ACTIONGROUP_FORM', array( $t_event_params ) );

if( $t_bugnote ) {
?>
<tr>
Expand Down
1 change: 1 addition & 0 deletions core/events_inc.php
Expand Up @@ -124,6 +124,7 @@
# Other bug events
'EVENT_BUG_DELETED' => EVENT_TYPE_EXECUTE,
'EVENT_BUG_ACTION' => EVENT_TYPE_EXECUTE,
'EVENT_BUG_ACTIONGROUP_FORM' => EVENT_TYPE_EXECUTE,

# Bugnote events
'EVENT_BUGNOTE_ADD_FORM' => EVENT_TYPE_EXECUTE,
Expand Down
36 changes: 36 additions & 0 deletions docbook/Developers_Guide/en-US/Events_Reference_Bug.xml
Expand Up @@ -242,6 +242,42 @@
</blockquote>
</blockquote>

<blockquote id="dev.eventref.bug.action.bugactiongroupform">
<title>EVENT_BUG_ACTIONGROUP_FORM (Execute)</title>

<blockquote>
<para>
This event allows plugins to do processing or display form elements in
the bug group action page form. It is triggered immediately after the standard fields,
and before bugnote fields (if applicable).
</para>

<para>
Any output here should be defining appropriate rows and columns for the
surrounding &lt;table&gt; elements.
</para>

<itemizedlist>
<title>Parameters</title>
<listitem><para>&lt;Array&gt;: Array of event data elements</para></listitem>
</itemizedlist>

<itemizedlist>
<title>Parameter array contents</title>
<para>The parameter array contains elements for these indexes:</para>
<listitem><para>'action' =&gt; &lt;String&gt;: Action title (see <filename>bug_actiongroup.php</filename>)</para></listitem>
<listitem><para>'bug_ids' =&gt; &lt;Array&gt;: Array of selected bug ids</para></listitem>
<listitem><para>'multiple_projects' =&gt; &lt;Boolean&gt;: Flag if selected bug ids span multiple projects</para></listitem>
<listitem><para>'has_bugnote' =&gt; &lt;Boolean&gt;: Flag if current group action form contains a bugnote input</para></listitem>
</itemizedlist>

<itemizedlist>
<para>Depending on the action, any of these indexes may appear:</para>
<listitem><para>'custom_field_id' =&gt; &lt;Integer&gt;: If action is 'CUSTOM', contains the custom field id selected for update</para></listitem>
</itemizedlist>
</blockquote>
</blockquote>

<blockquote id="dev.eventref.bug.action.bugaction">
<title>EVENT_BUG_ACTION (Execute)</title>

Expand Down

0 comments on commit b1c3160

Please sign in to comment.