static function removeFileInRepo($sha512, $orders_id) { $repoPath = GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/repository/"; $manifestsPath = GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/manifests/"; $order = new PluginFusioninventoryDeployOrder(); $rows = $order->find("id != '{$orders_id}'\n AND json LIKE '%" . substr($sha512, 0, 6) . "%'\n AND json LIKE '%{$sha512}%'"); if (count($rows) > 0) { //file found in other order, do not remove part in repo return FALSE; } //get current order json $datas = json_decode(PluginFusioninventoryDeployOrder::getJson($orders_id), TRUE); $multiparts = $datas['associatedFiles'][$sha512]['multiparts']; //parse all files part foreach ($multiparts as $part_sha512) { $dir = $repoPath . self::getDirBySha512($part_sha512) . '/'; //delete file parts unlink($dir . $part_sha512); } return TRUE; }
static function move_item($params) { //get current order json $datas = json_decode(PluginFusioninventoryDeployOrder::getJson($params['orders_id']), TRUE); //get data on old index $moved_check = $datas['jobs']['actions'][$params['old_index']]; //remove this old index in json unset($datas['jobs']['actions'][$params['old_index']]); //insert it in new index (array_splice for insertion, ex : http://stackoverflow.com/a/3797526) array_splice($datas['jobs']['actions'], $params['new_index'], 0, array($moved_check)); //update order PluginFusioninventoryDeployOrder::updateOrderJson($params['orders_id'], $datas); }