add('
'); $oP->add('

Creation of an archive for the business model: '.$sBizModel.'

'); $oP->p('Title of the archive: '); $oP->p('Description of this archive: '); $oP->p('Select the packages you want to include into this archive (When restoring the archive you will prompted to pick a package):'); $oP->p(' The full database (schema + data).'); $oP->p(' Only the schema but of the complete database.'); $oP->p(' The complete business model (all the tables used by the business model, schema + data).'); $oP->p(' Only the schema of the business model.'); $oP->add(''); $oP->add(''); $oP->add(''); $oP->add($oAppContext->GetForForm()); $oP->add('
'); $oP->p('Back to menu'); break; case 'do_create': $sTitle = utils::ReadParam('title', 'Unknown archive'); $sDescription = utils::ReadParam('description', 'No description provided for this archive.'); $bfullDump = utils::ReadParam('full', false); $bfullSchemaDump = utils::ReadParam('full_schema', false); $bBizDump = utils::ReadParam('biz', false); $bBizSchemaDump = utils::ReadParam('biz_schema', false); $sArchiveFile = '../tmp/archive1.zip'; $oArchive = new iTopArchive($sArchiveFile, iTopArchive::create); $oArchive->SetTitle($sTitle); $oArchive->SetDescription($sDescription); if ($bfullDump) { $oArchive->AddDatabaseDump("Full Database Dump", "Choose this option to completely reload your database. All current data will be deleted and replaced by the backup", "full-db.sql", 'itop', array(), false); } if ($bfullSchemaDump) { $oArchive->AddDatabaseDump("Full Schema Dump", "Choose this option to completely wipe out your database and start from an empty database", "full-schema.sql", 'itop', array(), true); } if ($bBizDump || $bBizSchemaDump) { // compute the list of the tables involved in the business model $aBizTables = array(); foreach(MetaModel::GetClasses('bizmodel') as $sClass) { $sTable = MetaModel::DBGetTable($sClass); $aBizTables[$sTable] = $sTable; } unset($aBizTables['']); if ($bfullDump) { $oArchive->AddDatabaseDump("Full Business Model Dump", "Choose this option to completely reload the business model part of your database. All current business data will be deleted and replaced by the backup. Application data (like menus...) are preserved.", "biz-db.sql", 'itop', $aBizTables, false); } if ($bfullSchemaDump) { $oArchive->AddDatabaseDump("Full Business Model Schema Dump", "Choose this option to wipe out the business data and start from an empty database. All current business data will be deleted. Application data (like menus...) are preserved.", "biz-schema.sql", 'itop', $aBizTables, true); } } $oArchive->WriteCatalog(); $oP->p("The archive '$sTitle' has been created in $sArchiveFile."); $oP->p('Back to menu'); break; case 'select_archive': $sArchivesDir = '../tmp'; $oP->add('
'); $oP->add('

Importation of an archive

'); $oP->p('Select the archive you want to import:'); $aArchives = array(); if ($handle = opendir($sArchivesDir)) { while (false !== ($sFileName = readdir($handle))) { if (strtolower(substr($sFileName, -3, 3)) == 'zip') { $oArchive = new iTopArchive('../tmp/'.$sFileName, iTopArchive::read); if ($oArchive->IsValid()) { $oArchive->ReadCatalog(); $aArchives['../tmp/'.$sFileName] = $oArchive->GetTitle(); } } } closedir($handle); } foreach($aArchives as $sFileName => $sTitle) { $oP->p(''.$sTitle); } $oP->add(''); $oP->add(''); $oP->add(''); $oP->add($oAppContext->GetForForm()); $oP->add('
'); $oP->p("(Archives are searched into the directory: $sArchivesDir.)"); $oP->p('Cancel'); break; case 'select_package': $sArchiveFile = utils::ReadParam('archive_file', ''); $oArchive = new iTopArchive($sArchiveFile, iTopArchive::read); $oArchive->ReadCatalog(); $oP->add('
'); $oP->add('

Selection of a package inside '.$oArchive->GetTitle().'

'); $oP->p('Select the package you want to apply:'); $aPackages = $oArchive->GetPackages(); foreach($aPackages as $sPackageName => $aPackage) { $oP->p(''.$aPackage['title']); $oP->p($aPackage['description']); } $oP->add(''); $oP->add(''); $oP->add(''); $oP->add(''); $oP->add($oAppContext->GetForForm()); $oP->add('
'); $oP->p('Cancel'); break; case 'import_package': $sArchiveFile = utils::ReadParam('archive_file', ''); $sPackageName = utils::ReadParam('package_name', ''); $oArchive = new iTopArchive($sArchiveFile, iTopArchive::read); $oArchive->ReadCatalog(); $oP->add('

Applying the package '.$sPackageName.'

'); if($oArchive->ImportSQL($sPackageName)) { $oP->p('Done.'); } else { $oP->p('Sorry, an error occured while applying the package...'); } $oP->p('Apply another package from the same archive'); $oP->p('Select another archive'); $oP->p('Back to the menu'); break; case 'menu': default: $oP->add('

Database backup & restore

'); $oP->add('

Select one of the actions below:

'); $oP->add('

Export the database to an archive

'); $oP->add('

Reload the database from an archive

'); } $oP->output(); ?>