/** * Display form to add exception of modules activation for each agent * * @param interger $items_id ID of the agent * * @return bool TRUE if form is ok * **/ function showFormAgentException($items_id) { global $CFG_GLPI; $pfAgent = new PluginFusioninventoryAgent(); $pfAgent->getFromDB($items_id); $canedit = $pfAgent->can($items_id, UPDATE); echo "<br/>"; if ($canedit) { echo "<form name='form_ic' method='post' action='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/agentmodule.form.php'>"; } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>" . __('Module', 'fusioninventory') . "</th>"; echo "<th>Activation</th>"; echo "<th>" . __('Module', 'fusioninventory') . "</th>"; echo "<th>Activation</th>"; echo "</tr>"; $a_modules = $this->find(); $i = 0; $a_methods = PluginFusioninventoryStaticmisc::getmethods(); foreach ($a_modules as $data) { if ($i == 0) { echo "<tr class='tab_bg_1'>"; } $modulename = $data["modulename"]; foreach ($a_methods as $datamod) { if (strtolower($data["modulename"]) == strtolower($datamod['method']) || isset($datamod['task']) && strtolower($data["modulename"]) == strtolower($datamod['task'])) { if (isset($datamod['name'])) { $modulename = $datamod['name']; } break; } } // Hack for snmpquery if ($data["modulename"] == 'SNMPQUERY') { $modulename = __('Network inventory (SNMP)', 'fusioninventory'); } // Hack for deploy if ($data["modulename"] == 'DEPLOY') { $modulename = __('Package deployment', 'fusioninventory'); } echo "<td width='50%'>" . $modulename . " :</td>"; echo "<td align='center'>"; $checked = $data['is_active']; $a_agentList = importArrayFromDB($data['exceptions']); if (in_array($items_id, $a_agentList)) { if ($checked == 1) { $checked = 0; } else { $checked = 1; } } $check = ""; if ($checked == 1) { $check = "checked='checked'"; } echo "<input type='checkbox' name='activation-" . $data["modulename"] . "' " . "value='Activation' " . $check . " />"; echo "</td>"; if ($i == 1) { echo "</tr>"; $i = -1; } $i++; } if ($i == 1) { echo "<td></td>"; echo "<td></td>"; echo "</tr>"; } if ($canedit) { echo "<tr>"; echo "<td class='tab_bg_2 center' colspan='4'>"; echo Html::hidden('id', array('value' => $items_id)); echo "<input type='submit' name='updateexceptions' " . "value=\"" . __('Update') . "\" class='submit'>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); } else { echo "</table>"; } }