function twitter_requirements in Twitter 6.5
Same name and namespace in other branches
- 6.4 twitter.install \twitter_requirements()
- 7.6 twitter.install \twitter_requirements()
- 7.4 twitter.install \twitter_requirements()
- 7.5 twitter.install \twitter_requirements()
Implements hook_requirements()
File
- ./
twitter.install, line 10 - Install, update and uninstall functions for the twitter module.
Code
function twitter_requirements($phase) {
$requirements = array();
$t = get_t();
if ($phase == 'runtime') {
// Verify that the Twitter Application keys are set.
$requirements['twitter_keys'] = array(
'title' => $t('Twitter Application keys'),
);
$consumer_key = variable_get('twitter_consumer_key', NULL);
$consumer_secret = variable_get('twitter_consumer_secret', NULL);
if (empty($consumer_key) || empty($consumer_secret)) {
$requirements['twitter_keys']['value'] = $t('Missing');
$requirements['twitter_keys']['description'] = $t('In order to interact with Twitter, you need to create an application at !twitter_dev and set the generated Application keys at the !twitter_settings_page.', array(
'!twitter_dev' => l('https://dev.twitter.com', 'https://dev.twitter.com'),
'!twitter_settings_page' => l($t('Twitter settings page'), 'admin/config/services/twitter'),
));
$requirements['twitter_keys']['severity'] = REQUIREMENT_ERROR;
}
else {
$requirements['twitter_keys']['value'] = $t('Configured');
$requirements['twitter_keys']['severity'] = REQUIREMENT_OK;
}
// Verify that the OAuth module is installed and supported - if the
// lib/OAuth.php file isn't available then the wrong version of OAuth is
// installed.
$path = drupal_get_path('module', 'oauth_common') . '/lib/OAuth.php';
if (!file_exists($path)) {
$requirements['twitter_oauth'] = array(
'title' => $t('Twitter module requirements'),
'severity' => REQUIREMENT_ERROR,
'value' => $t('OAuth module v6.x-3.x is required'),
'description' => $t('Upgrade to the latest v6.x-3.x release of the <a href="@oauth">OAuth module</a> in order for the Twitter module to work correctly, the v6.x-2.x releases will not work.', array(
'@oauth' => 'https://www.drupal.org/project/oauth',
)),
);
}
else {
$requirements['twitter_oauth'] = array(
'title' => $t('Twitter module requirements'),
'severity' => REQUIREMENT_OK,
'value' => $t('OAuth module v6.x-3.x is installed'),
'description' => $t('A compatible version of the OAuth module is installed.'),
);
}
}
return $requirements;
}