You are here

function rrssb_requirements in Ridiculously Responsive Social Sharing Buttons 7.2

Same name and namespace in other branches
  1. 8.2 rrssb.install \rrssb_requirements()
  2. 7 rrssb.module \rrssb_requirements()

Implements hook_requirements().

File

./rrssb.module, line 435

Code

function rrssb_requirements($phase) {

  // Check for library version.  We do a runtime check only, as we don't want to block install - the normal sequence
  // is to install the module and then use the drush command to get the library.
  $requirements = array();
  if ($phase == 'runtime') {
    $requirements['rrssb']['title'] = t('RRSSB+ library');
    $library = libraries_detect('rrssb-plus');
    if (!$library['installed']) {
      $requirements['rrssb']['value'] = t('Not installed');
      $requirements['rrssb']['severity'] = REQUIREMENT_ERROR;
      $requirements['rrssb']['description'] = '';
    }
    else {
      $requirements['rrssb']['value'] = $library['version'];
      $compare = version_compare($library['version'], RRSSB_LIBRARY_MIN_VERSION);
      if ($compare < 0) {
        $requirements['rrssb']['severity'] = REQUIREMENT_ERROR;
        $requirements['rrssb']['description'] = t('Library version is too old.  ');
      }
      else {
        $requirements['rrssb']['severity'] = REQUIREMENT_OK;
      }
    }
    if ($requirements['rrssb']['severity'] != REQUIREMENT_OK) {
      $requirements['rrssb']['description'] .= t('Please download the RRSSB library using "drush rrssb-plugin" or from !link.', array(
        '!link' => l(RRSSB_LIBRARY_URI, RRSSB_LIBRARY_URI),
      ));
    }
  }
  return $requirements;
}