/** * Returns the database prefix for the boards * * @return string */ public function getPrefix() { // if the value really doesn't exist in the db if ($this->preferences->get('foolfuuka.boards.prefix', null, true) === null) { return $this->dc->getPrefix() . 'board_'; } return $this->preferences->get('foolfuuka.boards.prefix'); }
public function install_modules() { $this->config->addPackage('unknown', ASSETSPATH); $class_name = $this->config->get('unknown', 'package', 'main.class_name'); $name_lowercase = strtolower($class_name); $modules = ['foolframe' => ['context' => '\\Foolz\\FoolFrame\\Model\\Context', 'namespace' => 'foolz/foolframe'], $name_lowercase => ['context' => $this->config->get('unknown', 'package', 'main.class_context'), 'namespace' => 'foolz/' . $name_lowercase]]; $dc = new DoctrineConnection($this->getContext(), $this->config); $sm = SchemaManager::forge($dc->getConnection(), $dc->getPrefix()); Schema::load($this->getContext(), $sm); $schema_class = '\\Foolz\\' . $class_name . '\\Model\\Schema'; $schema_class::load($this->getContext(), $sm); $sm->commit(); $this->config->set('foolz/foolframe', 'config', 'modules.installed', $modules); $this->config->set('foolz/foolframe', 'config', 'install.installed', true); $this->config->save('foolz/foolframe', 'config'); }
public function install($slug) { $plugin = $this->loader->get($slug); $plugin->install(); $this->dc->getConnection()->insert($this->dc->p('plugins'), ['slug' => $slug, 'enabled' => 1]); $this->clearCache(); // run the schema update $sm = \Foolz\FoolFrame\Model\SchemaManager::forge($this->dc->getConnection(), $this->dc->getPrefix() . 'plugin_'); foreach ($this->getInstalled() as $enabled) { try { $plug = $this->loader->get($enabled['slug']); if (!$plug->isBootstrapped()) { $plug->bootstrap(); } \Foolz\Plugin\Hook::forge('Foolz\\FoolFrame\\Model\\Plugin::install#' . $plug->getConfig('name'))->setParam('context', $this->getContext())->setParam('schema', $sm->getCodedSchema())->execute(); } catch (\OutOfBoundsException $e) { } } $sm->commit(); $this->clearCache(); }
public function action_database_setup() { if ($this->getPost()) { $validator = new Validator(); $validator->add('hostname', _i('Database Hostname'), [new Trim(), new Assert\NotBlank()])->add('prefix', _i('Table Prefix'), [new Trim()])->add('username', _i('Username'), [new Trim(), new Assert\NotBlank()])->add('database', _i('Database name'), [new Trim(), new Assert\NotBlank()]); $validator->validate($this->getPost()); if (!$validator->getViolations()->count()) { $input = $validator->getFinalValues(); $input['password'] = $this->getPost('password'); $input['type'] = $this->getPost('type'); if ($this->install->check_database($input)) { $this->install->setup_database($input); $dc = new DoctrineConnection($this->getContext(), $this->config); $sm = SchemaManager::forge($dc->getConnection(), $dc->getPrefix()); Schema::load($this->getContext(), $sm); $sm->commit(); $this->install->create_salts(); return new RedirectResponse($this->uri->create('install/create_admin')); } else { $this->notices->set('warning', _i('Connection to specified database failed. Please check your connection details again.')); } } else { $this->notices->set('warning', $validator->getViolations()->getText()); } } $this->process('database_setup'); $this->param_manager->setParam('method_title', _i('Database Setup')); $this->builder->createPartial('body', 'install/database_setup'); return new Response($this->builder->build()); }