/**
  * 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;
         }
     }
 }
 /**
  * Launch a command
  * 
  * @param array $values
  * 
  * @return void
  */
 static function lauchCommand($values)
 {
     global $CFG_GLPI;
     $items_to_execute = json_decode(stripslashes($values['items_to_execute']), true);
     if (!empty($items_to_execute)) {
         foreach ($items_to_execute as $key => $items) {
             PluginShellcommandsCommandGroup_Item::lauchCommand(array('itemID' => $items['items_id'], 'itemtype' => $items['itemtype'], 'id' => $values['command_group'], 'value' => null));
         }
     }
 }
 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.

 Shellcommands 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 shellcommands. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
Session::checkLoginUser();
$command = new PluginShellcommandsShellcommand();
$command_item = new PluginShellcommandsShellcommand_Item();
$command->checkGlobal(READ);
header("Content-Type: text/html; charset=UTF-8");
switch ($_POST['command_type']) {
    case 'PluginShellcommandsShellcommand':
        PluginShellcommandsShellcommand_Item::lauchCommand($_POST);
        break;
    case 'PluginShellcommandsCommandGroup':
        PluginShellcommandsCommandGroup_Item::lauchCommand($_POST);
        break;
    case 'PluginShellcommandsAdvanced_Execution':
        PluginShellcommandsAdvanced_Execution::lauchCommand($_POST);
        break;
}