Example #1
0
 private function writeParams($params)
 {
     try {
         $this->yamlManager->setParameters($params);
     } catch (IOException $e) {
         throw new AbortStageException(__f('Cannot write parameters to %s file.', 'custom_parameters.yml'));
     }
     // clear the cache
     $this->container->get('zikula.cache_clearer')->clear('symfony.config');
 }
Example #2
0
 private function writeParams($data = array())
 {
     $params = array_merge($this->yamlManager->getParameters(), $data);
     try {
         $this->yamlManager->setParameters($params);
     } catch (IOException $e) {
         throw new AbortStageException(__f('Cannot write parameters to %s file.', 'custom_parameters.yml'));
     }
     // setup multilingual
     $this->container->setParameter('language_i18n', $data['locale']);
     $this->container->setParameter('multilingual', true);
     $this->container->setParameter('languageurl', true);
     $this->container->setParameter('language_detect', false);
     //        $_lang = ZLanguage::getInstance();
     //        $_lang->setup($request);
 }
Example #3
0
 private function finalizeParameters()
 {
     \ModUtil::initCoreVars(true);
     // initialize the modvars array (includes ZConfig (System) vars)
     // Set the System Identifier as a unique string.
     if (!\System::getVar('system_identifier')) {
         \System::setVar('system_identifier', str_replace('.', '', uniqid(rand(1000000000, 9999999999), true)));
     }
     // store the recent version in a config var for later usage. This enables us to determine the version we are upgrading from
     \System::setVar('Version_Num', \Zikula_Core::VERSION_NUM);
     \System::setVar('language_i18n', \ZLanguage::getLanguageCode());
     // add new configuration parameters
     $params = $this->yamlManager->getParameters();
     unset($params['username'], $params['password']);
     if (!isset($params['secret']) || $params['secret'] == 'ThisTokenIsNotSoSecretChangeIt') {
         $params['secret'] = \RandomUtil::getRandomString(50);
     }
     if (!isset($params['url_secret'])) {
         $params['url_secret'] = \RandomUtil::getRandomString(10);
     }
     // Configure the Request Context
     // see http://symfony.com/doc/current/cookbook/console/sending_emails.html#configuring-the-request-context-globally
     $params['router.request_context.host'] = isset($params['router.request_context.host']) ? $params['router.request_context.host'] : $this->container->get('request')->getHost();
     $params['router.request_context.scheme'] = isset($params['router.request_context.scheme']) ? $params['router.request_context.scheme'] : 'http';
     $params['router.request_context.base_url'] = isset($params['router.request_context.base_url']) ? $params['router.request_context.base_url'] : $this->container->get('request')->getBasePath();
     $this->yamlManager->setParameters($params);
     return true;
 }
Example #4
0
 private function protectFiles()
 {
     // protect config.php and parameters.yml files
     foreach (array(realpath($this->container->get('kernel')->getRootDir() . '/../config/config.php'), realpath($this->container->get('kernel')->getRootDir() . '/../app/config/parameters.yml')) as $file) {
         @chmod($file, 0400);
         if (!is_readable($file)) {
             @chmod($file, 0440);
             if (!is_readable($file)) {
                 @chmod($file, 0444);
             }
         }
     }
     // set installed = true
     $params = $this->yamlManager->getParameters();
     $params['installed'] = true;
     $this->yamlManager->setParameters($params);
     // clear the cache
     $this->container->get('zikula.cache_clearer')->clear('symfony.config');
     return true;
 }
Example #5
0
 /**
  * Write admin credentials to param file as encoded values
  *
  * @param YamlDumper $yamlManager
  * @param array $data
  * @throws AbortStageException
  */
 public function writeEncodedAdminCredentials(YamlDumper $yamlManager, array $data)
 {
     foreach ($data as $k => $v) {
         $data[$k] = base64_encode($v);
         // encode so values are 'safe' for json
     }
     $params = array_merge($yamlManager->getParameters(), $data);
     try {
         $yamlManager->setParameters($params);
     } catch (IOException $e) {
         throw new AbortStageException(__f('Cannot write parameters to %s file.', 'custom_parameters.yml'));
     }
 }
