install/schemas/upgrade/1.1.6-1.1.7.php
author Dan
Mon, 19 Apr 2010 18:07:43 -0400
changeset 1243 db42b7c50e57
parent 1227 bdac73ed481e
permissions -rw-r--r--
Fixed registration admin override with account_activation set to disable.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1179
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
     1
<?php
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
     2
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
     3
// Migrate usernames in the logs table
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
     4
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
     5
global $db, $session, $paths, $template, $plugins; // Common objects
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
     6
1181
91911e183685 Forgot table_prefix in the logs table migrator
Dan
parents: 1179
diff changeset
     7
$q = $db->sql_query('SELECT user_id, username FROM ' . table_prefix . 'users;');
1179
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
     8
if ( !$q )
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
     9
	$db->_die();
1179
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    10
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    11
$map = array();
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    12
while($row = $db->fetchrow())
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    13
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    14
	$map[ $row['username'] ] = $row['user_id'];
1179
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    15
}
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    16
$db->free_result();
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    17
1181
91911e183685 Forgot table_prefix in the logs table migrator
Dan
parents: 1179
diff changeset
    18
$q = $db->sql_query('SELECT author FROM ' . table_prefix . 'logs WHERE author_uid = 1;');
1179
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    19
if ( !$q )
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    20
	$db->_die();
1179
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    21
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    22
$updated = array();
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    23
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    24
while ( $row = $db->fetchrow($q) )
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    25
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    26
	if ( isset($map[ $row['author'] ]) && !is_valid_ip($row['author']) && !in_array($row['author'], $updated) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    27
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    28
		$author = $db->escape($row['author']);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    29
		$sql = "UPDATE " . table_prefix . "logs SET author_uid = {$map[ $row['author'] ]} WHERE author = '$author';";
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    30
		if ( !$db->sql_query($sql) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    31
			$db->_die();
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    32
		$updated[] = $row['author'];
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1181
diff changeset
    33
	}
1179
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    34
}
ac861c01a764 Added an upgrade hook to populate the author_uid column in logs, pending test by Neal
Dan
parents:
diff changeset
    35