You are here

function user_deploy_check_user in Deploy - Content Staging 6

Check to see if a user should be added to the deployment plan currently being pushed.

This function goes through the motions of checking whether a user should be deployed, or whether it can just be ignored. This is part of the dependency checking mechanism for drupal items that refer to users (like for instance nodes.)

Parameters

$uid: The unique identifier for the user being checked.

1 call to user_deploy_check_user()
user_deploy_node_deploy_check in modules/user_deploy/user_deploy.module
Implementation of hook_node_deploy_check().

File

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

Code

function user_deploy_check_user($uid) {

  // Get the remote server info.
  $url = variable_get('deploy_server_url', '');
  $pid = variable_get('deploy_pid', 0);

  // If this user is already in the deployment plan then either
  // a) it was added by the user and will get checked down the line or
  // b) it was added through dependency checks and its already been
  // dealt with. So we just move on in this case.
  //
  // Also skip past if uid > 1 (IE this is not the admin or anonymous user)
  // If anyone knows of a less-ugly way to say that then I'd love to hear
  // about it.
  if (!deploy_item_is_in_plan($pid, 'user', $uid) && $uid > 1) {
    $account = user_load(array(
      'uid' => $uid,
    ));

    // Does this user exist on the remote server?
    $remote_key = deploy_get_remote_key($account->uuid, 'users');

    // If not we're going to add it to the deployment plan, with a weight
    // of min(weight) - 1.
    if (!$remote_key) {
      deploy_add_to_plan($pid, 'user', 'User: ' . $account->name, $uid, deploy_get_min_weight($pid) - 1, DEPLOY_USER_GROUP_WEIGHT);

      // Now that we're deploying a user, we need to check all of its
      // dependencies (might be able to skip this now that we've eliminated roles)
      module_invoke_all('user_deploy_check', $account);
    }
  }
}