/**
  * Adds a system configuration by path
  *
  * Example: ./typo3cms configuration:addbypath --path="DB/database" --value="myDatabase"
  *
  * @param string $path Path to system configuration that should be added. 
  * @param string $force If set, do not ask for confirmation
  */
 public function addByPathCommand($path = '', $value = '')
 {
     $args = $this->request->getArguments();
     $path = $args['path'];
     $value = $args['value'];
     $added = $this->configurationManager->setLocalConfigurationValueByPath($path, $value);
     if (!$added) {
         $this->outputLine('Paths seems invalid or empty. Nothing done!');
         $this->sendAndExit(1);
     }
     $this->outputLine('Added to system configuration');
 }
Пример #2
0
 /**
  * @param array $localconfValues
  * @return void
  */
 private function writeLocalconfArray(array $localconfValues)
 {
     if (!$this->configurationManager instanceof ConfigurationManager) {
         $this->configurationManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
     }
     $this->configurationManager->setLocalConfigurationValueByPath('EXT/extConf/snowbabel', serialize($localconfValues));
     ExtensionManagementUtility::removeCacheFiles();
 }
 /**
  * @test
  */
 public function setLocalConfigurationValueByPathUpdatesValueDefinedByPath()
 {
     $currentLocalConfiguration = array('notChanged' => 23, 'toUpdate' => 'notUpdated');
     $expectedConfiguration = array('notChanged' => 23, 'toUpdate' => 'updated');
     $this->createSubjectWithMockedMethods(array('isValidLocalConfigurationPath', 'getLocalConfiguration', 'writeLocalConfiguration'));
     $this->subject->expects($this->once())->method('isValidLocalConfigurationPath')->will($this->returnValue(true));
     $this->subject->expects($this->once())->method('getLocalConfiguration')->will($this->returnValue($currentLocalConfiguration));
     $this->subject->expects($this->once())->method('writeLocalConfiguration')->with($expectedConfiguration);
     $this->subject->setLocalConfigurationValueByPath('toUpdate', 'updated');
 }
 /**
  * Parse old curl options and set new http ones instead
  *
  * @return void
  */
 protected function transferDeprecatedCurlSettings()
 {
     $changed = false;
     try {
         $curlProxyServer = $this->configurationManager->getLocalConfigurationValueByPath('SYS/curlProxyServer');
     } catch (\RuntimeException $e) {
         $curlProxyServer = '';
     }
     try {
         $proxyHost = $this->configurationManager->getLocalConfigurationValueByPath('HTTP/proxy_host');
     } catch (\RuntimeException $e) {
         $proxyHost = '';
     }
     if (!empty($curlProxyServer) && empty($proxyHost)) {
         $curlProxy = rtrim(preg_replace('#^https?://#', '', $curlProxyServer), '/');
         $proxyParts = GeneralUtility::revExplode(':', $curlProxy, 2);
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/proxy_host', $proxyParts[0]);
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/proxy_port', $proxyParts[1]);
         $changed = true;
     }
     try {
         $curlProxyUserPass = $this->configurationManager->getLocalConfigurationValueByPath('SYS/curlProxyUserPass');
     } catch (\RuntimeException $e) {
         $curlProxyUserPass = '';
     }
     try {
         $proxyUser = $this->configurationManager->getLocalConfigurationValueByPath('HTTP/proxy_user');
     } catch (\RuntimeException $e) {
         $proxyUser = '';
     }
     if (!empty($curlProxyUserPass) && empty($proxyUser)) {
         $userPassParts = explode(':', $curlProxyUserPass, 2);
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/proxy_user', $userPassParts[0]);
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/proxy_password', $userPassParts[1]);
         $changed = true;
     }
     try {
         $curlUse = $this->configurationManager->getLocalConfigurationValueByPath('SYS/curlUse');
     } catch (\RuntimeException $e) {
         $curlUse = '';
     }
     try {
         $adapter = $this->configurationManager->getConfigurationValueByPath('HTTP/adapter');
     } catch (\RuntimeException $e) {
         $adapter = '';
     }
     if (!empty($curlUse) && $adapter !== 'curl') {
         $GLOBALS['TYPO3_CONF_VARS']['HTTP']['adapter'] = 'curl';
         $this->configurationManager->setLocalConfigurationValueByPath('HTTP/adapter', 'curl');
         $changed = true;
     }
     if ($changed) {
         $this->throwRedirectException();
     }
 }
