-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial release of CustomReporter MantisBT plugin
Original code by Carlos Proensa, and Cas Nuy as described in http://www.mantisbt.org/bugs/view.php?id=11615
- Loading branch information
0 parents
commit 13ffa6c
Showing
4 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__ ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) ); |