Esempio n. 1
0
function RebuildToolkitEnvironment()
{
    define('TOOLKITENV', 'toolkit');
    $oConfig = new Config(APPCONF . 'production' . '/' . ITOP_CONFIG_FILE);
    $oToolkitConfig = clone $oConfig;
    $oToolkitConfig->ChangeModulesPath('production', TOOLKITENV);
    if (file_exists(APPROOT . 'data/production.delta.xml')) {
        copy(APPROOT . 'data/production.delta.xml', APPROOT . 'data/toolkit.delta.xml');
    }
    $oEnvironment = new RunTimeEnvironment(TOOLKITENV);
    $oEnvironment->WriteConfigFileSafe($oToolkitConfig);
    $oEnvironment->CompileFrom('production');
}
Esempio n. 2
0
EOF
);
    $oP->add("<h1>Data Model Toolkit</h1>\n");
    define('TOOLKITENV', 'toolkit');
    // Compile the current code into the environment 'toolkit'
    // The environment will be rebuilt in case of refresh (if refreshing a view relying on this environment)
    //
    $oConfig = new Config(APPCONF . 'production/' . ITOP_CONFIG_FILE);
    if ($oConfig->Get('source_dir') == '') {
        throw new Exception('Missing entry source_dir from the config file');
    }
    $oToolkitConfig = clone $oConfig;
    $oToolkitConfig->ChangeModulesPath('production', TOOLKITENV);
    $oEnvironment = new RunTimeEnvironment(TOOLKITENV);
    $oEnvironment->WriteConfigFileSafe($oToolkitConfig);
    $oEnvironment->CompileFrom('production');
    $oP->add("<!-- tabs -->\n<div id=\"tabbedContent\" class=\"light\">\n");
    $oP->add("<ul>\n");
    $oP->add("<li><a href=\"#tab_0\" class=\"tab\"><span>Data Model Consistency</span></a></li>\n");
    $oP->add("<li><a href=\"#tab_1\" class=\"tab\"><span>iTop update</span></a></li>\n");
    $oP->add("<li><a href=\"#tab_2\" class=\"tab\"><span>Data Integrity</span></a></li>\n");
    $oP->add("<li><a href=\"#tab_3\" class=\"tab\"><span>Translations / Dictionnary</span></a></li>\n");
    $oP->add("</ul>\n");
    $oP->add("<div id=\"tab_0\">");
    CheckConsistency($oP);
    $oP->add("</div>\n");
    $oP->add("<div id=\"tab_1\">");
    CheckDBSchema($oP);
    $oP->add("</div>\n");
    $oP->add("<div id=\"tab_2\">");
    CheckDataIntegrity($oP);
 public function RestoreFromZip($sZipFile, $sEnvironment = 'production')
 {
     $this->LogInfo("Starting restore of " . basename($sZipFile));
     $oZip = new ZipArchiveEx();
     $res = $oZip->open($sZipFile);
     // Load the database
     //
     $sDataDir = tempnam(SetupUtils::GetTmpDir(), 'itop-');
     unlink($sDataDir);
     // I need a directory, not a file...
     SetupUtils::builddir($sDataDir);
     // Here is the directory
     $oZip->extractTo($sDataDir, 'itop-dump.sql');
     $sDataFile = $sDataDir . '/itop-dump.sql';
     $this->LoadDatabase($sDataFile);
     unlink($sDataFile);
     // Update the code
     //
     $sDeltaFile = APPROOT . 'data/' . $sEnvironment . '.delta.xml';
     if ($oZip->locateName('delta.xml') !== false) {
         // Extract and rename delta.xml => <env>.delta.xml;
         file_put_contents($sDeltaFile, $oZip->getFromName('delta.xml'));
     } else {
         @unlink($sDeltaFile);
     }
     if (is_dir(APPROOT . 'data/production-modules/')) {
         SetupUtils::rrmdir(APPROOT . 'data/production-modules/');
     }
     if ($oZip->locateName('production-modules/') !== false) {
         $oZip->extractDirTo(APPROOT . 'data/', 'production-modules/');
     }
     $sConfigFile = APPROOT . 'conf/' . $sEnvironment . '/config-itop.php';
     @chmod($sConfigFile, 0770);
     // Allow overwriting the file
     $oZip->extractTo(APPROOT . 'conf/' . $sEnvironment, 'config-itop.php');
     @chmod($sConfigFile, 0444);
     // Read-only
     $oEnvironment = new RunTimeEnvironment($sEnvironment);
     $oEnvironment->CompileFrom($sEnvironment);
 }