Skip to content

Commit

Permalink
Initial release of CustomReporter MantisBT plugin
Browse files Browse the repository at this point in the history
Original code by Carlos Proensa, and Cas Nuy as described in
http://www.mantisbt.org/bugs/view.php?id=11615
  • Loading branch information
Carlos Proensa, Cas Nuy authored and toto0000000000000000000000000000000007 committed Nov 12, 2010
0 parents commit 13ffa6c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
52 changes: 52 additions & 0 deletions CustomReporter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

class CustomReporterPlugin extends MantisPlugin {

function register() {
$this->name = 'CustomReporter';
$this->description = 'Ability to select Reporter';
$this->page = 'config';
$this->version = '1.0';
$this->requires = array( 'MantisCore' => '1.2.0', );
$this->author = 'Carlos Proensa';
$this->contact = '';
$this->url = '';
}

function config() {
return array(
'reporter_select_threshold' => DEVELOPER,
);
}


function init() {
plugin_event_hook( 'EVENT_REPORT_BUG_FORM_TOP', 'reportBugFormTop' );
plugin_event_hook( 'EVENT_REPORT_BUG_DATA', 'reportBug' );
}

function reportBugFormTop ( $p_event, $p_project_id){

#
#/ allow to change reporter_id (if access level is higher than defined)
#
$user_id= auth_get_current_user_id();
$access_level= user_get_access_level( $user_id, $p_project_id );
if ($access_level >plugin_config_get( 'reporter_select_threshold' )) {
echo '<tr><td class="category">';
echo 'Reporter: ';
echo '</td><td>';
echo '<select '.helper_get_tab_index().' name="user_id">';
print_reporter_option_list( $user_id, $p_new_bug->project_id );
echo '</select>';
}
echo '</td></tr>';
}


function reportBug($p_event,$p_bug_data) {
// this custom input was created on bug_report page event
$p_bug_data->reporter_id = gpc_get_int('user_id',auth_get_current_user_id());
return $p_bug_data;
}
}
5 changes: 5 additions & 0 deletions lang/strings_english.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?PHP
$s_plugin_format_title = "CustomReporterSelect";
$s_plugin_customceporter_config = "Configuration";
$s_reporter_select_threshold ="Treshold for selecting Reporter";
$s_change_configuration ="Update Config";
32 changes: 32 additions & 0 deletions pages/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
auth_reauthenticate();
access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );
html_page_top1( lang_get( 'plugin_format_title' ) );
html_page_top2();
print_manage_menu();
?>
<br/>
<form action="<?php echo plugin_page( 'config_edit' ) ?>" method="post">
<table align="center" class="width50" cellspacing="1">

<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'reporter_select_threshold' ) ?>
</td>
<td class="center">
<select name="reporter_select_threshold">
<?php print_enum_string_option_list( 'access_levels', plugin_config_get( 'reporter_select_threshold' ) ) ?>;
</select>
</td>
</tr>

<tr>
<td class="center" colspan="3">
<input type="submit" class="button" value="<?php echo lang_get( 'change_configuration' ) ?>" />
</td>
</tr>

</table>
<form>
<?php
html_page_bottom1( __FILE__ );
10 changes: 10 additions & 0 deletions pages/config_edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
// authenticate
auth_reauthenticate();
access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );
// Read results
$f_reporter_select_threshold = gpc_get_int( 'reporter_select_threshold', DEVELOPER );
// update results
plugin_config_set( 'reporter_select_threshold', $f_reporter_select_threshold );
// redirect
print_successful_redirect( plugin_page( 'config',TRUE ) );

0 comments on commit 13ffa6c

Please sign in to comment.