View source
<?php
function logintoboggan_update_1() {
return array();
}
function logintoboggan_update_2() {
$users = db_query('SELECT uid, data FROM {users}');
while ($user = db_fetch_object($users)) {
$data = unserialize($user->data);
$updated_data = array();
if (is_array($data)) {
foreach ($data as $key => $value) {
if (!in_array($key, array(
'conf_mail',
'conf_pass',
))) {
$updated_data[$key] = $value;
}
}
$updated_data = serialize($updated_data);
db_query("UPDATE {users} SET data = '%s' WHERE uid = %d", $updated_data, $user->uid);
}
}
drupal_set_message(t('logintoboggan cleaning of user data successful'));
return array();
}
function logintoboggan_update_3() {
if (variable_get('reg_passwd_set', 0) == 2) {
variable_set('reg_passwd_set', 1);
}
return array();
}
function logintoboggan_update_4() {
if (variable_get('toboggan_role', 2) == 1) {
variable_set('toboggan_role', 2);
drupal_set_message(t('Your previous setting for the logintoboggan pre-auth role was the anonymous user role, which is no longer allowed. The pre-auth role has now been set to the authenticated user role for your site. <em>Because of this change, all unvalidated users on your site now have authenticated user permissions!</em> If you wish to retain the previous functionality, create a new user role with the same access permissions as the anonymous user, and set the logintoboggan pre-auth role to the newly created role. You will also need to manually add any previously unvalidated users to the newly created pre-auth role.'), 'error');
}
return array();
}
function logintoboggan_update_5() {
$fields = db_query('SELECT fid, name FROM {profile_fields}');
while ($field = db_fetch_object($fields)) {
$fids[$field->fid] = $field->name;
$where[] = "data LIKE '%%%s%%'";
}
if (isset($fids)) {
$users = db_query('SELECT uid, data FROM {users} WHERE ' . implode(' OR ', $where), $fids);
while ($user = db_fetch_object($users)) {
$data = unserialize($user->data);
$updated_data = array();
if (is_array($data)) {
foreach ($data as $key => $value) {
if (!in_array($key, $fids)) {
$updated_data[$key] = $value;
}
elseif ($value) {
db_query("INSERT INTO {profile_values} VALUES (%d, %d, '%s')", array_search($key, $fids), $user->uid, $value);
}
}
$updated_data = serialize($updated_data);
db_query("UPDATE {users} SET data = '%s' WHERE uid = %d", $updated_data, $user->uid);
}
}
}
drupal_set_message(t('logintoboggan cleaning of user/profile data successful'));
return array();
}
function logintoboggan_update_6() {
variable_del('toboggan_display_logged_in');
return array();
}
function logintoboggan_uninstall() {
variable_del('toboggan_block_type');
variable_del('toboggan_block_msg');
variable_del('login_with_mail');
variable_del('email_reg_confirm');
variable_del('reg_passwd_set');
variable_del('toboggan_role');
variable_del('toboggan_redirect_on_register');
variable_del('toboggan_redirect_on_confirm');
variable_del('login_successful');
variable_del('toboggan_min_pass_length');
}