Skip to content

Commit 083cf5b

Browse files
author
Alexis POKORSKI
committed
DescriptionField plugin on GitHub
0 parents  commit 083cf5b

9 files changed

Lines changed: 195 additions & 0 deletions

DescriptionField.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: apokorski
5+
* Date: 26/07/2018
6+
* Time: 11:27
7+
*/
8+
9+
class DescriptionFieldPlugin extends MantisPlugin {
10+
11+
function register() {
12+
$this->name = lang_get( 'plugin_description_title' );
13+
$this->description = lang_get( 'plugin_description_description' );
14+
$this->page = 'config';
15+
16+
$this->version = '1.0';
17+
$this->requires = array(
18+
'MantisCore' => '2.0.0',
19+
);
20+
21+
$this->author = 'Alexis POKORSKI';
22+
$this->contact = '';
23+
$this->url = '';
24+
}
25+
26+
function hooks(){
27+
return array(
28+
"EVENT_CORE_HEADERS" => 'csp_headers',
29+
"EVENT_LAYOUT_RESOURCES" => 'ressources',
30+
"EVENT_LAYOUT_PAGE_FOOTER" => 'update_description'
31+
);
32+
}
33+
34+
function ressources(){
35+
if(basename($_SERVER['PHP_SELF']) === 'bug_report_page.php') {
36+
echo '<script type="text/javascript" src="' . plugin_file('UpdateDescriptionTextArea.js') . '" ></script>';
37+
}
38+
}
39+
40+
function update_description(){
41+
if(basename($_SERVER['PHP_SELF']) === 'bug_report_page.php') {
42+
$f_master_bug_id = gpc_get_int( 'm_id', 0 );
43+
if($f_master_bug_id == 0){
44+
$description = json_encode(plugin_config_get('description_text'));
45+
echo '<script type="text/javascript"> setDescription('. $description . '); </script>';
46+
}
47+
}
48+
}
49+
50+
function csp_headers(){
51+
http_csp_add( 'script-src', "'unsafe-inline'" );
52+
}
53+
54+
/**
55+
* Default plugin configuration.
56+
* @return array
57+
*/
58+
function config() {
59+
return array(
60+
'description_text' => '[u]Profil (Navigateur, utilisateur, poste de travail)[/u]:
61+
62+
[u]Description[/u] :
63+
64+
[u]Étapes pour reproduire[/u] :
65+
66+
[u]Résultat attendu[/u] :
67+
68+
'
69+
);
70+
}
71+
72+
73+
74+
75+
}

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
DescriptionField
2+
=============
3+
## Description
4+
5+
Mantis Bug Tracker plugin which add template on description field when you report a ticket.
6+
7+
If you want to guide your users in describing the problems, use this plugin !
8+
9+
## Repository Information
10+
11+
| Branch | Description |
12+
| ------------------------------------------------------------ | ------------------------------------------------------ |
13+
| [master](https://github.com/VirusTwo/DescriptionField) | Support for MantisBT 2.x (current production version). |
14+
15+
16+
## Installation
17+
18+
1. Download the files and place the folder `DescriptionField` in the directory `plugins/` of your Mantis installation.
19+
2. With administrator privileges, go to the page *"Manage"* / *"Manage Plugins"*
20+
3. In the list *"Available Plugins"*, you should see *"DescriptionField"*: click the install link for the plugin.
21+
4. When you have install, you can click on it to configure description template directly in configuration page.
22+
23+
The DescriptionField plugin is now available.
24+
25+
## Change Log
26+
27+
## Screenshots & Gif :
28+
29+
What change DescriptionField plugin ?
30+
31+
![DescriptionFieldConfig](https://github.com/VirusTwo/DescriptionField/blob/master/screenshots/descriptionFieldConfigScreen.PNG)
32+
33+
34+
![DescriptionFieldScreen](https://github.com/VirusTwo/DescriptionField/blob/master/screenshots/descriptionFieldScreen.png)
35+
36+

files/UpdateDescriptionTextArea.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
function setDescription(description) {
3+
$('textarea[name="description"]').val(description);
4+
};

lang/strings_english.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
$s_plugin_description_title = 'Template of description field';
3+
$s_plugin_description_description = 'Adds a description template to guide users';
4+
$s_plugin_description_config = 'Config';
5+
$s_plugin_description_template_title = 'Description Template :';
6+

lang/strings_french.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
$s_plugin_description_title = 'Template de description';
3+
$s_plugin_description_description = 'Ajoute un template de description pour orienter les utilisateurs.';
4+
$s_plugin_description_config = 'Configuration';
5+
$s_plugin_description_template_title = 'Template de description';
6+

pages/config.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
auth_reauthenticate( );
3+
access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );
4+
5+
layout_page_header( lang_get( 'plugin_description_title' ) );
6+
7+
layout_page_begin( 'manage_overview_page.php' );
8+
9+
print_manage_menu( 'manage_plugin_page.php' );
10+
11+
?>
12+
13+
<div class="col-md-12 col-xs-12">
14+
<div class="space-10"></div>
15+
<div class="form-container" >
16+
17+
<form id="formatting-config-form" action="<?php echo plugin_page( 'config_edit' )?>" method="post">
18+
<?php echo form_security_field( 'plugin_format_config_edit' ) ?>
19+
20+
<div class="widget-box widget-color-blue2">
21+
<div class="widget-header widget-header-small">
22+
<h4 class="widget-title lighter">
23+
<i class="ace-icon fa fa-text-width"></i>
24+
<?php echo lang_get( 'plugin_description_title' ) . ': ' . lang_get( 'plugin_description_config' )?>
25+
</h4>
26+
</div>
27+
<div class="widget-body">
28+
<div class="widget-main no-padding">
29+
<div class="table-responsive">
30+
<table class="table table-bordered table-condensed table-striped">
31+
<tr>
32+
<th class="category width-40">
33+
<?php echo lang_get( 'plugin_description_template_title' )?>
34+
</th>
35+
<td class="center" width="20%">
36+
<textarea name="description" cols="80" rows="10"><?php echo plugin_config_get('description_text')?></textarea>
37+
</td>
38+
</tr>
39+
40+
</table>
41+
</div>
42+
</div>
43+
<div class="widget-toolbox padding-8 clearfix">
44+
<input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'change_configuration' )?>" />
45+
</div>
46+
</div>
47+
</div>
48+
</form>
49+
</div>
50+
</div>
51+
52+
<?php
53+
layout_page_end();

pages/config_edit.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
form_security_validate( 'plugin_format_config_edit' );
3+
4+
auth_reauthenticate( );
5+
access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );
6+
7+
$f_description_text = gpc_get_string( 'description');
8+
9+
if( plugin_config_get( 'description_text' ) != $f_description_text ) {
10+
plugin_config_set( 'description_text', $f_description_text );
11+
}
12+
13+
form_security_purge( 'plugin_format_config_edit' );
14+
15+
print_successful_redirect( plugin_page( 'config', true ) );
27.1 KB
Loading
73.3 KB
Loading

0 commit comments

Comments
 (0)