function fb_requirements in Drupal for Facebook 7.4
Same name and namespace in other branches
- 6.3 fb.install \fb_requirements()
- 6.2 fb.install \fb_requirements()
- 7.3 fb.install \fb_requirements()
Implementation of hook_requirements().
File
- ./
fb.install, line 167
Code
function fb_requirements($phase) {
$t = get_t();
$items = array();
// Disable these checks at install time, because failure then causes more
// problems due to module dependencies and Drupal's poor handling of
// requirement errors.
if ($phase != 'runtime') {
return $items;
}
// Default token
$status = array(
'title' => $t('Drupal for Facebook <a href=!url>Default Token</a>', array(
'!url' => url(FB_PATH_ADMIN_CONFIG . '/settings/token'),
)),
);
if ($token = variable_get(FB_VAR_ADMIN_ACCESS_TOKEN, NULL)) {
try {
$batch = fb_graph_batch(array(
'me',
'app',
), $token);
extract($batch);
// $me and $app
$args = array(
'!me_logo' => '//graph.facebook.com/' . $me['id'] . '/picture?type=square',
'!me' => l($me['name'], $me['link']),
'!app_logo' => $app['logo_url'],
'!app' => l($app['name'], $app['link']),
);
$status += array(
'severity' => REQUIREMENT_OK,
'value' => $t('<img src=!me_logo /> <img src=!app_logo /> Token has the privileges of !me, via the application !app.', $args),
);
} catch (Exception $e) {
$status += array(
'severity' => REQUIREMENT_ERROR,
'value' => $t('Token is not valid.'),
'description' => $e
->getMessage(),
);
}
}
else {
$status += array(
'severity' => REQUIREMENT_WARNING,
'value' => $t('No default token configured'),
);
}
$items[] = $status;
// Default App
$status = array(
'title' => $t('Drupal for Facebook <a href=!url>Default Application</a>', array(
'!url' => url(FB_PATH_ADMIN_CONFIG . '/settings/app'),
)),
);
$args = array();
$app_data = variable_get(FB_VAR_DEFAULT_APP, NULL);
if (!empty($app_data)) {
try {
$app = fb_graph($app_data['client_id']);
foreach ($app as $key => $value) {
$args['!' . $key] = $value;
}
$status += array(
'severity' => REQUIREMENT_OK,
'value' => l($app['name'], $app['link']),
'description' => $t('<img src="!logo_url" />', $args),
);
} catch (Exception $e) {
$status += array(
'severity' => REQUIREMENT_ERROR,
'value' => $t('Failed to get application details from facebook.'),
'description' => $e
->getMessage(),
);
}
}
else {
$status += array(
'severity' => REQUIREMENT_WARNING,
'value' => $t('No default application configured.'),
);
}
$items[] = $status;
if (!defined('JSON_BIGINT_AS_STRING')) {
$items[] = array(
'title' => $t('Drupal for Facebook PHP JSON decoding'),
'severity' => REQUIREMENT_WARNING,
'description' => $t('modules/fb expects JSON_BIGINT_AS_STRING for correct json decoding.'),
'value' => phpversion(),
);
}
return $items;
}