/** * Set up maintenance user and install lock. * @param string $data POST data if any. * @return \Jivoo\Routing\Response|string Response. */ public function configure($data = null) { $this->viewData['title'] = tr('Configure maintenance user'); $form = new Form('user'); $form->addField('username', DataType::string(), tr('Username')); $form->addField('password', DataType::string(), tr('Password')); $form->addField('confirmPassword', DataType::string(), tr('Confirm password')); $form->username = '******'; if (isset($data)) { $form->addData($data['user']); if ($form->isValid()) { if ($form->password !== $form->confirmPassword) { $form->addError('password', tr('The two passwords are not identical.')); } else { $auth = $this->m->Setup->getAuth(); $password = $auth->passwordHasher->hash($form->password); $this->m->Setup->lock($form->username, $password); return $this->next(); } } } $this->viewData['user'] = $form; return $this->render(); }
/** * Installer step: Configure database driver. * @param array $data POST data. * @return \Jivoo\Routing\Response|string Response. */ public function configure($data = null) { if (!isset($this->config['driver'])) { return $this->back(); } $driver = $this->DatabaseDrivers->checkDriver($this->config['driver']); if (!isset($driver) or $driver['isAvailable'] !== true) { unset($this->config['driver']); if ($this->config->save()) { return $this->back(); } else { return $this->saveConfig(); } } $this->viewData['title'] = tr('Configure %1', $driver['name']); $form = new Form('driver'); foreach ($driver['requiredOptions'] as $option) { $form->addString($option, $this->getOptionLabel($option)); } foreach ($driver['optionalOptions'] as $option) { $form->addString($option, $this->getOptionLabel($option), false); } if (isset($data)) { $form->addData($data['driver']); if ($form->isValid()) { $class = 'Jivoo\\Databases\\Drivers\\' . $driver['driver'] . '\\' . $driver['driver'] . 'Database'; try { new $class(new DatabaseSchemaBuilder(), $form->getData()); $options = array_flip(array_merge($driver['requiredOptions'], $driver['optionalOptions'])); foreach ($form->getData() as $key => $value) { if (isset($options[$key])) { $this->config[$key] = $value; } } unset($this->config['migration']); return $this->saveConfigAndContinue(); } catch (ConnectionException $exception) { $this->Notify->error = tr('An error occured: %1', $exception->getMessage()); } } } else { $form->addData($this->config->toArray()); } $this->viewData['driver'] = $driver; $this->viewData['driverForm'] = $form; return $this->render(); }