public function testExtractAndMove()
 {
     $objFilesystem = new class_filesystem();
     $objFilesystem->folderCreate(_projectpath_ . "/temp/moduletest");
     file_put_contents(_realpath_ . _projectpath_ . "/temp/moduletest/metadata.xml", $this->getStrMetadata());
     $objFilesystem->folderCreate(_projectpath_ . "/temp/moduletest/system");
     file_put_contents(_realpath_ . _projectpath_ . "/temp/moduletest/system/test.txt", $this->getStrMetadata());
     $objZip = new class_zip();
     $objZip->openArchiveForWriting(_projectpath_ . "/temp/autotest.zip");
     $objZip->addFile(_projectpath_ . "/temp/moduletest/metadata.xml", "/metadata.xml");
     $objZip->addFile(_projectpath_ . "/temp/moduletest/system/test.txt", "/system/test.txt");
     $objZip->closeArchive();
     $objFilesystem->folderDeleteRecursive(_projectpath_ . "/temp/moduletest/");
     $objManager = new class_module_packagemanager_manager();
     $objPackageManager = $objManager->getPackageManagerForPath(_projectpath_ . "/temp/autotest.zip");
     $this->assertEquals(get_class($objPackageManager), "class_module_packagemanager_packagemanager_module");
     $objPackageManager = $objManager->extractPackage(_projectpath_ . "/temp/autotest.zip");
     $this->assertEquals(get_class($objPackageManager), "class_module_packagemanager_packagemanager_module");
     $objPackageManager->move2Filesystem();
     $this->assertFileExists(_realpath_ . "/core/module_autotest/metadata.xml");
     $this->assertFileExists(_realpath_ . "/core/module_autotest/system/test.txt");
     $objMetadata = new class_module_packagemanager_metadata();
     $objMetadata->autoInit("/core/module_autotest/");
     $this->assertEquals("Autotest", $objMetadata->getStrTitle());
     $this->assertEquals("", $objMetadata->getStrDescription());
     $this->assertEquals("3.9.1", $objMetadata->getStrVersion());
     $this->assertEquals("Kajona Team", $objMetadata->getStrAuthor());
     $this->assertEquals("module_autotest", $objMetadata->getStrTarget());
     $this->assertEquals(class_module_packagemanager_manager::STR_TYPE_MODULE, $objMetadata->getStrType());
     $this->assertEquals(false, $objMetadata->getBitProvidesInstaller());
     $arrRequired = $objMetadata->getArrRequiredModules();
     $arrModules = array_keys($arrRequired);
     $arrVersion = array_values($arrRequired);
     $this->assertEquals("system", $arrModules[0]);
     $this->assertEquals("3.4.1", $arrVersion[0]);
     $this->assertEquals("pages", $arrModules[1]);
     $this->assertEquals("3.4.2", $arrVersion[1]);
     $arrImages = $objMetadata->getArrScreenshots();
     $this->assertEquals(1, count($arrImages));
     $this->assertEquals("/test.jpg", $arrImages[0]);
     $objFilesystem->folderDeleteRecursive("/core/module_autotest");
     $objFilesystem->fileDelete(_projectpath_ . "/temp/autotest.zip");
 }
 /**
  * Triggers the installation of a package
  * @permissions edit
  * @return string
  */
 protected function actionInstallPackage()
 {
     $this->setArrModuleEntry("template", "/folderview.tpl");
     $strReturn = "";
     $strLog = "";
     $strFile = $this->getParam("package");
     $objManager = new class_module_packagemanager_manager();
     if ($objManager->validatePackage($strFile)) {
         if (uniSubstr($strFile, -4) == ".zip") {
             $objHandler = $objManager->extractPackage($strFile);
             $objFilesystem = new class_filesystem();
             $objFilesystem->fileDelete($strFile);
             $objHandler->move2Filesystem();
             class_classloader::getInstance()->flushCache();
             class_reflection::flushCache();
             class_resourceloader::getInstance()->flushCache();
             //reload the module-ids
             bootstrapIncludeModuleIds();
             //reload the current request in order to flush the class-loader
             $this->adminReload(class_link::getLinkAdminHref("packagemanager", "installPackage", "&package=" . $objHandler->getStrTargetPath()));
             return;
         } else {
             $objHandler = $objManager->getPackageManagerForPath($strFile);
         }
         if ($objHandler->getObjMetadata()->getBitProvidesInstaller()) {
             $strLog .= $objHandler->installOrUpdate();
         }
         $strLog .= "Updating default template pack...\n";
         $objHandler->updateDefaultTemplate();
         $strOnSubmit = 'window.parent.parent.location.reload();';
         if ($strLog !== "") {
             $strReturn .= $this->objToolkit->formHeadline($this->getLang("package_install_success"));
             $strReturn .= $this->objToolkit->getPreformatted(array($strLog));
             $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "list"), "", "", "javascript:" . $strOnSubmit);
             $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_ok"));
             $strReturn .= $this->objToolkit->formClose();
         } else {
             // break out of dialog and remove iframes by reloading main window
             $strReturn .= '<script>' . $strOnSubmit . '</script>';
         }
     }
     return $strReturn;
 }
 private function update_43_431()
 {
     $strReturn = "Updating 4.3 to 4.3.1...\n";
     $strReturn .= "This update removes the flot chart module and replaces it with the jqplot chart module...\n\n";
     //1. install module jqplot
     $strReturn .= "Installing module jqplot if not exist...\n";
     $objManager = new class_module_packagemanager_manager();
     $objExistingJqPlotPackage = $objManager->getPackage("jqplot");
     //if jqplot is not installed, install it
     if ($objExistingJqPlotPackage === null) {
         $objContentProvider = new class_module_packagemanager_contentprovider_kajona();
         $arrPackageMetaData = $objContentProvider->searchPackage("jqplot");
         //if a package was found
         if ($arrPackageMetaData !== null && count($arrPackageMetaData) == 1) {
             //upload the package to projects/temp
             class_carrier::getInstance()->setParam("systemid", $arrPackageMetaData[0]["systemid"]);
             $strFile = $objContentProvider->processPackageUpload();
             if ($objManager->validatePackage($strFile)) {
                 if (uniSubstr($strFile, -4) == ".zip") {
                     //now extract the zip file and......
                     $objHandler = $objManager->extractPackage($strFile);
                     $objFilesystem = new class_filesystem();
                     $objFilesystem->fileDelete($strFile);
                     //move the created folder to /core
                     $objHandler->move2Filesystem();
                 }
             } else {
                 $strReturn .= "Package file is not valid...\n";
                 $strReturn .= "Update to version 4.3.1 cancelled...\n";
                 return $strReturn;
             }
         } else {
             $strReturn = "Module jqplot was not found via the packagemanager...\n";
             $strReturn .= "Update to version 4.3.1 cancelled...\n";
             return $strReturn;
         }
     }
     //2. uninstall module flot
     $strReturn .= "Removing module flotchart if exists...\n";
     $objFlotPackage = $objManager->getPackage("flotchart");
     if ($objFlotPackage !== null) {
         //uninstall flot
         $class_filesystem = new class_filesystem();
         $class_filesystem->folderDeleteRecursive($objFlotPackage->getStrPath());
     }
     //3. set jqplot as standard chart library
     $strReturn .= "Set jqplot as standard chart library if flot was selected standard chart library...\n";
     $objSetting = class_module_system_setting::getConfigByName("_system_graph_type_");
     if ($objSetting->getStrValue() == "flot") {
         $objSetting->setStrValue("jqplot");
         $objSetting->updateObjectToDb();
     }
     //4. update version to 4.3.1
     $strReturn .= "Updating module-versions...\n";
     $this->updateModuleVersion("", "4.3.1");
     //5. reload classloader etc.
     class_resourceloader::getInstance()->flushCache();
     class_classloader::getInstance()->flushCache();
     class_reflection::flushCache();
     return $strReturn;
 }