$users = array() // Build a custom query that selects all user_id and facebook_auth_id and forms them into an array. Maybe fetchPairs would work.
foreach ($users AS $key => $user)
{
$auth = $this->_getUserModel()->getUserAuthenticationObjectByUserId($user['user_id']);
$this->getModelFromCache('XenForo_Model_UserExternal')->deleteExternalAuthAssociation(
'facebook', $user['facebook_auth_id'], $user['user_id']
);
if (!$auth->hasPassword())
{
$this->getModelFromCache('XenForo_Model_UserConfirmation')->resetPassword($user['user_id']);
}
}