You are here

function userreference_node_deploy in Deploy - Content Staging 6

Implementation of hook_node_deploy(),

Parameters

$node: Unique identifier for the node we're deploying.

File

modules/userreference_deploy/userreference_deploy.module, line 71
Deployment module for userreferences

Code

function userreference_node_deploy(&$node) {
  $userreference_fields = userreference_deploy_get_userreference_fields();
  foreach ($userreference_fields as $field_name => $widget_type) {
    if (property_exists($node, $field_name)) {
      $field = array();
      foreach ($node->{$field_name} as $key => $userreference) {
        if (!empty($userreference['uid'])) {
          switch ($widget_type) {
            case 'userreference_select':
              if ($userreference['uid'] == 0 || $userreference['uid'] == 1) {
                $field['uid']['uid'][$key] = $userreference['uid'];
              }
              else {
                $uuid = deploy_uuid_get_user_uuid($userreference['uid']);
                $remote_data = deploy_get_remote_key($uuid, 'users');
                if ($remote_data) {
                  $field['uid']['uid'][$key] = $remote_data['uid'];
                }
              }
              break;
            case 'userreference_autocomplete':
              $account = user_load(array(
                'uid' => $userreference['uid'],
              ));
              $field[$key]['uid']['uid'] = $account->name;
              break;
            default:

              # code...
              break;
          }
        }
      }
      $node->{$field_name} = $field;
    }
  }
}