示例#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');
 }
示例#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);
 }
示例#3
0
 private function clearCaches()
 {
     // clear cache with zikula's method
     $cacheClearer = $this->container->get('zikula.cache_clearer');
     $cacheClearer->clear('symfony');
     // use full symfony cache_clearer not zikula's to clear entire cache and set for warmup
     // console commands always run in `dev` mode but site should be `prod` mode. clear both for good measure.
     $this->container->get('cache_clearer')->clear('dev');
     $this->container->get('cache_clearer')->clear('prod');
     if (in_array($this->container->getParameter('env'), array('dev', 'prod'))) {
         // this is just in case anyone ever creates a mode that isn't dev|prod
         $this->container->get('cache_clearer')->clear($this->container->getParameter('env'));
     }
     // finally remove upgrading flag in parameters
     $this->yamlManager->delParameter('upgrading');
     return true;
 }
示例#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;
 }
示例#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'));
     }
 }
示例#6
0
 /**
  * @Route("/ml")
  * @Method("POST")
  *
  * update ML settings
  *
  * @param Request $request
  *
  * @return RedirectResponse
  *
  * @throws AccessDeniedException Thrown if the user doesn't have admin access to the module
  */
 public function updatemultilingualAction(Request $request)
 {
     $this->checkCsrfToken();
     // security check
     if (!SecurityUtil::checkPermission('ZikulaSettingsModule::', '::', ACCESS_ADMIN)) {
         throw new AccessDeniedException();
     }
     $locale = $request->request->get('mlsettings_language_i18n', 'en');
     $settings = array('mlsettings_language_i18n' => 'language_i18n', 'mlsettings_timezone_offset' => 'timezone_offset', 'mlsettings_timezone_server' => 'timezone_server', 'mlsettings_multilingual' => 'multilingual', 'mlsettings_language_detect' => 'language_detect', 'mlsettings_languageurl' => 'languageurl', 'mlsettings_timezone_adjust' => 'tzadjust', 'idnnames' => 'idnnames');
     // we can't detect language if multilingual feature is off so reset this to false
     if ($request->request->get('mlsettings_multilingual', null) == 0) {
         if (System::getVar('language_detect')) {
             System::setVar('language_detect', 0);
             unset($settings['mlsettings_language_detect']);
             $request->getSession()->getFlashBag()->add('status', $this->__('Notice: Language detection is automatically disabled when multi-lingual features are disabled.'));
         }
         $deleteLangUrl = true;
     }
     if (isset($deleteLangUrl)) {
         // reset language settings
         SessionUtil::delVar('language');
     }
     // Write the vars
     foreach ($settings as $formname => $varname) {
         $newvalue = $request->request->get($formname, null);
         $oldvalue = System::getVar($varname);
         if ($newvalue != $oldvalue) {
             System::setVar($varname, $newvalue);
         }
     }
     // update the custom_parameters.yml file
     $yamlManager = new YamlDumper($this->get('kernel')->getRootDir() . '/config');
     $yamlManager->setParameter('locale', $locale);
     // Reload multilingual routing settings.
     ModUtil::apiFunc('ZikulaRoutesModule', 'admin', 'reloadMultilingualRoutingSettings');
     // clear all cache and compile directories
     ModUtil::apiFunc('ZikulaSettingsModule', 'admin', 'clearallcompiledcaches');
     // all done successfully
     $request->getSession()->getFlashBag()->add('status', $this->__('Done! Saved localisation settings.'));
     $url = $this->get('router')->generate('zikulasettingsmodule_admin_multilingual', array(), RouterInterface::ABSOLUTE_URL);
     return new RedirectResponse($url);
 }
示例#7
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!");
 }
示例#8
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>');
 }