diff --git a/hook.php b/hook.php index 88eb873..4147bf5 100644 --- a/hook.php +++ b/hook.php @@ -557,6 +557,11 @@ function plugin_example_addParamFordynamicReport($itemtype) { function plugin_example_install() { global $DB; + $config = new Config(); + $config->setConfigurationValues('plugin:Example', array('configuration' => false)); + + ProfileRight::addProfileRights(array('example:read')); + if (!TableExists("glpi_plugin_example_examples")) { $query = "CREATE TABLE `glpi_plugin_example_examples` ( `id` int(11) NOT NULL auto_increment, @@ -611,6 +616,10 @@ function plugin_example_install() { function plugin_example_uninstall() { global $DB; + $config = new Config(); + $config->deleteConfigurationValues('plugin:Example', array('configuration' => false)); + + ProfileRight::deleteProfileRights(array('example:read')); $notif = new Notification(); $options = array('itemtype' => 'Ticket', diff --git a/inc/config.class.php b/inc/config.class.php new file mode 100644 index 0000000..9bb0950 --- /dev/null +++ b/inc/config.class.php @@ -0,0 +1,88 @@ +. + -------------------------------------------------------------------------- + */ + +class PluginExampleConfig extends CommonDBTM { + + static protected $notable = true; + + function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { + + if (!$withtemplate) { + if ($item->getType() == 'Config') { + return __('Example plugin'); + } + } + return ''; + } + + static function configUpdate($input) { + $input['configuration'] = 1 - $input['configuration']; + return $input; + } + + function showFormExample() { + global $CFG_GLPI; + + if (!Session::haveRight("config", "w")) { + return false; + } + + $my_config = Config::getConfigurationValues('plugin:Example'); + + echo "
"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + + + echo ""; + echo ""; + + echo "
" . __('Example setup') . "
" . __('My boolean choice :') . ""; + echo ""; + echo ""; + Dropdown::showYesNo("configuration", $my_config['configuration']); + echo "
"; + echo ""; + echo "
"; + Html::closeForm(); + } + + static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { + + if ($item->getType() == 'Config') { + $config = new self(); + $config->showFormExample(); + } + } + +} +?> \ No newline at end of file diff --git a/setup.php b/setup.php index 5b66d42..d36b260 100755 --- a/setup.php +++ b/setup.php @@ -42,6 +42,9 @@ function plugin_init_example() { // array('classname' => 'PluginExampleExample', // )); + Plugin::registerClass('PluginExampleConfig', array('addtabon' => 'Config')); + Plugin::registerClass('PluginExampleRight', array('addtabon' => 'Profile')); + // Params : plugin name - string type - ID - Array of attributes Plugin::registerClass('PluginExampleDropdown');