Example #6
0
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException When the target directory does not exist or symlink cannot be used
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (version_compare(ZIKULACORE_CURRENT_INSTALLED_VERSION, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION, '<')) {
         $output->writeln(__f('The current installed version of Zikula is reporting (%1$s). You must upgrade to version (%2$s) before you can use this upgrade.', array(ZIKULACORE_CURRENT_INSTALLED_VERSION, UpgraderController::ZIKULACORE_MINIMUM_UPGRADE_VERSION)));
         return false;
     }
     $output->writeln(array("<info>---------------------------</info>", "| Zikula Upgrader Script |", "<info>---------------------------</info>"));
     $output->writeln("*** UPGRADING TO ZIKULA CORE v" . \Zikula_Core::VERSION_NUM . " ***");
     $env = $this->getContainer()->get('kernel')->getEnvironment();
     $output->writeln('Upgrading Zikula in <info>' . $env . '</info> environment.');
     $this->bootstrap(false);
     $output->writeln('Initializing upgrade...');
     $initStage = new InitStage($this->getContainer());
     $initStage->isNecessary();
     // runs init and upgradeUsersModule methods and intentionally returns false
     $output->writeln('Initialization complete');
     $warnings = $this->getContainer()->get('core_installer.controller.util')->initPhp();
     if (!empty($warnings)) {
         $this->printWarnings($output, $warnings);
         return;
     }
     $checks = $this->getContainer()->get('core_installer.controller.util')->requirementsMet($this->getContainer());
     if (true !== $checks) {
         $this->printRequirementsWarnings($output, $checks);
         return;
     }
     // get the settings from user input
     $formType = new LocaleType();
     $settings = $this->getHelper('form')->interactUsingForm($formType, $input, $output);
     $formType = new LoginType();
     $data = $this->getHelper('form')->interactUsingForm($formType, $input, $output);
     foreach ($data as $k => $v) {
         $data[$k] = base64_encode($v);
         // encode so values are 'safe' for json
     }
     $settings = array_merge($settings, $data);
     $formType = new RequestContextType();
     $data = $this->getHelper('form')->interactUsingForm($formType, $input, $output);
     foreach ($data as $k => $v) {
         $newKey = str_replace(':', '.', $k);
         $data[$newKey] = $v;
         unset($data[$k]);
     }
     $settings = array_merge($settings, $data);
     // write the parameters to custom_parameters.yml
     $yamlManager = new YamlDumper($this->getContainer()->get('kernel')->getRootDir() . '/config', 'custom_parameters.yml');
     $params = array_merge($yamlManager->getParameters(), $settings);
     $yamlManager->setParameters($params);
     // upgrade!
     $ajaxInstallerStage = new AjaxUpgraderStage();
     $stages = $ajaxInstallerStage->getTemplateParams();
     foreach ($stages['stages'] as $key => $stage) {
         $output->writeln($stage[AjaxInstallerStage::PRE]);
         $output->writeln("<fg=blue;options=bold>" . $stage[AjaxInstallerStage::DURING] . "</fg=blue;options=bold>");
         $status = $this->getContainer()->get('core_installer.controller.ajaxupgrade')->commandLineAction($stage[AjaxInstallerStage::NAME]);
         $message = $status ? "<info>" . $stage[AjaxInstallerStage::SUCCESS] . "</info>" : "<error>" . $stage[AjaxInstallerStage::FAIL] . "</error>";
         $output->writeln($message);
     }
     $output->writeln("UPGRADE COMPLETE!");
 }
Example #7
0
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException When the target directory does not exist or symlink cannot be used
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(array("<info>---------------------------</info>", "| Zikula Installer Script |", "<info>---------------------------</info>"));
     $this->bootstrap();
     if ($this->getContainer()->getParameter('installed') == true) {
         $output->writeln("<error>" . __('Zikula already appears to be installed.') . "</error>");
         return;
     }
     $warnings = $this->getContainer()->get('core_installer.controller.util')->initPhp();
     if (!empty($warnings)) {
         $this->printWarnings($output, $warnings);
         return;
     }
     $checks = $this->getContainer()->get('core_installer.controller.util')->requirementsMet($this->getContainer());
     if (true !== $checks) {
         $this->printRequirementsWarnings($output, $checks);
         return;
     }
     if ($input->isInteractive()) {
         $env = $this->getContainer()->get('kernel')->getEnvironment();
         $output->writeln('Configuring Zikula installation in <info>' . $env . '</info> environment.');
         $output->writeln("Please follow the instructions to install Zikula " . Zikula_Core::VERSION_NUM . ".");
     }
     // get the settings from user input
     $formType = new LocaleType();
     $settings = $this->getHelper('form')->interactUsingForm($formType, $input, $output);
     $formType = new RequestContextType();
     $data = $this->getHelper('form')->interactUsingForm($formType, $input, $output);
     foreach ($data as $k => $v) {
         $newKey = str_replace(':', '.', $k);
         $data[$newKey] = $v;
         unset($data[$k]);
     }
     $settings = array_merge($settings, $data);
     $formType = new DbCredsType();
     $data = $this->getHelper('form')->interactUsingForm($formType, $input, $output);
     $settings = array_merge($settings, $data);
     $formType = new CreateAdminType();
     $data = $this->getHelper('form')->interactUsingForm($formType, $input, $output);
     foreach ($data as $k => $v) {
         $data[$k] = base64_encode($v);
         // encode so values are 'safe' for json
     }
     $settings = array_merge($settings, $data);
     if ($input->isInteractive()) {
         $output->writeln(array("", "", ""));
         $output->writeln("Configuration successful. Please verify your parameters below:");
         $output->writeln("(Admin credentials have been encoded to make them json-safe.)");
     }
     $this->printSettings($settings, $output);
     $output->writeln("");
     if ($input->isInteractive()) {
         $helper = $this->getHelper('question');
         $question = new ConfirmationQuestion('<info>Start installation? <comment>[yes/no]</comment></info>: ', true);
         if (!$helper->ask($input, $output, $question)) {
             $output->writeln('<error>Installation aborted.</error>');
             return;
         }
     }
     // write the parameters to personal_config.php and custom_parameters.yml
     $yamlManager = new YamlDumper($this->getContainer()->get('kernel')->getRootDir() . '/config', 'custom_parameters.yml', 'parameters.yml');
     $params = array_merge($yamlManager->getParameters(), $settings);
     $dbh = new \PDO("{$params['database_driver']}:host={$params['database_host']};dbname={$params['database_name']}", $params['database_user'], $params['database_password']);
     $params['database_server_version'] = $dbh->getAttribute(\PDO::ATTR_SERVER_VERSION);
     $params['database_driver'] = 'pdo_' . $params['database_driver'];
     // doctrine requires prefix in custom_parameters.yml
     $yamlManager->setParameters($params);
     $this->getContainer()->get('core_installer.config.util')->writeLegacyConfig($params);
     $this->getContainer()->get('zikula.cache_clearer')->clear('symfony.config');
     $output->writeln('<info>First stage of installation complete. Run `php app/console zikula:install:finish` to complete the installation.</info>');
 }