You are here

function account_sync_sync_all in Account Sync 7.2

Same name and namespace in other branches
  1. 6 account_sync.admin.inc \account_sync_sync_all()

Sync all accounts from this site to a 3rd party drupal site.

1 string reference to 'account_sync_sync_all'
account_sync_settings in ./account_sync.admin.inc
FAPI callback for the admin settings form.

File

./account_sync.admin.inc, line 54
Admin settings for account_sync.

Code

function account_sync_sync_all() {
  module_load_include('inc', 'account_sync', 'account_sync.sender');
  $roles = account_sync_allowed_roles();
  $uids = db_query("SELECT uid FROM {users_roles} WHERE rid IN (:rids) ORDER BY uid", array(
    ':rids' => array_keys($roles),
  ))
    ->fetchCol();
  $accounts = user_load_multiple($uids);
  foreach ($accounts as $account) {
    $edit = (array) $account;
    unset($edit['uid']);
    unset($edit['data']);
    if ($result = _account_sync_send_update($edit, $account, 'account')) {
      if ($result == 1) {
        drupal_set_message(t("Sync'd account information for %username", array(
          '%username' => $account->name,
        )));
      }
      elseif ($result == WATCHDOG_ERROR) {
        drupal_set_message(t('Error syncing account information for %username, see recent log entries for more details', array(
          '%username' => $account->name,
        )));
      }
    }
  }
}