/** * Custom fonction to process shellcommand massive action **/ function doMassiveAction(MassiveAction $ma, array $ids) { if (!empty($ids)) { $input = $ma->getInput(); $itemtype = $ma->getItemType(false); $commands_id = $input['commandgroup']; switch ($ma->getAction()) { case 'generate': echo "<div class='center'>"; echo "<table class='tab_cadre_fixe center'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='4'>" . PluginShellcommandsCommandGroup::getTypeName(2) . "</th>"; echo "</tr>"; foreach ($ids as $key => $items_id) { PluginShellcommandsCommandGroup_Item::lauchCommand(array('itemID' => $items_id, 'itemtype' => $itemtype, 'id' => $commands_id, 'value' => null)); } echo "</table>"; echo "</div>"; break; } } }
/** * @since version 0.85 * * @see CommonDBTM::showMassiveActionsSubForm() **/ static function showMassiveActionsSubForm(MassiveAction $ma) { global $CFG_GLPI; switch ($ma->getAction()) { case 'move_under': $itemtype = $ma->getItemType(true); _e('As child of'); Dropdown::show($itemtype, array('name' => 'parent', 'comments' => 0, 'entity' => $_SESSION['glpiactive_entity'])); echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Move') . "'>\n"; return true; } return parent::showMassiveActionsSubForm($ma); }
/** * Custom fonction to process shellcommand massive action **/ function doMassiveAction(MassiveAction $ma, array $ids) { if (!empty($ids)) { $input = $ma->getInput(); $itemtype = $ma->getItemType(false); $commands_id = $input['command']; switch ($ma->getAction()) { case 'generate': $shellcommands_item = new PluginShellcommandsShellcommand_Item(); $shellcommands = new PluginShellcommandsShellcommand(); $item = getItemForItemtype($itemtype); echo "<div class='center'>"; echo "<table class='tab_cadre_fixe center'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='4'>" . PluginShellcommandsShellcommand::getTypeName(2) . "</th>"; echo "</tr>"; foreach ($ids as $key => $items_id) { if (!$shellcommands_item->getFromDBbyShellCommandsAndItem($commands_id, $itemtype)) { continue; } $shellcommands->getFromDB($commands_id); $item->getFromDB($items_id); $targetParam = PluginShellcommandsShellcommand_Item::resolveLinkOfCommand($shellcommands->getID(), $item); // Exec command on each targets : stop on first success $selectedTarget = null; if ($targetParam !== false) { foreach ($targetParam as $target) { list($error, $message) = PluginShellcommandsShellcommand_Item::execCommand($shellcommands->getID(), $target); if (!$error) { $selectedTarget = $target; break; } } } echo "<tr class='tab_bg_1 shellcommands_result_line'>"; echo "<td class='center' colspan='4'>" . __($item->getType()) . ' : ' . $item->getLink() . " - " . $selectedTarget . "</td>"; echo "</tr>"; PluginShellcommandsShellcommand::displayCommandResult($shellcommands, $selectedTarget, $message, $error); } echo "</table>"; echo "</div>"; break; } } }