static function getMenuContent() { global $CFG_GLPI; $menu = array(); $menu['title'] = self::getMenuName(); $menu['page'] = "/plugins/ocsinventoryng/front/ocsng.php"; $menu['links']['search'] = "/plugins/ocsinventoryng/front/ocsng.php"; if (Session::haveRight(static::$rightname, UPDATE) || Session::haveRight("config", UPDATE)) { //Entry icon in breadcrumb $menu['links']['config'] = PluginOcsinventoryngConfig::getSearchURL(false); //Link to config page in admin plugins list $menu['config_page'] = PluginOcsinventoryngConfig::getSearchURL(false); } // Ocsserver $menu['options']['ocsserver']['title'] = __s("Configuration of OCSNG server", 'ocsinventoryng'); $menu['options']['ocsserver']['page'] = '/plugins/ocsinventoryng/front/ocsserver.php'; $menu['options']['ocsserver']['links']['add'] = '/plugins/ocsinventoryng/front/ocsserver.form.php'; $menu['options']['ocsserver']['links']['search'] = '/plugins/ocsinventoryng/front/ocsserver.php'; // Import $menu['options']['import']['title'] = __s('Import new computers', 'ocsinventoryng'); $menu['options']['import']['page'] = '/plugins/ocsinventoryng/front/ocsng.import.php'; // Sync $menu['options']['sync']['title'] = __s('Synchronize computers already imported', 'ocsinventoryng'); $menu['options']['sync']['page'] = '/plugins/ocsinventoryng/front/ocsng.sync.php'; // Link $menu['options']['link']['title'] = __s('Link new OCSNG computers to existing GLPI computers', 'ocsinventoryng'); $menu['options']['link']['page'] = '/plugins/ocsinventoryng/front/ocsng.link.php'; // Thread $menu['options']['thread']['title'] = __s('Scripts execution of automatic actions', 'ocsinventoryng'); $menu['options']['thread']['page'] = '/plugins/ocsinventoryng/front/thread.php'; // Detail $menu['options']['detail']['title'] = __('Computers imported by automatic actions', 'ocsinventoryng'); $menu['options']['detail']['page'] = '/plugins/ocsinventoryng/front/detail.php'; // Notimported $menu['options']['notimported']['title'] = __s('Computers not imported by automatic actions', 'ocsinventoryng'); $menu['options']['notimported']['page'] = '/plugins/ocsinventoryng/front/notimportedcomputer.php'; if (Session::haveRight("plugin_ocsinventoryng_clean", READ)) { // Deleted_equiv $menu['options']['deleted_equiv']['title'] = __s('Clean OCSNG deleted computers', 'ocsinventoryng'); $menu['options']['deleted_equiv']['page'] = '/plugins/ocsinventoryng/front/deleted_equiv.php'; // Clean $menu['options']['clean']['title'] = __s('Clean links between GLPI and OCSNG', 'ocsinventoryng'); $menu['options']['clean']['page'] = '/plugins/ocsinventoryng/front/ocsng.clean.php'; } return $menu; }
//Check if plugin is installed $plugin = new Plugin(); if (!$plugin->isInstalled("ocsinventoryng")) { echo "Disabled plugin\n"; exit(1); } if (!$plugin->isActivated("ocsinventoryng")) { echo "Disabled plugin\n"; exit(1); } $thread_nbr = ''; $threadid = ''; $ocsservers_id = -1; $fields = array(); //Get script configuration $config = new PluginOcsinventoryngConfig(); $notimport = new PluginOcsinventoryngNotimportedcomputer(); $config->getFromDB(1); if (!isset($_GET["ocs_server_id"]) || $_GET["ocs_server_id"] == '') { $ocsservers_id = -1; } else { $ocsservers_id = $_GET["ocs_server_id"]; } if (isset($_GET["managedeleted"]) && $_GET["managedeleted"] == 1) { //echo "=====================================================\n"; //echo "\tClean old Not Imported machine list (" . $notimport->cleanNotImported($ocsservers_id) . ")\n"; if ($ocsservers_id != -1) { FirstPass($ocsservers_id); } else { echo "\tManage delete items in all OCS server\n"; echo "=====================================================\n";
/** * @param $target **/ function showProcesses($target) { global $DB, $CFG_GLPI; $canedit = Session::haveRight("plugin_ocsinventoryng", UPDATE); $config = new PluginOcsinventoryngConfig(); $config->getFromDB(1); $minfreq = 9999; //$task = new CronTask(); //if ($task->getFromDBbyName('PluginOcsinventoryngThread', 'CleanOldThreads')) { //First of all, deleted old processes // $this->deleteOldProcesses($task->fields['param']); // if ($task->fields['param'] > 0) { // $minfreq=$task->fields['param']; // } //} $imported_number = new PluginOcsinventoryngMiniStat(); $synchronized_number = new PluginOcsinventoryngMiniStat(); $linked_number = new PluginOcsinventoryngMiniStat(); $failed_number = new PluginOcsinventoryngMiniStat(); $notupdated_number = new PluginOcsinventoryngMiniStat(); $notunique_number = new PluginOcsinventoryngMiniStat(); $linkedrefused_number = new PluginOcsinventoryngMiniStat(); $process_time = new PluginOcsinventoryngMiniStat(); $sql = "SELECT `id`, `processid`, SUM(`total_number_machines`) AS total_machines,\n `plugin_ocsinventoryng_ocsservers_id`, `status`, COUNT(*) AS threads_number,\n MIN(`start_time`) AS starting_date, MAX(`end_time`) AS ending_date,\n TIME_TO_SEC(MAX(`end_time`)) - TIME_TO_SEC(MIN(`start_time`)) AS duree,\n SUM(`imported_machines_number`) AS imported_machines,\n SUM(`synchronized_machines_number`) AS synchronized_machines,\n SUM(`linked_machines_number`) AS linked_machines,\n SUM(`failed_rules_machines_number`) AS failed_rules_machines,\n SUM(`notupdated_machines_number`) AS notupdated_machines,\n SUM(`not_unique_machines_number`) AS not_unique_machines_number,\n SUM(`link_refused_machines_number`) AS link_refused_machines_number,\n `end_time` >= DATE_ADD(NOW(), INTERVAL - " . $minfreq . " HOUR) AS DoStat\n FROM `" . $this->getTable() . "`\n GROUP BY `processid`\n ORDER BY `id` DESC\n LIMIT 50"; $result = $DB->query($sql); echo "<div class='center'>"; echo "<form name='processes' id='processes' action='{$target}' method='post'>"; echo "<table class='tab_cadrehov'>"; echo "<tr><th colspan='16'>" . __('Processes execution of automatic actions', 'ocsinventoryng') . "</th></tr>"; echo "<tr>"; echo "<th> </th>"; echo "<th> </th>"; echo "<th>" . __('Status') . "</th>"; echo "<th>" . __('Number of threads', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Beginning date of execution', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Ending date of execution', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers imported by automatic actions', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers synchronized', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers linked', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers not imported by automatic actions', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers not updated', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers not unique', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Computers refused', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Process time execution', 'ocsinventoryng') . "</th>"; echo "<th>" . __('Server') . "</th>"; echo "<th> </th>"; echo "</th></tr>\n"; if ($DB->numrows($result)) { while ($thread = $DB->fetch_array($result)) { if ($config->fields["is_displayempty"] || $thread["status"] != PLUGIN_OCSINVENTORYNG_STATE_FINISHED || !$config->fields["is_displayempty"] && $thread["total_machines"] > 0 && $thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) { if ($thread["DoStat"] && $thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) { $imported_number->AddValue($thread["imported_machines"]); $synchronized_number->AddValue($thread["synchronized_machines"]); $linked_number->AddValue($thread["linked_machines"]); $failed_number->AddValue($thread["failed_rules_machines"]); $notupdated_number->AddValue($thread["notupdated_machines"]); $notunique_number->AddValue($thread["not_unique_machines_number"]); $linkedrefused_number->AddValue($thread["link_refused_machines_number"]); $process_time->AddValue($thread["duree"]); } else { if ($imported_number->GetCount() > 0) { $this->showshowStat($minfreq, $imported_number, $synchronized_number, $linked_number, $failed_number, $notupdated_number, $notunique_number, $linkedrefused_number, $process_time); $imported_number->Reset(); } } echo "<tr class='tab_bg_1'>"; echo "<td width='10'>"; if ($canedit) { echo "<input type='checkbox' name='item[" . $thread["processid"] . "]' value='1'>"; } else { echo " "; } echo "</td>"; echo "<td class='center'>"; echo "<a href=\"./thread.form.php?pid=" . $thread["processid"] . "\">" . $thread["processid"] . "</a></td>"; echo "<td class='center'>"; $this->displayProcessStatusIcon($this->getProcessStatus($thread["processid"])); echo "</td>"; echo "<td class='center'>" . $thread["threads_number"] . "</td>"; echo "<td class='center'>" . Html::convDateTime($thread["starting_date"]) . "</td>"; echo "<td class='center'>" . Html::convDateTime($thread["ending_date"]) . "</td>"; echo "<td class='center'>" . $thread["imported_machines"] . "</td>"; echo "<td class='center'>" . $thread["synchronized_machines"] . "</td>"; echo "<td class='center'>" . $thread["linked_machines"] . "</td>"; echo "<td class='center'>" . $thread["failed_rules_machines"] . "</td>"; echo "<td class='center'>" . $thread["notupdated_machines"] . "</td>"; echo "<td class='center'>" . $thread["not_unique_machines_number"] . "</td>"; echo "<td class='center'>" . $thread["link_refused_machines_number"] . "</td>"; echo "<td class='center'>"; if ($thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) { echo Html::timestampToString($thread["duree"]); } else { echo Dropdown::EMPTY_VALUE; } echo "</td>"; echo "<td class='center'>"; if ($thread["plugin_ocsinventoryng_ocsservers_id"] != -1) { $ocsConfig = PluginOcsinventoryngOcsServer::getConfig($thread["plugin_ocsinventoryng_ocsservers_id"]); echo "<a href=\"ocsserver.form.php?id=" . $ocsConfig["id"] . "\">" . $ocsConfig["name"] . "</a>"; } else { _e('All servers', 'ocsinventoryng'); } echo "</td>"; echo "<td class='center'>"; echo "<a href=\"detail.php?reset=reset_before&field[0]=" . "5&contains[0]=^" . $thread["processid"] . '$">' . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png'</a></td>"; echo "</tr>\n"; } } } if ($imported_number->GetCount() > 0) { $this->showshowStat($minfreq, $imported_number, $synchronized_number, $linked_number, $failed_number, $notupdated_number, $notunique_number, $linkedrefused_number, $process_time); } echo "</table>"; if ($canedit) { Html::openArrowMassives("processes"); Html::closeArrowMassives(array("delete_processes" => _x('button', 'Delete permanently'))); } Html::closeForm(); }
/** * @return array */ function getAdditionalFields() { $can_update = PluginOcsinventoryngConfig::canUpdateOCS(); return array(array('name' => 'reason', 'label' => __('Reason of rejection'), 'type' => 'reason'), array('name' => 'rules_id', 'label' => __('Verified rules', 'ocsinventoryng'), 'type' => 'echo_rule'), array('name' => 'ocsid', 'label' => __('OCSNG ID', 'ocsinventoryng'), 'type' => 'echo'), array('name' => 'plugin_ocsinventoryng_ocsservers_id', 'label' => __('Server'), 'type' => 'echo_dropdown', 'table' => 'glpi_plugin_ocsinventoryng_ocsservers'), array('name' => 'ocs_deviceid', 'label' => __('Device ID', 'ocsinventoryng'), 'type' => 'echo'), array('name' => 'serial', 'label' => __('Serial number'), 'type' => $can_update ? 'text' : 'echo'), array('name' => 'tag', 'label' => __('OCSNG TAG', 'ocsinventoryng'), 'type' => $can_update ? 'text' : 'echo'), array('name' => 'useragent', 'label' => __('Inventory agent', 'ocsinventoryng'), 'type' => 'echo'), array('name' => 'ipaddr', 'label' => __('IP'), 'type' => 'echo'), array('name' => 'domain', 'label' => __('Domain'), 'type' => 'echo'), array('name' => 'last_inventory', 'label' => __('Last OCSNG inventory date', 'ocsinventoryng'), 'type' => 'echo_datetime')); }
Ocsinventoryng plugin 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. Ocsinventoryng plugin 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 ocsinventoryng. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Session::checkRight("plugin_ocsinventoryng", UPDATE); $config = new PluginOcsinventoryngConfig(); if (isset($_POST["update"])) { $config->update($_POST); Html::back(); } if (isset($_POST["soft_lock"])) { $config->setScriptLock(); } if (isset($_POST["soft_unlock"])) { $config->removeScriptLock(); } $plugin = new Plugin(); if ($plugin->isActivated("ocsinventoryng")) { Html::header(__("Automatic synchronization's configuration", 'ocsinventoryng'), '', "tools", "pluginocsinventoryngmenu", "config"); $config->showForm($_SERVER['PHP_SELF']); } else {
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. ocsinventoryng 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 ocsinventoryng. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Session::checkRight("plugin_ocsinventoryng", UPDATE); $config = new PluginOcsinventoryngConfig(); if (isset($_POST["update"])) { $config->update($_POST); Html::back(); } if (isset($_POST["soft_lock"])) { $config->setScriptLock(); } if (isset($_POST["soft_unlock"])) { $config->removeScriptLock(); } $plugin = new Plugin(); if ($plugin->isActivated("ocsinventoryng")) { Html::header(__("Automatic synchronization's configuration", 'ocsinventoryng'), '', "tools", "pluginocsinventoryngmenu", "config"); $config->display(array('id' => 1)); } else {
LICENSE This file is part of ocsinventoryng. Ocsinventoryng plugin 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. Ocsinventoryng plugin 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 ocsinventoryng. If not, see <http://www.gnu.org/licenses/>. ---------------------------------------------------------------------------------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $plugin = new Plugin(); if ($plugin->isActivated("ocsinventoryng") && plugin_ocsinventoryng_haveRight("ocsng", "w")) { Html::header('OCSInventory NG', "", "plugins", "ocsinventoryng"); // choose config server or config synchro PluginOcsinventoryngConfig::showMenu(); } else { Html::header(__('Setup'), '', "config", "plugins"); echo "<div class='center'><br><br>"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt='" . __s('Warning') . "'><br><br>"; echo "<b>" . __('Please activate the plugin', 'ocsinventoryng') . "</b></div>"; } Html::footer();
static function canUpdateOCS() { $config = new PluginOcsinventoryngConfig(); $config->getFromDB(1); return $config->fields['allow_ocs_update']; }
//Check if plugin is installed $plugin = new Plugin(); if (!$plugin->isInstalled("ocsinventoryng")) { echo "Disabled plugin\n"; exit(1); } if (!$plugin->isActivated("ocsinventoryng")) { echo "Disabled plugin\n"; exit(1); } $thread_nbr = ''; $threadid = ''; $ocsservers_id = -1; $fields = array(); //Get script configuration $config = new PluginOcsinventoryngConfig(); //$notimport = new PluginOcsinventoryngNotimportedcomputer(); $config->getFromDB(1); if (!isset($_GET["ocs_server_id"]) || $_GET["ocs_server_id"] == '') { $ocsservers_id = -1; } else { $ocsservers_id = $_GET["ocs_server_id"]; } if (isset($_GET["thread_nbr"]) || isset($_GET["thread_id"])) { if (!isset($_GET["thread_id"]) || $_GET["thread_id"] > $_GET["thread_nbr"] || $_GET["thread_id"] <= 0) { echo "Threadid invalid: threadid must be between 1 and thread_nbr\n\n"; exit(1); } $thread_nbr = $_GET["thread_nbr"]; $threadid = $_GET["thread_id"]; echo "=====================================================\n";