本文整理汇总了PHP中phpbb\db\driver\driver_interface::get_sql_error_sql方法的典型用法代码示例。如果您正苦于以下问题:PHP driver_interface::get_sql_error_sql方法的具体用法?PHP driver_interface::get_sql_error_sql怎么用?PHP driver_interface::get_sql_error_sql使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\db\driver\driver_interface
的用法示例。
在下文中一共展示了driver_interface::get_sql_error_sql方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$languages = $this->language_helper->get_available_languages();
$installed_languages = array();
foreach ($languages as $lang_info) {
$lang_pack = array('lang_iso' => $lang_info['iso'], 'lang_dir' => $lang_info['iso'], 'lang_english_name' => htmlspecialchars($lang_info['name']), 'lang_local_name' => htmlspecialchars($lang_info['local_name'], ENT_COMPAT, 'UTF-8'), 'lang_author' => htmlspecialchars($lang_info['author'], ENT_COMPAT, 'UTF-8'));
$this->db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $this->db->sql_build_array('INSERT', $lang_pack));
$installed_languages[] = (int) $this->db->sql_nextid();
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message($error['message']);
}
}
$sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE;
$result = $this->db->sql_query($sql);
$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE);
while ($row = $this->db->sql_fetchrow($result)) {
foreach ($installed_languages as $lang_id) {
$insert_buffer->insert(array('field_id' => $row['field_id'], 'lang_id' => $lang_id, 'lang_name' => strtoupper(substr($row['field_name'], 6)), 'lang_explain' => '', 'lang_default_value' => ''));
}
}
$this->db->sql_freeresult($result);
$insert_buffer->flush();
}
示例2: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$table_prefix = $this->config->get('table_prefix');
$dbms = $this->config->get('dbms');
$dbms_info = $this->database_helper->get_available_dbms($dbms);
// Get schema data from file
$sql_query = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema_data.sql');
// Clean up SQL
$sql_query = $this->replace_dbms_specific_sql($sql_query);
$sql_query = preg_replace('# phpbb_([^\\s]*) #i', ' ' . $table_prefix . '\\1 ', $sql_query);
$sql_query = preg_replace_callback('#\\{L_([A-Z0-9\\-_]*)\\}#s', array($this, 'lang_replace_callback'), $sql_query);
$sql_query = $this->database_helper->remove_comments($sql_query);
$sql_query = $this->database_helper->split_sql_file($sql_query, $dbms_info[$dbms]['DELIM']);
$i = $this->config->get('add_default_data_index', 0);
$total = sizeof($sql_query);
$sql_query = array_slice($sql_query, $i);
foreach ($sql_query as $sql) {
if (!$this->db->sql_query($sql)) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
$i++;
// Stop execution if resource limit is reached
if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0) {
break;
}
}
$this->config->set('add_default_data_index', $i);
if ($i < $total) {
throw new resource_limit_reached_exception();
}
}
示例3: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$server_name = $this->install_config->get('server_name');
$current_time = time();
$user_ip = phpbb_ip_normalise($this->iohandler->get_server_variable('REMOTE_ADDR'));
$user_ip = $user_ip === false ? '' : $user_ip;
$referer = $this->iohandler->get_server_variable('REFERER');
// Calculate cookie domain
$cookie_domain = $server_name;
if (strpos($cookie_domain, 'www.') === 0) {
$cookie_domain = substr($cookie_domain, 3);
}
// Set default config and post data, this applies to all DB's
$sql_ary = array('INSERT INTO ' . $this->config_table . " (config_name, config_value)\n\t\t\t\tVALUES ('board_startdate', '{$current_time}')", 'INSERT INTO ' . $this->config_table . " (config_name, config_value)\n\t\t\t\tVALUES ('default_lang', '" . $this->db->sql_escape($this->install_config->get('default_lang')) . "')", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('img_imagick')) . "'\n\t\t\t\tWHERE config_name = 'img_imagick'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('server_name')) . "'\n\t\t\t\tWHERE config_name = 'server_name'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('server_port')) . "'\n\t\t\t\tWHERE config_name = 'server_port'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "'\n\t\t\t\tWHERE config_name = 'board_email'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "'\n\t\t\t\tWHERE config_name = 'board_contact'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($cookie_domain) . "'\n\t\t\t\tWHERE config_name = 'cookie_domain'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "'\n\t\t\t\tWHERE config_name = 'default_dateformat'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('email_enable')) . "'\n\t\t\t\tWHERE config_name = 'email_enable'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_delivery')) . "'\n\t\t\t\tWHERE config_name = 'smtp_delivery'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_host')) . "'\n\t\t\t\tWHERE config_name = 'smtp_host'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_port')) . "'\n\t\t\t\tWHERE config_name = 'smtp_port'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_auth')) . "'\n\t\t\t\tWHERE config_name = 'smtp_auth_method'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_user')) . "'\n\t\t\t\tWHERE config_name = 'smtp_username'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_pass')) . "'\n\t\t\t\tWHERE config_name = 'smtp_password'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('cookie_secure')) . "'\n\t\t\t\tWHERE config_name = 'cookie_secure'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('force_server_vars')) . "'\n\t\t\t\tWHERE config_name = 'force_server_vars'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('script_path')) . "'\n\t\t\t\tWHERE config_name = 'script_path'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('server_protocol')) . "'\n\t\t\t\tWHERE config_name = 'server_protocol'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'\n\t\t\t\tWHERE config_name = 'newest_username'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . md5(mt_rand()) . "'\n\t\t\t\tWHERE config_name = 'avatar_salt'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . md5(mt_rand()) . "'\n\t\t\t\tWHERE config_name = 'plupload_salt'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('board_name')) . "'\n\t\t\t\tWHERE config_name = 'sitename'", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->install_config->get('board_description')) . "'\n\t\t\t\tWHERE config_name = 'site_desc'", 'UPDATE ' . $this->user_table . "\n\t\t\t\tSET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "',\n\t\t\t\t\tuser_password='" . $this->password_manager->hash($this->install_config->get('admin_passwd')) . "',\n\t\t\t\t\tuser_ip = '" . $this->db->sql_escape($user_ip) . "',\n\t\t\t\t\tuser_lang = '" . $this->db->sql_escape($this->install_config->get('user_language', 'en')) . "',\n\t\t\t\t\tuser_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "',\n\t\t\t\t\tuser_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "',\n\t\t\t\t\tuser_email_hash = " . $this->db->sql_escape(phpbb_email_hash($this->install_config->get('board_email'))) . ",\n\t\t\t\t\tusername_clean = '" . $this->db->sql_escape(utf8_clean_string($this->install_config->get('admin_name'))) . "'\n\t\t\t\tWHERE username = 'Admin'", 'UPDATE ' . $this->moderator_cache_table . "\n\t\t\t\tSET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'\n\t\t\t\tWHERE username = 'Admin'", 'UPDATE ' . $this->forums_table . "\n\t\t\t\tSET forum_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'\n\t\t\t\tWHERE forum_last_poster_name = 'Admin'", 'UPDATE ' . $this->topics_table . "\n\t\t\t\tSET topic_first_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "',\n\t\t\t\ttopic_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'\n\t\t\t\tWHERE topic_first_poster_name = 'Admin'\n\t\t\t\t\tOR topic_last_poster_name = 'Admin'", 'UPDATE ' . $this->user_table . "\n\t\t\t\tSET user_regdate = {$current_time}", 'UPDATE ' . $this->posts_table . "\n\t\t\t\tSET post_time = {$current_time}, poster_ip = '" . $this->db->sql_escape($user_ip) . "'", 'UPDATE ' . $this->topics_table . "\n\t\t\t\tSET topic_time = {$current_time}, topic_last_post_time = {$current_time}", 'UPDATE ' . $this->forums_table . "\n\t\t\t\tSET forum_last_post_time = {$current_time}", 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->db->sql_server_info(true)) . "'\n\t\t\t\tWHERE config_name = 'dbms_version'");
if (@extension_loaded('gd')) {
$sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = 'core.captcha.plugins.gd'\n\t\t\t\tWHERE config_name = 'captcha_plugin'";
$sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '1'\n\t\t\t\tWHERE config_name = 'captcha_gd'";
}
$ref = substr($referer, strpos($referer, '://') + 3);
if (!(stripos($ref, $server_name) === 0)) {
$sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '0'\n\t\t\t\tWHERE config_name = 'referer_validation'";
}
// We set a (semi-)unique cookie name to bypass login issues related to the cookie name.
$cookie_name = 'phpbb3_';
$rand_str = md5(mt_rand());
$rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35));
$rand_str = substr($rand_str, 0, 5);
$cookie_name .= strtolower($rand_str);
$sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\tSET config_value = '" . $this->db->sql_escape($cookie_name) . "'\n\t\t\tWHERE config_name = 'cookie_name'";
// Disable avatars if upload directory is not writable
if (!$this->filesystem->is_writable($this->phpbb_root_path . 'images/avatars/upload/')) {
$sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '0'\n\t\t\t\tWHERE config_name = 'allow_avatar'";
$sql_ary[] = 'UPDATE ' . $this->config_table . "\n\t\t\t\tSET config_value = '0'\n\t\t\t\tWHERE config_name = 'allow_avatar_upload'";
}
$i = $this->install_config->get('add_config_settings_index', 0);
$total = sizeof($sql_ary);
$sql_ary = array_slice($sql_ary, $i);
foreach ($sql_ary as $sql) {
if (!$this->db->sql_query($sql)) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
$i++;
// Stop execution if resource limit is reached
if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
break;
}
}
if ($i < $total) {
$this->install_config->set('add_config_settings_index', $i);
throw new resource_limit_reached_exception();
}
}
示例4: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$table_prefix = $this->config->get('table_prefix');
$dbms = $this->config->get('dbms');
$dbms_info = $this->database_helper->get_available_dbms($dbms);
// Get schema data from file
$sql_query = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema_data.sql');
// Clean up SQL
$sql_query = $this->replace_dbms_specific_sql($sql_query);
$sql_query = preg_replace('# phpbb_([^\\s]*) #i', ' ' . $table_prefix . '\\1 ', $sql_query);
$sql_query = preg_replace_callback('#\\{L_([A-Z0-9\\-_]*)\\}#s', array($this, 'lang_replace_callback'), $sql_query);
$sql_query = $this->database_helper->remove_comments($sql_query);
$sql_query = $this->database_helper->split_sql_file($sql_query, $dbms_info[$dbms]['DELIM']);
foreach ($sql_query as $sql) {
if (!$this->db->sql_query($sql)) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
}
}
示例5: sql_query
/**
* Wrapper for running queries to generate user feedback on updates
*
* @param string $sql SQL query to run on the database
* @return mixed Query result from db->sql_query()
*/
protected function sql_query($sql)
{
$this->queries[] = $sql;
$this->db->sql_return_on_error(true);
if ($sql === 'begin') {
$result = $this->db->sql_transaction('begin');
} else {
if ($sql === 'commit') {
$result = $this->db->sql_transaction('commit');
} else {
$result = $this->db->sql_query($sql);
if ($this->db->get_sql_error_triggered()) {
$this->errors[] = array('sql' => $this->db->get_sql_error_sql(), 'code' => $this->db->get_sql_error_returned());
}
}
}
$this->db->sql_return_on_error(false);
return $result;
}
示例6: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$dbms = $this->config->get('dbms');
$dbms_info = $this->database_helper->get_available_dbms($dbms);
$delimiter = $dbms_info[$dbms]['DELIM'];
$table_prefix = $this->config->get('table_prefix');
$sql_query = @file_get_contents($this->schema_file_path);
$sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
$sql_query = $this->database_helper->remove_comments($sql_query);
$sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter);
foreach ($sql_query as $sql) {
if (!$this->db->sql_query($sql)) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
}
unset($sql_query);
}
示例7: add_module_extras
/**
* Add extra modules
*
* @param string $module_class
*/
protected function add_module_extras($module_class)
{
foreach ($this->module_extras[$module_class] as $cat_name => $mods) {
$sql = 'SELECT module_id, left_id, right_id
FROM ' . MODULES_TABLE . "\n\t\t\t\tWHERE module_langname = '" . $this->db->sql_escape($cat_name) . "'\n\t\t\t\t\tAND module_class = '" . $this->db->sql_escape($module_class) . "'";
$result = $this->db->sql_query_limit($sql, 1);
$row2 = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
foreach ($mods as $mod_name) {
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_langname = '" . $this->db->sql_escape($mod_name) . "'\n\t\t\t\t\t\tAND module_class = '" . $this->db->sql_escape($module_class) . "'\n\t\t\t\t\t\tAND module_basename <> ''";
$result = $this->db->sql_query_limit($sql, 1);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$module_data = array('module_basename' => $row['module_basename'], 'module_enabled' => (int) $row['module_enabled'], 'module_display' => (int) $row['module_display'], 'parent_id' => (int) $row2['module_id'], 'module_class' => $row['module_class'], 'module_langname' => $row['module_langname'], 'module_mode' => $row['module_mode'], 'module_auth' => $row['module_auth']);
$this->module_manager->update_module_data($module_data);
// Check for last sql error happened
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
}
}
}
示例8: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$dbms = $this->config->get('dbms');
$dbms_info = $this->database_helper->get_available_dbms($dbms);
$schema_name = $dbms_info[$dbms]['SCHEMA'];
$delimiter = $dbms_info[$dbms]['DELIM'];
$table_prefix = $this->config->get('table_prefix');
if ($dbms === 'mysql') {
if (version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) {
$schema_name .= '_41';
} else {
$schema_name .= '_40';
}
}
$db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql';
// Load database vendor specific code if there is any
if ($this->filesystem->exists($db_schema_path)) {
$sql_query = @file_get_contents($db_schema_path);
$sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
$sql_query = $this->database_helper->remove_comments($sql_query);
$sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter);
foreach ($sql_query as $sql) {
if (!$this->db->sql_query($sql)) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
}
unset($sql_query);
}
$change_prefix = false;
// Generate database schema
if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) {
$db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json');
$db_table_schema = json_decode($db_table_schema, true);
$change_prefix = true;
} else {
global $table_prefix;
$table_prefix = $this->config->get('table_prefix');
if (!defined('CONFIG_TABLE')) {
// We need to include the constants file for the table constants
// when we generate the schema from the migration files.
include $this->phpbb_root_path . 'includes/constants.' . $this->php_ext;
}
$finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext);
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($this->db, true);
$schema_generator = new \phpbb\db\migration\schema_generator($migrator_classes, new \phpbb\config\config(array()), $this->db, $db_tools, $this->phpbb_root_path, $this->php_ext, $table_prefix);
$db_table_schema = $schema_generator->get_schema();
}
if (!defined('CONFIG_TABLE')) {
// CONFIG_TABLE is required by sql_create_index() to check the
// length of index names. However table_prefix is not defined
// here yet, so we need to create the constant ourselves.
define('CONFIG_TABLE', $table_prefix . 'config');
}
foreach ($db_table_schema as $table_name => $table_data) {
$this->db_tools->sql_create_table($change_prefix ? $table_prefix . substr($table_name, 6) : $table_name, $table_data);
}
}
示例9: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->db->sql_return_on_error(true);
$module_classes = array('acp', 'mcp', 'ucp');
foreach ($module_classes as $module_class) {
$categories = array();
foreach ($this->module_categories[$module_class] as $cat_name => $subs) {
// Check if this sub-category has a basename. If it has, use it.
$basename = isset($this->module_categories_basenames[$cat_name]) ? $this->module_categories_basenames[$cat_name] : '';
$module_data = array('module_basename' => $basename, 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => 0, 'module_class' => $module_class, 'module_langname' => $cat_name, 'module_mode' => '', 'module_auth' => '');
$this->module_manager->update_module_data($module_data);
// Check for last sql error happened
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
$categories[$cat_name]['id'] = (int) $module_data['module_id'];
$categories[$cat_name]['parent_id'] = 0;
if (is_array($subs)) {
foreach ($subs as $level2_name) {
// Check if this sub-category has a basename. If it has, use it.
$basename = isset($this->module_categories_basenames[$level2_name]) ? $this->module_categories_basenames[$level2_name] : '';
$module_data = array('module_basename' => $basename, 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => (int) $categories[$cat_name]['id'], 'module_class' => $module_class, 'module_langname' => $level2_name, 'module_mode' => '', 'module_auth' => '');
$this->module_manager->update_module_data($module_data);
// Check for last sql error happened
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
$categories[$level2_name]['id'] = (int) $module_data['module_id'];
$categories[$level2_name]['parent_id'] = (int) $categories[$cat_name]['id'];
}
}
}
// Get the modules we want to add... returned sorted by name
$module_info = $this->module_manager->get_module_infos($module_class);
foreach ($module_info as $module_basename => $fileinfo) {
foreach ($fileinfo['modes'] as $module_mode => $row) {
foreach ($row['cat'] as $cat_name) {
if (!isset($categories[$cat_name])) {
continue;
}
$module_data = array('module_basename' => $module_basename, 'module_enabled' => 1, 'module_display' => isset($row['display']) ? (int) $row['display'] : 1, 'parent_id' => (int) $categories[$cat_name]['id'], 'module_class' => $module_class, 'module_langname' => $row['title'], 'module_mode' => $module_mode, 'module_auth' => $row['auth']);
$this->module_manager->update_module_data($module_data);
// Check for last sql error happened
if ($this->db->get_sql_error_triggered()) {
$error = $this->db->sql_error($this->db->get_sql_error_sql());
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
}
}
}
}
// Move some of the modules around since the code above will put them in the wrong place
if ($module_class === 'acp') {
// Move main module 4 up...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'acp_main'\n\t\t\t\t\t\tAND module_class = 'acp'\n\t\t\t\t\t\tAND module_mode = 'main'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
// Move permissions intro screen module 4 up...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'acp_permissions'\n\t\t\t\t\t\tAND module_class = 'acp'\n\t\t\t\t\t\tAND module_mode = 'intro'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
// Move manage users screen module 5 up...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'acp_users'\n\t\t\t\t\t\tAND module_class = 'acp'\n\t\t\t\t\t\tAND module_mode = 'overview'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'acp', 'move_up', 5);
// Move extension management module 1 up...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_langname = 'ACP_EXTENSION_MANAGEMENT'\n\t\t\t\t\t\tAND module_class = 'acp'\n\t\t\t\t\t\tAND module_mode = ''\n\t\t\t\t\t\tAND module_basename = ''";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'acp', 'move_up', 1);
}
if ($module_class == 'mcp') {
// Move pm report details module 3 down...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'mcp_pm_reports'\n\t\t\t\t\t\tAND module_class = 'mcp'\n\t\t\t\t\t\tAND module_mode = 'pm_report_details'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
// Move closed pm reports module 3 down...
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_basename = 'mcp_pm_reports'\n\t\t\t\t\t\tAND module_class = 'mcp'\n\t\t\t\t\t\tAND module_mode = 'pm_reports_closed'";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
//.........这里部分代码省略.........