View source
<?php
function migrate_extras_migrate_api() {
$api = array(
'api' => 1,
'integration modules' => array(
'content',
'content_profile' => array(
'status' => FALSE,
),
'email_registration' => array(
'status' => FALSE,
),
'filefield' => array(
'status' => FALSE,
),
'location' => array(
'status' => FALSE,
),
'location_user' => array(
'status' => FALSE,
),
'privatemsg' => array(
'status' => FALSE,
),
),
);
return $api;
}
function migrate_extras_settings() {
$form = array();
$form['users'] = array(
'#type' => 'fieldset',
'#title' => t('Users'),
);
$form['users']['migrate_extras_use_md5'] = array(
'#type' => 'checkbox',
'#title' => t('MD5 password field'),
'#default_value' => variable_get('migrate_extras_use_md5', 0),
'#description' => t("Enable an md5 password field for users, use\n this if you are migrating passwords that are already encrypted."),
);
$form['users']['migrate_extras_user_fields_all'] = array(
'#type' => 'checkbox',
'#title' => t("Use all user fields"),
'#default_value' => variable_get('migrate_extras_user_fields_all', 0),
'#description' => t('Enable all the core drupal user fields
available, for advanced imports. None of these fields are required
to import users. Some fields may only take data in specialized
format. See <a href="http://api.drupal.org/api/function/user_schema">
http://api.drupal.org/api/function/user_schema</a> for more info.'),
);
$form['node'] = array(
'#type' => 'fieldset',
'#title' => t('Nodes'),
);
$form['node']['migrate_extras_use_master_node_map'] = array(
'#type' => 'checkbox',
'#title' => t('Use the migrate extras master node map.'),
'#default_value' => variable_get('migrate_extras_use_master_node_map', 0),
'#description' => t("This will make sure that when any node content\n set adds a new node, that a map will be added to the 'migrate_extras_node_map'\n table. This is good if you are using multiple content sets to import nodes and\n want the convenience of using just one map table as the basis for\n following imports like comments. Only use this if source ids across\n content sets are unique and are all of integer type."),
);
return system_settings_form($form);
}
function migrate_extras_menu() {
$items = array();
$items['admin/content/migrate/extras'] = array(
'title' => 'Extras',
'description' => 'Migrate Extras module settings',
'weight' => 10,
'page callback' => 'drupal_get_form',
'page arguments' => array(
'migrate_extras_settings',
),
'access arguments' => array(
MIGRATE_ACCESS_ADVANCED,
),
'type' => MENU_LOCAL_TASK,
);
return $items;
}
function migrate_extras_migrate_fields_user($type) {
$fields = array();
if (variable_get('migrate_extras_use_md5', 0)) {
$fields['md5pass'] = t('User: Password(md5)');
}
if (variable_get('migrate_extras_user_fields_all', 0)) {
$fields['mode'] = t('User: Mode');
$fields['sort'] = t('User: Sort');
$fields['threshold'] = t('User: Threshold (unused)');
$fields['theme'] = t('User: Theme');
$fields['signature'] = t('User: Signature');
$fields['signature_format'] = t('User: Signature Format');
$fields['timezone'] = t('User: Timezone');
$fields['language'] = t('User: Language');
$fields['picture'] = t('User: Picture');
$fields['init'] = t('User: (Init)ial Email');
$fields['data'] = t('User: Data (depricated)');
}
return $fields;
}
function migrate_extras_migrate_prepare_user(&$newuser, $tblinfo, $row) {
$srckey = $tblinfo->sourcekey;
$uid = $row->{$srckey};
if (isset($newuser['md5pass'])) {
unset($newuser['md5pass']);
}
}
function migrate_extras_migrate_complete_user(&$account, $tblinfo, $row) {
$errors = array();
$md5pass = FALSE;
if (isset($tblinfo->fields['md5pass']['srcfield'])) {
$md5_src = $tblinfo->fields['md5pass']['srcfield'];
if (isset($row->{$md5_src})) {
$md5pass = $row->{$md5_src};
}
else {
$errors[] = migrate_message('No MD5 password provided for this user.');
return $errors;
}
}
if ($account->uid && $md5pass !== FALSE && variable_get('migrate_extras_use_md5', 0)) {
$ret = db_query("UPDATE {users} SET pass = '%s' WHERE uid = %d", $md5pass, $account->uid);
$check_user = user_load($account->uid);
if ($check_user->pass != $md5pass) {
$errors[] = migrate_message(t("md5 encoded passwords don't match"));
}
}
return $errors;
}
function migrate_extras_migrate_complete_node($node, $tblinfo, $row) {
if (variable_get('migrate_extras_use_master_node_map', 0) && $node->nid) {
$sourcekey = $tblinfo->sourcekey;
static $maptables = array();
if (!isset($maptables[$mcsid])) {
$maptables[$mcsid] = migrate_map_table_name($tblinfo->mcsid);
}
$needs_update = db_result(db_query('SELECT needs_update
FROM {' . $maptables[$mcsid] . "}\n WHERE sourceid='%s'", $row->{$sourcekey}));
if ($needs_update == 1) {
}
elseif ($needs_update !== 0) {
db_query("INSERT INTO {migrate_extras_node_map} (sourceid, destid)\n VALUES('%s', %d)", $row->{$sourcekey}, $node->nid);
}
}
}
function migrate_extras_migrate_delete_node($nid) {
if ($nid) {
db_query("DELETE FROM {migrate_extras_node_map} WHERE destid=%d", $nid);
}
}