install/convertors/convert_phpbb20.php
author indvdum (gotoindvdum[at]gmail[dot]com)
Wed, 07 Mar 2012 23:06:09 +0400
changeset 6 40f90a92f114
parent 0 ceef6d64c21d
permissions -rw-r--r--
Game logo
indvdum@0
     1
<?php
indvdum@0
     2
/**
indvdum@0
     3
*
indvdum@0
     4
* @package install
indvdum@0
     5
* @version $Id$
indvdum@0
     6
* @copyright (c) 2006 phpBB Group
indvdum@0
     7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
indvdum@0
     8
*
indvdum@0
     9
*/
indvdum@0
    10
indvdum@0
    11
/**
indvdum@0
    12
* NOTE to potential convertor authors. Please use this file to get
indvdum@0
    13
* familiar with the structure since we added some bare explanations here.
indvdum@0
    14
*
indvdum@0
    15
* Since this file gets included more than once on one page you are not able to add functions to it.
indvdum@0
    16
* Instead use a functions_ file.
indvdum@0
    17
*
indvdum@0
    18
* @ignore
indvdum@0
    19
*/
indvdum@0
    20
if (!defined('IN_PHPBB'))
indvdum@0
    21
{
indvdum@0
    22
	exit;
indvdum@0
    23
}
indvdum@0
    24
indvdum@0
    25
include($phpbb_root_path . 'config.' . $phpEx);
indvdum@0
    26
unset($dbpasswd);
indvdum@0
    27
indvdum@0
    28
/**
indvdum@0
    29
* $convertor_data provides some basic information about this convertor which is
indvdum@0
    30
* used on the initial list of convertors and to populate the default settings
indvdum@0
    31
*/
indvdum@0
    32
$convertor_data = array(
indvdum@0
    33
	'forum_name'	=> 'phpBB 2.0.x',
indvdum@0
    34
	'version'		=> '1.0.3',
indvdum@0
    35
	'phpbb_version'	=> '3.0.10',
indvdum@0
    36
	'author'		=> '<a href="http://www.phpbb.com/">phpBB Group</a>',
indvdum@0
    37
	'dbms'			=> $dbms,
indvdum@0
    38
	'dbhost'		=> $dbhost,
indvdum@0
    39
	'dbport'		=> $dbport,
indvdum@0
    40
	'dbuser'		=> $dbuser,
indvdum@0
    41
	'dbpasswd'		=> '',
indvdum@0
    42
	'dbname'		=> $dbname,
indvdum@0
    43
	'table_prefix'	=> 'phpbb_',
indvdum@0
    44
	'forum_path'	=> '../forums',
indvdum@0
    45
	'author_notes'	=> '',
indvdum@0
    46
);
indvdum@0
    47
indvdum@0
    48
/**
indvdum@0
    49
* $tables is a list of the tables (minus prefix) which we expect to find in the
indvdum@0
    50
* source forum. It is used to guess the prefix if the specified prefix is incorrect
indvdum@0
    51
*/
indvdum@0
    52
$tables = array(
indvdum@0
    53
	'auth_access',
indvdum@0
    54
	'banlist',
indvdum@0
    55
	'categories',
indvdum@0
    56
	'disallow',
indvdum@0
    57
	'forum_prune',
indvdum@0
    58
	'forums',
indvdum@0
    59
	'groups',
indvdum@0
    60
	'posts',
indvdum@0
    61
	'posts_text',
indvdum@0
    62
	'privmsgs',
indvdum@0
    63
	'privmsgs_text',
indvdum@0
    64
	'ranks',
indvdum@0
    65
	'smilies',
indvdum@0
    66
	'topics',
indvdum@0
    67
	'topics_watch',
indvdum@0
    68
	'user_group',
indvdum@0
    69
	'users',
indvdum@0
    70
	'vote_desc',
indvdum@0
    71
	'vote_results',
indvdum@0
    72
	'vote_voters',
indvdum@0
    73
	'words'
indvdum@0
    74
);
indvdum@0
    75
indvdum@0
    76
/**
indvdum@0
    77
* $config_schema details how the board configuration information is stored in the source forum.
indvdum@0
    78
*
indvdum@0
    79
* 'table_format' can take the value 'file' to indicate a config file. In this case array_name
indvdum@0
    80
* is set to indicate the name of the array the config values are stored in
indvdum@0
    81
* Example of using a file:
indvdum@0
    82
* $config_schema = array(
indvdum@0
    83
* 	'table_format'	=>	'file',
indvdum@0
    84
* 	'filename'	=>	'NAME OF FILE', // If the file is not in the root directory, the path needs to be added with no leading slash
indvdum@0
    85
* 	'array_name' => 'NAME OF ARRAY', // Only used if the configuration file stores the setting in an array.
indvdum@0
    86
* 	'settings'		=>	array(
indvdum@0
    87
*        'board_email' => 'SUPPORT_EMAIL', // target config name => source target name
indvdum@0
    88
* 	)
indvdum@0
    89
* );
indvdum@0
    90
* 'table_format' can be an array if the values are stored in a table which is an assosciative array
indvdum@0
    91
* (as per phpBB 2.0.x)
indvdum@0
    92
* If left empty, values are assumed to be stored in a table where each config setting is
indvdum@0
    93
* a column (as per phpBB 1.x)
indvdum@0
    94
*
indvdum@0
    95
* In either of the latter cases 'table_name' indicates the name of the table in the database
indvdum@0
    96
*
indvdum@0
    97
* 'settings' is an array which maps the name of the config directive in the source forum
indvdum@0
    98
* to the config directive in phpBB3. It can either be a direct mapping or use a function.
indvdum@0
    99
* Please note that the contents of the old config value are passed to the function, therefore
indvdum@0
   100
* an in-built function requiring the variable passed by reference is not able to be used. Since
indvdum@0
   101
* empty() is such a function we created the function is_empty() to be used instead.
indvdum@0
   102
*/
indvdum@0
   103
$config_schema = array(
indvdum@0
   104
	'table_name'	=>	'config',
indvdum@0
   105
	'table_format'	=>	array('config_name' => 'config_value'),
indvdum@0
   106
	'settings'		=>	array(
indvdum@0
   107
		'allow_bbcode'			=> 'allow_bbcode',
indvdum@0
   108
		'allow_smilies'			=> 'allow_smilies',
indvdum@0
   109
		'allow_sig'				=> 'allow_sig',
indvdum@0
   110
		'allow_namechange'		=> 'allow_namechange',
indvdum@0
   111
		'allow_avatar_local'	=> 'allow_avatar_local',
indvdum@0
   112
		'allow_avatar_remote'	=> 'allow_avatar_remote',
indvdum@0
   113
		'allow_avatar_upload'	=> 'allow_avatar_upload',
indvdum@0
   114
		'board_disable'			=> 'board_disable',
indvdum@0
   115
		'sitename'				=> 'phpbb_set_encoding(sitename)',
indvdum@0
   116
		'site_desc'				=> 'phpbb_set_encoding(site_desc)',
indvdum@0
   117
		'session_length'		=> 'session_length',
indvdum@0
   118
		'board_email_sig'		=> 'phpbb_set_encoding(board_email_sig)',
indvdum@0
   119
		'posts_per_page'		=> 'posts_per_page',
indvdum@0
   120
		'topics_per_page'		=> 'topics_per_page',
indvdum@0
   121
		'enable_confirm'		=> 'enable_confirm',
indvdum@0
   122
		'board_email_form'		=> 'board_email_form',
indvdum@0
   123
		'override_user_style'	=> 'override_user_style',
indvdum@0
   124
		'hot_threshold'			=> 'hot_threshold',
indvdum@0
   125
		'max_poll_options'		=> 'max_poll_options',
indvdum@0
   126
		'max_sig_chars'			=> 'max_sig_chars',
indvdum@0
   127
		'pm_max_msgs'			=> 'max_inbox_privmsgs',
indvdum@0
   128
		'smtp_delivery'			=> 'smtp_delivery',
indvdum@0
   129
		'smtp_host'				=> 'smtp_host',
indvdum@0
   130
		'smtp_username'			=> 'smtp_username',
indvdum@0
   131
		'smtp_password'			=> 'smtp_password',
indvdum@0
   132
		'require_activation'	=> 'require_activation',
indvdum@0
   133
		'flood_interval'		=> 'flood_interval',
indvdum@0
   134
		'avatar_filesize'		=> 'avatar_filesize',
indvdum@0
   135
		'avatar_max_width'		=> 'avatar_max_width',
indvdum@0
   136
		'avatar_max_height'		=> 'avatar_max_height',
indvdum@0
   137
		'default_dateformat'	=> 'phpbb_set_encoding(default_dateformat)',
indvdum@0
   138
		'board_timezone'		=> 'board_timezone',
indvdum@0
   139
		'allow_privmsg'			=> 'not(privmsg_disable)',
indvdum@0
   140
		'gzip_compress'			=> 'gzip_compress',
indvdum@0
   141
		'coppa_enable'			=> '!is_empty(coppa_mail)',
indvdum@0
   142
		'coppa_fax'				=> 'coppa_fax',
indvdum@0
   143
		'coppa_mail'			=> 'coppa_mail',
indvdum@0
   144
		'record_online_users'	=> 'record_online_users',
indvdum@0
   145
		'record_online_date'	=> 'record_online_date',
indvdum@0
   146
		'board_startdate'		=> 'board_startdate',
indvdum@0
   147
	)
indvdum@0
   148
);
indvdum@0
   149