Пример #5
0
 /**
  * Migrate the configuration setting BE/lockSSL to boolean if set in the LocalConfiguration.php file
  *
  * @return void
  */
 protected function migrateLockSslSetting()
 {
     try {
         $currentOption = $this->configurationManager->getLocalConfigurationValueByPath('BE/lockSSL');
         // check if the current option is an integer/string and if it is active
         if (!is_bool($currentOption) && (int) $currentOption > 0) {
             $this->configurationManager->setLocalConfigurationValueByPath('BE/lockSSL', true);
             $this->throwRedirectException();
         }
     } catch (\RuntimeException $e) {
         // no change inside the LocalConfiguration.php found, so nothing needs to be modified
     }
 }
 /**
  * The encryption key is crucial for securing form tokens
  * and the whole TYPO3 link rendering later on. A random key is set here in
  * LocalConfiguration if it does not exist yet. This might possible happen
  * during upgrading and will happen during first install.
  *
  * @return void
  */
 protected function generateEncryptionKeyIfNeeded()
 {
     try {
         $currentValue = $this->configurationManager->getLocalConfigurationValueByPath('SYS/encryptionKey');
     } catch (\RuntimeException $e) {
         // If an exception is thrown, the value is not set in LocalConfiguration
         $currentValue = '';
     }
     if (empty($currentValue)) {
         $randomKey = GeneralUtility::getRandomHexString(96);
         $this->configurationManager->setLocalConfigurationValueByPath('SYS/encryptionKey', $randomKey);
         $this->throwRedirectException();
     }
 }
 /**
  * Write the current configuration to localconf.php
  * This is needed for any sites that were relying on the former default
  * values which are going to change in TYPO3 4.5.
  *
  * @param 	array		&$dbQueries: queries done in this update
  * @param 	mixed		&$customMessages: custom messages
  * @return 	boolean		whether the updated was made or not
  */
 public function performUpdate(array &$dbQueries, &$customMessages)
 {
     // Update "setDBinit" setting
     $result1 = FALSE;
     if (\TYPO3\CMS\Core\Configuration\ConfigurationManager::getLocalConfigurationValueByPath('SYS/setDBinit') === '-1') {
         $result1 = \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('SYS/setDBinit', '');
     }
     // Update the "forceCharset" setting
     $result2 = FALSE;
     if (\TYPO3\CMS\Core\Configuration\ConfigurationManager::getLocalConfigurationValueByPath('BE/forceCharset') !== '') {
         $result2 = \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('BE/forceCharset', '');
     }
     if ($result1 && $result2) {
         $customMessages[] = 'The configuration was successfully updated.';
         return TRUE;
     } else {
         return FALSE;
     }
 }
 /**
  * Migrate the definition of the image processor from the configuration value
  * im_version_5 to the setting processor.
  *
  * @return void
  */
 protected function migrateImageProcessorSetting()
 {
     $changedSettings = array();
     $settingsToRename = array('GFX/im' => 'GFX/processor_enabled', 'GFX/im_version_5' => 'GFX/processor', 'GFX/im_v5effects' => 'GFX/processor_effects', 'GFX/im_path' => 'GFX/processor_path', 'GFX/im_path_lzw' => 'GFX/processor_path_lzw', 'GFX/im_mask_temp_ext_gif' => 'GFX/processor_allowTemporaryMasksAsPng', 'GFX/im_noScaleUp' => 'GFX/processor_allowUpscaling', 'GFX/im_noFramePrepended' => 'GFX/processor_allowFrameSelection', 'GFX/im_stripProfileCommand' => 'GFX/processor_stripColorProfileCommand', 'GFX/im_useStripProfileByDefault' => 'GFX/processor_stripColorProfileByDefault', 'GFX/colorspace' => 'GFX/processor_colorspace');
     foreach ($settingsToRename as $oldPath => $newPath) {
         try {
             $value = $this->configurationManager->getLocalConfigurationValueByPath($oldPath);
             $this->configurationManager->setLocalConfigurationValueByPath($newPath, $value);
             $changedSettings[$oldPath] = true;
         } catch (\RuntimeException $e) {
             // If an exception is thrown, the value is not set in LocalConfiguration
             $changedSettings[$oldPath] = false;
         }
     }
     if (!empty($changedSettings['GFX/im_version_5'])) {
         $currentProcessorValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_version_5');
         $newProcessorValue = $currentProcessorValue === 'gm' ? 'GraphicsMagick' : 'ImageMagick';
         $this->configurationManager->setLocalConfigurationValueByPath('GFX/processor', $newProcessorValue);
     }
     if (!empty($changedSettings['GFX/im_noScaleUp'])) {
         $currentProcessorValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_noScaleUp');
         $newProcessorValue = !$currentProcessorValue;
         $this->configurationManager->setLocalConfigurationValueByPath('GFX/processor_allowUpscaling', $newProcessorValue);
     }
     if (!empty($changedSettings['GFX/im_noFramePrepended'])) {
         $currentProcessorValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_noFramePrepended');
         $newProcessorValue = !$currentProcessorValue;
         $this->configurationManager->setLocalConfigurationValueByPath('GFX/processor_allowFrameSelection', $newProcessorValue);
     }
     if (!empty($changedSettings['GFX/im_mask_temp_ext_gif'])) {
         $currentProcessorValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_mask_temp_ext_gif');
         $newProcessorValue = !$currentProcessorValue;
         $this->configurationManager->setLocalConfigurationValueByPath('GFX/processor_allowTemporaryMasksAsPng', $newProcessorValue);
     }
     if (!empty(array_filter($changedSettings))) {
         $this->configurationManager->removeLocalConfigurationKeysByPath(array_keys($changedSettings));
         $this->throwRedirectException();
     }
 }
