static function displayList(PluginFusioninventoryDeployOrder $order, $datas, $rand) { global $CFG_GLPI; $pfDeployPackage = new PluginFusioninventoryDeployPackage(); $pfDeployPackage->getFromDB($order->fields['plugin_fusioninventory_deploypackages_id']); $o_file = new self(); // compute short shas to find the corresponding entries in database $short_shas = array(); foreach ($datas['jobs']['associatedFiles'] as $sha512) { $short_shas[] = "'" . substr($sha512, 0, 6) . "'"; } // find corresponding file entries $files = $o_file->find("shortsha512 IN (" . implode(",", $short_shas) . ")"); // do a quick mapping between database id and short shas $files_mapping = array(); foreach ($files as $f) { $files_mapping[$f['shortsha512']] = $f['id']; } echo "<table class='tab_cadrehov package_item_list' id='table_file_{$rand}'>"; $i = 0; foreach ($datas['jobs']['associatedFiles'] as $sha512) { $short_sha = substr($sha512, 0, 6); $fileregistry_error = 0; // check if the files is registered in database if (!array_key_exists($short_sha, $files_mapping)) { $fileregistry_error |= self::REGISTRY_NO_DB_ENTRY; } if (!$o_file->checkPresenceManifest($sha512)) { $fileregistry_error |= self::REGISTRY_NO_MANIFEST; } // get database entries if (!$fileregistry_error) { $file_id = $files_mapping[$short_sha]; // get file's name $file_name = $files[$file_id]['name']; // get file's size $file_size = $files[$file_id]['filesize']; //mimetype icon if (isset($files[$file_id]['mimetype'])) { $file_mimetype = str_replace('/', '__', $files[$file_id]['mimetype']); } else { $file_mimetype = NULL; } } else { // get file's name from what has been saved in json $file_name = $datas['associatedFiles'][$sha512]['name']; $file_size = NULL; $file_mimetype = NULL; } $file_uncompress = $datas['associatedFiles'][$sha512]['uncompress']; $file_p2p = $datas['associatedFiles'][$sha512]['p2p']; $file_p2p_retention_duration = $datas['associatedFiles'][$sha512]['p2p-retention-duration']; // start new line $pics_path = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/"; echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2); if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<td class='control'>"; Html::showCheckbox(array('name' => 'file_entries[]', 'value' => 0)); echo "</td>"; } echo "<td class='filename'>"; if (!empty($file_mimetype) && file_exists(GLPI_ROOT . "/plugins/fusioninventory/pics/ext/extensions/{$file_mimetype}.png")) { echo "<img src='" . $pics_path . "ext/extensions/{$file_mimetype}.png' />"; } else { echo "<img src='" . $pics_path . "ext/extensions/documents.png' />"; } //filename echo " " . "<a class='edit' " . " onclick=\"edit_subtype(" . " 'file', {$order->fields['id']}, {$rand}, this " . " )\"" . ">{$file_name}</a>"; //p2p icon if (isset($file_p2p) && $file_p2p != 0) { echo "<a title='" . __('p2p', 'fusioninventory') . ", " . __("retention", 'fusioninventory') . " : " . $file_p2p_retention_duration . " " . __("days", 'fusioninventory') . "' class='more'>"; echo "<img src='" . $pics_path . "p2p.png' />"; echo "<sup>" . $file_p2p_retention_duration . "</sup>"; echo "</a>"; } //uncompress icon if (isset($file_uncompress) && $file_uncompress != 0) { echo "<a title='" . __('uncompress', 'fusioninventory') . "' class='more'><img src='" . $pics_path . "uncompress.png' /></a>"; } //sha fingerprint $sha_status = "good"; if ($fileregistry_error != 0) { $sha_status = "bad"; } echo "<div class='fingerprint'>"; echo "<div class='fingerprint_" . $sha_status . "'>" . $sha512; if ($fileregistry_error & self::REGISTRY_NO_DB_ENTRY) { echo "<div class='fingerprint_badmsg'>" . __("This file is not correctly registered in database.") . "<br/>" . __("You can fix it by uploading or selecting the good one."); echo "</div>"; } if ($fileregistry_error & self::REGISTRY_NO_MANIFEST) { echo "<div class='fingerprint_badmsg'>" . __("This file doesn't have any manifest file associated.") . "<br/>" . __("You must upload the file."); echo "</div>"; } echo "</div>"; echo "</div>"; //filesize if (!$fileregistry_error) { echo "<div class='size'>"; echo __('Size') . ": " . self::processFilesize($file_size); echo "</div>"; } echo "</td>"; if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>"; } $i++; } if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<tr><th>"; Html::checkAllAsCheckbox("filesList{$rand}", mt_rand()); echo "</th><th colspan='3' class='mark'></th></tr>"; } echo "</table>"; if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo " <img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt=''>"; echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'>"; } }