function run($taskjobstate) { //get order type label $order_type_label = str_replace("deploy", "", $taskjobstate->method); //get numeric order type from label $order_type = PluginFusioninventoryDeployOrder::getRender($order_type_label); //get order by type and package id $order = new PluginFusioninventoryDeployOrder($order_type, $taskjobstate->fields['items_id']); //decode order data $order_data = json_decode($order->fields['json'], TRUE); /* TODO: * This has to be done properly in each corresponding classes. * Meanwhile, I just split the data to rebuild a proper and compliant JSON */ $order_job = $order_data['jobs']; //add uniqid to response data $order_job['uuid'] = $taskjobstate->fields['uniqid']; /* TODO: * Orders should only contain job data and associatedFiles should be retrieved from the * list inside Orders data like the following : * * $order_files = array() * foreach($order_job["associatedFiles"] as $hash) { * if (!isset($order_files[$hash]) { * $order_files[$hash] = PluginFusioninventoryDeployFile::getByHash($hash); * $order_files[$hash]['mirrors'] = $mirrors * } * } */ $order_files = $order_data['associatedFiles']; //Add mirrors to associatedFiles $mirrors = PluginFusioninventoryDeployMirror::getList($taskjobstate->fields['plugin_fusioninventory_agents_id']); foreach ($order_files as $hash => $params) { $order_files[$hash]['mirrors'] = $mirrors; $manifest = GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/manifests/" . $hash; $order_files[$hash]['multiparts'] = array(); if (file_exists($manifest)) { $handle = fopen($manifest, "r"); if ($handle) { while (($buffer = fgets($handle)) !== FALSE) { $order_files[$hash]['multiparts'][] = trim($buffer); } fclose($handle); } } } //Send an empty json dict instead of empty json list if (count($order_files) == 0) { $order_files = (object) array(); } $order = array("job" => $order_job, "associatedFiles" => $order_files); return $order; }