$sSize = SetupUtils::HumanReadableSize(filesize($sBackupFile)); $sConfirmRestore = addslashes(Dict::Format('bkp-confirm-restore', $sFileName)); $sFileEscaped = addslashes($sFilePath); $sRestoreBtn = '<button class="restore" onclick="LaunchRestoreNow(\'' . $sFileEscaped . '\', \'' . $sConfirmRestore . '\');" ' . $sDisableRestore . '>' . Dict::S('bkp-button-restore-now') . '</button>'; if (in_array($sBackupFile, $aFilesToDelete)) { $aDetails[] = array('file' => $sName . ' <span class="next_to_delete" title="' . Dict::S('bkp-next-to-delete') . '">*</span>', 'size' => $sSize, 'actions' => $sRestoreBtn); } else { $aDetails[] = array('file' => $sName, 'size' => $sSize, 'actions' => $sRestoreBtn); } } $aConfig = array('file' => array('label' => Dict::S('bkp-table-file'), 'description' => Dict::S('bkp-table-file+')), 'size' => array('label' => Dict::S('bkp-table-size'), 'description' => Dict::S('bkp-table-size+')), 'actions' => array('label' => Dict::S('bkp-table-actions'), 'description' => Dict::S('bkp-table-actions+'))); $oP->add("<fieldset>"); $oP->add("<legend>" . Dict::S('bkp-status-backups-auto') . "</legend>"); if (count($aDetails) > 0) { $oP->add('<div style="max-height:400px; overflow: auto;">'); $oP->table($aConfig, array_reverse($aDetails)); $oP->add('</div>'); } else { $oP->p(Dict::S('bkp-status-backups-none')); } $oP->add("</fieldset>"); // 2nd table: list the backups made manually // $aDetails = array(); foreach ($oBackup->ListFiles($sBackupDirManual) as $sBackupFile) { $sFileName = basename($sBackupFile); $sFilePath = 'manual/' . $sFileName; if (MetaModel::GetConfig()->Get('demo_mode')) { $sName = $sFileName; } else { $sAjax = utils::GetAbsoluteUrlModulePage('itop-backup', 'ajax.backup.php', array('operation' => 'download', 'file' => $sFilePath));
/** * Display the details of an import */ static function DisplayImportHistoryDetails(iTopWebPage $oPage, $iChange) { if ($iChange == 0) { throw new Exception("Missing parameter changeid"); } $oChange = MetaModel::GetObject('CMDBChange', $iChange, false); if (is_null($oChange)) { throw new Exception("Unknown change: {$iChange}"); } $oPage->add("<div><p><h1>" . Dict::Format('UI:History:BulkImportDetails', $oChange->Get('date'), $oChange->GetUserName()) . "</h1></p></div>\n"); // Assumption : change made one single class of objects $aObjects = array(); $aAttributes = array(); // array of attcode => occurences $oOpSearch = DBObjectSearch::FromOQL("SELECT CMDBChangeOp WHERE change = :change_id"); $oOpSet = new DBObjectSet($oOpSearch, array(), array('change_id' => $iChange)); while ($oOperation = $oOpSet->Fetch()) { $sClass = $oOperation->Get('objclass'); $iKey = $oOperation->Get('objkey'); $iObjId = "{$sClass}::{$iKey}"; if (!isset($aObjects[$iObjId])) { $aObjects[$iObjId] = array(); $aObjects[$iObjId]['__class__'] = $sClass; $aObjects[$iObjId]['__id__'] = $iKey; } if (get_class($oOperation) == 'CMDBChangeOpCreate') { $aObjects[$iObjId]['__created__'] = true; } elseif ($oOperation instanceof CMDBChangeOpSetAttribute) { $sAttCode = $oOperation->Get('attcode'); if (get_class($oOperation) == 'CMDBChangeOpSetAttributeScalar') { $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); if ($oAttDef->IsExternalKey()) { $sOldValue = Dict::S('UI:UndefinedObject'); if ($oOperation->Get('oldvalue') != 0) { $oOldTarget = MetaModel::GetObject($oAttDef->GetTargetClass(), $oOperation->Get('oldvalue')); $sOldValue = $oOldTarget->GetHyperlink(); } $sNewValue = Dict::S('UI:UndefinedObject'); if ($oOperation->Get('newvalue') != 0) { $oNewTarget = MetaModel::GetObject($oAttDef->GetTargetClass(), $oOperation->Get('newvalue')); $sNewValue = $oNewTarget->GetHyperlink(); } } else { $sOldValue = $oOperation->GetAsHTML('oldvalue'); $sNewValue = $oOperation->GetAsHTML('newvalue'); } $aObjects[$iObjId][$sAttCode] = $sOldValue . ' -> ' . $sNewValue; } else { $aObjects[$iObjId][$sAttCode] = 'n/a'; } if (isset($aAttributes[$sAttCode])) { $aAttributes[$sAttCode]++; } else { $aAttributes[$sAttCode] = 1; } } } $aDetails = array(); foreach ($aObjects as $iUId => $aObjData) { $aRow = array(); $oObject = MetaModel::GetObject($aObjData['__class__'], $aObjData['__id__'], false); if (is_null($oObject)) { $aRow['object'] = $aObjData['__class__'] . '::' . $aObjData['__id__'] . ' (deleted)'; } else { $aRow['object'] = $oObject->GetHyperlink(); } if (isset($aObjData['__created__'])) { $aRow['operation'] = Dict::S('Change:ObjectCreated'); } else { $aRow['operation'] = Dict::S('Change:ObjectModified'); } foreach ($aAttributes as $sAttCode => $iOccurences) { if (isset($aObjData[$sAttCode])) { $aRow[$sAttCode] = $aObjData[$sAttCode]; } elseif (!is_null($oObject)) { // This is the current vaslue: $oObject->GetAsHtml($sAttCode) // whereas we are displaying the value that was set at the time // the object was created // This requires addtional coding...let's do that later $aRow[$sAttCode] = ''; } else { $aRow[$sAttCode] = ''; } } $aDetails[] = $aRow; } $aConfig = array(); $aConfig['object'] = array('label' => MetaModel::GetName($sClass), 'description' => MetaModel::GetClassDescription($sClass)); $aConfig['operation'] = array('label' => Dict::S('UI:History:Changes'), 'description' => Dict::S('UI:History:Changes+')); foreach ($aAttributes as $sAttCode => $iOccurences) { $aConfig[$sAttCode] = array('label' => MetaModel::GetLabel($sClass, $sAttCode), 'description' => MetaModel::GetDescription($sClass, $sAttCode)); } $oPage->table($aConfig, $aDetails); }