You are here

function user_deploy in Deploy - Content Staging 6

Implementation of hook_deploy().

Called when an item is being deployed (as opposed to when we're checking to see if it can be deployed.)

Parameters

$uid: Unique identifier for the user we're deploying.

Return value

The results of our xmlrpc call.

File

modules/user_deploy/user_deploy.module, line 78
Deployment API which enables modules to deploy items between servers.

Code

function user_deploy($uid) {

  // Does this user exist? If not abort.
  $account = user_load($uid);
  if (empty($account)) {
    return xmlrpc_error($xmlrpcusererr + 1, t('User not found'));
  }

  // add in any authmap info if it exists
  $result = db_query("SELECT * from {authmap} WHERE uid = %d", $account->uid);
  while ($row = db_fetch_array($result)) {
    $auth = "authname_" . $row['module'];
    $account->{$auth} = $row['authname'];
  }

  // Check to see if the user exists on the remote site. If so, set our
  // user's UID to the remote user's UID and push. If not, then this will
  // be a new user on the other side.
  $remote_key = deploy_get_remote_key($account->uuid, 'users');
  if ($remote_key) {
    $account->uid = $remote_key['uid'];
  }
  else {
    unset($account->uid);
  }

  // There is some special action that needs to take place on the remote
  // server when a user is saved via deployment, so we add this flag to signal
  // where this user came from. This is similar to the method used in
  // node_deploy().
  $account->deploy = TRUE;
  return deploy_send(array(
    'user.save',
  ), array(
    $account,
  ));
}