-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathConfig.php
More file actions
99 lines (84 loc) · 3.15 KB
/
Config.php
File metadata and controls
99 lines (84 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* -------------------------------------------------------------------------
* Example plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of Example.
*
* Example is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Example is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Example. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2006-2022 by Example plugin team.
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
* @link https://github.com/pluginsGLPI/example
* -------------------------------------------------------------------------
*/
namespace GlpiPlugin\Example;
use CommonDBTM;
use CommonGLPI;
use Config as GlpiConfig;
use Dropdown;
use Html;
use Session;
use Toolbox;
class Config extends CommonDBTM
{
protected static $notable = true;
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
if (!$withtemplate && $item->getType() == 'Config') {
return __s('Example plugin');
}
return '';
}
public static function configUpdate($input)
{
$input['configuration'] = 1 - $input['configuration'];
return $input;
}
public function showFormExample()
{
global $CFG_GLPI;
if (!Session::haveRight('config', UPDATE)) {
return false;
}
$my_config = GlpiConfig::getConfigurationValues('plugin:Example');
echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL('Config') . "\" method='post'>";
echo "<div class='center' id='tabsbody'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='4'>" . __s('Example setup') . '</th></tr>';
echo '<td >' . __s('My boolean choice :') . '</td>';
echo "<td colspan='3'>";
echo "<input type='hidden' name='config_class' value='" . self::class . "'>";
echo "<input type='hidden' name='config_context' value='plugin:Example'>";
Dropdown::showYesNo('configuration', $my_config['configuration']);
echo '</td></tr>';
echo "<tr class='tab_bg_2'>";
echo "<td colspan='4' class='center'>";
echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . '">';
echo '</td></tr>';
echo '</table></div>';
Html::closeForm();
}
public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
{
if ($item->getType() == 'Config') {
$config = new self();
$config->showFormExample();
}
return true;
}
}