Example #1
0
 protected function CompileBranding($oBrandingNode, $sTempTargetDir, $sFinalTargetDir)
 {
     if ($oBrandingNode) {
         // Transform file refs into files in the images folder
         SetupUtils::builddir($sTempTargetDir . '/branding');
         $this->CompileFiles($oBrandingNode, $sTempTargetDir . '/branding', $sFinalTargetDir . '/branding', 'branding');
         $this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'main_logo', 'main-logo');
         $this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'login_logo', 'login-logo');
         $this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'portal_logo', 'portal-logo');
         // Cleanup the images directory (eventually made by CompileFiles)
         if (file_exists($sTempTargetDir . '/branding/images')) {
             SetupUtils::rrmdir($sTempTargetDir . '/branding/images');
         }
     }
 }
 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);
 }