function fb_permission_access_perms in Drupal for Facebook 7.3
File
- contrib/
fb_permission.module, line 19 - Code pertaining to Facebook's extended permissions. see http://wiki.developers.facebook.com/index.php/Extended_permissions
Code
function fb_permission_access_perms($perms) {
if (is_string($perms)) {
$perms = explode(',', $perms);
}
$count = 0;
extract(fb_vars());
if ($fbu) {
try {
$api_data = fb_api('me/permissions');
$granted = $api_data['data'][0];
foreach ($perms as $perm) {
if (empty($granted[$perm]) || !$granted[$perm]) {
$auth_url = url('http://www.facebook.com/dialog/oauth/', array(
'query' => array(
'scope' => implode(',', $perms),
'client_id' => $fb_app->id,
'redirect_uri' => url(request_path(), array(
'absolute' => TRUE,
)),
'response_type' => 'token',
),
'absolute' => TRUE,
));
drupal_set_message(t('Additional permissions are required. <a href="!url">Grant permissions to continue</a>.', array(
'!url' => $auth_url,
)), 'error');
$GLOBALS['_fb_permission_extra_perms'] = $perms;
return FALSE;
}
else {
$count++;
}
}
} catch (Exception $e) {
fb_log_exception($e, __FUNCTION__);
}
}
else {
// User not connected.
// Ensure all connect buttons on this page include these perms.
$GLOBALS['_fb_permission_extra_perms'] = $perms;
drupal_set_message(t('Facebook Connect is required. !login_button', array(
'!login_button' => theme('fb_login_button', array(
'text' => t('Connect to continue'),
)),
)), 'error');
}
return $count == count($perms);
}