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+ }
0 commit comments