diff --git a/hook.php b/hook.php index 51d6be3..acd0849 100644 --- a/hook.php +++ b/hook.php @@ -25,6 +25,17 @@ function plugin_remotesupport_install() { global $DB; + $config = new Config(); + $config->setConfigurationValues('plugin:Remotesupport', + [ 'run_mode' => 'None', + 'threads' => 100, + 'show_in_tickets' => true, + 'show_in_computers' => true, + 'easy_novnc' => true, + 'fusion' => true] + ); + + Toolbox::logInFile("remotsupport", "Installing plugin"); $state_online = [ 'name' => 'Online', diff --git a/inc/config.class.php b/inc/config.class.php new file mode 100644 index 0000000..f13228c --- /dev/null +++ b/inc/config.class.php @@ -0,0 +1,112 @@ +. + -------------------------------------------------------------------------- + */ + +class PluginRemotesupportConfig extends CommonDBTM { + + static protected $notable = true; + + function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { + + if (!$withtemplate) { + if ($item->getType() == 'Config') { + return __('Remote Support plugin'); + } + } + return ''; + } + + static function configUpdate($input) { + $input['configuration'] = 1 - $input['configuration']; + return $input; + } + + function showFormRemotesupport() { + global $CFG_GLPI; + + if (!Session::haveRight("config", UPDATE)) { + return false; + } + + $my_config = Config::getConfigurationValues('plugin:Remotesupport'); + + echo "
"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + + echo ""; + echo ""; + + echo "
" . __('Remote support setup') . "
" . __('Run Mode:') . ""; + Dropdown::showFromArray('run_mode', array('None' => 'None','Serial'=>'Serial','Parallel' => 'Parallel'), array('value' => 'Serial')); + echo "" . __('EasyNoVNC Installed:') . ""; + Dropdown::showYesNo("easy_novnc", $my_config['easy_novnc']); + echo "
" . __('Show in Computers:') . ""; + Dropdown::showYesNo("show_in_computers", $my_config['show_in_computers']); + echo "" . __('Show in Tickets:') . ""; + Dropdown::showYesNo("show_in_tickets", $my_config['show_in_tickets']); + echo "
" . __('Threads:') . ""; + Dropdown::showNumber("threads", + [ + 'value' => 100, + 'min' => 1, + 'max' => 100 + ]); + echo "" . __('Fusion inventory:') . ""; + Dropdown::showYesNo("fusion", $my_config['fusion']); + echo "
"; + echo ""; + echo "
"; + Html::closeForm(); + } + + static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { + + if ($item->getType() == 'Config') { + $config = new self(); + $config->showFormRemotesupport(); + } + } + +} diff --git a/setup.php b/setup.php index 9c9e7f0..a99db11 100644 --- a/setup.php +++ b/setup.php @@ -37,6 +37,8 @@ function plugin_init_remotesupport() 'Computer' => array('PluginRemotesupportRemotesupport', 'showInfo'), ); + Plugin::registerClass('PluginRemotesupportConfig', ['addtabon' => 'Config']); + CronTask::Register('PluginRemotesupportRemotesupport', 'remotesupport', 300, ['mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30, 'comment' => 'Remotesupport crontab search agents']);