public function create_db(array $data) { Container::get('hooks')->fire('controller.install.create_db'); // Handle db prefix $data['db_prefix'] = !empty($data['db_prefix']) ? $data['db_prefix'] : ''; // Init DB Core::init_db($data); // Load appropriate language translate('install', 'featherbb', $data['default_lang']); // Create tables foreach ($this->model->get_database_scheme() as $table => $sql) { if (!$this->model->create_table($data['db_prefix'] . $table, $sql)) { // Error handling $this->errors[] = 'A problem was encountered while creating table ' . $table; } } // Populate group table with default values foreach ($this->model->load_default_groups() as $group_name => $group_data) { $this->model->add_data('groups', $group_data); } Container::get('perms')->allowGroup(3, array('forum.read', 'users.view', 'search.topics', 'search.users')); Container::get('perms')->allowGroup(4, array('topic.reply', 'topic.post', 'topic.delete', 'post.delete', 'post.edit', 'email.send')); Container::get('perms')->allowGroup(2, array('mod.*', 'board.title.set')); Container::get('perms')->allowGroup(1, array('board.*')); Container::get('prefs')->set(array('post.min_interval' => 60, 'search.min_interval' => 30, 'email.min_interval' => 60, 'report.min_interval' => 60, 'core.timezone' => 0, 'core.time_format' => 'H:i:s', 'core.date_format' => 'Y-m-d', 'core.lang' => $data['default_lang'], 'core.style' => $data['default_style'], 'smilies.post.show' => 1, 'smilies.signature.show' => 1)); Container::get('prefs')->setGroup(2, array('post.min_interval' => 0, 'search.min_interval' => 0, 'email.min_interval' => 0, 'report.min_interval' => 0)); // Populate user table with default values $this->model->add_data('users', $this->model->load_default_user()); $this->model->add_data('users', $this->model->load_admin_user($data)); // Populate categories, forums, topics, posts $this->model->add_mock_forum($this->model->load_mock_forum_data($data)); // Store config in DB $this->model->save_config($this->load_default_config($data)); // Handle .htaccess if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) { $this->write_htaccess(); } // Redirect to homepage with success message return Router::redirect(Router::pathFor('home'), ['success', __('Message')]); }
public function create_db(array $data) { Core::init_db($data); // Load appropriate language load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'] . 'featherbb/lang/' . $data['default_lang'] . '/install.mo'); // Handle db prefix $data['db_prefix'] = !empty($data['db_prefix']) ? $data['db_prefix'] : ''; // Create tables foreach ($this->model->get_database_scheme() as $table => $sql) { if (!$this->model->create_table($data['db_prefix'] . $table, $sql)) { // Error handling $this->errors[] = 'A problem was encountered while creating table ' . $table; } } // Populate group table with default values foreach ($this->model->load_default_groups() as $group_name => $group_data) { $this->model->add_data('groups', $group_data); } // Populate user table with default values $this->model->add_data('users', $this->model->load_default_user()); $this->model->add_data('users', $this->model->load_admin_user($data)); // Populate categories, forums, topics, posts $this->model->add_mock_forum($this->model->load_mock_forum_data($data)); // Store config in DB $this->model->save_config($this->load_default_config($data)); // Handle .htaccess if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) { $this->write_htaccess(); } // Install success flash message $flash = new \Slim\Middleware\Flash(); $flash->set('success', __('Message')); $flash->save(); // Redirect to homepage Url::redirect($this->feather->urlFor('home')); }