indvdum@0
   150
/**
indvdum@0
   151
* $test_file is the name of a file which is present on the source
indvdum@0
   152
* forum which can be used to check that the path specified by the
indvdum@0
   153
* user was correct
indvdum@0
   154
*/
indvdum@0
   155
$test_file = 'modcp.php';
indvdum@0
   156
indvdum@0
   157
/**
indvdum@0
   158
* If this is set then we are not generating the first page of information but getting the conversion information.
indvdum@0
   159
*/
indvdum@0
   160
if (!$get_info)
indvdum@0
   161
{
indvdum@0
   162
	// Test to see if the birthday MOD is installed on the source forum
indvdum@0
   163
	// Niels' birthday mod
indvdum@0
   164
	if (get_config_value('birthday_required') !== false || get_config_value('bday_require') !== false)
indvdum@0
   165
	{
indvdum@0
   166
		define('MOD_BIRTHDAY', true);
indvdum@0
   167
	}
indvdum@0
   168
indvdum@0
   169
	// TerraFrost's validated birthday mod
indvdum@0
   170
	if (get_config_value('bday_require') !== false)
indvdum@0
   171
	{
indvdum@0
   172
		define('MOD_BIRTHDAY_TERRA', true);
indvdum@0
   173
	}
indvdum@0
   174
indvdum@0
   175
	// Test to see if the attachment MOD is installed on the source forum
indvdum@0
   176
	// If it is, we will convert this data as well
indvdum@0
   177
	$src_db->sql_return_on_error(true);
indvdum@0
   178
indvdum@0
   179
	$sql = "SELECT config_value
indvdum@0
   180
		FROM {$convert->src_table_prefix}attachments_config
indvdum@0
   181
		WHERE config_name = 'upload_dir'";
indvdum@0
   182
	$result = $src_db->sql_query($sql);
indvdum@0
   183
indvdum@0
   184
	if ($result && $row = $src_db->sql_fetchrow($result))
indvdum@0
   185
	{
indvdum@0
   186
		// Here the constant is defined
indvdum@0
   187
		define('MOD_ATTACHMENT', true);
indvdum@0
   188
indvdum@0
   189
		// Here i add more tables to be checked in the old forum
indvdum@0
   190
		$tables += array(
indvdum@0
   191
			'attachments',
indvdum@0
   192
			'attachments_desc',
indvdum@0
   193
			'extensions',
indvdum@0
   194
			'extension_groups'
indvdum@0
   195
		);
indvdum@0
   196
indvdum@0
   197
		$src_db->sql_freeresult($result);
indvdum@0
   198
	}
indvdum@0
   199
	else if ($result)
indvdum@0
   200
	{
indvdum@0
   201
		$src_db->sql_freeresult($result);
indvdum@0
   202
	}
indvdum@0
   203
indvdum@0
   204
indvdum@0
   205
	/**
indvdum@0
   206
	* Tests for further MODs can be included here.
indvdum@0
   207
	* Please use constants for this, prefixing them with MOD_
indvdum@0
   208
	*/
indvdum@0
   209
indvdum@0
   210
	$src_db->sql_return_on_error(false);
indvdum@0
   211
indvdum@0
   212
	// Now let us set a temporary config variable for user id incrementing
indvdum@0
   213
	$sql = "SELECT user_id
indvdum@0
   214
		FROM {$convert->src_table_prefix}users
indvdum@0
   215
		WHERE user_id = 1";
indvdum@0
   216
	$result = $src_db->sql_query($sql);
indvdum@0
   217
	$user_id = (int) $src_db->sql_fetchfield('user_id');
indvdum@0
   218
	$src_db->sql_freeresult($result);
indvdum@0
   219
indvdum@0
   220
	// If there is a user id 1, we need to increment user ids. :/
indvdum@0
   221
	if ($user_id === 1)
indvdum@0
   222
	{
indvdum@0
   223
		// Try to get the maximum user id possible...
indvdum@0
   224
		$sql = "SELECT MAX(user_id) AS max_user_id
indvdum@0
   225
			FROM {$convert->src_table_prefix}users";
indvdum@0
   226
		$result = $src_db->sql_query($sql);
indvdum@0
   227
		$user_id = (int) $src_db->sql_fetchfield('max_user_id');
indvdum@0
   228
		$src_db->sql_freeresult($result);
indvdum@0
   229
indvdum@0
   230
		set_config('increment_user_id', ($user_id + 1), true);
indvdum@0
   231
	}
indvdum@0
   232
	else
indvdum@0
   233
	{
indvdum@0
   234
		set_config('increment_user_id', 0, true);
indvdum@0
   235
	}
indvdum@0
   236
indvdum@0
   237
	// Overwrite maximum avatar width/height
indvdum@0
   238
	@define('DEFAULT_AVATAR_X_CUSTOM', get_config_value('avatar_max_width'));
indvdum@0
   239
	@define('DEFAULT_AVATAR_Y_CUSTOM', get_config_value('avatar_max_height'));
indvdum@0
   240
indvdum@0
   241
	// additional table used only during conversion
indvdum@0
   242
	@define('USERCONV_TABLE', $table_prefix . 'userconv');
indvdum@0
   243
indvdum@0
   244
/**
indvdum@0
   245
*	Description on how to use the convertor framework.
indvdum@0
   246
*
indvdum@0
   247
*	'schema' Syntax Description
indvdum@0
   248
*		-> 'target'			=> Target Table. If not specified the next table will be handled
indvdum@0
   249
*		-> 'primary'		=> Primary Key. If this is specified then this table is processed in batches
indvdum@0
   250
*		-> 'query_first'	=> array('target' or 'src', Query to execute before beginning the process
indvdum@0
   251
*								(if more than one then specified as array))
indvdum@0
   252
*		-> 'function_first'	=> Function to execute before beginning the process (if more than one then specified as array)
indvdum@0
   253
*								(This is mostly useful if variables need to be given to the converting process)
indvdum@0
   254
*		-> 'test_file'		=> This is not used at the moment but should be filled with a file from the old installation
indvdum@0
   255
*
indvdum@0
   256
*		// DB Functions
indvdum@0
   257
*		'distinct'	=> Add DISTINCT to the select query
indvdum@0
   258
*		'where'		=> Add WHERE to the select query
indvdum@0
   259
*		'group_by'	=> Add GROUP BY to the select query
indvdum@0
   260
*		'left_join'	=> Add LEFT JOIN to the select query (if more than one joins specified as array)
indvdum@0
   261
*		'having'	=> Add HAVING to the select query
indvdum@0
   262
*
indvdum@0
   263
*		// DB INSERT array
indvdum@0
   264
*		This one consist of three parameters
indvdum@0
   265
*		First Parameter:
indvdum@0
   266
*							The key need to be filled within the target table
indvdum@0
   267
*							If this is empty, the target table gets not assigned the source value
indvdum@0
   268
*		Second Parameter:
indvdum@0
   269
*							Source value. If the first parameter is specified, it will be assigned this value.
indvdum@0
   270
*							If the first parameter is empty, this only gets added to the select query
indvdum@0
   271
*		Third Parameter:
indvdum@0
   272
*							Custom Function. Function to execute while storing source value into target table.
indvdum@0
   273
*							The functions return value get stored.
indvdum@0
   274
*							The function parameter consist of the value of the second parameter.
indvdum@0
   275
*
indvdum@0
   276
*							types:
indvdum@0
   277
*								- empty string == execute nothing
indvdum@0
   278
*								- string == function to execute
indvdum@0
   279
*								- array == complex execution instructions
indvdum@0
   280
*
indvdum@0
   281
*		Complex execution instructions:
indvdum@0
   282
*		@todo test complex execution instructions - in theory they will work fine
indvdum@0
   283
*
indvdum@0
   284
*							By defining an array as the third parameter you are able to define some statements to be executed. The key
indvdum@0
   285
*							is defining what to execute, numbers can be appended...
indvdum@0
   286
*
indvdum@0
   287
*							'function' => execute function
indvdum@0
   288
*							'execute' => run code, whereby all occurrences of {VALUE} get replaced by the last returned value.
indvdum@0
   289
*										The result *must* be assigned/stored to {RESULT}.
indvdum@0
   290
*							'typecast'	=> typecast value
indvdum@0
   291
*
indvdum@0
   292
*							The returned variables will be made always available to the next function to continue to work with.
indvdum@0
   293
*
indvdum@0
   294
*							example (variable inputted is an integer of 1):
indvdum@0
   295
*
indvdum@0
   296
*							array(
indvdum@0
   297
*								'function1'		=> 'increment_by_one',		// returned variable is 2
indvdum@0
   298
*								'typecast'		=> 'string',				// typecast variable to be a string
indvdum@0
   299
*								'execute'		=> '{RESULT} = {VALUE} . ' is good';', // returned variable is '2 is good'
indvdum@0
   300
*								'function2'		=> 'replace_good_with_bad',				// returned variable is '2 is bad'
indvdum@0
   301
*							),
indvdum@0
   302
*
indvdum@0
   303
*/
indvdum@0
   304
indvdum@0
   305
	$convertor = array(
indvdum@0
   306
		'test_file'				=> 'viewtopic.php',
indvdum@0
   307
indvdum@0
   308
		'avatar_path'			=> get_config_value('avatar_path') . '/',
indvdum@0
   309
		'avatar_gallery_path'	=> get_config_value('avatar_gallery_path') . '/',
indvdum@0
   310
		'smilies_path'			=> get_config_value('smilies_path') . '/',
indvdum@0
   311
		'upload_path'			=> (defined('MOD_ATTACHMENT')) ? phpbb_get_files_dir() . '/' : '',
indvdum@0
   312
		'thumbnails'			=> (defined('MOD_ATTACHMENT')) ? array('thumbs/', 't_') : '',
indvdum@0
   313
		'ranks_path'			=> false, // phpBB 2.0.x had no config value for a ranks path
indvdum@0
   314
indvdum@0
   315
		// We empty some tables to have clean data available
indvdum@0
   316
		'query_first'			=> array(
indvdum@0
   317
			array('target', $convert->truncate_statement . SEARCH_RESULTS_TABLE),
indvdum@0
   318
			array('target', $convert->truncate_statement . SEARCH_WORDLIST_TABLE),
indvdum@0
   319
			array('target', $convert->truncate_statement . SEARCH_WORDMATCH_TABLE),
indvdum@0
   320
			array('target', $convert->truncate_statement . LOG_TABLE),
indvdum@0
   321
		),
indvdum@0
   322
indvdum@0
   323
//	with this you are able to import all attachment files on the fly. For large boards this is not an option, therefore commented out by default.
indvdum@0
   324
//	Instead every file gets copied while processing the corresponding attachment entry.
indvdum@0
   325
//		if (defined("MOD_ATTACHMENT")) { import_attachment_files(); phpbb_copy_thumbnails(); }
indvdum@0
   326
indvdum@0
   327
		// phpBB2 allowed some similar usernames to coexist which would have the same
indvdum@0
   328
		// username_clean in phpBB3 which is not possible, so we'll give the admin a list
indvdum@0
   329
		// of user ids and usernames and let him deicde what he wants to do with them
indvdum@0
   330
		'execute_first'	=> '
indvdum@0
   331
			phpbb_create_userconv_table();
indvdum@0
   332
			import_avatar_gallery();
indvdum@0
   333
			if (defined("MOD_ATTACHMENT")) phpbb_import_attach_config();
indvdum@0
   334
			phpbb_insert_forums();
indvdum@0
   335
		',
indvdum@0
   336
indvdum@0
   337
		'execute_last'	=> array('
indvdum@0
   338
			add_bots();
indvdum@0
   339
		', '
indvdum@0
   340
			update_folder_pm_count();
indvdum@0
   341
		', '
indvdum@0
   342
			update_unread_count();
indvdum@0
   343
		', '
indvdum@0
   344
			phpbb_convert_authentication(\'start\');
indvdum@0
   345
		', '
indvdum@0
   346
			phpbb_convert_authentication(\'first\');
indvdum@0
   347
		', '
indvdum@0
   348
			phpbb_convert_authentication(\'second\');
indvdum@0
   349
		', '
indvdum@0
   350
			phpbb_convert_authentication(\'third\');
indvdum@0
   351
		'),
indvdum@0
   352
indvdum@0
   353
		'schema' => array(
indvdum@0
   354
			array(
indvdum@0
   355
				'target'	=> USERCONV_TABLE,
indvdum@0
   356
				'query_first'   => array('target', $convert->truncate_statement . USERCONV_TABLE),
indvdum@0
   357
indvdum@0
   358
indvdum@0
   359
				array('user_id',			'users.user_id', 	''),
indvdum@0
   360
				array('username_clean',		'users.username',	array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_clean_string')),
indvdum@0
   361
			),
indvdum@0
   362
indvdum@0
   363
			array(
indvdum@0
   364
				'target'		=> (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
indvdum@0
   365
				'primary'		=> 'attachments.attach_id',
indvdum@0
   366
				'query_first'	=> (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . ATTACHMENTS_TABLE) : '',
indvdum@0
   367
				'autoincrement'	=> 'attach_id',
indvdum@0
   368
indvdum@0
   369
				array('attach_id',				'attachments.attach_id',				''),
indvdum@0
   370
				array('post_msg_id',			'attachments.post_id',					''),
indvdum@0
   371
				array('topic_id',				'posts.topic_id',						''),
indvdum@0
   372
				array('in_message',				0,										''),
indvdum@0
   373
				array('is_orphan',				0,										''),
indvdum@0
   374
				array('poster_id',				'attachments.user_id_1 AS poster_id',	'phpbb_user_id'),
indvdum@0
   375
				array('physical_filename',		'attachments_desc.physical_filename',	'import_attachment'),
indvdum@0
   376
				array('real_filename',			'attachments_desc.real_filename',		'phpbb_set_encoding'),
indvdum@0
   377
				array('download_count',			'attachments_desc.download_count',		''),
indvdum@0
   378
				array('attach_comment',			'attachments_desc.comment',				array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
indvdum@0
   379
				array('extension',				'attachments_desc.extension',			''),
indvdum@0
   380
				array('mimetype',				'attachments_desc.mimetype',			''),
indvdum@0
   381
				array('filesize',				'attachments_desc.filesize',			''),
indvdum@0
   382
				array('filetime',				'attachments_desc.filetime',			''),
indvdum@0
   383
				array('thumbnail',				'attachments_desc.thumbnail',			''),
indvdum@0
   384
indvdum@0
   385
				'where'			=> 'attachments_desc.attach_id = attachments.attach_id AND attachments.privmsgs_id = 0 AND posts.post_id = attachments.post_id',
indvdum@0
   386
				'group_by'		=> 'attachments.attach_id'
indvdum@0
   387
			),
indvdum@0
   388
indvdum@0
   389
			array(
indvdum@0
   390
				'target'		=> (defined('MOD_ATTACHMENT')) ? ATTACHMENTS_TABLE : '',
indvdum@0
   391
				'primary'		=> 'attachments.attach_id',
indvdum@0
   392
				'autoincrement'	=> 'attach_id',
indvdum@0
   393
indvdum@0
   394
				array('attach_id',				'attachments.attach_id',				''),
indvdum@0
   395
				array('post_msg_id',			'attachments.privmsgs_id',				''),
indvdum@0
   396
				array('topic_id',				0,										''),
indvdum@0
   397
				array('in_message',				1,										''),
indvdum@0
   398
				array('is_orphan',				0,										''),
indvdum@0
   399
				array('poster_id',				'attachments.user_id_1 AS poster_id',	'phpbb_user_id'),
indvdum@0
   400
				array('physical_filename',		'attachments_desc.physical_filename',	'import_attachment'),
indvdum@0
   401
				array('real_filename',			'attachments_desc.real_filename',		''),
indvdum@0
   402
				array('download_count',			'attachments_desc.download_count',		''),
indvdum@0
   403
				array('attach_comment',			'attachments_desc.comment',				array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
indvdum@0
   404
				array('extension',				'attachments_desc.extension',			''),
indvdum@0
   405
				array('mimetype',				'attachments_desc.mimetype',			''),
indvdum@0
   406
				array('filesize',				'attachments_desc.filesize',			''),
indvdum@0
   407
				array('filetime',				'attachments_desc.filetime',			''),
indvdum@0
   408
				array('thumbnail',				'attachments_desc.thumbnail',			''),
indvdum@0
   409
indvdum@0
   410
				'where'			=> 'attachments_desc.attach_id = attachments.attach_id AND attachments.post_id = 0',
indvdum@0
   411
				'group_by'		=> 'attachments.attach_id'
indvdum@0
   412
			),
indvdum@0
   413
indvdum@0
   414
			array(
indvdum@0
   415
				'target'		=> (defined('MOD_ATTACHMENT')) ? EXTENSIONS_TABLE : '',
indvdum@0
   416
				'query_first'	=> (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . EXTENSIONS_TABLE) : '',
indvdum@0
   417
				'autoincrement'	=> 'extension_id',
indvdum@0
   418
indvdum@0
   419
				array('extension_id',			'extensions.ext_id',				''),
indvdum@0
   420
				array('group_id',				'extensions.group_id',				''),
indvdum@0
   421
				array('extension',				'extensions.extension',				''),
indvdum@0
   422
			),
indvdum@0
   423
indvdum@0
   424
			array(
indvdum@0
   425
				'target'		=> (defined('MOD_ATTACHMENT')) ? EXTENSION_GROUPS_TABLE : '',
indvdum@0
   426
				'query_first'	=> (defined('MOD_ATTACHMENT')) ? array('target', $convert->truncate_statement . EXTENSION_GROUPS_TABLE) : '',
indvdum@0
   427
				'autoincrement'	=> 'group_id',
indvdum@0
   428
indvdum@0
   429
				array('group_id',				'extension_groups.group_id',			''),
indvdum@0
   430
				array('group_name',				'extension_groups.group_name',			array('function1' => 'phpbb_set_encoding', 'function2' => 'utf8_htmlspecialchars')),
indvdum@0
   431
				array('cat_id',					'extension_groups.cat_id',				'phpbb_attachment_category'),
indvdum@0
   432
				array('allow_group',			'extension_groups.allow_group',			''),
indvdum@0
   433
				array('download_mode',			1,										''),
indvdum@0
   434
				array('upload_icon',			'',										''),
indvdum@0
   435
				array('max_filesize',			'extension_groups.max_filesize',		''),
indvdum@0
   436
				array('allowed_forums',			'extension_groups.forum_permissions',	'phpbb_attachment_forum_perms'),
indvdum@0
   437
				array('allow_in_pm',			1,										''),
indvdum@0
   438
			),
indvdum@0
   439
indvdum@0
   440
			array(
indvdum@0
   441
				'target'		=> BANLIST_TABLE,
indvdum@0
   442
				'execute_first'	=> 'phpbb_check_username_collisions();',
indvdum@0
   443
				'query_first'	=> array('target', $convert->truncate_statement . BANLIST_TABLE),
indvdum@0
   444
indvdum@0
   445
				array('ban_ip',					'banlist.ban_ip',					'decode_ban_ip'),
indvdum@0
   446
				array('ban_userid',				'banlist.ban_userid',				'phpbb_user_id'),
indvdum@0
   447
				array('ban_email',				'banlist.ban_email',				''),
indvdum@0
   448
				array('ban_reason',				'',									''),
indvdum@0
   449
				array('ban_give_reason',		'',									''),
indvdum@0
   450
indvdum@0
   451
				'where'			=> "banlist.ban_ip NOT LIKE '%.%'",
indvdum@0
   452
			),
indvdum@0
   453
indvdum@0
   454
			array(
indvdum@0
   455
				'target'		=> BANLIST_TABLE,
indvdum@0
   456
indvdum@0
   457
				array('ban_ip',					'banlist.ban_ip',	''),
indvdum@0
   458
				array('ban_userid',				0,					''),
indvdum@0
   459
				array('ban_email',				'',					''),
indvdum@0
   460
				array('ban_reason',				'',					''),
indvdum@0
   461
				array('ban_give_reason',		'',					''),
indvdum@0
   462
indvdum@0
   463
				'where'			=> "banlist.ban_ip LIKE '%.%'",
indvdum@0
   464
			),
indvdum@0
   465
indvdum@0
   466
			array(
indvdum@0
   467
				'target'		=> DISALLOW_TABLE,
indvdum@0
   468
				'query_first'	=> array('target', $convert->truncate_statement . DISALLOW_TABLE),
indvdum@0
   469
indvdum@0
   470
				array('disallow_username',		'disallow.disallow_username',				'phpbb_disallowed_username'),
indvdum@0
   471
			),
indvdum@0
   472
indvdum@0
   473
			array(
indvdum@0
   474
				'target'		=> RANKS_TABLE,
indvdum@0
   475
				'query_first'	=> array('target', $convert->truncate_statement . RANKS_TABLE),
indvdum@0
   476
				'autoincrement'	=> 'rank_id',
indvdum@0
   477
indvdum@0
   478
				array('rank_id',					'ranks.rank_id',				''),
indvdum@0
   479
				array('rank_title',					'ranks.rank_title',				array('function1' => 'phpbb_set_default_encoding', 'function2' => 'utf8_htmlspecialchars')),
indvdum@0
   480
				array('rank_min',					'ranks.rank_min',				array('typecast' => 'int', 'execute' => '{RESULT} = ({VALUE}[0] < 0) ? 0 : {VALUE}[0];')),
indvdum@0
   481
				array('rank_special',				'ranks.rank_special',			''),
indvdum@0
   482
				array('rank_image',					'ranks.rank_image',				'import_rank'),
indvdum@0
   483
			),
indvdum@0
   484
indvdum@0
   485
			array(
indvdum@0
   486
				'target'		=> TOPICS_TABLE,
indvdum@0
   487
				'query_first'	=> array('target', $convert->truncate_statement . TOPICS_TABLE),
indvdum@0
   488
				'primary'		=> 'topics.topic_id',
indvdum@0
   489
				'autoincrement'	=> 'topic_id',
indvdum@0
   490
indvdum@0
   491
				array('topic_id',				'topics.topic_id',					''),
indvdum@0
   492
				array('forum_id',				'topics.forum_id',					''),
indvdum@0
   493
				array('icon_id',				0,									''),
indvdum@0
   494
				array('topic_poster',			'topics.topic_poster AS poster_id',	'phpbb_user_id'),
indvdum@0
   495
				array('topic_attachment',		((defined('MOD_ATTACHMENT')) ? 'topics.topic_attachment' : 0), ''),
indvdum@0
   496
				array('topic_title',			'topics.topic_title',				'phpbb_set_encoding'),
indvdum@0
   497
				array('topic_time',				'topics.topic_time',				''),
indvdum@0
   498
				array('topic_views',			'topics.topic_views',				''),
indvdum@0
   499
				array('topic_replies',			'topics.topic_replies',				''),
indvdum@0
   500
				array('topic_replies_real',		'topics.topic_replies',				''),
indvdum@0
   501
				array('topic_last_post_id',		'topics.topic_last_post_id',		''),
indvdum@0
   502
				array('topic_status',			'topics.topic_status',				'is_topic_locked'),
indvdum@0
   503
				array('topic_moved_id',			0,									''),
indvdum@0
   504
				array('topic_type',				'topics.topic_type',				'phpbb_convert_topic_type'),
indvdum@0
   505
				array('topic_first_post_id',	'topics.topic_first_post_id',		''),
indvdum@0
   506
				array('topic_last_view_time',	'posts.post_time',					'intval'),
indvdum@0
   507
				array('poll_title',				'vote_desc.vote_text',				array('function1' => 'null_to_str', 'function2' => 'phpbb_set_encoding', 'function3' => 'htmlspecialchars_decode', 'function4' => 'utf8_htmlspecialchars')),
indvdum@0
   508
				array('poll_start',				'vote_desc.vote_start',				'null_to_zero'),
indvdum@0
   509
				array('poll_length',			'vote_desc.vote_length',			'null_to_zero'),
indvdum@0
   510
				array('poll_max_options',		1,									''),
indvdum@0
   511
				array('poll_vote_change',		0,									''),
indvdum@0
   512
indvdum@0
   513
				'left_join'		=>	array (	'topics LEFT JOIN vote_desc ON topics.topic_id = vote_desc.topic_id AND topics.topic_vote = 1',
indvdum@0
   514
											'topics LEFT JOIN posts ON topics.topic_last_post_id = posts.post_id',
indvdum@0
   515
									),
indvdum@0
   516
				'where'			=> 'topics.topic_moved_id = 0',
indvdum@0
   517
			),
indvdum@0
   518
indvdum@0
   519
			array(
indvdum@0
   520
				'target'		=> TOPICS_TABLE,
indvdum@0
   521
				'primary'		=> 'topics.topic_id',
indvdum@0
   522
				'autoincrement'	=> 'topic_id',
indvdum@0
   523
indvdum@0
   524
				array('topic_id',				'topics.topic_id',					''),
indvdum@0
   525
				array('forum_id',				'topics.forum_id',					''),
indvdum@0
   526
				array('icon_id',				0,									''),
indvdum@0
   527
				array('topic_poster',			'topics.topic_poster AS poster_id',	'phpbb_user_id'),
indvdum@0
   528
				array('topic_attachment',		((defined('MOD_ATTACHMENT')) ? 'topics.topic_attachment' : 0), ''),
indvdum@0
   529
				array('topic_title',			'topics.topic_title',				'phpbb_set_encoding'),
indvdum@0
   530
				array('topic_time',				'topics.topic_time',				''),
indvdum@0
   531
				array('topic_views',			'topics.topic_views',				''),
indvdum@0
   532
				array('topic_replies',			'topics.topic_replies',				''),
indvdum@0
   533
				array('topic_replies_real',		'topics.topic_replies',				''),
indvdum@0
   534
				array('topic_last_post_id',		'topics.topic_last_post_id',		''),
indvdum@0
   535
				array('topic_status',			ITEM_MOVED,							''),
indvdum@0
   536
				array('topic_moved_id',			'topics.topic_moved_id',			''),
indvdum@0
   537
				array('topic_type',				'topics.topic_type',				'phpbb_convert_topic_type'),
indvdum@0
   538
				array('topic_first_post_id',	'topics.topic_first_post_id',		''),
indvdum@0
   539
indvdum@0
   540
				array('poll_title',				'vote_desc.vote_text',				array('function1' => 'null_to_str', 'function2' => 'phpbb_set_encoding', 'function3' => 'htmlspecialchars_decode', 'function4' => 'utf8_htmlspecialchars')),
indvdum@0
   541
				array('poll_start',				'vote_desc.vote_start',				'null_to_zero'),
indvdum@0
   542
				array('poll_length',			'vote_desc.vote_length',			'null_to_zero'),
indvdum@0
   543
				array('poll_max_options',		1,									''),
indvdum@0
   544
				array('poll_vote_change',		0,									''),
indvdum@0
   545
indvdum@0
   546
				'left_join'		=> 'topics LEFT JOIN vote_desc ON topics.topic_id = vote_desc.topic_id AND topics.topic_vote = 1',
indvdum@0
   547
				'where'			=> 'topics.topic_moved_id <> 0',
indvdum@0
   548
			),
indvdum@0
   549
indvdum@0
   550
			array(
indvdum@0
   551
				'target'		=> TOPICS_WATCH_TABLE,
indvdum@0
   552
				'primary'		=> 'topics_watch.topic_id',
indvdum@0
   553
				'query_first'	=> array('target', $convert->truncate_statement . TOPICS_WATCH_TABLE),
indvdum@0
   554
indvdum@0
   555
				array('topic_id',				'topics_watch.topic_id',			''),
indvdum@0
   556
				array('user_id',				'topics_watch.user_id',				'phpbb_user_id'),
indvdum@0
   557
				array('notify_status',			'topics_watch.notify_status',		''),
indvdum@0
   558
			),
indvdum@0
   559
indvdum@0
   560
			array(
indvdum@0
   561
				'target'		=> SMILIES_TABLE,
indvdum@0
   562
				'query_first'	=> array('target', $convert->truncate_statement . SMILIES_TABLE),
indvdum@0
   563
				'autoincrement'	=> 'smiley_id',
indvdum@0
   564
indvdum@0
   565
				array('smiley_id',				'smilies.smilies_id',				''),
indvdum@0
   566
				array('code',					'smilies.code',						array('function1' => 'phpbb_smilie_html_decode', 'function2' => 'phpbb_set_encoding', 'function3' => 'utf8_htmlspecialchars')),
indvdum@0
   567
				array('emotion',				'smilies.emoticon',					'phpbb_set_encoding'),
indvdum@0
   568
				array('smiley_url',				'smilies.smile_url',				'import_smiley'),
indvdum@0
   569
				array('smiley_width',			'smilies.smile_url',				'get_smiley_width'),
indvdum@0
   570
				array('smiley_height',			'smilies.smile_url',				'get_smiley_height'),
indvdum@0
   571
				array('smiley_order',			'smilies.smilies_id',				''),
indvdum@0
   572
				array('display_on_posting',		'smilies.smilies_id',				'get_smiley_display'),
indvdum@0
   573
indvdum@0
   574
				'order_by'		=> 'smilies.smilies_id ASC',
indvdum@0
   575
			),
indvdum@0
   576
indvdum@0
   577
			array(
indvdum@0
   578
				'target'		=> POLL_OPTIONS_TABLE,
indvdum@0
   579
				'primary'		=> 'vote_results.vote_option_id',
indvdum@0
   580
				'query_first'	=> array('target', $convert->truncate_statement . POLL_OPTIONS_TABLE),
indvdum@0
   581
indvdum@0
   582
				array('poll_option_id',			'vote_results.vote_option_id',		''),
indvdum@0
   583
				array('topic_id',				'vote_desc.topic_id',				''),
indvdum@0
   584
				array('',						'topics.topic_poster AS poster_id',	'phpbb_user_id'),
indvdum@0
   585
				array('poll_option_text',		'vote_results.vote_option_text',	array('function1' => 'phpbb_set_encoding', 'function2' => 'htmlspecialchars_decode', 'function3' => 'utf8_htmlspecialchars')),
indvdum@0
   586
				array('poll_option_total',		'vote_results.vote_result',			''),
indvdum@0
   587
indvdum@0
   588
				'where'			=> 'vote_results.vote_id = vote_desc.vote_id',
indvdum@0
   589
				'left_join'		=> 'vote_desc LEFT JOIN topics ON topics.topic_id = vote_desc.topic_id',
indvdum@0
   590
			),
indvdum@0
   591
indvdum@0
   592
			array(
indvdum@0
   593
				'target'		=> POLL_VOTES_TABLE,
indvdum@0
   594
				'primary'		=> 'vote_desc.topic_id',
indvdum@0
   595
				'query_first'	=> array('target', $convert->truncate_statement . POLL_VOTES_TABLE),
indvdum@0
   596
indvdum@0
   597
				array('poll_option_id',			VOTE_CONVERTED,						''),
indvdum@0
   598
				array('topic_id',				'vote_desc.topic_id',				''),
indvdum@0
   599
				array('vote_user_id',			'vote_voters.vote_user_id',			'phpbb_user_id'),
indvdum@0
   600
				array('vote_user_ip',			'vote_voters.vote_user_ip',			'decode_ip'),
indvdum@0
   601
indvdum@0
   602
				'where'			=> 'vote_voters.vote_id = vote_desc.vote_id',
indvdum@0
   603
			),
indvdum@0
   604
indvdum@0
   605
			array(
indvdum@0
   606
				'target'		=> WORDS_TABLE,
indvdum@0
   607
				'primary'		=> 'words.word_id',
indvdum@0
   608
				'query_first'	=> array('target', $convert->truncate_statement . WORDS_TABLE),
indvdum@0
   609
				'autoincrement'	=> 'word_id',
indvdum@0
   610
indvdum@0
   611
				array('word_id',				'words.word_id',					''),
indvdum@0
   612
				array('word',					'words.word',						'phpbb_set_encoding'),
indvdum@0
   613
				array('replacement',			'words.replacement',				'phpbb_set_encoding'),
indvdum@0
   614
			),
indvdum@0
   615
indvdum@0
   616
			array(
indvdum@0
   617
				'target'		=> POSTS_TABLE,
indvdum@0
   618
				'primary'		=> 'posts.post_id',
indvdum@0
   619
				'autoincrement'	=> 'post_id',
indvdum@0
   620
				'query_first'	=> array('target', $convert->truncate_statement . POSTS_TABLE),
indvdum@0
   621
				'execute_first'	=> '
indvdum@0
   622
					$config["max_post_chars"] = 0;
indvdum@0
   623
					$config["min_post_chars"] = 0;
indvdum@0
   624
					$config["max_quote_depth"] = 0;
indvdum@0
   625
				',
indvdum@0
   626
indvdum@0
   627
				array('post_id',				'posts.post_id',					''),
indvdum@0
   628
				array('topic_id',				'posts.topic_id',					''),
indvdum@0
   629
				array('forum_id',				'posts.forum_id',					''),
indvdum@0
   630
				array('poster_id',				'posts.poster_id',					'phpbb_user_id'),
indvdum@0
   631
				array('icon_id',				0,									''),
indvdum@0
   632
				array('poster_ip',				'posts.poster_ip',					'decode_ip'),
indvdum@0
   633
				array('post_time',				'posts.post_time',					''),
indvdum@0
   634
				array('enable_bbcode',			'posts.enable_bbcode',				''),
indvdum@0
   635
				array('',						'posts.enable_html',				''),
indvdum@0
   636
				array('enable_smilies',			'posts.enable_smilies',				''),
indvdum@0
   637
				array('enable_sig',				'posts.enable_sig',					''),
indvdum@0
   638
				array('enable_magic_url',		1,									''),
indvdum@0
   639
				array('post_username',			'posts.post_username',				'phpbb_set_encoding'),
indvdum@0
   640
				array('post_subject',			'posts_text.post_subject',			'phpbb_set_encoding'),
indvdum@0
   641
				array('post_attachment',		((defined('MOD_ATTACHMENT')) ? 'posts.post_attachment' : 0), ''),
indvdum@0
   642
				array('post_edit_time',			'posts.post_edit_time',				array('typecast' => 'int')),
indvdum@0
   643
				array('post_edit_count',		'posts.post_edit_count',			''),
indvdum@0
   644
				array('post_edit_reason',		'',									''),
indvdum@0
   645
				array('post_edit_user',			'',									'phpbb_post_edit_user'),
indvdum@0
   646
indvdum@0
   647
				array('bbcode_uid',				'posts.post_time',					'make_uid'),
indvdum@0
   648
				array('post_text',				'posts_text.post_text',				'phpbb_prepare_message'),
indvdum@0
   649
				array('',						'posts_text.bbcode_uid AS old_bbcode_uid',			''),
indvdum@0
   650
				array('bbcode_bitfield',		'',									'get_bbcode_bitfield'),
indvdum@0
   651
				array('post_checksum',			'',									''),
indvdum@0
   652
indvdum@0
   653
				// Commented out inline search indexing, this takes up a LOT of time. :D
indvdum@0
   654
				// @todo We either need to enable this or call the rebuild search functionality post convert
indvdum@0
   655
/*				array('',						'',									'search_indexing'),
indvdum@0
   656
				array('',						'posts_text.post_text AS message',	''),
indvdum@0
   657
				array('',						'posts_text.post_subject AS title',	''),*/
indvdum@0
   658
indvdum@0
   659
				'where'			=>	'posts.post_id = posts_text.post_id'
indvdum@0
   660
			),
indvdum@0
   661
indvdum@0
   662
			array(
indvdum@0
   663
				'target'		=> PRIVMSGS_TABLE,
indvdum@0
   664
				'primary'		=> 'privmsgs.privmsgs_id',
indvdum@0
   665
				'autoincrement'	=> 'msg_id',
indvdum@0
   666
				'query_first'	=> array(
indvdum@0
   667
					array('target', $convert->truncate_statement . PRIVMSGS_TABLE),
indvdum@0
   668
					array('target', $convert->truncate_statement . PRIVMSGS_RULES_TABLE),
indvdum@0
   669
				),
indvdum@0
   670
indvdum@0
   671
				'execute_first'	=> '
indvdum@0
   672
					$config["max_post_chars"] = 0;
indvdum@0
   673
					$config["min_post_chars"] = 0;
indvdum@0
   674
					$config["max_quote_depth"] = 0;
indvdum@0
   675
				',
indvdum@0
   676
indvdum@0
   677
				array('msg_id',					'privmsgs.privmsgs_id',				''),
indvdum@0
   678
				array('root_level',				0,									''),
indvdum@0
   679
				array('author_id',				'privmsgs.privmsgs_from_userid AS poster_id',	'phpbb_user_id'),
indvdum@0
   680
				array('icon_id',				0,									''),
indvdum@0
   681
				array('author_ip',				'privmsgs.privmsgs_ip',				'decode_ip'),
indvdum@0
   682
				array('message_time',			'privmsgs.privmsgs_date',			''),
indvdum@0
   683
				array('enable_bbcode',			'privmsgs.privmsgs_enable_bbcode AS enable_bbcode',	''),
indvdum@0
   684
				array('',						'privmsgs.privmsgs_enable_html AS enable_html',	''),
indvdum@0
   685
				array('enable_smilies',			'privmsgs.privmsgs_enable_smilies AS enable_smilies',	''),
indvdum@0
   686
				array('enable_magic_url',		1,									''),
indvdum@0
   687
				array('enable_sig',				'privmsgs.privmsgs_attach_sig',		''),
indvdum@0
   688
				array('message_subject',		'privmsgs.privmsgs_subject',		'phpbb_set_encoding'), // Already specialchared in 2.0.x
indvdum@0
   689
				array('message_attachment',		((defined('MOD_ATTACHMENT')) ? 'privmsgs.privmsgs_attachment' : 0), ''),
indvdum@0
   690
				array('message_edit_reason',	'',									''),
indvdum@0
   691
				array('message_edit_user',		0,									''),
indvdum@0
   692
				array('message_edit_time',		0,									''),
indvdum@0
   693
				array('message_edit_count',		0,									''),
indvdum@0
   694
indvdum@0
   695
				array('bbcode_uid',				'privmsgs.privmsgs_date AS post_time',	'make_uid'),
indvdum@0
   696
				array('message_text',			'privmsgs_text.privmsgs_text',			'phpbb_prepare_message'),
indvdum@0
   697
				array('',						'privmsgs_text.privmsgs_bbcode_uid AS old_bbcode_uid',			''),
indvdum@0
   698
				array('bbcode_bitfield',		'',										'get_bbcode_bitfield'),
indvdum@0
   699
				array('to_address',				'privmsgs.privmsgs_to_userid',			'phpbb_privmsgs_to_userid'),
indvdum@0
   700
				array('bcc_address',			'',										''),
indvdum@0
   701
indvdum@0
   702
				'where'			=>	'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id'
indvdum@0
   703
			),
indvdum@0
   704
indvdum@0
   705
			array(
indvdum@0
   706
				'target'		=> PRIVMSGS_FOLDER_TABLE,
indvdum@0
   707
				'primary'		=> 'users.user_id',
indvdum@0
   708
				'query_first'	=> array('target', $convert->truncate_statement . PRIVMSGS_FOLDER_TABLE),
indvdum@0
   709
indvdum@0
   710
				array('user_id',				'users.user_id',						'phpbb_user_id'),
indvdum@0
   711
				array('folder_name',			$user->lang['CONV_SAVED_MESSAGES'],		''),
indvdum@0
   712
				array('pm_count',				0,										''),
indvdum@0
   713
indvdum@0
   714
				'where'			=> 'users.user_id <> -1',
indvdum@0
   715
			),
indvdum@0
   716
indvdum@0
   717
			// Inbox
indvdum@0
   718
			array(
indvdum@0
   719
				'target'		=> PRIVMSGS_TO_TABLE,
indvdum@0
   720
				'primary'		=> 'privmsgs.privmsgs_id',
indvdum@0
   721
				'query_first'	=> array('target', $convert->truncate_statement . PRIVMSGS_TO_TABLE),
indvdum@0
   722
indvdum@0
   723
				array('msg_id',					'privmsgs.privmsgs_id',					''),
indvdum@0
   724
				array('user_id',				'privmsgs.privmsgs_to_userid',			'phpbb_user_id'),
indvdum@0
   725
				array('author_id',				'privmsgs.privmsgs_from_userid',		'phpbb_user_id'),
indvdum@0
   726
				array('pm_deleted',				0,										''),
indvdum@0
   727
				array('pm_new',					'privmsgs.privmsgs_type',				'phpbb_new_pm'),
indvdum@0
   728
				array('pm_unread',				'privmsgs.privmsgs_type',				'phpbb_unread_pm'),
indvdum@0
   729
				array('pm_replied',				0,										''),
indvdum@0
   730
				array('pm_marked',				0,										''),
indvdum@0
   731
				array('pm_forwarded',			0,										''),
indvdum@0
   732
				array('folder_id',				PRIVMSGS_INBOX,							''),
indvdum@0
   733
indvdum@0
   734
				'where'			=> 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
indvdum@0
   735
										AND (privmsgs.privmsgs_type = 0 OR privmsgs.privmsgs_type = 1 OR privmsgs.privmsgs_type = 5)',
indvdum@0
   736
			),
indvdum@0
   737
indvdum@0
   738
			// Outbox
indvdum@0
   739
			array(
indvdum@0
   740
				'target'		=> PRIVMSGS_TO_TABLE,
indvdum@0
   741
				'primary'		=> 'privmsgs.privmsgs_id',
indvdum@0
   742
indvdum@0
   743
				array('msg_id',					'privmsgs.privmsgs_id',					''),
indvdum@0
   744
				array('user_id',				'privmsgs.privmsgs_from_userid',		'phpbb_user_id'),
indvdum@0
   745
				array('author_id',				'privmsgs.privmsgs_from_userid',		'phpbb_user_id'),
indvdum@0
   746
				array('pm_deleted',				0,										''),
indvdum@0
   747
				array('pm_new',					0,										''),
indvdum@0
   748
				array('pm_unread',				0,										''),
indvdum@0
   749
				array('pm_replied',				0,										''),
indvdum@0
   750
				array('pm_marked',				0,										''),
indvdum@0
   751
				array('pm_forwarded',			0,										''),
indvdum@0
   752
				array('folder_id',				PRIVMSGS_OUTBOX,						''),
indvdum@0
   753
indvdum@0
   754
				'where'			=> 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
indvdum@0
   755
										AND (privmsgs.privmsgs_type = 1 OR privmsgs.privmsgs_type = 5)',
indvdum@0
   756
			),
indvdum@0
   757
indvdum@0
   758
			// Sentbox
indvdum@0
   759
			array(
indvdum@0
   760
				'target'		=> PRIVMSGS_TO_TABLE,
indvdum@0
   761
				'primary'		=> 'privmsgs.privmsgs_id',
indvdum@0
   762
indvdum@0
   763
				array('msg_id',					'privmsgs.privmsgs_id',					''),
indvdum@0
   764
				array('user_id',				'privmsgs.privmsgs_from_userid',		'phpbb_user_id'),
indvdum@0
   765
				array('author_id',				'privmsgs.privmsgs_from_userid',		'phpbb_user_id'),
indvdum@0
   766
				array('pm_deleted',				0,										''),
indvdum@0
   767
				array('pm_new',					'privmsgs.privmsgs_type',				'phpbb_new_pm'),
indvdum@0
   768
				array('pm_unread',				'privmsgs.privmsgs_type',				'phpbb_unread_pm'),
indvdum@0
   769
				array('pm_replied',				0,										''),
indvdum@0
   770
				array('pm_marked',				0,										''),
indvdum@0
   771
				array('pm_forwarded',			0,										''),
indvdum@0
   772
				array('folder_id',				PRIVMSGS_SENTBOX,						''),
indvdum@0
   773
indvdum@0
   774
				'where'			=> 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
indvdum@0
   775
										AND privmsgs.privmsgs_type = 2',
indvdum@0
   776
			),
indvdum@0
   777
indvdum@0
   778
			// Savebox (SAVED IN)
indvdum@0
   779
			array(
indvdum@0
   780
				'target'		=> PRIVMSGS_TO_TABLE,
indvdum@0
   781
				'primary'		=> 'privmsgs.privmsgs_id',
indvdum@0
   782
indvdum@0
   783
				array('msg_id',					'privmsgs.privmsgs_id',					''),
indvdum@0
   784
				array('user_id',				'privmsgs.privmsgs_to_userid',			'phpbb_user_id'),
indvdum@0
   785
				array('author_id',				'privmsgs.privmsgs_from_userid',		'phpbb_user_id'),
indvdum@0
   786
				array('pm_deleted',				0,										''),
indvdum@0
   787
				array('pm_new',					'privmsgs.privmsgs_type',				'phpbb_new_pm'),
indvdum@0
   788
				array('pm_unread',				'privmsgs.privmsgs_type',				'phpbb_unread_pm'),
indvdum@0
   789
				array('pm_replied',				0,										''),
indvdum@0
   790
				array('pm_marked',				0,										''),
indvdum@0
   791
				array('pm_forwarded',			0,										''),
indvdum@0
   792
				array('folder_id',				'privmsgs.privmsgs_to_userid',			'phpbb_get_savebox_id'),
indvdum@0
   793
indvdum@0
   794
				'where'			=> 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
indvdum@0
   795
										AND privmsgs.privmsgs_type = 3',
indvdum@0
   796
			),
indvdum@0
   797
indvdum@0
   798
			// Savebox (SAVED OUT)
indvdum@0
   799
			array(
indvdum@0
   800
				'target'		=> PRIVMSGS_TO_TABLE,
indvdum@0
   801
				'primary'		=> 'privmsgs.privmsgs_id',
indvdum@0
   802
indvdum@0
   803
				array('msg_id',					'privmsgs.privmsgs_id',					''),
indvdum@0
   804
				array('user_id',				'privmsgs.privmsgs_from_userid',		'phpbb_user_id'),
indvdum@0
   805
				array('author_id',				'privmsgs.privmsgs_from_userid',		'phpbb_user_id'),
indvdum@0
   806
				array('pm_deleted',				0,										''),
indvdum@0
   807
				array('pm_new',					'privmsgs.privmsgs_type',				'phpbb_new_pm'),
indvdum@0
   808
				array('pm_unread',				'privmsgs.privmsgs_type',				'phpbb_unread_pm'),
indvdum@0
   809
				array('pm_replied',				0,										''),
indvdum@0
   810
				array('pm_marked',				0,										''),
indvdum@0
   811
				array('pm_forwarded',			0,										''),
indvdum@0
   812
				array('folder_id',				'privmsgs.privmsgs_from_userid',		'phpbb_get_savebox_id'),
indvdum@0
   813
indvdum@0
   814
				'where'			=> 'privmsgs.privmsgs_id = privmsgs_text.privmsgs_text_id
indvdum@0
   815
										AND privmsgs.privmsgs_type = 4',
indvdum@0
   816
			),
indvdum@0
   817
indvdum@0
   818
			array(
indvdum@0
   819
				'target'		=> GROUPS_TABLE,
indvdum@0
   820
				'autoincrement'	=> 'group_id',
indvdum@0
   821
				'query_first'	=> array('target', $convert->truncate_statement . GROUPS_TABLE),
indvdum@0
   822
indvdum@0
   823
				array('group_id',				'groups.group_id',					''),
indvdum@0
   824
				array('group_type',				'groups.group_type',				'phpbb_convert_group_type'),
indvdum@0
   825
				array('group_display',			0,									''),
indvdum@0
   826
				array('group_legend',			0,									''),
indvdum@0
   827
				array('group_name',				'groups.group_name',				'phpbb_convert_group_name'), // phpbb_set_encoding called in phpbb_convert_group_name
indvdum@0
   828
				array('group_desc',				'groups.group_description',			'phpbb_set_encoding'),
indvdum@0
   829
indvdum@0
   830
				'where'			=> 'groups.group_single_user = 0',
indvdum@0
   831
			),
indvdum@0
   832
indvdum@0
   833
			array(
indvdum@0
   834
				'target'		=> USER_GROUP_TABLE,
indvdum@0
   835
				'query_first'	=> array('target', $convert->truncate_statement . USER_GROUP_TABLE),
indvdum@0
   836
				'execute_first'	=> '
indvdum@0
   837
					add_default_groups();
indvdum@0
   838
				',
indvdum@0
   839
indvdum@0
   840
				array('group_id',		'groups.group_id',					''),
indvdum@0
   841
				array('user_id',		'groups.group_moderator',			'phpbb_user_id'),
indvdum@0
   842
				array('group_leader',	1,									''),
indvdum@0
   843
				array('user_pending',	0,									''),
indvdum@0
   844
indvdum@0
   845
				'where'			=> 'groups.group_single_user = 0 AND groups.group_moderator <> 0',
indvdum@0
   846
			),
indvdum@0
   847
indvdum@0
   848
			array(
indvdum@0
   849
				'target'		=> USER_GROUP_TABLE,
indvdum@0
   850
indvdum@0
   851
				array('group_id',		'user_group.group_id',				''),
indvdum@0
   852
				array('user_id',		'user_group.user_id',				'phpbb_user_id'),
indvdum@0
   853
				array('group_leader',	0,									''),
indvdum@0
   854
				array('user_pending',	'user_group.user_pending',			''),
indvdum@0
   855
indvdum@0
   856
				'where'			=> 'user_group.group_id = groups.group_id AND groups.group_single_user = 0 AND groups.group_moderator <> user_group.user_id',
indvdum@0
   857
			),
indvdum@0
   858
indvdum@0
   859
			array(
indvdum@0
   860
				'target'		=> USERS_TABLE,
indvdum@0
   861
				'primary'		=> 'users.user_id',
indvdum@0
   862
				'autoincrement'	=> 'user_id',
indvdum@0
   863
				'query_first'	=> array(
indvdum@0
   864
					array('target', 'DELETE FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS),
indvdum@0
   865
					array('target', $convert->truncate_statement . BOTS_TABLE)
indvdum@0
   866
				),
indvdum@0
   867
indvdum@0
   868
				'execute_last'	=> '
indvdum@0
   869
					remove_invalid_users();
indvdum@0
   870
				',
indvdum@0
   871
indvdum@0
   872
				array('user_id',				'users.user_id',					'phpbb_user_id'),
indvdum@0
   873
				array('',						'users.user_id AS poster_id',		'phpbb_user_id'),
indvdum@0
   874
				array('user_type',				'users.user_active',				'set_user_type'),
indvdum@0
   875
				array('group_id',				'users.user_level',					'phpbb_set_primary_group'),
indvdum@0
   876
				array('user_regdate',			'users.user_regdate',				''),
indvdum@0
   877
				array('username',				'users.username',					'phpbb_set_default_encoding'), // recode to utf8 with default lang
indvdum@0
   878
				array('username_clean',			'users.username',					array('function1' => 'phpbb_set_default_encoding', 'function2' => 'utf8_clean_string')),
indvdum@0
   879
				array('user_password',			'users.user_password',				'phpbb_hash'),
indvdum@0
   880
				array('user_pass_convert',		1,									''),
indvdum@0
   881
				array('user_posts',				'users.user_posts',					'intval'),
indvdum@0
   882
				array('user_email',				'users.user_email',					'strtolower'),
indvdum@0
   883
				array('user_email_hash',		'users.user_email',					'gen_email_hash'),
indvdum@0
   884
				array('user_birthday',			((defined('MOD_BIRTHDAY')) ? 'users.user_birthday' : ''),	'phpbb_get_birthday'),
indvdum@0
   885
				array('user_lastvisit',			'users.user_lastvisit',				'intval'),
indvdum@0
   886
				array('user_lastmark',			'users.user_lastvisit',				'intval'),
indvdum@0
   887
				array('user_lang',				$config['default_lang'],			''),
indvdum@0
   888
				array('',						'users.user_lang',					''),
indvdum@0
   889
				array('user_timezone',			'users.user_timezone',				'floatval'),
indvdum@0
   890
				array('user_dateformat',		'users.user_dateformat',			array('function1' => 'phpbb_set_encoding', 'function2' => 'fill_dateformat')),
indvdum@0
   891
				array('user_inactive_reason',	'',									'phpbb_inactive_reason'),
indvdum@0
   892
				array('user_inactive_time',		'',									'phpbb_inactive_time'),
indvdum@0
   893
indvdum@0
   894
				array('user_interests',			'users.user_interests',				array('function1' => 'phpbb_set_encoding')),
indvdum@0
   895
				array('user_occ',				'users.user_occ',					array('function1' => 'phpbb_set_encoding')),
indvdum@0
   896
				array('user_website',			'users.user_website',				'validate_website'),
indvdum@0
   897
				array('user_jabber',			'',									''),
indvdum@0
   898
				array('user_msnm',				'users.user_msnm',					array('function1' => 'phpbb_set_encoding')),
indvdum@0
   899
				array('user_yim',				'users.user_yim',					array('function1' => 'phpbb_set_encoding')),
indvdum@0
   900
				array('user_aim',				'users.user_aim',					array('function1' => 'phpbb_set_encoding')),
indvdum@0
   901
				array('user_icq',				'users.user_icq',					array('function1' => 'phpbb_set_encoding')),
indvdum@0
   902
				array('user_from',				'users.user_from',					array('function1' => 'phpbb_set_encoding')),
indvdum@0
   903
				array('user_rank',				'users.user_rank',					'intval'),
indvdum@0
   904
				array('user_permissions',		'',									''),
indvdum@0
   905
indvdum@0
   906
				array('user_avatar',			'users.user_avatar',				'phpbb_import_avatar'),
indvdum@0
   907
				array('user_avatar_type',		'users.user_avatar_type',			'phpbb_avatar_type'),
indvdum@0
   908
				array('user_avatar_width',		'users.user_avatar',				'phpbb_get_avatar_width'),
indvdum@0
   909
				array('user_avatar_height',		'users.user_avatar',				'phpbb_get_avatar_height'),
indvdum@0
   910
indvdum@0
   911
				array('user_new_privmsg',		'users.user_new_privmsg',			''),
indvdum@0
   912
				array('user_unread_privmsg',	0,									''), //'users.user_unread_privmsg'
indvdum@0
   913
				array('user_last_privmsg',		'users.user_last_privmsg',			'intval'),
indvdum@0
   914
				array('user_emailtime',			'users.user_emailtime',				'null_to_zero'),
indvdum@0
   915
				array('user_notify',			'users.user_notify',				'intval'),
indvdum@0
   916
				array('user_notify_pm',			'users.user_notify_pm',				'intval'),
indvdum@0
   917
				array('user_notify_type',		NOTIFY_EMAIL,						''),
indvdum@0
   918
				array('user_allow_pm',			'users.user_allow_pm',				'intval'),
indvdum@0
   919
				array('user_allow_viewonline',	'users.user_allow_viewonline',		'intval'),
indvdum@0
   920
				array('user_allow_viewemail',	'users.user_viewemail',				'intval'),
indvdum@0
   921
				array('user_actkey',			'users.user_actkey',				''),
indvdum@0
   922
				array('user_newpasswd',			'',									''), // Users need to re-request their password...
indvdum@0
   923
				array('user_style',				$config['default_style'],			''),
indvdum@0
   924
indvdum@0
   925
				array('user_options',			'',									'set_user_options'),
indvdum@0
   926
				array('',						'users.user_popup_pm AS popuppm',	''),
indvdum@0
   927
				array('',						'users.user_allowhtml AS html',		''),
indvdum@0
   928
				array('',						'users.user_allowbbcode AS bbcode',	''),
indvdum@0
   929
				array('',						'users.user_allowsmile AS smile',	''),
indvdum@0
   930
				array('',						'users.user_attachsig AS attachsig',''),
indvdum@0
   931
indvdum@0
   932
				array('user_sig_bbcode_uid',		'users.user_regdate',							'make_uid'),
indvdum@0
   933
				array('user_sig',					'users.user_sig',								'phpbb_prepare_message'),
indvdum@0
   934
				array('',							'users.user_sig_bbcode_uid AS old_bbcode_uid',	''),
indvdum@0
   935
				array('user_sig_bbcode_bitfield',	'',												'get_bbcode_bitfield'),
indvdum@0
   936
				array('',							'users.user_regdate AS post_time',				''),
indvdum@0
   937
indvdum@0
   938
				'where'			=> 'users.user_id <> -1',
indvdum@0
   939
			),
indvdum@0
   940
		),
indvdum@0
   941
	);
indvdum@0
   942
}
indvdum@0
   943
indvdum@0
   944
?>