groups/modules/groups/groups_oauth2/groups_oauth2.drush.inc
Marton Kiss 209d444c00 User profile migration tool for user name normalization
The user name and full name fields of the user profile contains
duplicated last name for newly registered users. This drush tool
helps to migrate the user profile data into a normalized format.
The duplication happened due to an integration issue between
groups portal and oauth2 service.

Usage:
  drush migrate-profiles

Change-Id: I4a2f64b93fc320448cc1b250674fb99604ebd01b
2016-06-28 18:13:24 +02:00

51 lines
1.3 KiB
PHP

<?php
/**
* @file
* Groups user profile name migration commands.
*
*/
/**
* Implementation of hook_drush_help()
*/
function groups_oauth2_drush_help($section) {
switch ($section) {
case 'meta:dsd:title':
return dt('Groups portal user profile migration commands');
case 'meta:dsd:summary':
return dt('Normalize user profile user names and full names.');
}
}
/**
* Implementation of hook_drush_command()
*/
function groups_oauth2_drush_command() {
$items['migrate-profiles'] = array(
'description' => 'Migrate user profiles',
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'arguments' => array(),
);
return $items;
}
/**
* Trigger meetup event import. Fetch all meetup urls
* from group node's resource links, and import the ical
* calendar into event entitites.
*/
function drush_groups_oauth2_migrate_profiles() {
module_load_include('inc', 'groups_oauth2', 'groups_oauth2.migrate');
$users = entity_load('user');
drush_print(dt("Processing user profiles..."));
foreach ($users as $key => $value) {
$fullname = _groups_oauth2_normalize_user_name($value);
if ($fullname != NULL) {
drush_print(dt('@uid @fullname => @fullnamenew', array(
'@uid' => $value->uid,
'@fullname' => $value->data['oauth2_fullname'],
'@fullnamenew' => $fullname)));
}
}
}