You are here

function twitter_requirements in Twitter 7.5

Same name and namespace in other branches
  1. 6.5 twitter.install \twitter_requirements()
  2. 6.4 twitter.install \twitter_requirements()
  3. 7.6 twitter.install \twitter_requirements()
  4. 7.4 twitter.install \twitter_requirements()

Implements hook_requirements()

File

./twitter.install, line 11
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;
    }
  }
  return $requirements;
}