function fbconnect_unregister in Facebook Connect 6.2
Same name and namespace in other branches
- 6 fbconnect.module \fbconnect_unregister()
Remove user from table fbconnect
Parameters
Int $fbuid: Facebook user id
Return value
boolean Success or fail.
1 call to fbconnect_unregister()
- fbconnect_user_settings_form_submit in ./
fbconnect.pages.inc - Handle post-validation user_settingsForm submission.
File
- ./
fbconnect.module, line 614 - Integration with Facebook Connect API.
Code
function fbconnect_unregister($fbuid) {
if (!fbconnect_facebook_client()) {
return FALSE;
}
if ($fbuid && ($uid = _fbconnect_is_user($fbuid))) {
try {
try {
fbconnect_facebook_client()
->api(array(
'method' => 'auth.revokeAuthorization',
'uid' => $fbuid,
));
} catch (FacebookApiException $e) {
drupal_set_message($e
->getMessage(), 'error');
throw $e;
}
} catch (Exception $e) {
$msg = 'Exception thrown while using fbconnect_unregister: @code';
$args = array(
'@code' => $e
->getMessage(),
);
watchdog('fbconnect', $msg, $args, WATCHDOG_ERROR);
}
db_query("DELETE FROM {fbconnect_users} WHERE fbuid = '%s'", $fbuid);
$account = user_load($uid);
$account->fbuid = NULL;
user_save($account, array(
'fbuid' => NULL,
));
module_invoke('rules', 'invoke_event', 'fbconnect_user_unregistered', $account);
watchdog('fbconnect', "Users authorization is revoked (fbuid: @fbuid)", array(
'@fbuid' => $fbuid,
), WATCHDOG_NOTICE, l(t('edit'), "user/{$uid}/edit/fbconnect"));
return TRUE;
}
$msg = __FUNCTION__ . ' is called with wrong $fbuid(@fbuid) argument ';
watchdog('fbconnect', $msg, array(
'@fbuid' => $fbuid,
), WATCHDOG_ERROR);
return FALSE;
}