Пример #9
0
 /**
  * Writes the TSstyleconf values to "localconf.php"
  * Removes the temp_CACHED* files before return.
  *
  * @param string $extensionKey Extension key
  * @param array $newConfiguration Configuration array to write back
  * @return void
  */
 public function writeExtensionTypoScriptStyleConfigurationToLocalconf($extensionKey, $newConfiguration)
 {
     \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('EXT/extConf/' . $extensionKey, serialize($newConfiguration));
     \TYPO3\CMS\Core\Extension\ExtensionManager::removeCacheFiles();
 }
Пример #10
0
 /**
  * Update selected languages
  *
  * @param array $languages
  * @return array
  */
 public function updateSelectedLanguages($languages)
 {
     // Add possible dependencies for selected languages
     $dependencies = array();
     foreach ($languages as $language) {
         $dependencies = array_merge($dependencies, $this->locales->getLocaleDependencies($language));
     }
     if (count($dependencies)) {
         $languages = array_unique(array_merge($languages, $dependencies));
     }
     $dir = count($languages) - count($this->selectedLanguages);
     $diff = $dir < 0 ? array_diff($this->selectedLanguages, $languages) : array_diff($languages, $this->selectedLanguages);
     \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath($this->configurationPath, array('availableLanguages' => $languages));
     return array('success' => count($diff) > 0, 'dir' => $dir, 'diff' => array_values($diff), 'languages' => $languages);
 }
Пример #11
0
 /**
  * Marks some wizard as being "seen" so that it not shown again.
  *
  * Writes the info in LocalConfiguration.php
  *
  * @param mixed $confValue The configuration is set to this value
  * @return void
  */
 protected function markWizardAsDone($confValue = 1)
 {
     \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('INSTALL/wizardDone/' . get_class($this), $confValue);
 }
Пример #12
0
 /**
  * Writes extension list and clear cache files.
  *
  * @TODO : This method should be protected, but with current em it is hard to do so,
  * @param array Extension array to load, loader order is kept
  * @return void
  * @internal
  */
 public static function writeNewExtensionList(array $newExtensionList)
 {
     $extensionList = array_unique($newExtensionList);
     \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('EXT/extListArray', $extensionList);
     // @deprecated: extList as string is deprecated, the handling will be removed with 6.2
     // For now, this value is still set for better backwards compatibility
     \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('EXT/extList', implode(',', $extensionList));
     static::removeCacheFiles();
 }
Пример #13
0
 /**
  * Activates saltedpasswords.
  *
  * @return void
  */
 protected function activateSaltedPasswords()
 {
     if (!\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('rsaauth')) {
         \TYPO3\CMS\Core\Extension\ExtensionManager::loadExtension('rsaauth');
     }
     if (!\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('saltedpasswords')) {
         \TYPO3\CMS\Core\Extension\ExtensionManager::loadExtension('saltedpasswords');
     }
     \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('EXT/extConf/saltedpasswords', 'a:2:{s:3:"FE.";a:2:{s:7:"enabled";s:1:"1";s:21:"saltedPWHashingMethod";s:28:"tx_saltedpasswords_salts_md5";}s:3:"BE.";a:2:{s:7:"enabled";s:1:"1";s:21:"saltedPWHashingMethod";s:28:"tx_saltedpasswords_salts_md5";}}');
     \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('BE/loginSecurityLevel', 'rsa');
     \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('FE/loginSecurityLevel', 'rsa');
 }
Пример #14
0
 /**
  * Performs the update itself
  *
  * @param 	array		pointer where to insert all DB queries made, so they can be shown to the user if wanted
  * @param 	string		pointer to output custom messages
  * @return 	boolean		TRUE if update succeeded, FALSE otherwise
  * @todo Define visibility
  */
 public function performUpdate(&$dbQueries, &$customMessages)
 {
     $customMessages = '';
     // if we just set it to an older version
     if ($this->userInput['version']) {
         $customMessages .= 'If you want to see what you need to do to use the new features, run the update wizard again!';
     }
     $version = $this->userInput['version'] ? $this->userInput['version'] : TYPO3_branch;
     \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('SYS/compat_version', $version);
     $customMessages .= '<br />The compatibility version has been set to ' . $version . '.';
     return 1;
 }