function _account_sync_send_update in Account Sync 7.2
Same name and namespace in other branches
- 6 account_sync.sender.inc \_account_sync_send_update()
Helper function to do the heavy lifting of the account information transfer.
2 calls to _account_sync_send_update()
- account_sync_send_update in ./
account_sync.sender.inc - Send an account update to all target sites.
- account_sync_sync_all in ./
account_sync.admin.inc - Sync all accounts from this site to a 3rd party drupal site.
File
- ./
account_sync.sender.inc, line 34 - Handler for sending account data to other sites
Code
function _account_sync_send_update($edit, $account, $category, $username = NULL) {
// Check sync account permission and don't sync user with uid 0
// or 1 (unless permitted).
if (!$account->uid || !user_access('sync account', $account) || $account->uid == 1 && !variable_get('account_sync_uid1', FALSE)) {
return;
}
// No need to send a plain text password across. We can just send the hash.
unset($edit['pass']);
// Flag to verify that account data was sent somewhere.
$data_sent = 0;
_account_sync_update_roles($account);
// Send the data to all target servers.
foreach (account_sync_servers($account) as $server_url) {
$results = xmlrpc($server_url . '/xmlrpc.php', array(
'account_sync.updateUser' => array(
variable_get('account_sync_server_key', ''),
$username ? $username : $account->name,
$edit,
(array) $account,
$category,
user_roles(),
),
));
if ($errmsg = xmlrpc_error_msg()) {
watchdog('account_sync', 'XMLRPC error received while syncing users to @server: ' . $errmsg, array(
'@server' => $server_url,
), WATCHDOG_ERROR);
return WATCHDOG_ERROR;
}
if (is_array($results)) {
$vars = is_array($results[2]) ? $results[2] : array();
$vars['@server'] = $server_url;
watchdog('account_sync', '@server: ' . $results[1], $vars, $results[0]);
$data_sent = $results[0] == WATCHDOG_ERROR ? WATCHDOG_ERROR : 1;
}
}
return $data_sent;
}