/** * @test * @return void */ public function updateWizardDoesNotRunIfCssStyledContentIsInstalled() { $this->packageManagerProphecy->isPackageActive('fluid_styled_content')->willReturn(true); $this->packageManagerProphecy->isPackageActive('css_styled_content')->willReturn(true); $description = ''; $this->assertFalse($this->updateWizard->checkForUpdate($description)); }
/** * Unloads given extension * * Warning: This method only works if the ugrade wizard to transform * localconf.php to LocalConfiguration.php was already run * * @param string $extensionKey Extension key to remove * @return void * @throws \RuntimeException */ public static function unloadExtension($extensionKey) { if (!static::$packageManager->isPackageActive($extensionKey)) { throw new \RuntimeException('Extension not loaded', 1342345487); } static::$packageManager->deactivatePackage($extensionKey); }
/** * Shows information about the distribution * * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension */ public function showAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) { $extensionKey = $extension->getExtensionKey(); // Check if extension/package is installed $active = $this->packageManager->isPackageActive($extensionKey); // Create link for extension configuration if ($active && file_exists(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey) . 'ext_conf_template.txt')) { $uriBuilder = $this->controllerContext->getUriBuilder(); $action = 'showConfigurationForm'; $configurationLink = $uriBuilder->reset()->uriFor($action, array('extension' => array('key' => $extensionKey)), 'Configuration'); } else { $configurationLink = FALSE; } $this->view->assign('distributionActive', $active); $this->view->assign('configurationLink', $configurationLink); $this->view->assign('extension', $extension); }
/** * @test */ public function deletePackageRemovesPackageFromAvailableAndActivePackagesAndDeletesThePackageDirectory() { $this->createPackage('Acme.YetAnotherTestPackage'); $this->assertTrue($this->packageManager->isPackageActive('Acme.YetAnotherTestPackage')); $this->assertTrue($this->packageManager->isPackageAvailable('Acme.YetAnotherTestPackage')); $this->packageManager->deletePackage('Acme.YetAnotherTestPackage'); $this->assertFalse($this->packageManager->isPackageActive('Acme.YetAnotherTestPackage')); $this->assertFalse($this->packageManager->isPackageAvailable('Acme.YetAnotherTestPackage')); }
/** * Creates users based on given array. * * @param $packageKey * @param $configuration * @param $configurationController */ public function createCLIUsers($packageKey, $configuration, $configurationController) { // Only create CLI users on configuration save of template bootstrap package if (TemplateBootstrapUtility::getPackageKey() !== $packageKey) { return; } // Get cli user names that supposedly need to be created $userNames = GeneralUtility::trimExplode(',', $configuration['createCLIUsers']['value']); foreach ($userNames as $userName) { $cliUserName = '******' . $userName; $cliUserNameQuoted = $GLOBALS['TYPO3_DB']->fullQuoteStr($cliUserName, 'be_users'); // Check, if user exists already $userExistsResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'be_users', 'username='******'TYPO3_DB']->sql_error()) { PostInstallInfoLogger::log('Failed to check whether BE user "' . $cliUserName . '" exists. Therefore cancelled. Error: ' . $GLOBALS['TYPO3_DB']->sql_error(), PostInstallInfoLogger::MESSAGE_TYPE_SYSTEM_ERROR); continue; } // User exists - (re-) activate, in case it has been deleted previously if ($GLOBALS['TYPO3_DB']->sql_num_rows($userExistsResult) > 0) { $existingUserRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($userExistsResult); if ($existingUserRow['deleted']) { $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_users', 'uid=' . $existingUserRow['uid'], array('deleted' => 0)); $updatedError = $GLOBALS['TYPO3_DB']->sql_error(); if ($updatedError) { PostInstallInfoLogger::log('Failed to reactivate (un-delete) BE user "' . $cliUserName . '". Error: ' . $GLOBALS['TYPO3_DB']->sql_error(), PostInstallInfoLogger::MESSAGE_TYPE_SYSTEM_ERROR); } else { PostInstallInfoLogger::log('Reactivated (un-deleted) BE user "' . $cliUserName . '"' . $GLOBALS['TYPO3_DB']->sql_error(), PostInstallInfoLogger::MESSAGE_TYPE_OK); } } // Skip to next user(name) as this one was handled by simply reactivating it. continue; } // Create user $saltedPassword = md5($this->getRandomPassword()); if (PackageManager::isPackageActive('saltedpasswords')) { $saltingInstance = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(); $saltedPassword = $saltingInstance->getHashedPassword($saltedPassword); } $createdSqlResult = $GLOBALS['TYPO3_DB']->exec_INSERTquery('be_users', array('crdate' => time(), 'tstamp' => time(), 'cruser_id' => $GLOBALS['BE_USER']->user['uid'], 'username' => $cliUserName, 'password' => $saltedPassword)); // Failed to create user if ($GLOBALS['TYPO3_DB']->sql_error()) { PostInstallInfoLogger::log('Failed to create BE user "' . $cliUserName . '". Error: ' . $GLOBALS['TYPO3_DB']->sql_error(), PostInstallInfoLogger::MESSAGE_TYPE_SYSTEM_ERROR); // User successfully created } else { PostInstallInfoLogger::log('Created BE user "' . $cliUserName . '"', PostInstallInfoLogger::MESSAGE_TYPE_OK); } } // foreach user that needs to be created }
/** * Wrapper function to check for loaded extensions * * @param string $extensionKey * @return boolean TRUE if extension is loaded */ public function isLoaded($extensionKey) { return $this->packageManager->isPackageActive($extensionKey); }